mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-05 16:02:17 +00:00
fix(vowifi): accept MT SMS with 202, drop PCMU, and hold after vocall connect
Inbound RP-DATA now answers SIP 202 per TS 24.341, then still sends RP-ACK. The originating offer is IR.92 AMR/AMR-WB/EVS plus telephone-event at 8 kHz and 16 kHz; PCMU is off the m-line, maxptime is 240, and RTCP is advertised. vocall hold_seconds>=8 now sends a 24.610 hold re-INVITE two seconds after 200 OK and resumes three seconds later.
This commit is contained in:
1 parent
579d6af284
commit
93a7b96660
12 files changed
+69
-19
No files matched your search
@@ -84,7 +84,7 @@ func TestInboundMemoryFullSendsRPError22ThenSMMA(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(response, "SIP/2.0 200") {
|
||||
if !strings.HasPrefix(response, "SIP/2.0 202") {
|
||||
t.Fatalf("SIP response = %q", response)
|
||||
}
|
||||
select {
|
||||
@@ -290,7 +290,7 @@ func TestInboundDummyMSISDNWithoutFeatureCapsIsDiscarded(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(response, "SIP/2.0 200") {
|
||||
if !strings.HasPrefix(response, "SIP/2.0 202") {
|
||||
t.Fatalf("SIP response = %q", response)
|
||||
}
|
||||
select {
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *Service) handleInboundTPStatusReport(raw string, rpMR byte, payload []b
|
||||
if err != nil {
|
||||
return s.inboundSMSProtocolError(raw, 400, rpMR, true, err)
|
||||
}
|
||||
response, err := buildSIPRequestResponse(raw, 200)
|
||||
response, err := buildSIPRequestResponse(raw, inboundRPDataSIPStatus)
|
||||
if err != nil {
|
||||
return inboundSIPResult{}, err
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ import (
|
||||
const (
|
||||
imsSMSContentType = "application/vnd.3gpp.sms"
|
||||
rpCauseTemporaryFailure = byte(41)
|
||||
inboundSMSAckTimeout = 10 * time.Second
|
||||
inboundSMSFragmentTTL = 3 * time.Minute
|
||||
// TS 24.341 5.3.2.3: MT RP-DATA is accepted with SIP 202, then RP-ACK
|
||||
// is sent in a separate MESSAGE. RP-ACK/RP-ERROR of our MO stay 200.
|
||||
inboundRPDataSIPStatus = 202
|
||||
inboundSMSAckTimeout = 10 * time.Second
|
||||
inboundSMSFragmentTTL = 3 * time.Minute
|
||||
// A carrier response arrived 35m37s late in production. One hour keeps a
|
||||
// bounded recovery margin without delaying the 3-minute user notification.
|
||||
inboundSMSLateReassemblyTTL = time.Hour
|
||||
@@ -172,7 +175,7 @@ func (s *Service) handleInboundRPData(raw string, rpdu []byte, rpMR byte, xml sh
|
||||
}
|
||||
if smscodec.IsDummyMSISDN(message.sender) {
|
||||
if !hasMSISDNLessFeatureCaps(raw) {
|
||||
response, responseErr := buildSIPRequestResponse(raw, 200)
|
||||
response, responseErr := buildSIPRequestResponse(raw, inboundRPDataSIPStatus)
|
||||
return inboundSIPResult{response: response}, responseErr
|
||||
}
|
||||
message.msisdnLess = true
|
||||
@@ -182,7 +185,7 @@ func (s *Service) handleInboundRPData(raw string, rpdu []byte, rpMR byte, xml sh
|
||||
}
|
||||
}
|
||||
s.logInboundSMSCorrelation(raw, message)
|
||||
response, err := buildSIPRequestResponse(raw, 200)
|
||||
response, err := buildSIPRequestResponse(raw, inboundRPDataSIPStatus)
|
||||
if err != nil {
|
||||
return inboundSIPResult{}, err
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestInboundSMSDeliversEventAndSendsRPAck(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatalf("dispatchInboundSIP: %v", err)
|
||||
}
|
||||
if !strings.HasPrefix(response, "SIP/2.0 200") {
|
||||
if !strings.HasPrefix(response, "SIP/2.0 202") {
|
||||
t.Fatalf("SIP response = %q", response)
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ func dispatchInboundMultipartPart(t *testing.T, service *Service, rawTPDU []byte
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(response, "SIP/2.0 200") {
|
||||
if !strings.HasPrefix(response, "SIP/2.0 202") {
|
||||
t.Fatalf("SIP response = %q", response)
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -255,8 +255,10 @@ func buildBasicSDP(ip string, port int, sessionID int64) []byte {
|
||||
"s=VoHive Call\r\n"+
|
||||
"c=IN %s %s\r\n"+
|
||||
"t=0 0\r\n"+
|
||||
"m=audio %d RTP/AVP 104 110 102 108 106 101 0\r\n"+
|
||||
"m=audio %d RTP/AVP 104 110 102 108 106 96 101\r\n"+
|
||||
"b=AS:80\r\n"+
|
||||
"b=RS:0\r\n"+
|
||||
"b=RR:0\r\n"+
|
||||
"a=rtpmap:104 AMR-WB/16000\r\n"+
|
||||
"a=fmtp:104 mode-change-capability=2;max-red=0\r\n"+
|
||||
"a=rtpmap:110 AMR-WB/16000\r\n"+
|
||||
@@ -267,14 +269,16 @@ func buildBasicSDP(ip string, port int, sessionID int64) []byte {
|
||||
"a=fmtp:108 octet-align=1;mode-change-capability=2;max-red=0\r\n"+
|
||||
"a=rtpmap:106 EVS/16000\r\n"+
|
||||
"a=fmtp:106 evs-mode-switch=1;hf-only=0;br=6.6-23.85;bw=wb;ch-aw-recv=-1;max-red=0\r\n"+
|
||||
"a=rtpmap:96 telephone-event/16000\r\n"+
|
||||
"a=fmtp:96 0-15\r\n"+
|
||||
"a=rtpmap:101 telephone-event/8000\r\n"+
|
||||
"a=fmtp:101 0-15\r\n"+
|
||||
"a=rtpmap:0 PCMU/8000\r\n"+
|
||||
sdpQoSReservedLocal +
|
||||
sdpQoSReservedLocal+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=ptime:20\r\n"+
|
||||
"a=maxptime:20\r\n",
|
||||
sessionID, sessionID, ipFamily, ip, ipFamily, ip, port))
|
||||
"a=maxptime:240\r\n"+
|
||||
"a=rtcp:%d\r\n",
|
||||
sessionID, sessionID, ipFamily, ip, ipFamily, ip, port, port+1))
|
||||
}
|
||||
|
||||
func (a *Agent) localAddr() string {
|
||||
|
||||
+7
-2
@@ -9,12 +9,17 @@ import (
|
||||
"github.com/iniwex5/vowifi-go/internal/vowifi/voice/callstate"
|
||||
)
|
||||
|
||||
// HoldCall puts an established call on hold with a sendonly re-INVITE.
|
||||
// ErrHoldNotAligned is kept for the phone/API mapping of a hold that the
|
||||
// live IMS dialog cannot send. Originating hold/resume now sends the
|
||||
// TS 24.610 re-INVITE via setCallHold.
|
||||
var ErrHoldNotAligned = errors.New("voice: hold is not aligned to 24.229/24.610 on the live network")
|
||||
|
||||
// HoldCall sends a mid-dialog hold re-INVITE (a=sendonly).
|
||||
func (a *Agent) HoldCall(ctx context.Context, callID string) error {
|
||||
return a.setCallHold(ctx, callID, true)
|
||||
}
|
||||
|
||||
// ResumeCall retrieves a locally held call with a sendrecv re-INVITE.
|
||||
// ResumeCall sends a mid-dialog resume re-INVITE (a=sendrecv).
|
||||
func (a *Agent) ResumeCall(ctx context.Context, callID string) error {
|
||||
return a.setCallHold(ctx, callID, false)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/iniwex5/vowifi-go/internal/vowifi/logging"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -50,9 +52,31 @@ func (a *Agent) SimulateCall(
|
||||
if request.OnConnected != nil {
|
||||
request.OnConnected()
|
||||
}
|
||||
if request.HoldSeconds >= 8 {
|
||||
go a.exerciseSimulatedHoldResume(call)
|
||||
}
|
||||
return a.holdSimulatedCall(ctx, call, request.HoldSeconds, startedAt)
|
||||
}
|
||||
|
||||
func (a *Agent) exerciseSimulatedHoldResume(call *Call) {
|
||||
if a == nil || call == nil {
|
||||
return
|
||||
}
|
||||
callID := call.CallID()
|
||||
time.Sleep(2 * time.Second)
|
||||
if err := a.HoldCall(context.Background(), callID); err != nil {
|
||||
logging.Info("IMS simulated hold failed", "device", a.deviceID, "err", err)
|
||||
return
|
||||
}
|
||||
logging.Info("IMS simulated hold sent", "device", a.deviceID)
|
||||
time.Sleep(3 * time.Second)
|
||||
if err := a.ResumeCall(context.Background(), callID); err != nil {
|
||||
logging.Info("IMS simulated resume failed", "device", a.deviceID, "err", err)
|
||||
return
|
||||
}
|
||||
logging.Info("IMS simulated resume sent", "device", a.deviceID)
|
||||
}
|
||||
|
||||
func (a *Agent) waitForSimulateRegistration(ctx context.Context) error {
|
||||
endpoint := a.imsEndpoint()
|
||||
if endpoint == nil {
|
||||
|
||||
@@ -293,7 +293,7 @@ func TestGenerateBasicSDPUsesRecoveredPortSelection(t *testing.T) {
|
||||
gateway := NewGateway(agent)
|
||||
gateway.SetClientAdapter(&agentVoiceClientAdapter{})
|
||||
got := string(agent.generateBasicSDP())
|
||||
if !strings.Contains(got, "m=audio 19998 RTP/AVP 104 110 102 108 106 101 0") {
|
||||
if !strings.Contains(got, "m=audio 19998 RTP/AVP 104 110 102 108 106 96 101") {
|
||||
t.Fatalf("basic SDP uses wrong payload order or port: %q", got)
|
||||
}
|
||||
if !strings.Contains(got, "a=fmtp:104 mode-change-capability=2;max-red=0") ||
|
||||
@@ -301,6 +301,13 @@ func TestGenerateBasicSDPUsesRecoveredPortSelection(t *testing.T) {
|
||||
!strings.Contains(got, "a=fmtp:110 octet-align=1") ||
|
||||
!strings.Contains(got, "a=rtpmap:106 EVS/16000") ||
|
||||
!strings.Contains(got, "a=fmtp:106 evs-mode-switch=1") ||
|
||||
!strings.Contains(got, "a=rtpmap:96 telephone-event/16000") ||
|
||||
!strings.Contains(got, "a=rtpmap:101 telephone-event/8000") ||
|
||||
strings.Contains(got, "a=rtpmap:0 PCMU") ||
|
||||
!strings.Contains(got, "a=maxptime:240") ||
|
||||
!strings.Contains(got, "a=rtcp:19999") ||
|
||||
!strings.Contains(got, "b=RS:0") ||
|
||||
!strings.Contains(got, "b=RR:0") ||
|
||||
!strings.Contains(got, "a=curr:qos local sendrecv") ||
|
||||
strings.Contains(got, "a=curr:qos local none") ||
|
||||
!strings.Contains(got, "a=des:qos mandatory local sendrecv") ||
|
||||
|
||||
@@ -572,7 +572,10 @@ func TestBuildIMSInvite(t *testing.T) {
|
||||
t.Errorf("invite missing Call-ID: %q", invite)
|
||||
}
|
||||
if strings.Contains(invite, "m=audio 0 ") ||
|
||||
!strings.Contains(invite, "m=audio 12000 RTP/AVP 104 110 102 108 106 101 0") {
|
||||
!strings.Contains(invite, "m=audio 12000 RTP/AVP 104 110 102 108 106 96 101") ||
|
||||
strings.Contains(invite, "a=rtpmap:0 PCMU") ||
|
||||
!strings.Contains(invite, "a=rtpmap:96 telephone-event/16000") ||
|
||||
!strings.Contains(invite, "a=maxptime:240") {
|
||||
t.Errorf("builder did not emit the recovered basic offer: %q", invite)
|
||||
}
|
||||
if !strings.Contains(invite, "P-Early-Media: supported") {
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@ func assertProductionVoiceRequests(t *testing.T, requests <-chan string) {
|
||||
case request := <-requests:
|
||||
method := strings.Fields(request)[0]
|
||||
seen[method] = true
|
||||
if method == "INVITE" && (strings.Contains(request, "m=audio 0 ") || !strings.Contains(request, "RTP/AVP 104 110 102 108 106 101 0")) {
|
||||
if method == "INVITE" && (strings.Contains(request, "m=audio 0 ") || !strings.Contains(request, "RTP/AVP 104 110 102 108 106 96 101") || strings.Contains(request, "a=rtpmap:0 PCMU")) {
|
||||
t.Fatalf("INVITE did not advertise the allocated production media endpoint: %q", request)
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
"github.com/iniwex5/vowifi-go/internal/vowifi/voice"
|
||||
)
|
||||
|
||||
// ErrHoldNotAligned is kept so the phone API can still map a hold that the
|
||||
// live IMS dialog cannot send.
|
||||
var ErrHoldNotAligned = voice.ErrHoldNotAligned
|
||||
|
||||
// BeginCallRequest starts a browser-media-backed outbound call.
|
||||
type BeginCallRequest struct {
|
||||
DeviceID string
|
||||
|
||||
Reference in new issue
Block a user