diff --git a/icsmediaconv/icsmediaconv.go b/icsmediaconv/icsmediaconv.go index 19131fa..1a1c16e 100644 --- a/icsmediaconv/icsmediaconv.go +++ b/icsmediaconv/icsmediaconv.go @@ -1,7 +1,6 @@ package icsmediaconv import ( - "fmt" "sync" "gitlab.com/ics_cinnamon/joy4/av" @@ -96,7 +95,7 @@ func NewConverter(id int, pt icspacketparser.PayloadType, dec bool) (*Converter, var err error conv.encoder, err = ffmpeg.NewAudioEncoderByCodecType(conv.codec.Type()) if err != nil { - fmt.Println("########111", err) + // fmt.Println("########111", err) icserror.ICSERRCONVNotSupportedCodec.SetError(err) return nil, icserror.ICSERRCONVNotSupportedCodec } diff --git a/icspacketparser/icssipparser_test.go b/icspacketparser/icssipparser_test.go index 80af9d1..fb43e6c 100644 --- a/icspacketparser/icssipparser_test.go +++ b/icspacketparser/icssipparser_test.go @@ -59,11 +59,11 @@ func TestGetModName(t *testing.T) { sip.SipParser(sipByteArray) - fmt.Printf("sip %+v\n\n", sip) + // fmt.Printf("sip %+v\n\n", sip) if sip.Content != nil { - fmt.Printf("sdp %+v\n\n", sip.Content) - fmt.Printf("sdp media %+v\n\n", sip.Content.Media) + // fmt.Printf("sdp %+v\n\n", sip.Content) + // fmt.Printf("sdp media %+v\n\n", sip.Content.Media) } // assert.Equal(t, "INVITE", sip.Method, "not expected value") @@ -84,10 +84,10 @@ func TestGetModName(t *testing.T) { // a = 2048 // ack // a = 0 // bye // a = 3072 // cancel - fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE) + // fmt.Printf("%016b\n", ICS_SIP_AUTOMATA_INVITE) // 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 ( diff --git a/icssessionmanager/agentoperator.go b/icssessionmanager/agentoperator.go index 1894404..9e6a9bd 100644 --- a/icssessionmanager/agentoperator.go +++ b/icssessionmanager/agentoperator.go @@ -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를 넣어줘야함. s.uri = fmt.Sprintf("sip:%s@%s", s.AgentName, ip) to := fmt.Sprintf("", s.AgentName, ip) + from := fmt.Sprintf(";tag=%s", inviteto, ip, sipasm.GenerateTag()) if conf.Representative.Value { inviteMethod = fmt.Sprintf("sip:%s@%s;transport=%s", "AISB", ip, transport) s.uri = fmt.Sprintf("sip:%s@%s", "AISB", ip) to = fmt.Sprintf("", "AISB", ip) + agentName := s.AgentName + agentSplit := agentName[len(agentName)-2:len(agentName)] + telNo := fmt.Sprintf("010243427%s", agentSplit) + from = fmt.Sprintf(";tag=%s", telNo, ip, sipasm.GenerateTag()) } reqInvite := sipasm.NewSIPMessage(sipasm.ICSSIP_METHOD_INVITE, inviteMethod) via := fmt.Sprintf("SIP/2.0/UDP %s:5090;branch=%s", ip, sipasm.GenerateBranch()) maxforwards := "70" - from := fmt.Sprintf(";tag=%s", inviteto, ip, sipasm.GenerateTag()) 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 port := conf.SIPConfig.Port - fmt.Println("sip.Media ", sip.Media) + // fmt.Println("sip.Media ", sip.Media) mediaPort, _ := strconv.Atoi(sip.Media) proxy := conf.SIPConfig.SIPProxy @@ -423,7 +427,7 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError { formats := strings.Split(format, " ") reqInvite.SDP = sipasm.NewSDPMessage(ip, mediaPort, formats[:], 0) 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] reqInvite.AddSIPHeader(sipasm.ICSSIP_HEADER_VIA, via) @@ -448,23 +452,23 @@ func (s *IcsSession) PassInvite(sip *icspacketparser.SIP) *icserror.IcsError { reqInvite) // sendINVITE := fmt.Sprintf("%+v",sip) - wlen, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String())) + _, werr := (*s.sipNeter).WriteSIP([]byte(reqInvite.String())) if werr != nil { l.Print(icslog.LOG_LEVEL_FATAL, s.ID, werr.GetMessage()) s.SetAgentStatus(STATUS_AGENT_READY) return werr } - fmt.Println(wlen) + // fmt.Println(wlen) s.InviteSIP = nil s1 := icspacketparser.NewSIP() err := s1.SipParser([]byte(reqInvite.String())) 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 { s.InviteSIP = &s1 - fmt.Printf("########### %+v\r\n",s1) - fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP) + // fmt.Printf("########### %+v\r\n",s1) + // fmt.Printf("########### %s, \r\n %+v\r\n",reqInvite.String(), s.InviteSIP) } // s.RemoveSession() @@ -672,7 +676,7 @@ func (s *IcsSession) ProcInvite(sip *icspacketparser.SIP) *icserror.IcsError { //TODO : agent conf //station := conf.AgentConfig[s.ID].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) cust2 := strings.SplitN(cust1[0], ":", 2) @@ -886,7 +890,7 @@ func (s *IcsSession) ProcACKInvite(sip *icspacketparser.SIP) *icserror.IcsError s.SetAgentStatus(STATUS_AGENT_CALLING) } status := s.GetAgentStatus() - fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING) + // fmt.Println("BOT STATUS ", status == STATUS_AGENT_CALLING) if status == STATUS_AGENT_CALLING { 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", wlen, (*s.sipNeter).LocalAddr().String(), @@ -1271,8 +1275,8 @@ func (s *IcsSession) SendRequestInvite() { l := icslog.GetIcsLog() conf := icsconf.GetIcsConfig() - fmt.Println("######### sim loop count!! ", conf.SimLoopCount) - fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount) + // fmt.Println("######### sim loop count!! ", conf.SimLoopCount) + // fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.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) time.Sleep(time.Second*1) @@ -1346,8 +1350,8 @@ func (s *IcsSession) ProcSIP20Bye(sip *icspacketparser.SIP) *icserror.IcsError { // } // s.RemoveSession() - fmt.Println("######### sim loop count!! ", conf.SimLoopCount) - fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.simLoopCount) + // fmt.Println("######### sim loop count!! ", conf.SimLoopCount) + // fmt.Printf("Send Call Start Sip(%s) count %d!!!!!!!", s.AgentName, s.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) s.RequestInvite("01024342788") @@ -1404,7 +1408,7 @@ func (s *IcsSession) SendRTPCB(t *icscbtimer.IcsCBTimer) { voiceFilePath := "/home/icsvsim/voice/Sample.pcm" readPcmData, ferr := ioutil.ReadFile(voiceFilePath) 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") return } @@ -1743,7 +1747,7 @@ func (s *IcsSession) ReadRTP() { // func (s *IcsSession)ExpiredRTP(t *icscbtimer.IcsCBTimer) { func (s *IcsSession)ExpiredRTP(t time.Ticker) { s.mychannel = make(chan bool) - fmt.Println("### timer start") + // fmt.Println("### timer start") // valCheckTimer := time.NewTicker(time.Second) s.expRead = time.Now() for { @@ -1755,7 +1759,7 @@ func (s *IcsSession)ExpiredRTP(t time.Ticker) { fmt.Println("agent : ", s.AgentName , " ", tm) } else if !s.expCheck { 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.expCheck = true } @@ -2026,11 +2030,11 @@ func (s *IcsSession) RequestBYESIM() { func (s *IcsSession) RequestBYE(inviteSIP *icspacketparser.SIP) { l := icslog.GetIcsLog() conf := icsconf.GetIcsConfig() - fmt.Printf("inviteSIP %+v\r\n", inviteSIP) + // fmt.Printf("inviteSIP %+v\r\n", inviteSIP) ip := conf.InfoConfig.ServerIP port := conf.SIPConfig.Port transport := conf.SIPConfig.Transport - fmt.Println(">>>contact", inviteSIP.Contact) + // fmt.Println(">>>contact", inviteSIP.Contact) // contactName1 := strings.SplitN(inviteSIP.Contact, "sip:", 2) // contactName := strings.SplitN(contactName1[1], "@", 2) diff --git a/icssessionmanager/csprocessor.go b/icssessionmanager/csprocessor.go index 9e8feaf..827ea67 100644 --- a/icssessionmanager/csprocessor.go +++ b/icssessionmanager/csprocessor.go @@ -107,6 +107,7 @@ func (s *IcsSession) Processing(sip *parser.SIP) *icserror.IcsError { s.RemoveSession() } case ICS_SIP_JOB_TYPE_INVITE: + s.InviteSIP = sip //l.Printf(icslog.LOG_LEVEL_DEBUG2, s.ID, "sip20 invite - %s", 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_OPTIONS: - s.RequestInvite("01024342788") + // s.RequestInvite("01024342788") case ICS_SIP_JOB_TYPE_INFO: case ICS_SIP_JOB_TYPE_UPDATE: case ICS_SIP_JOB_TYPE_REFER: diff --git a/icssessionmanager/icssession.go b/icssessionmanager/icssession.go index 19518c3..7509084 100644 --- a/icssessionmanager/icssession.go +++ b/icssessionmanager/icssession.go @@ -308,7 +308,7 @@ func (s *IcsSession) Run() *icserror.IcsError { //fmt.Println(rtp) s.analyzeRTP(&rtp) default: - fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!") + // fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!") } } diff --git a/icssessionmanager/icssessionmanager.go b/icssessionmanager/icssessionmanager.go index 7cbab37..ac815eb 100644 --- a/icssessionmanager/icssessionmanager.go +++ b/icssessionmanager/icssessionmanager.go @@ -598,7 +598,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) { if agentStatus == STATUS_AGENT_BUSY { s.RequestBYE(s.InviteSIP) s.SetAgentStatus(STATUS_AGENT_BYEING) - fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) + // fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) } s.BotStatus = ttscmd } else { @@ -618,7 +618,7 @@ func BotCommand(t *icsnet.IcsTCPNet, bufend string) { tts, rlen, rerr := t.Read(int(ttspl)) if rerr != nil { 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 } 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 { s.RequestRefer(telNo, s.InviteSIP) s.SetAgentStatus(STATUS_AGENT_BYEING) - fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) + // fmt.Println("AGENT_STATUS : ", s.GetAgentStatus()) } s.BotStatus = ttscmd } 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) } } - fmt.Println("418LINE rlen", rlen, rerr) + // fmt.Println("418LINE rlen", rlen, rerr) } } diff --git a/icssessionmanager/sessionoperator.go b/icssessionmanager/sessionoperator.go index 3b7d068..5c1fce9 100644 --- a/icssessionmanager/sessionoperator.go +++ b/icssessionmanager/sessionoperator.go @@ -1,7 +1,6 @@ package icssessionmanager import ( - "fmt" "runtime" "runtime/debug" "strconv" @@ -84,7 +83,7 @@ func findSessionWithSessionStatus(callID string) *IcsSession { sessions := getSessionInstance(nil) for idx, session := range sessions { 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 { // session.callID = callID session.m.Unlock() @@ -339,10 +338,10 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError { // s.rtpMediaNeter.Close() // s.rtpMediaNeter = nil // } - fmt.Println("### s.readTimer Stop", s.AgentName) + // fmt.Println("### s.readTimer Stop", s.AgentName) s.RTPSenderCallBackTimer.Stop() if s.rtpMediaNeter != nil { - fmt.Println("voice neter nil!!") + // fmt.Println("voice neter nil!!") s.rtpMediaNeter.Close() s.rtpMediaNeter = nil } @@ -389,7 +388,7 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError { // s.referto = "" s.SetAgentStatus(STATUS_AGENT_READY) s.SetRegisterStatus(STATUS_REGISTER_READY) - fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus()) + // fmt.Println("REMOVE SESSION STATUS: ", s.GetAgentStatus()) s.m.Unlock() return nil diff --git a/icssvc/icssvc.go b/icssvc/icssvc.go index 84fd410..a785cf3 100644 --- a/icssvc/icssvc.go +++ b/icssvc/icssvc.go @@ -87,7 +87,7 @@ func (s IcsService) GetIcsLog() (log *icslog.IcsLog) { 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) - 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 } diff --git a/sim/simphone/simphone.go b/sim/simphone/simphone.go index d7f0a0c..1c81d81 100644 --- a/sim/simphone/simphone.go +++ b/sim/simphone/simphone.go @@ -101,7 +101,7 @@ func (s *SimPhone) Run() *icserror.IcsError { if lerr == nil { wgRTPListen.Add(1) 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) totalRlen := 0 for s.mediaStart != 2 || !svc.GetExit() || !svc.GetStop() { @@ -110,8 +110,8 @@ func (s *SimPhone) Run() *icserror.IcsError { s.expTime = time.Now() totalRlen += rlen } else { - fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen) - fmt.Println("##### id : ", s.ID) + // fmt.Printf("\nTotal Recved RTP Length[%d]\n", totalRlen) + // fmt.Println("##### id : ", s.ID) break } } @@ -129,9 +129,9 @@ func (s *SimPhone) Run() *icserror.IcsError { id := fmt.Sprintf("%d", s.ID+7000) toid := fmt.Sprintf("%d", s.ID+21016) - fmt.Println("############################################################################## id : ", id) - fmt.Println("############################################################################## id : ", toid) - fmt.Println("############################################################################## id : ", s.TRTPTxPort) + // fmt.Println("############################################################################## id : ", id) + // fmt.Println("############################################################################## id : ", toid) + // fmt.Println("############################################################################## id : ", s.TRTPTxPort) ra := icsnet.NewNetAddrWithIPPort(simconf.GetSimTargetIP(), s.TSIPPort) s.rsaddr = &ra @@ -146,13 +146,13 @@ func (s *SimPhone) Run() *icserror.IcsError { ///////////////////// // send regi sip - fmt.Println("###################### regi") + // fmt.Println("###################### regi") if simconf.RegiCount != 0 { regiCount := 0 for { 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 { - fmt.Println(err) + // fmt.Println(err) } n := bytes.Index(buf[:rlen], []byte{32}) if string(buf[:n]) == "REGISTER" { @@ -182,7 +182,7 @@ func (s *SimPhone) Run() *icserror.IcsError { simScenarioConf := icsconf.GetSimScenarioConfig() // var stopByeTimer *time.Ticker for _, ord := range simScenarioConf.SipOrder.Order { - fmt.Println("######################################################## : ", strings.ToUpper(ord)) + // fmt.Println("######################################################## : ", strings.ToUpper(ord)) switch strings.ToUpper(ord) { // case "WAIT": // set send bye time // 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) return } 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])) // 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) @@ -262,7 +262,7 @@ func (s *SimPhone) Run() *icserror.IcsError { } func (s *SimPhone) RunMedia(port int, pt int) { - fmt.Println("#### RunMedia") + // fmt.Println("#### RunMedia") defer func() { s.wgMedia.Done() }() @@ -366,7 +366,7 @@ func (s *SimPhone) ExpireReadRTP(t *time.Ticker) { // s.sendRTPStatus = false // } else if time.Now().Sub(s.expTime) >= time.Second { - fmt.Println(t) + // fmt.Println(t) s.sendRTPStatus = true break } else if s.sendRTPStatus { diff --git a/testrtp/testrtp.go b/testrtp/testrtp.go index e275c46..f91b524 100644 --- a/testrtp/testrtp.go +++ b/testrtp/testrtp.go @@ -12,11 +12,11 @@ import ( func main() { alawData, ferr := ioutil.ReadFile("../voice/ohmygirl-dolphin-mono.alaw") if ferr != nil { - fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr) + // fmt.Println("COULD NOT READ OHMYGIRL'S DOLPHIN!!!", ferr) return } alawDataLen := len(alawData) - fmt.Println("alawDataLen", alawDataLen) + // fmt.Println("alawDataLen", alawDataLen) rtp := icsrtp.NewRTP(1, int(icspacketparser.PCMA), @@ -25,5 +25,5 @@ func main() { 0x3d99e5cd, alawData[:160]) - fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload)) + // fmt.Printf("%v\nPayload len: %d\n", rtp, len(rtp.Payload)) }