External media stop stream when channel.play

I’m utilizing JavaScript, and external media functions properly except when the program attempts to play audio using channel.play . Whenever channel.play is invoked, the stream halts. How can I resolve this issue?

You’re going to need to be more specific about what exactly you are doing, what channels are involved, how they are connected, what API calls you’ve done.

I created ARI - externalMedia. This application facilitates the creation of a bridge and the attachment of a snoop channel to it. Additionally, it allows for the playback of audio during a call.

Let say PJSIP/1112 call in and invoke an external stasis application.

exten => 1000,1,Answer()
same => n,Stasis(test)

In the test.js, it will create a externalMedia channel and a bridge. Then add two channels (externalMedia & PJSIP/1112) to the bridge.

channel.externalMedia({
          app: 'externalMedia',
          external_host: '127.0.0.1:9999',
          format: 'ulaw',
        });

Upon exploration, I found that playing audio in the inbound channel results in external media not streaming the inbound channel’s audio while playback is ongoing.

channel.play({
              media: 'sound:hello-world',
            });

Conversely, playing audio in the bridge causes external media to stream all audio, including the playback, which is undesired.

bridge.play({
              media: 'sound:hello-world',
            });

I aim to have external media stream only the audio from the inbound channel, excluding any audio I play during the call.

Thanks.

You would need to use a snoop channel[1] to passively spy on the channel you want to stream, and place the snoop channel and the external media channel in a bridge. Fundamentally multiple things can’t control a channel at once, which is what you are currently trying to do.

[1] Channels - Asterisk Documentation

Thanks for your help.

So, my audio should play in PJSIP/1112 channel and it wont be copy to snoop channel?
If snoop channel spy on the the PJSIP/1112, snoop channel only copy the audio from inbound sound (softphone audio)?

Snoop channels spy on the direction you state. If you only want audio coming from the channel, then you specify that when creating the snoop channel and that is what you’ll get.

I am using node-ari-client and I am not sure the Parameters meaning

I guess:
channelId → The unique id to assign the channel on creation
spy → fill the channel ID which I need to copy the audio
whisper → fill the channel ID which output the copied audio

Am I right? Thanks

###### Available Parameters
* app (string) - Application the snooping channel is placed into
* appArgs (string) - The application arguments to pass to the Stasis application
* channelId (string) - Channel's id
* snoopId (string) - Unique ID to assign to snooping channel
* spy (string) - Direction of audio to spy on
* whisper (string) - Direction of audio to whisper into

No.

channelId is the channel you want to snoop on.
snoopId is the uniqueid that will be assigned to the snoop channel.
spy is the direction of audio you want to spy on.
whisper is the direction of audio you want to whisper into.

As well as app and appArgs.

I don’t have any experience with node-ari-client, so can’t comment on its usage. I can only state what the API parameters itself are.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.