Compare commits

...

13 Commits

Author SHA1 Message Date
jiyoungcheon 98b9860369 AnounceMents assign directly to request.TalkText 2 weeks ago
jiyoungcheon 144931542c } 위치 변경 2 weeks ago
jiyoungcheon c1db8b0981 init일때 bot action STT로 2 weeks ago
jiyoungcheon 0398e7d078 STT: count+1->count, INIT:[dnis][1]->[dnis][0] 2 weeks ago
jiyoungcheon 44b06f9f8c to see what happens after init 2 weeks ago
jiyoungcheon 35d5c8a4a9 delete voiceagent 2 weeks ago
jiyoungcheon 7867c8d771 checking init announcement 2 weeks ago
jiyoungcheon a684516327 missing } 2 weeks ago
jiyoungcheon 488dfc2fb0 deleted unnecessary logics except 9012 2 weeks ago
jiyoungcheon 94b7da3e3d config path to 192.168.0.15 2 weeks ago
jiyoungcheon 22b1d92fa8 there is no println.. 2 weeks ago
jiyoungcheon ac2314e51a joy4 deleted 2 weeks ago
jiyoungcheon 4845e9ee5f 로그추가 2 weeks ago

@ -7,7 +7,6 @@ require (
cloud.google.com/go/texttospeech v1.0.0
github.com/gorilla/websocket v1.4.2
github.com/stretchr/testify v1.7.0
gitlab.com/ics_cinnamon/joy4 v1.0.25
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
)

@ -162,7 +162,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@ -180,10 +179,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
gitlab.com/ics_cinnamon/joy4 v1.0.24 h1:MQlMxeJ5ZBEerHzHf1D+/ruTeA1YXJKL5XbJdI3NVf4=
gitlab.com/ics_cinnamon/joy4 v1.0.24/go.mod h1:LFfF6nA92KMmd/hrGEgQzkIsX/n+IlqCI8vbY8/NnNI=
gitlab.com/ics_cinnamon/joy4 v1.0.25 h1:e20ciX68hnLv50GVENWDeyYkKz0XiX6ALevQfeSfrQc=
gitlab.com/ics_cinnamon/joy4 v1.0.25/go.mod h1:LFfF6nA92KMmd/hrGEgQzkIsX/n+IlqCI8vbY8/NnNI=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@ -193,8 +188,6 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
gocv.io/x/gocv v0.27.0 h1:3X8I74ULsWHd4m7DQRv2Nqx5VkKscfUFnKgLNodiboI=
gocv.io/x/gocv v0.27.0/go.mod h1:n4LnYjykU6y9gn48yZf4eLCdtuSb77XxSkW6g0wGf/A=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

