1. 대표번호 to, from 수정

2. fmt.print 제거
main
jjLee 2 years ago
parent c422b56a6f
commit 271798ddda

@ -1,7 +1,6 @@
package icsmediaconv package icsmediaconv
import ( import (
"fmt"
"sync" "sync"
"gitlab.com/ics_cinnamon/joy4/av" "gitlab.com/ics_cinnamon/joy4/av"
@ -96,7 +95,7 @@ func NewConverter(id int, pt icspacketparser.PayloadType, dec bool) (*Converter,
var err error var err error
conv.encoder, err = ffmpeg.NewAudioEncoderByCodecType(conv.codec.Type()) conv.encoder, err = ffmpeg.NewAudioEncoderByCodecType(conv.codec.Type())
if err != nil { if err != nil {
fmt.Println("########111", err) // fmt.Println("########111", err)
icserror.ICSERRCONVNotSupportedCodec.SetError(err) icserror.ICSERRCONVNotSupportedCodec.SetError(err)
return nil, icserror.ICSERRCONVNotSupportedCodec return nil, icserror.ICSERRCONVNotSupportedCodec
} }

@ -59,11 +59,11 @@ func TestGetModName(t *testing.T) {
sip.SipParser(sipByteArray) sip.SipParser(sipByteArray)
fmt.Printf("sip %+v\n\n", sip) // fmt.Printf("sip %+v\n\n", sip)
if sip.Content != nil { if sip.Content != nil {
fmt.Printf("sdp %+v\n\n", sip.Content) // fmt.Printf("sdp %+v\n\n", sip.Content)
fmt.Printf("sdp media %+v\n\n", sip.Content.Media) // fmt.Printf("sdp media %+v\n\n", sip.Content.Media)
} }
// assert.Equal(t, "INVITE", sip.Method, "not expected value") // assert.Equal(t, "INVITE", sip.Method, "not expected value")
@ -84,10 +84,10 @@ func TestGetModName(t *testing.T) {
// a = 2048 // ack // a = 2048 // ack
// a = 0 // bye // a = 0 // bye
// a = 3072 // cancel // a = 3072 // cancel
fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE) // fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE)
// b := 1 // b := 1
fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE&ICS_SIP_JOB_TYPE_ACK) // fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE&ICS_SIP_JOB_TYPE_ACK)
} }
const ( const (

@ -278,16 +278,20 @@ func (s *IcsSession) RequestInvite(inviteto string) {
inviteMethod := fmt.Sprintf("sip:%s@172.31.29.47;transport=%s", s.AgentName, transport) // nlb(DNS)를 한번 갔다온 ip를 넣어줘야함. inviteMethod := fmt.Sprintf("sip:%s@172.31.29.47;transport=%s", s.AgentName, transport) // nlb(DNS)를 한번 갔다온 ip를 넣어줘야함.
s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip) s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip)
to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.AgentName, ip) to := fmt.Sprintf("<sip:%s@%s;user=phone>", s.AgentName, ip)
from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
if conf.Representative.Value { if conf.Representative.Value {
inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport) inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport)
s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip) s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip)
to = fmt.Sprintf("<sip:%s@%s;user=phone>", "AISB", ip) to = fmt.Sprintf("<sip:%s@%s;user=phone>", "AISB", ip)
agentName := s.AgentName
agentSplit := agentName[len(agentName)-2:len(agentName)]
telNo := fmt.Sprintf("010243427%s", agentSplit)
from = fmt.Sprintf("<sip:%s@%s>;tag=%s", telNo, ip, sipasm.GenerateTag())
} }
reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod) reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod)
via := fmt.Sprintf("SIP/2.0/UDP %s:5090;branch=%s", ip, sipasm.GenerateBranch()) via := fmt.Sprintf("SIP/2.0/UDP %s:5090;branch=%s", ip, sipasm.GenerateBranch())
maxforwards := "70" maxforwards := "70"
from := fmt.Sprintf("<sip:%s@%s>;tag=%s", inviteto, ip, sipasm.GenerateTag())
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Set URI [%s]", s.uri)
@ -376,7 +380,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
ip := conf.InfoConfig.ServerIP ip := conf.InfoConfig.ServerIP
port := conf.SIPConfig.Port port := conf.SIPConfig.Port
fmt.Println("sip.Media ", sip.Media) // fmt.Println("sip.Media ", sip.Media)
mediaPort, _ := strconv.Atoi(sip.Media) mediaPort, _ := strconv.Atoi(sip.Media)
proxy := conf.SIPConfig.SIPProxy proxy := conf.SIPConfig.SIPProxy
@ -423,7 +427,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
formats := strings.Split(format, " ") formats := strings.Split(format, " ")
reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0) reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0)
sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String())) sdpLength := fmt.Sprintf("%d", len(reqInvite.SDP.String()))
fmt.Println("###### X-AICALL ", sip.XAICall) // fmt.Println("###### X-AICALL ", sip.XAICall)
// refer := strings.Split(sip.XAICall, "@")[0] // refer := strings.Split(sip.XAICall, "@")[0]
reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via) reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via)
@ -448,23 +452,23 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError {
reqInvite) reqInvite)
// sendINVITE := fmt.Sprintf("%+v",sip) // sendINVITE := fmt.Sprintf("%+v",sip)
wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String())) _, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String()))
if werr != nil { if werr != nil {
l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage()) l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage())
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
return werr return werr
} }
fmt.Println(wlen) // fmt.Println(wlen)
s.InviteSIP = nil s.InviteSIP = nil
s1 := icspacketparser.NewSIP() s1 := icspacketparser.NewSIP()
err := s1.SipParser([]byte(reqInvite.String())) err := s1.SipParser([]byte(reqInvite.String()))
if err != nil { if err != nil {
fmt.Printf("########### ererererrererer %s \r\n %+v\r\n", reqInvite.String(), s.InviteSIP) // fmt.Printf("########### ererererrererer %s \r\n %+v\r\n", reqInvite.String(), s.InviteSIP)
} else { } else {
s.InviteSIP = &s1 s.InviteSIP = &s1
fmt.Printf("########### %+v\r\n",s1) // fmt.Printf("########### %+v\r\n",s1)
fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP) // fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP)
} }
// s.RemoveSession() // s.RemoveSession()
@ -672,7 +676,7 @@ func (s *IcsSession) ProcInvite(sip *icspacketparser.SIP) *icserror.IcsError {
//TODO : agent conf //TODO : agent conf
//station := conf.AgentConfig[s.ID].Name //station := conf.AgentConfig[s.ID].Name
s.Station = s.AgentInfo.Name s.Station = s.AgentInfo.Name
fmt.Println("s.Station = s.AgentInfo.Name>>>>>", s.Station) // fmt.Println("s.Station = s.AgentInfo.Name>>>>>", s.Station)
/////////// ///////////
cust1 := strings.SplitN(sip.From, "@", 2) cust1 := strings.SplitN(sip.From, "@", 2)
cust2 := strings.SplitN(cust1[0], ":", 2) cust2 := strings.SplitN(cust1[0], ":", 2)
@ -886,7 +890,7 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
s.SetAgentStatus(STATUS_AGENT_CALLING) s.SetAgentStatus(STATUS_AGENT_CALLING)
} }
status := s.GetAgentStatus() status := s.GetAgentStatus()
fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING) // fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING)
if status == STATUS_AGENT_CALLING { if status == STATUS_AGENT_CALLING {
ackMethod := fmt.Sprintf("sip:01025670081@%s;transport=%s", "192.168.0.222:5090", transport) ackMethod := fmt.Sprintf("sip:01025670081@%s;transport=%s", "192.168.0.222:5090", transport)
@ -1080,7 +1084,7 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError
/////////////////////////////////////////// ///////////////////////////////////////////
/////////////////////////////////////////// ///////////////////////////////////////////
fmt.Println(s) // fmt.Println(s)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Sent Data(%d) [%s]->[%s]>\n%s", l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Sent Data(%d) [%s]->[%s]>\n%s",
wlen, wlen,
(*s.sipNeter).LocalAddr().String(), (*s.sipNeter).LocalAddr().String(),
@ -1271,8 +1275,8 @@ func (s *IcsSession) SendRequestInvite() {
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
conf := icsconf.GetIcsConfig() conf := icsconf.GetIcsConfig()
fmt.Println("######### sim loop count!! ", conf.SimLoopCount) // fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount) // fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
if s.simLoopCount < conf.SimLoopCount { if s.simLoopCount < conf.SimLoopCount {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
time.Sleep(time.Second*1) time.Sleep(time.Second*1)
@ -1346,8 +1350,8 @@ func (s *IcsSession) ProcSIP20Bye(sip *icspacketparser.SIP) *icserror.IcsError {
// } // }
// s.RemoveSession() // s.RemoveSession()
fmt.Println("######### sim loop count!! ", conf.SimLoopCount) // fmt.Println("######### sim loop count!! ", conf.SimLoopCount)
fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount) // fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount)
if s.simLoopCount < conf.SimLoopCount { if s.simLoopCount < conf.SimLoopCount {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Send Call Start Sip(%s) count %d!!!!!!!\r\n", s.AgentName, s.simLoopCount)
s.RequestInvite("01024342788") s.RequestInvite("01024342788")
@ -1404,7 +1408,7 @@ func (s *IcsSession) SendRTPCB(t *icscbtimer.IcsCBTimer) {
voiceFilePath := "/home/icsvsim/voice/Sample.pcm" voiceFilePath := "/home/icsvsim/voice/Sample.pcm"
readPcmData, ferr := ioutil.ReadFile(voiceFilePath) readPcmData, ferr := ioutil.ReadFile(voiceFilePath)
if ferr != nil { if ferr != nil {
fmt.Println("Read Voice File error ", ferr) // fmt.Println("Read Voice File error ", ferr)
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "############ VoiceFile Read ERROR") l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "############ VoiceFile Read ERROR")
return return
} }
@ -1743,7 +1747,7 @@ func (s *IcsSession) ReadRTP() {
// func (s *IcsSession)ExpiredRTP(t *icscbtimer.IcsCBTimer) { // func (s *IcsSession)ExpiredRTP(t *icscbtimer.IcsCBTimer) {
func (s *IcsSession)ExpiredRTP(t time.Ticker) { func (s *IcsSession)ExpiredRTP(t time.Ticker) {
s.mychannel = make(chan bool) s.mychannel = make(chan bool)
fmt.Println("### timer start") // fmt.Println("### timer start")
// valCheckTimer := time.NewTicker(time.Second) // valCheckTimer := time.NewTicker(time.Second)
s.expRead = time.Now() s.expRead = time.Now()
for { for {
@ -1755,7 +1759,7 @@ func (s *IcsSession)ExpiredRTP(t time.Ticker) {
fmt.Println("agent : ", s.AgentName , " ", tm) fmt.Println("agent : ", s.AgentName , " ", tm)
} else if !s.expCheck { } else if !s.expCheck {
if time.Now().Sub(s.expRead) > time.Second { if time.Now().Sub(s.expRead) > time.Second {
fmt.Printf("### session expired %s\n", s.AgentName) // fmt.Printf("### session expired %s\n", s.AgentName)
s.RTPSenderCallBackTimer.Start() s.RTPSenderCallBackTimer.Start()
s.expCheck = true s.expCheck = true
} }
@ -2026,11 +2030,11 @@ func (s *IcsSession) RequestBYESIM() {
func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) { func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) {
l := icslog.GetIcsLog() l := icslog.GetIcsLog()
conf := icsconf.GetIcsConfig() conf := icsconf.GetIcsConfig()
fmt.Printf("inviteSIP %+v\r\n", inviteSIP) // fmt.Printf("inviteSIP %+v\r\n", inviteSIP)
ip := conf.InfoConfig.ServerIP ip := conf.InfoConfig.ServerIP
port := conf.SIPConfig.Port port := conf.SIPConfig.Port
transport := conf.SIPConfig.Transport transport := conf.SIPConfig.Transport
fmt.Println(">>>contact", inviteSIP.Contact) // fmt.Println(">>>contact", inviteSIP.Contact)
// contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2) // contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2)
// contactName := strings.SplitN(contactName1[1], "@", 2) // contactName := strings.SplitN(contactName1[1], "@", 2)

@ -107,6 +107,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
s.RemoveSession() s.RemoveSession()
} }
case ICS_SIP_JOB_TYPE_INVITE: case ICS_SIP_JOB_TYPE_INVITE:
s.InviteSIP = sip
//l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "sip20 invite - %s", sip.Source) //l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "sip20 invite - %s", sip.Source)
code := sip.Source code := sip.Source
@ -123,7 +124,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError {
} }
case ICS_SIP_JOB_TYPE_PUBLISH: case ICS_SIP_JOB_TYPE_PUBLISH:
case ICS_SIP_JOB_TYPE_OPTIONS: case ICS_SIP_JOB_TYPE_OPTIONS:
s.RequestInvite("01024342788") // s.RequestInvite("01024342788")
case ICS_SIP_JOB_TYPE_INFO: case ICS_SIP_JOB_TYPE_INFO:
case ICS_SIP_JOB_TYPE_UPDATE: case ICS_SIP_JOB_TYPE_UPDATE:
case ICS_SIP_JOB_TYPE_REFER: case ICS_SIP_JOB_TYPE_REFER:

@ -308,7 +308,7 @@ func (s *IcsSession) Run() *icserror.IcsError {
//fmt.Println(rtp) //fmt.Println(rtp)
s.analyzeRTP(&rtp) s.analyzeRTP(&rtp)
default: default:
fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!") // fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!")
} }
} }

@ -598,7 +598,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY { if agentStatus == STATUS_AGENT_BUSY {
s.RequestBYE(s.InviteSIP) s.RequestBYE(s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING) s.SetAgentStatus(STATUS_AGENT_BYEING)
fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) // fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
} }
s.BotStatus = ttscmd s.BotStatus = ttscmd
} else { } else {
@ -618,7 +618,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
tts, rlen, rerr := t.Read(int(ttspl)) tts, rlen, rerr := t.Read(int(ttspl))
if rerr != nil { if rerr != nil {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv TTS(%d,%s)", rlen, rerr.GetError()) l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv TTS(%d,%s)", rlen, rerr.GetError())
fmt.Println("error : ", rerr.GetError()) // fmt.Println("error : ", rerr.GetError())
return return
} }
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Recved TTS data. Length: %d", len(tts)) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Recved TTS data. Length: %d", len(tts))
@ -668,7 +668,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
if agentStatus == STATUS_AGENT_BUSY { if agentStatus == STATUS_AGENT_BUSY {
s.RequestRefer(telNo, s.InviteSIP) s.RequestRefer(telNo, s.InviteSIP)
s.SetAgentStatus(STATUS_AGENT_BYEING) s.SetAgentStatus(STATUS_AGENT_BYEING)
fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) // fmt.Println("AGENT_STATUS : ", s.GetAgentStatus())
} }
s.BotStatus = ttscmd s.BotStatus = ttscmd
} else { } else {
@ -685,6 +685,6 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "485LINE %+v, %+v, %+v, %s", ttscmd, ttsrc, ttspl, agentName) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "485LINE %+v, %+v, %+v, %s", ttscmd, ttsrc, ttspl, agentName)
} }
} }
fmt.Println("418LINE rlen", rlen, rerr) // fmt.Println("418LINE rlen", rlen, rerr)
} }
} }

