originate new ARI channel without nonexistent originator

This commit is contained in:
2026-10-05 09:58:40 +08:00
parent ef246717d7
commit f88b73b463
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -122,7 +122,9 @@ func dialWithClient(ctx context.Context, client ari.Client, request NativeDial)
if call.subscription == nil {
return nil, &NativeCallFailure{Phase: "subscribe", Cause: errors.New("native ARI channel subscription unavailable before origination")}
}
call.outbound, err = client.Channel().Originate(key, originate)
// The reference key is an existing originator, not the new channel ID.
// ChannelID in originate already fixes this call's identity.
call.outbound, err = client.Channel().Originate(nil, originate)
if err != nil {
// The HTTP response can be lost after Asterisk has created the
// channel. Do not originate again: try to stop the same identity.
+4 -1
View File
@@ -36,6 +36,7 @@ type testChannels struct {
ari.Channel
events chan ari.Event
originate ari.OriginateRequest
originateRef *ari.Key
media ari.ExternalMediaOptions
issued int
originateErr error
@@ -44,8 +45,9 @@ type testChannels struct {
mediaPeerIP string
}
func (c *testChannels) Originate(_ *ari.Key, request ari.OriginateRequest) (*ari.ChannelHandle, error) {
func (c *testChannels) Originate(reference *ari.Key, request ari.OriginateRequest) (*ari.ChannelHandle, error) {
c.issued++
c.originateRef = reference
c.originate = request
if c.originateErr != nil {
return nil, c.originateErr
@@ -143,6 +145,7 @@ func TestNativeCallUsesOneARIOriginateAndActualRTPBridge(t *testing.T) {
}
if call.Media == nil || client.channels.issued != 1 || client.channels.originate.Endpoint != "PJSIP/708915000000001@shuqi" ||
client.channels.originate.CallerID != "BD1234" || client.channels.originate.ChannelID != "exec-1" ||
client.channels.originateRef != nil || client.channels.originate.Originator != "" ||
client.channels.media.Format != "slin16" || client.channels.media.App != "go-sip-agent" ||
len(client.bridges.attached) != 2 || client.bridges.attached[0] != "exec-1" {
t.Fatal("native channel/ExternalMedia was not attached exactly once to the approved bridge")