Ari External Media Code Issue

Eh, we haven’t heard that at all and it certainly works for us beyond Asterisk 20. Are you talking about the “official” codec_opus from Index of /pub/telephony/codec_opus/ or the “other” one?

EDIT: Just to clarify… The codec_opus we (Sangoma) provide is exactly the same for all current asterisk versions.

Yes. I don’t know of another one.

OK, exactly which versions don’t work and what about them doesn’t work? As I said, the code is exactly the same.

For Asterisk version 21+ if you use ‘wget’ and compile it with Opus support Asterisk fails with a segfault or the Opus codec just doesn’t work.

My solution was use git checkout and manually install the Opus codec for Asterisk 20.

You should just select “codec_opus” in the Codecs section of menuselect and let make install do the work of downloading the correct version.

Start a new topic with the exact steps you use we’ll see if we can sort you out.

The binary is different. The size jumped up with Asterisk 21+ (compared to 20).

Yes, the binaries may be different sizes because they’re compiled against different versions of asterisk but the source code is the same. Start a new topic with the details please.

Can anyone tell me what i can do now for this @gjoseph @cable ?

I’m working on this issue now but I don’t have a timeframe for completion yet.

1 Like

oh okay

Just an update i even tried on asterisk 20.16.0-rc1 the same error comes for opus one @cable

There’s a pull request up for review that addresses the codec_opus issues…

Please test.

NOTE: It’s not possible for chan_websocket to re-frame or re-time opus media. I’ve added a “p” option to the dial string that tells chan_websocket to go into “passthrough” mode which means that the remote app is responsible for correctly framing and timing the media it sends to Asterisk. I’ll be updating the documentation page shortly.

ohh Thanks @gjoseph but what about the ari-client repo how can we send there this ??
this means the. ari-client repo will also get an update for this ?? because i am using external media through ari node js repo that is ari-client and

i checked when i use slin16 o ulaw
in asterisk debug i got

WebSocket/connection1/c(sln16)

so when i pass the format as opus

does it automatically add
WebSocket/connection1/c(opus)p ?? or there will an update in ari-client repo also?

I tried with this code but using ari client i got

Channel PJSIP/Opensips-Incoming-TATA_625024292b95f-00000000 joined ‘simple_bridge’ stasis-bridge <536f364d-78f0-4e42-9937-e95c9b63596c>
– Called ace_media_ws/c(opus)
– WebSocket/ace_media_ws/0x7cc35c0073b0 answered

Launching Stasis(voice-bot,chanType:streaming) on WebSocket/ace_media_ws/0x7cc35c0073b0
– Channel WebSocket/ace_media_ws/0x7cc35c0073b0 joined 'simple_

[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] WARNING[805863]: translate.c:408 framein: no samples for opustolin
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] WARNING[805863]: translate.c:408 framein: no samples for opustolin
[Sep 19 11:23:02] ERROR[805863]: codec_opus.c:386 opus_dec_decode: Opus: decoding: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] ERROR[805862]: codec_opus.c:503 opus_samples_count: Opus: Unable to parse packet for number of samples: corrupted stream
[Sep 19 11:23:02] WARNING[805863]: translate.c:424 framein: Out of buffer space

You’re going to have to give me more information. Which ari-client repo are you talking about and exactly how do you create the WebSocket channel? Nothing is automatically added.

That implies that the passthrough parameter isn’t being set OR you’re sending media that’s not in the correct format. Where is the media coming from? Can you just echo the media Asterisk sends the app back to Asterisk again and see what happens?

I’ve updated the pull request to automatically set passthrough mode for codecs whose data streams can’t be broken up on arbitrary byte boundaries. This includes opus, speex and g729a. You no longer have to specify the “p” option for those codecs.

Redownload the PR and test again.

Hi @gjoseph i have tested the above code with the use of Dial command and passing the p and its worked but the ari-client repo which i am taking is the

That is managed by asterisk and i am using this package and in this package there is a function called external media which expects the format and in websocket it does support slin16 ulaw but when i pass the opus it does not play because on the ari debug i get this

Called ace_media_ws/c(opus)

so how can i use the ari-client repo because my complete code is written with node ari-client wrapper and this does not expects the p parameter

and the flow which i am doing is dialing an call and sending that call to stasis application and there i create a externalMedia channel using node-ari-client package and then add both channel in bridge and the socket which it gets connected i am streaming packets in opus format but i am not able to use this package because it does not support the “p“ in that

here is the same code how i am doing this

return await channel.externalMedia(
    {
        channelId      : externalMediaId,
        app            : `${constants.CALL_TYPE},chanType:streaming`,
        external_host: "ace_media_ws",
        format         : "opus",
        transport      : "websocket",
        encapsulation  : "none",
        direction      : "both"
    });




If you get the latest version of the PR, you don’t need to specify the “p” parameter any more. It’s automatically set if you use the opus codec.

okay i am testing it just give me 5 mins