@ -7,7 +7,6 @@ import (
"io/ioutil"
"math/big"
"net/http"
"strconv"
"strings"
"sync"
"time"
@ -151,7 +150,7 @@ func TTSFunc2(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "TTS func 2", r)
}
//post
// post
func TTSFunc3(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "TTS func 3", r)
body := make([]byte, r.ContentLength)
@ -163,13 +162,13 @@ func TTSFunc3(w http.ResponseWriter, r *http.Request) {
fmt.Println(string(body))
}
//post
// post
func TTSFunc4(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "TTS func 4", r)
}
/////////////////////////////////////////////
//BOT
// ///////////////////////////////////////////
// BOT
func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) {
// get scenario config
l := icslog.GetIcsLog()
@ -190,436 +189,65 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) {
}
agent := strings.SplitN(request.CallId, "@", 2)
fmt.Printf(">>>>>> DATA INFO - method [%s], agent [%s], token [%s]\n", request.Method, agent, request.Token)
l.Printf(icslog.LOG_LEVEL_INFO, -1, ">>>>>> DATA INFO - method [%s], agent [%s], token [%s] talk[%s]", request.Method, agent, request.Token, request.TalkText)
response := new(Response)
dnis := request.Dnis
s.m.Lock()
if request.Method == "HANGUP" {
response.ResultCode = 200
response.Token = request.Token
response.Action = ""
response.AnounceMents = ""
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 10
} else if request.Method != "INIT" && request.TalkText != "" {
l.Printf(icslog.LOG_LEVEL_INFO, -1, "dnis: %s", dnis)
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf[dnis][s.session[request.Token].Count].Action
// response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count].AnounceMents
response.AnounceMents = request.TalkText
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count].DigitTerm
response.Data.RecodingFile = "Y"
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count, Status: scnarioConf[dnis][s.session[request.Token].Count].Action}
l.Printf(icslog.LOG_LEVEL_INFO, -1, "response: %+v", response)
////////////////////////////////////
///////////// EXCEPT ///////////////
////////////////////////////////////
if conf.ExceptTest.TestInfo.Value {
// eType := conf.ExceptTest.TestInfo.Type
// if request.Method == "INIT" {
// response.ResultCode = conf.ExceptTest.TestInfo.ResultCode
// response.Token = conf.ExceptTest.TestInfo.Token
// response.Action = conf.ExceptTest.TestInfo.Action
// response.AnounceMents = conf.ExceptTest.TestInfo.Announcement
// response.Data.BargeIn = conf.ExceptTest.TestInfo.Bargein
// response.Data.RecodingFile = conf.ExceptTest.TestInfo.Recodingfile
// response.Data.SttMaxTime = conf.ExceptTest.TestInfo.Sttmaxtime
// s.session[conf.ExceptTest.TestInfo.Token] = ResStatus{Count: 1, Status: scnarioConf[dnis].Action[0], NotUnderstand: 0}
// } else if request.TalkText == "ERROR_TTS" || request.TalkText == "ERROR_STT" {
// response.ResultCode = 200
// response.Token = request.Token
// response.AnounceMents = "서비스에 문제가 발생하여 매장으로 연결해드릴게요."
// response.Action = "TRANSFER"
// response.Data.BargeIn = ""
// response.Data.RecodingFile = ""
// response.Data.SttMaxTime = 10
// } else if request.Method == "REFER" {
// response.ResultCode = 200
// response.Token = request.Token
// response.AnounceMents = "서비스에 문제가 발생하여 매장으로 연결해드릴게요."
// response.Action = "TRANSFER"
// response.Data.BargeIn = ""
// response.Data.RecodingFile = ""
// response.Data.SttMaxTime = 10
// } else if request.Method != "INIT" && request.TalkText == "" {
// response.ResultCode = 200
// response.Token = request.Token
// if s.session[request.Token].NotUnderstand == 3 {
// response.AnounceMents = "잘 이해하지 못했습니다. 정확한 상담을 위해 매장으로 연결해드릴게요."
// response.Action = "END"
// } else {
// response.AnounceMents = "잘 이해하지 못했습니다. 다시 말씀해주세요."
// response.Action = "STT"
// s.session[request.Token] = ResStatus{Count: 1, Status: scnarioConf[dnis].Action[0], NotUnderstand: s.session[request.Token].NotUnderstand + 1}
// }
// response.Data.BargeIn = ""
// response.Data.RecodingFile = ""
// response.Data.SttMaxTime = 10
// }
} else {
////////////////////////////////////
//////// SCENARIO MAPPING///////////
////////////////////////////////////
fmt.Println(request.Method)
if request.Method == "HANGUP" {
switch request.Method {
case "INIT":
l.Printf(icslog.LOG_LEVEL_INFO, -1, "INIT..scnarioConf[dnis][1].AnounceMents: %s", scnarioConf[dnis][1].AnounceMents)
token := createToken(request.CallId)
response.ResultCode = 200
response.Token = request.Token
response.Action = ""
response.AnounceMents = ""
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 10
} else if request.Method != "INIT" && request.TalkText == "" {
if request.TalkText == "" {
request.TalkText = "잘못된 값 입력 "
}
fmt.Println(dnis)
if dnis == "AISB" || dnis == "07075999956" || dnis == "821462" || dnis == "1462" {
dnis = "9013"
}
fmt.Println(dnis)
if dnis != "07012345678" && dnis != "07077442711" {
dnis = "sim"
}
if dnis == "07012345678" || dnis == "07077442711" {
dnis = "sim3"
}
if dnis == "9012" {
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf[dnis][s.session[request.Token].Count+1].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count+1].AnounceMents
if s.session[request.Token].Count != 0 && dnis == "9012" {
response.AnounceMents = strings.ReplaceAll(response.AnounceMents, "$", request.TalkText)
}
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count+1].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count+1].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count+1].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count+1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count+1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count+1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count+1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count+1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count+1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count+1].DigitTerm
response.Data.RecodingFile = "Y"
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
} else if dnis == "sim3" {
//시뮬레이터
response.ResultCode = 200
response.Action = scnarioConf[dnis][s.session[request.Token].Count].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count].AnounceMents
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count+1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count].DigitTerm
response.Data.RecodingFile = "Y"
if s.session[request.Token].LoopCount > 100 {
s.session[request.Token] = ResStatus{LoopCount: s.session[request.Token].LoopCount, Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
} else {
s.session[request.Token] = ResStatus{LoopCount: s.session[request.Token].LoopCount + 1, Count: 1, Status: scnarioConf[dnis][s.session[request.Token].Count].Action}
}
} else {
response.ResultCode = 200
response.Token = request.Token
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.AnnounceFilePath = scnarioConf[dnis][1].AudioFilePath
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][1].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][1].Action}
//s.m.Unlock()
}
} else {
fmt.Println("RECV METHOD")
fmt.Println(dnis)
// if dnis != "9012" && dnis != "9013" && dnis != "9014" {
// dnis = "sim"
// } else
if dnis == "AISB" || dnis == "07075999956" || dnis == "821462" || dnis == "1462" {
dnis = "9013"
}
fmt.Println(dnis)
if dnis == "9012" || dnis == "07012345678" || dnis == "07077442711" {
dnis = "sim3"
}
if dnis == "9013" {
dnis = "9014"
}
fmt.Println(scnarioConf[dnis])
switch request.Method {
case "INIT":
token := createToken(request.CallId)
response.ResultCode = 200
response.Token = token
response.Action = scnarioConf[dnis][s.session[request.Token].Count+1].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count+1].AnounceMents
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count+1].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count+1].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count+1].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count+1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count+1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count+1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count+1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count+1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count+1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count+1].DigitTerm
response.AnnounceFilePath = scnarioConf[dnis][s.session[request.Token].Count+1].AudioFilePath
response.Data.RecodingFile = "Y"
//s.m.Lock()
s.session[token] = ResStatus{Count: 1, Status: scnarioConf[dnis][0].Action, NotUnderstand: 0, PreEventNum: 1}
// s.m.Unlock()
case "STT", "DTMF", "BOTH", "MEMO", "NONE":
response.ResultCode = 200
response.Token = request.Token
if dnis == "9013" || dnis == "9014" {
response.Action = scnarioConf[dnis][s.session[request.Token].Count+1].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count+1].AnounceMents
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count+1].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count+1].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count+1].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count+1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count+1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count+1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count+1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count+1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count+1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count+1].DigitTerm
response.AnnounceFilePath = scnarioConf[dnis][s.session[request.Token].Count+1].AudioFilePath
response.Data.RecodingFile = "Y"
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
// s.m.Unlock()
} else if dnis == "9012" {
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
// response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
// response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count+1].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][1].Action}
// s.m.Unlock()
} else if dnis == "1000" {
preEventNum := s.session[request.Token].PreEventNum
fmt.Printf("\n num %+v\n", preEventNum)
switch preEventNum {
case 1:
actionNum, err := strconv.Atoi(request.TalkText)
if err == nil {
response.Action = scnarioConf[dnis][actionNum+2].Action
response.AnounceMents = scnarioConf[dnis][actionNum+2].AnounceMents
response.Data.Speed = scnarioConf[dnis][actionNum+2].Speed
response.Data.VoiceName = scnarioConf[dnis][actionNum+2].VoiceName
response.Data.Volume = scnarioConf[dnis][actionNum+2].Volume
response.Data.Pitch = scnarioConf[dnis][actionNum+2].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][actionNum+2].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][actionNum+2].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][actionNum+2].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][actionNum+2].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][actionNum+2].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][actionNum+2].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][actionNum+2].Action, PreEventNum: actionNum + 2}
// s.m.Unlock()
} else {
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][1].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][1].Action, PreEventNum: 1}
// s.m.Unlock()
}
case 2:
actionNum, err := strconv.Atoi(request.TalkText)
if err == nil {
if actionNum == 1 {
response.Action = scnarioConf[dnis][s.session[request.Token].PreEventNum2].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].PreEventNum2].AnounceMents
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].PreEventNum2].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].PreEventNum2].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].PreEventNum2].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].PreEventNum2].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].PreEventNum2].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].PreEventNum2].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].PreEventNum2].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].PreEventNum2].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].PreEventNum2].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].PreEventNum2].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].PreEventNum2].Action, PreEventNum: s.session[request.Token].PreEventNum2}
// s.m.Unlock()
} else {
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][1].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][1].Action, PreEventNum: 1, PreEventNum2: 1}
// s.m.Unlock()
}
} else {
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][1].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][1].Action, PreEventNum: 1}
// s.m.Unlock()
}
default:
response.Action = scnarioConf[dnis][2].Action
response.AnounceMents = "결과 " + request.TalkText + " " + scnarioConf[dnis][2].AnounceMents
response.Data.Speed = scnarioConf[dnis][2].Speed
response.Data.VoiceName = scnarioConf[dnis][2].VoiceName
response.Data.Volume = scnarioConf[dnis][2].Volume
response.Data.Pitch = scnarioConf[dnis][2].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][2].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][2].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][2].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][2].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][2].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][2].DigitTerm
response.Data.RecodingFile = "Y"
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][2].Action, PreEventNum: 2, PreEventNum2: s.session[request.Token].PreEventNum}
//s.m.Unlock()
}
} else {
//시뮬레이터
response.Action = scnarioConf[dnis][s.session[request.Token].Count].Action
response.AnounceMents = scnarioConf[dnis][s.session[request.Token].Count].AnounceMents
response.Data.Speed = scnarioConf[dnis][s.session[request.Token].Count].Speed
response.Data.VoiceName = scnarioConf[dnis][s.session[request.Token].Count].VoiceName
response.Data.Volume = scnarioConf[dnis][s.session[request.Token].Count].Volume
response.Data.Pitch = scnarioConf[dnis][s.session[request.Token].Count].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][s.session[request.Token].Count].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][s.session[request.Token].Count].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][s.session[request.Token].Count].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][s.session[request.Token].Count].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][s.session[request.Token].Count+1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][s.session[request.Token].Count].DigitTerm
response.Data.RecodingFile = "Y"
if s.session[request.Token].LoopCount > 100 {
s.session[request.Token] = ResStatus{LoopCount: s.session[request.Token].LoopCount, Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count].Action}
} else {
s.session[request.Token] = ResStatus{LoopCount: s.session[request.Token].LoopCount + 1, Count: s.session[request.Token].Count, Status: scnarioConf[dnis][s.session[request.Token].Count].Action}
}
// s.m.Lock()
// s.m.Unlock()
}
case "REFER":
response.ResultCode = 200
response.Token = request.Token
response.Action = "TRANSFER"
response.AnounceMents = "네. 매장으로 연결해드릴게요."
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 0
response.Data.TelNo = request.TelNo
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
case "TRANSFER":
response.ResultCode = 200
response.Token = request.Token
response.Action = "TRANSFER"
response.AnounceMents = "네. 매장으로 연결해드릴게요."
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 0
response.Data.TelNo = request.TelNo
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
// s.m.Unlock()
case "TRNASFER2": // 전화 종료 요청
response.ResultCode = 200
response.Token = request.Token
response.Action = "TRANSFER2"
response.AnounceMents = "네. 매장으로 연결해드릴게요."
response.Data.BargeIn = ""
response.Data.RecodingFile = ""
response.Data.SttMaxTime = 0
response.Data.TelNo = request.TelNo
// s.m.Lock()
s.session[request.Token] = ResStatus{Count: s.session[request.Token].Count + 1, Status: scnarioConf[dnis][s.session[request.Token].Count+1].Action}
// s.m.Unlock()
response.Token = request.Token
response.Action = "END"
response.AnounceMents = "접수가 완료되었습니다."
response.Data.BargeIn = "N"
response.Data.RecodingFile = "Y"
response.Data.SttMaxTime = 0
}
response.Token = token
response.Action = scnarioConf[dnis][1].Action
response.AnounceMents = scnarioConf[dnis][1].AnounceMents
response.Data.Speed = scnarioConf[dnis][1].Speed
response.Data.VoiceName = scnarioConf[dnis][1].VoiceName
response.Data.Volume = scnarioConf[dnis][1].Volume
response.Data.Pitch = scnarioConf[dnis][1].Pitch
response.Data.MaxWaitTime = scnarioConf[dnis][1].MaxWaitTime
response.Data.BargeIn = scnarioConf[dnis][1].BargeIn
response.Data.SttMaxTime = scnarioConf[dnis][1].SttMaxTime
response.Data.MaxDigit = scnarioConf[dnis][1].MaxDigit
response.Data.EndCharacter = []string{scnarioConf[dnis][1].EndCharacter}
response.Data.DigitTerm = scnarioConf[dnis][1].DigitTerm
response.AnnounceFilePath = scnarioConf[dnis][1].AudioFilePath
response.Data.RecodingFile = "Y"
s.session[token] = ResStatus{Count: 1, Status: scnarioConf[dnis][1].Action, NotUnderstand: 0, PreEventNum: 1}
}
}
response.Data.UUI = json.RawMessage{}
uuiMap := map[string]interface{}{
"test1": "testdata1231",
@ -630,21 +258,22 @@ func (s *ScenarioSession) BOTPFunc(w http.ResponseWriter, r *http.Request) {
// 맵을 JSON으로 마샬링
uuiJSON, err := json.Marshal(uuiMap)
if err != nil {
fmt.Println("Error marshaling UUI:", err)
l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Error marshaling UUI: %v", err)
return
}
// 마샬링된 JSON을 json.RawMessage로 변환
response.Data.UUI = json.RawMessage(uuiJSON)
response.Data.TelNo = request.TelNo
s.m.Unlock()
// s.m.Unlock()
// response marshal
resMarshal, jerr := json.Marshal(response)
if jerr != nil {
fmt.Println("Json Marshal error ", jerr)
l.Printf(icslog.LOG_LEVEL_ERROR, -1, "Json Marshal error %v", jerr)
}
fmt.Printf("%+v", response)
l.Printf(icslog.LOG_LEVEL_INFO, -1, "%+v", response)
l.Printf(icslog.LOG_LEVEL_INFO, -1, "Send Message\n %s", string(resMarshal))
// if s.session[request.Token].Count < len(scnarioConf[dnis]) && scnarioConf[dnis][s.session[request.Token].Count].TimeValue {

@ -1,147 +0,0 @@
package icsmediaconv
import (
"sync"
"gitlab.com/cinnamon/voiceagent/icserror"
"gitlab.com/cinnamon/voiceagent/icslog"
"gitlab.com/cinnamon/voiceagent/icspacketparser"
"gitlab.com/ics_cinnamon/joy4/av"
"gitlab.com/ics_cinnamon/joy4/cgo/ffmpeg"
"gitlab.com/ics_cinnamon/joy4/codec"
)
const (
ICS_PT_MULAW = 0
ICS_PT_ALAW = 8
ICS_PT_G729 = 18
ICS_PT_END = ICS_PT_G729
)
const PCM_8K_16BIT_10MS_SIZE = 160
type Converter struct {
payloadtype icspacketparser.PayloadType
codec av.AudioCodecData
decoder *ffmpeg.AudioDecoder
samplingRate int
onePacketSize int
isStart bool
m *sync.Mutex
ID int
}
func NewConverter(id int, pt icspacketparser.PayloadType) (*Converter, *icserror.IcsError) {
conv := &Converter{payloadtype: pt}
conv.ID = id
conv.isStart = false
conv.m = &sync.Mutex{}
switch pt {
case ICS_PT_MULAW:
conv.codec = codec.NewPCMMulawCodecData()
conv.samplingRate = 8000
conv.onePacketSize = 160
case ICS_PT_ALAW:
conv.codec = codec.NewPCMAlawCodecData()
conv.samplingRate = 8000
conv.onePacketSize = 160
case ICS_PT_G729:
conv.codec = codec.NewG729CodecData()
conv.samplingRate = 8000
conv.onePacketSize = 10
default:
return nil, icserror.ICSERRCONVNotSupportedCodec
}
var err error
conv.decoder, err = ffmpeg.NewAudioDecoder(conv.codec)
if err != nil {
icserror.ICSERRCONVNotSupportedCodec.SetError(err)
return nil, icserror.ICSERRCONVNotSupportedCodec
}
ffmpeg.SetLogLevel(ffmpeg.QUIET)
conv.Start()
l := icslog.GetIcsLog()
l.Printf(icslog.LOG_LEVEL_DEBUG2, id, "### NewDecode()")
return conv, nil
}
func (c *Converter) Start() {
c.m.Lock()
c.isStart = true
c.m.Unlock()
}
func (c *Converter) Stop() {
c.m.Lock()
c.isStart = false
c.m.Unlock()
}
func (c *Converter) IsStart() bool {
return c.isStart
}
func (c *Converter) Close() {
c.Stop()
c.decoder.Close()
l := icslog.GetIcsLog()
l.Print(icslog.LOG_LEVEL_INFO, c.ID, "Closed Decoder")
}
func (c *Converter) Decode(packet []byte) ([]byte, *icserror.IcsError) {
//l := icslog.GetIcsLog()
//l.Printf(icslog.LOG_LEVEL_DEBUG2, -1, "converter### Decode() packet length: %d", len(packet))
retBuf := make([]byte, PCM_8K_16BIT_10MS_SIZE*2)
packetLen := len(packet)
iter := 0
for packetLen >= c.onePacketSize {
packetLen -= c.onePacketSize
//fmt.Printf("### Decode() iter(%d) packetlen(%d)\n", iter, packetLen)
buf := packet[c.onePacketSize*iter : c.onePacketSize*(iter+1)]
//fmt.Printf("### Decode() iter(%d), buf length %d %v\n", iter, len(buf), buf)
//l.Printf(icslog.LOG_LEVEL_DEBUG2, c.ID, "### Decode() iter(%d), buf length %d %v", iter, len(buf), buf)
c.m.Lock()
if c.IsStart() {
ok, frame, errDec := c.decoder.Decode(buf)
if !ok {
icserror.ICSERRCONVDecodeFail.SetError(errDec)
//icserror.ICSERRCONVDecodeFail.Print()
c.m.Unlock()
return nil, icserror.ICSERRCONVDecodeFail
}
//fmt.Println("###frame len", iter, PCM_8K_16BIT_10MS_SIZE*iter, PCM_8K_16BIT_10MS_SIZE*(iter+1))
//fmt.Println("###frame len", len(frame.Data[0]), len(frame.Data), frame)
copy(retBuf[PCM_8K_16BIT_10MS_SIZE*iter:PCM_8K_16BIT_10MS_SIZE*(iter+1)], frame.Data[0][:PCM_8K_16BIT_10MS_SIZE])
}
c.m.Unlock()
/*
f1, err := os.OpenFile("./tx.voice.raw", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
f1.Write(frame.Data[0][:PCM_8K_16BIT_10MS_SIZE])
f1.Sync()
f1.Close()
*/
iter++
}
//fmt.Println("###retBuf len", len(retBuf), retBuf)
return retBuf, nil
}

@ -1,76 +0,0 @@
package icssessionmanager
import (
"strings"
"gitlab.com/cinnamon/voiceagent/icserror"
"gitlab.com/cinnamon/voiceagent/icslog"
"gitlab.com/cinnamon/voiceagent/icspacketparser"
"gitlab.com/cinnamon/voiceagent/icssvc"
"gitlab.com/cinnamon/voiceagent/recorddata"
)
func (s *IcsSession) analyzeRTP(rtp *icspacketparser.RTP) *icserror.IcsError {
l := icslog.GetIcsLog()
RPT := rtp.GetPayloadType()
SPT := s.GetPayloadType()
if SPT == RPT {
if s.VoiceNeter == nil {
l.Print(icslog.LOG_LEVEL_ERROR, s.ID, icserror.ICSERRNETNotConnectError.GetMessage())
return icserror.ICSERRNETNotConnectError
}
voicedata := recorddata.NewVoiceData()
svc := icssvc.GetServiceStatus()
conf := svc.GetIcsConfig()
if strings.Compare(conf.HTTPConfig.SrcIP, rtp.SrcAddr.IPv4String) == 0 { //RX
//if strings.Compare(conf.PbxConfig.PbxIp, rtp.SrcAddr.IPv4String) == 0 { //RX
/*//////////////////
s.rxFile.Write(rtp.Payload)
*/ //////////////////
pcm, err := s.RxConverter.Decode(rtp.Payload)
if err != nil {
l.Print(icslog.LOG_LEVEL_ERROR, s.ID, err.GetMessage())
return err
}
if s.rxSeq == -1 {
s.rxSeq = int(rtp.Seq)
}
voicedata.SetData(s.ServerID, s.Station, int32(rtp.Seq-uint16(s.rxSeq)), s.StartTimeStamp, "0", "0", pcm)
wsize, err := s.VoiceNeter.Write(voicedata.GetData())
if wsize == -1 || err != nil {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "RTP send error-%v", err.GetError())
return err
}
} else { //TX
/*//////////////////
s.txFile.Write(rtp.Payload)
*/ //////////////////
pcm, err := s.TxConverter.Decode(rtp.Payload)
if err != nil {
l.Print(icslog.LOG_LEVEL_ERROR, s.ID, err.GetMessage())
return err
}
if s.txSeq == -1 {
s.txSeq = int(rtp.Seq)
}
voicedata.SetData(s.ServerID, s.Station, int32(rtp.Seq-uint16(s.txSeq)), s.StartTimeStamp, "1", "0", pcm)
wsize, err := s.VoiceNeter.Write(voicedata.GetData())
if wsize == -1 || err != nil {
//l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "RTP send error-%v", err.GetError())
return err
}
}
} else {
l.Print(icslog.LOG_LEVEL_ERROR, s.ID, "NO same payload type!!!")
}
return nil
}

@ -1,211 +0,0 @@
package icssessionmanager
import (
"strconv"
"strings"
"time"
"gitlab.com/cinnamon/voiceagent/icserror"
"gitlab.com/cinnamon/voiceagent/icslog"
"gitlab.com/cinnamon/voiceagent/icsmediaconv"
"gitlab.com/cinnamon/voiceagent/icsnet"
"gitlab.com/cinnamon/voiceagent/icspacketparser"
"gitlab.com/cinnamon/voiceagent/icssvc"
"gitlab.com/cinnamon/voiceagent/recorddata/writecallsignal"
)
func (s *IcsSession) analyzeSIP(sip *icspacketparser.SIP) *icserror.IcsError {
// fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>")
// fmt.Println("sip.Method", sip.Method)
// fmt.Println("sip.Version", sip.Version)
// fmt.Println("sip.Headers", sip.Headers)
// fmt.Println("sip.Source", sip.Source)
// fmt.Printf("%+v\n", sip)
//fmt.Println(">>>>>>>>>>>>>>>>>>>>>>> sip.Method", sip.Method)
l := icslog.GetIcsLog()
// fmt.Println(">>>>>>>>>>>>>>>>>>>>>>> sip.Method", sip.Method)
if sip.Method == icspacketparser.ICS_SIP_METHOD_INVITE {
s.setSrcPort(sip)
payload, err := s.setSDPMediaPayload(sip)
if err != nil {
return icserror.ICSERRSDPAudiotagPortValue
} else {
s.invitePayloads = payload
}
} else if strings.Contains(sip.Cseq, " INVITE") {
s.setDstPort(sip)
}
if sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && !s.isFoundPayload {
// fmt.Println(">>>>>>>>>>>>>>> ICS_SIP_METHOD_SIP20", sip.ResType, sip.ContentType, sip.ContentLength)
if strings.Contains(sip.ContentType, "sdp") && sip.ContentLength > 0 {
payload, err := s.compareSDPMediaPayload(sip)
if err != nil {
return icserror.ICSERRSDPAudiotagPortValue
} else {
s.isFoundPayload = true
s.payloadType = icspacketparser.PayloadType(payload)
//fmt.Println("s.payload >>>>>>>>>>>>>>>", s.payloadType)
//create media decoder
var cerr *icserror.IcsError
s.TxConverter, cerr = icsmediaconv.NewConverter(s.ID, s.payloadType)
if cerr != nil {
//s.isFoundPayload = false
//cerr.Print()
l.Printf(icslog.LOG_LEVEL_FATAL, s.ID, "Failed to New Tx Converter-%v", cerr)
s.SendVoiceGatewayByeSignal()
return cerr
} else {
l.Print(icslog.LOG_LEVEL_INFO, s.ID, "New Tx Converter(Decoder)")
}
s.RxConverter, cerr = icsmediaconv.NewConverter(s.ID, s.payloadType)
if cerr != nil {
//s.isFoundPayload = false
l.Printf(icslog.LOG_LEVEL_FATAL, s.ID, "Failed to New Rx Converter-%v", cerr)
s.SendVoiceGatewayByeSignal()
return cerr
} else {
l.Print(icslog.LOG_LEVEL_INFO, s.ID, "New Rx Converter(Decoder)")
}
//init VoiceAgent net
conf := icssvc.GetServiceStatus().GetIcsConfig()
if conf != nil {
//set call signal remote addr
csraddr := icsnet.NewNetAddrWithIPPort("127.0.0.1", 1111)
csladdr := icsnet.NewNetAddrWithIPPort("127.0.0.1", 2222)
//csraddr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.AgentAddr.VoiceAgentIP, conf.VoiceAgentConfig.AgentAddr.CallSignalPort)
//csladdr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.MyAddr.ServerIP, conf.VoiceAgentConfig.MyAddr.ServerPort)
//set Voice remote addr
vraddr := icsnet.NewNetAddrWithIPPort("127.0.0.1", 3333)
//vraddr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.AgentAddr.VoiceAgentIP, conf.VoiceAgentConfig.AgentAddr.VoicePort)
//vladdr := icsnet.NewNetAddrWithIPPort(conf.VoiceAgentConfig.MyAddr.ServerIP, conf.VoiceAgentConfig.MyAddr.BasePort)
s.VoiceNeter = icsnet.NewUDP(nil, &vraddr)
//s.VoiceNeter = icsnet.NewUDP(&vladdr, &vraddr)
conerr := s.VoiceNeter.Connect()
if conerr != nil {
l.Printf(icslog.LOG_LEVEL_ERROR, s.ID, "Error init Voice Neter[%s->%s]-%v", s.VoiceNeter.LocalAddr().String(), vraddr.String(), conerr.GetError())
s.SendVoiceGatewayByeSignal()
return conerr
}
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Voice(UDP) Connected to VoiceAgent[%s->%s]", s.VoiceNeter.LocalAddr().String(), vraddr.String())
//send call signal data to VoiceAgent
defer func() {
if err := recover(); err != nil {
l.Print(icslog.LOG_LEVEL_WARN, s.ID, icserror.ICSERRNETNotConnectError.GetMessage())
}
}()
var inout string = "O"
if s.GetDirection() {
inout = "I"
}
callsignal := writecallsignal.NewCallSignalData()
//callsignal := recorddata.NewCallSignalData()
//s.StartTimeStamp = time.Now().UnixNano() / 1e6
s.StartTimeStamp = time.Now().UnixNano()
callsignal.SetData(s.ChannelID, s.ServerID, s.Station, "CUSTID", s.StartTimeStamp, 0, "S", inout)
wlen, werr := icsnet.SendCallSignal(&csladdr, &csraddr, callsignal.GetData())
if werr == nil {
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Transmitted Call-Start signal to VoiceAgent(%d)", wlen)
}
}
}
}
}
return nil
}
func (s *IcsSession) setSrcPort(sip *icspacketparser.SIP) *icserror.IcsError {
if sip.Content == nil {
//error 처리 invite인데, sdp 데이터가 없음
return icserror.ICSERRINVITERequired
} else {
// fmt.Println("sdpMedias", *sip.Content.Media)
port, err := s.findSDPMediaAudioPort(sip)
if err != nil {
return icserror.ICSERRSDPAudiotagPortValue
} else {
s.srcPort = port
}
}
return nil
}
func (s *IcsSession) setDstPort(sip *icspacketparser.SIP) *icserror.IcsError {
// fmt.Println(">>>>>>>>>>>>>>>>>>>>>>> sip.Cseq", sip.Cseq, sip.Method)
if sip.Method == icspacketparser.ICS_SIP_METHOD_SIP20 && sip.ResType == "200" {
if sip.Content == nil {
//error 처리 INVITE처리의 200 OK인데, sdp 데이터가 없음
return icserror.ICSERR200OKRequired
} else {
// fmt.Println("sdpMedias", *sip.Content.Media)
port, err := s.findSDPMediaAudioPort(sip)
if err != nil {
return icserror.ICSERRSDPAudiotagPortValue
} else {
s.dstPort = port
}
}
} else if sip.Method == icspacketparser.ICS_SIP_METHOD_BYE {
//fmt.Println(">>>>>>>>>>> haup up event")
// s.RemoveSession()
}
return nil
}
func (s *IcsSession) findSDPMediaAudioPort(sip *icspacketparser.SIP) (int, *icserror.IcsError) {
for _, value := range *sip.Content.Media {
if strings.Contains(value.MediaDescription, "audio ") {
arrSdpMedia := strings.Split(value.MediaDescription, " ")
port, err := strconv.Atoi(arrSdpMedia[1])
if err != nil {
return -1, icserror.ICSERRSDPAudiotagPortValue
} else {
//fmt.Println(">>>>>>>>>>>>>>>>>>>>>>> port", port)
return port, nil
}
} else {
return -1, icserror.ICSERRNotFoundSdpMedia
}
}
return -1, icserror.ICSERRNotFoundSdpMedia
}
func (s *IcsSession) setSDPMediaPayload(sip *icspacketparser.SIP) ([]string, *icserror.IcsError) {
for _, value := range *sip.Content.Media {
if strings.Contains(value.MediaDescription, "audio ") {
//fmt.Println("value.Payload >>>>>>>>>>>", value.Payload)
return value.Payload, nil
} else {
return nil, icserror.ICSERRNotFoundSdpMedia
}
}
return nil, icserror.ICSERRNotFoundSdpMedia
}
func (s *IcsSession) compareSDPMediaPayload(sip *icspacketparser.SIP) (int, *icserror.IcsError) {
for _, value := range *sip.Content.Media {
for _, thisPayload := range value.Payload {
for _, invitePayload := range s.invitePayloads {
if thisPayload == invitePayload {
payload, err := strconv.Atoi(thisPayload)
if err != nil {
return -1, icserror.ICSERRSDPAudiotagPortValue
} else {
return payload, nil
}
}
}
}
}
return -1, icserror.ICSERRNotFoundSdpMedia
}

@ -14,7 +14,6 @@ import (
"gitlab.com/cinnamon/voiceagent/icsevent"
"gitlab.com/cinnamon/voiceagent/icshttpclient"
"gitlab.com/cinnamon/voiceagent/icslog"
"gitlab.com/cinnamon/voiceagent/icsmediaconv"
"gitlab.com/cinnamon/voiceagent/icsnet"
"gitlab.com/cinnamon/voiceagent/icspacketparser"
"gitlab.com/cinnamon/voiceagent/icssvc"
@ -23,7 +22,6 @@ import (
"gitlab.com/cinnamon/voiceagent/recorddata/readcallsignal"
"gitlab.com/cinnamon/voiceagent/recorddata/responsecs"
"gitlab.com/cinnamon/voiceagent/stt"
"gitlab.com/ics_cinnamon/joy4/format"
)
type IcsSession struct {
@ -52,13 +50,13 @@ type IcsSession struct {
invitePayloads []string
payloadType icspacketparser.PayloadType
isFoundPayload bool
TxConverter *icsmediaconv.Converter
RxConverter *icsmediaconv.Converter
txSeq int //first TX seq num
rxSeq int //first RX seq num
STTTx *stt.STT
STTRx *stt.STT
cs *readcallsignal.CallSignal
// TxConverter *icsmediaconv.Converter
// RxConverter *icsmediaconv.Converter
txSeq int //first TX seq num
rxSeq int //first RX seq num
STTTx *stt.STT
STTRx *stt.STT
cs *readcallsignal.CallSignal
isSTTStartTimer *time.Timer
isSTTStart bool
@ -107,12 +105,12 @@ const (
//////////////////////////////////////////////////////////////////
//session routine
//init ffmpeg
func init() {
format.RegisterAll()
}
// init ffmpeg
// func init() {
// format.RegisterAll()
// }
//on/off check the session idle
// on/off check the session idle
func (s *IcsSession) Start() {
s.SetTimestamp(time.Now())
@ -358,13 +356,13 @@ func (s *IcsSession) Run() *icserror.IcsError {
*/
case icspacketparser.SIP:
l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Get SIP Event[%d]", evt.ID)
sip := v
s.analyzeSIP(&sip)
// sip := v
// s.analyzeSIP(&sip)
case icspacketparser.RTP:
//l.Printf(icslog.LOG_LEVEL_INFO, s.ID, "Get RTP Event[%d]", evt.ID)
rtp := v
// rtp := v
//fmt.Println(rtp)
s.analyzeRTP(&rtp)
// s.analyzeRTP(&rtp)
//default:
//fmt.Println(time.Now(), "NOT DEFINED EVENT TYPE!!!!!!!!!!!!!!!!!")
default:

@ -17,8 +17,8 @@ import (
"gitlab.com/cinnamon/voiceagent/recorddata/responsecs"
)
//////////////////////////////////////////////////////////////////
//session operator
// ////////////////////////////////////////////////////////////////
// session operator
func findSessionWithCallID(callId string) *IcsSession {
sessions := getSessionInstance()
for _, session := range sessions {
@ -256,14 +256,14 @@ func (s *IcsSession) RemoveSession() *icserror.IcsError {
s.sstation = e.sstation
s.isFoundPayload = false
if s.RxConverter != nil {
s.RxConverter.Close()
s.RxConverter = nil
}
if s.TxConverter != nil {
s.TxConverter.Close()
s.TxConverter = nil
}
// if s.RxConverter != nil {
// s.RxConverter.Close()
// s.RxConverter = nil
// }
// if s.TxConverter != nil {
// s.TxConverter.Close()
// s.TxConverter = nil
// }
s.botStatus = nil
s.botToken = ""
@ -313,8 +313,7 @@ func (s *IcsSession) CheckSignalMethod(sip icspacketparser.SIP) *icserror.IcsErr
return nil
}
//////////////////////////////////////////////////////////////////
//
// ////////////////////////////////////////////////////////////////
func (s *IcsSession) SetTimestamp(now time.Time) {
s.lastTimestamp = now
}
@ -412,8 +411,8 @@ func (s *IcsSession) SendVoiceGatewayBotByeSignal(url string, custid string, sst
}
}
//////////////////////////////////////////
//DTMF
// ////////////////////////////////////////
// DTMF
// add DTMF
func (s *IcsSession) AddDtmf() {
inputDtmf := s.cs.InOut

@ -62,7 +62,7 @@ func main() {
}
//configuration
configFile := fmt.Sprintf("/home/icsbot/config/icsbot.xml")
configFile := fmt.Sprintf("/home/jiyoungc/svc/icsbot/config/icsbot.xml")
//configFile := fmt.Sprintf("%s/config/icsvc.xml", service.GetHomeDir())
//fmt.Println("Config file:", configFile)
conf, confErr := icsconf.OpenConfig(configFile, homeDir)

Loading…
Cancel
Save