@ -1,7 +1,6 @@
package icssessionmanager package icssessionmanager
import ( import (
"fmt"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"strconv" "strconv"
@ -84,7 +83,7 @@ func findSessionWithSessionStatus(callID string) *IcsSession {
sessions := getSessionInstance(nil) sessions := getSessionInstance(nil)
for idx, session := range sessions { for idx, session := range sessions {
session.m.Lock() session.m.Lock()
fmt.Println(session.AgentName, session.agentStatus) // fmt.Println(session.AgentName, session.agentStatus)
if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 { if strings.Compare(conf.AgentConfig[idx].Value, "true") == 0 && session.agentStatus == 64 {
// session.callID = callID // session.callID = callID
session.m.Unlock() session.m.Unlock()
@ -339,10 +338,10 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
// s.rtpMediaNeter.Close() // s.rtpMediaNeter.Close()
// s.rtpMediaNeter = nil // s.rtpMediaNeter = nil
// } // }
fmt.Println("### s.readTimer Stop", s.AgentName) // fmt.Println("### s.readTimer Stop", s.AgentName)
s.RTPSenderCallBackTimer.Stop() s.RTPSenderCallBackTimer.Stop()
if s.rtpMediaNeter != nil { if s.rtpMediaNeter != nil {
fmt.Println("voice neter nil!!") // fmt.Println("voice neter nil!!")
s.rtpMediaNeter.Close() s.rtpMediaNeter.Close()
s.rtpMediaNeter = nil s.rtpMediaNeter = nil
} }
@ -389,7 +388,7 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
// s.referto = "" // s.referto = ""
s.SetAgentStatus(STATUS_AGENT_READY) s.SetAgentStatus(STATUS_AGENT_READY)
s.SetRegisterStatus(STATUS_REGISTER_READY) s.SetRegisterStatus(STATUS_REGISTER_READY)
fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus()) // fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus())
s.m.Unlock() s.m.Unlock()
return nil return nil

@ -87,7 +87,7 @@ func (s IcsService) GetIcsLog() (log *icslog.IcsLog) {
func (s IcsService) ShowServiceInfo() (info string) { func (s IcsService) ShowServiceInfo() (info string) {
info = fmt.Sprintf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME) info = fmt.Sprintf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME)
fmt.Printf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME) // fmt.Printf("%s Voice Gateway version %s\nCopyright (C) 2022 %s\n\n", COMPANY_NAME, VERSION, COMPANY_NAME)
return info return info
} }

@ -101,7 +101,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
if lerr == nil { if lerr == nil {
wgRTPListen.Add(1) wgRTPListen.Add(1)
go func() { go func() {
fmt.Println("############### start rtp", s.laddr) // fmt.Println("############### start rtp", s.laddr)
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Start RTP Listen[%v]\n", s.laddr) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Start RTP Listen[%v]\n", s.laddr)
totalRlen := 0 totalRlen := 0
for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() { for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() {
@ -110,8 +110,8 @@ func (s *SimPhone) Run() *icserror.IcsError {
s.expTime = time.Now() s.expTime = time.Now()
totalRlen += rlen totalRlen += rlen
} else { } else {
fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen) // fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen)
fmt.Println("##### id : ", s.ID) // fmt.Println("##### id : ", s.ID)
break break
} }
} }
@ -129,9 +129,9 @@ func (s *SimPhone) Run() *icserror.IcsError {
id := fmt.Sprintf("%d", s.ID+7000) id := fmt.Sprintf("%d", s.ID+7000)
toid := fmt.Sprintf("%d", s.ID+21016) toid := fmt.Sprintf("%d", s.ID+21016)
fmt.Println("############################################################################## id : ", id) // fmt.Println("############################################################################## id : ", id)
fmt.Println("############################################################################## id : ", toid) // fmt.Println("############################################################################## id : ", toid)
fmt.Println("############################################################################## id : ", s.TRTPTxPort) // fmt.Println("############################################################################## id : ", s.TRTPTxPort)
ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort) ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort)
s.rsaddr = &ra s.rsaddr = &ra
@ -146,13 +146,13 @@ func (s *SimPhone) Run() *icserror.IcsError {
///////////////////// /////////////////////
// send regi sip // send regi sip
fmt.Println("###################### regi") // fmt.Println("###################### regi")
if simconf.RegiCount != 0 { if simconf.RegiCount != 0 {
regiCount := 0 regiCount := 0
for { for {
buf, rlen, err := simprocnew.NewReadSIP(s.ID, s.CallID, simconf.SimPhoneConfig.MYIP, s.TSIPPort, ra, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP) buf, rlen, err := simprocnew.NewReadSIP(s.ID, s.CallID, simconf.SimPhoneConfig.MYIP, s.TSIPPort, ra, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP)
if err != nil { if err != nil {
fmt.Println(err) // fmt.Println(err)
} }
n := bytes.Index(buf[:rlen], []byte{32}) n := bytes.Index(buf[:rlen], []byte{32})
if string(buf[:n]) == "REGISTER" { if string(buf[:n]) == "REGISTER" {
@ -182,7 +182,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
simScenarioConf := icsconf.GetSimScenarioConfig() simScenarioConf := icsconf.GetSimScenarioConfig()
// var stopByeTimer *time.Ticker // var stopByeTimer *time.Ticker
for _, ord := range simScenarioConf.SipOrder.Order { for _, ord := range simScenarioConf.SipOrder.Order {
fmt.Println("######################################################## : ", strings.ToUpper(ord)) // fmt.Println("######################################################## : ", strings.ToUpper(ord))
switch strings.ToUpper(ord) { switch strings.ToUpper(ord) {
// case "WAIT": // set send bye time // case "WAIT": // set send bye time
// stopByeTimer = time.NewTicker(time.Second * time.Duration(simScenarioConf.SipOrder.StopTime)) // stopByeTimer = time.NewTicker(time.Second * time.Duration(simScenarioConf.SipOrder.StopTime))
@ -209,7 +209,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv BYE - %v", err) l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Failed to recv BYE - %v", err)
return return
} else { } else {
fmt.Println(string(buf[:rlen])) // fmt.Println(string(buf[:rlen]))
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Receved BYE Message : %s", string(buf[:rlen])) l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Receved BYE Message : %s", string(buf[:rlen]))
// stopByeTimer.Stop() // stopByeTimer.Stop()
sendSip := simprocnew.NewSIPSignal("BYE200", s.ID, id, toid, ra, s.CallID, simconf.SimPhoneConfig.MYIP, s.TRTPTxPort, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP, nil, 0) sendSip := simprocnew.NewSIPSignal("BYE200", s.ID, id, toid, ra, s.CallID, simconf.SimPhoneConfig.MYIP, s.TRTPTxPort, s.laddr, s.rsaddr, s.lsaddr, localSIPUDP, nil, 0)
@ -262,7 +262,7 @@ func (s *SimPhone) Run() *icserror.IcsError {
} }
func (s *SimPhone) RunMedia(port int, pt int) { func (s *SimPhone) RunMedia(port int, pt int) {
fmt.Println("#### RunMedia") // fmt.Println("#### RunMedia")
defer func() { defer func() {
s.wgMedia.Done() s.wgMedia.Done()
}() }()
@ -366,7 +366,7 @@ func (s *SimPhone) ExpireReadRTP(t *time.Ticker) {
// s.sendRTPStatus = false // s.sendRTPStatus = false
// } else // } else
if time.Now().Sub(s.expTime) >= time.Second { if time.Now().Sub(s.expTime) >= time.Second {
fmt.Println(t) // fmt.Println(t)
s.sendRTPStatus = true s.sendRTPStatus = true
break break
} else if s.sendRTPStatus { } else if s.sendRTPStatus {

@ -12,11 +12,11 @@ import (
func main() { func main() {
alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw") alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw")
if ferr != nil { if ferr != nil {
fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr) // fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr)
return return
} }
alawDataLen := len(alawData) alawDataLen := len(alawData)
fmt.Println("alawDataLen", alawDataLen) // fmt.Println("alawDataLen", alawDataLen)
rtp := icsrtp.NewRTP(1, rtp := icsrtp.NewRTP(1,
int(icspacketparser.PCMA), int(icspacketparser.PCMA),
@ -25,5 +25,5 @@ func main() {
0x3d99e5cd, 0x3d99e5cd,
alawData[:160]) alawData[:160])
fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload)) // fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload))
} }

Loading…
Cancel
Save