[External Media] How to inject the media using the External Media

Hi team,

I’m trying to use external media to inject the media into the channel(Asterisk 21.1.0).

So, I created a simple echo program to receive the RTP and send it back to the Asterisk.
But having trouble with injecting the RTP stream into the external media channel.

The Receiving/Sending looks OK. I can check the RTP packet in/out.

But the Asterisk couldn’t read the RTP packet with the below debug messages.

[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20843 Arrival sec: 416.576  Arrival ts:    3332606  RX ts:  327219003 Transit samp: -323886397 Last transit samp: -323886238 d:  159 Curr jitter:      -4(536870.912) Prev Jitter:     219(  0.027) New Jitter:     215(  0.027)
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20844 Arrival sec: 416.576  Arrival ts:    3332606  RX ts:  327219163 Transit samp: -323886557 Last transit samp: -323886397 d:  160 Curr jitter:      -3(536870.912) Prev Jitter:     215(  0.027) New Jitter:     212(  0.026)
[Mar 24 16:53:59] DEBUG[1220446]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but got 5 instead
[Mar 24 16:53:59] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:53:59] DEBUG[1220446]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but got 5 instead
[Mar 24 16:53:59] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20845 Arrival sec: 416.676  Arrival ts:    3333404  RX ts:  327219323 Transit samp: -323885919 Last transit samp: -323886557 d:  638 Curr jitter:      27(  0.003) Prev Jitter:     212(  0.026) New Jitter:     239(  0.030)
[Mar 24 16:53:59] DEBUG[1220409]: audiohook.c:203 ast_audiohook_write_frame: Audiohook 0x7ce85003d420 has stale audio in its factories. Flushing them both
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20846 Arrival sec: 416.676  Arrival ts:    3333405  RX ts:  327219483 Transit samp: -323886078 Last transit samp: -323885919 d:  159 Curr jitter:      -5(536870.912) Prev Jitter:     239(  0.030) New Jitter:     234(  0.029)
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20847 Arrival sec: 416.676  Arrival ts:    3333405  RX ts:  327219643 Transit samp: -323886238 Last transit samp: -323886078 d:  160 Curr jitter:      -5(536870.912) Prev Jitter:     234(  0.029) New Jitter:     229(  0.029)
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20848 Arrival sec: 416.676  Arrival ts:    3333405  RX ts:  327219803 Transit samp: -323886398 Last transit samp: -323886238 d:  160 Curr jitter:      -4(536870.912) Prev Jitter:     229(  0.029) New Jitter:     225(  0.028)
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20849 Arrival sec: 416.682  Arrival ts:    3333458  RX ts:  327219963 Transit samp: -323886505 Last transit samp: -323886398 d:  107 Curr jitter:      -7(536870.911) Prev Jitter:     225(  0.028) New Jitter:     217(  0.027)
[Mar 24 16:53:59] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20850 Arrival sec: 416.682  Arrival ts:    3333459  RX ts:  327220123 Transit samp: -323886664 Last transit samp: -323886505 d:  159 Curr jitter:      -4(536870.912) Prev Jitter:     217(  0.027) New Jitter:     214(  0.027)
[Mar 24 16:54:00] DEBUG[1220446]: res_timing_timerfd.c:167 timerfd_timer_ack: Expected to acknowledge 1 ticks but got 5 instead
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5088 rtp_raw_write: (0x7ce8500415b0) RTP audio difference is 3368, ms is 441
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16239 Arrival sec: 374.947  Arrival ts:    2999579  RX ts:    2938176 Transit samp:  61403 Last transit samp:  57986 d: 3417 Curr jitter:     198(  0.025) Prev Jitter:     246(  0.031) New Jitter:     445(  0.056)
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:203 ast_audiohook_write_frame: Audiohook 0x7ce85003e988 has stale audio in its factories. Flushing them both
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16240 Arrival sec: 374.948  Arrival ts:    2999580  RX ts:    2938336 Transit samp:  61244 Last transit samp:  61403 d:  159 Curr jitter:     -18(536870.910) Prev Jitter:     445(  0.056) New Jitter:     427(  0.053)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16241 Arrival sec: 374.948  Arrival ts:    2999580  RX ts:    2938496 Transit samp:  61084 Last transit samp:  61244 d:  160 Curr jitter:     -17(536870.910) Prev Jitter:     427(  0.053) New Jitter:     410(  0.051)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16242 Arrival sec: 374.948  Arrival ts:    2999581  RX ts:    2938656 Transit samp:  60925 Last transit samp:  61084 d:  159 Curr jitter:     -16(536870.910) Prev Jitter:     410(  0.051) New Jitter:     394(  0.049)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16243 Arrival sec: 374.948  Arrival ts:    2999581  RX ts:    2938816 Transit samp:  60765 Last transit samp:  60925 d:  160 Curr jitter:     -15(536870.910) Prev Jitter:     394(  0.049) New Jitter:     380(  0.047)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16244 Arrival sec: 374.948  Arrival ts:    2999582  RX ts:    2938976 Transit samp:  60606 Last transit samp:  60765 d:  159 Curr jitter:     -14(536870.910) Prev Jitter:     380(  0.047) New Jitter:     366(  0.046)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16245 Arrival sec: 374.948  Arrival ts:    2999582  RX ts:    2939136 Transit samp:  60446 Last transit samp:  60606 d:  160 Curr jitter:     -13(536870.910) Prev Jitter:     366(  0.046) New Jitter:     353(  0.044)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16246 Arrival sec: 374.948  Arrival ts:    2999583  RX ts:    2939296 Transit samp:  60287 Last transit samp:  60446 d:  159 Curr jitter:     -12(536870.910) Prev Jitter:     353(  0.044) New Jitter:     341(  0.043)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16247 Arrival sec: 374.948  Arrival ts:    2999583  RX ts:    2939456 Transit samp:  60127 Last transit samp:  60287 d:  160 Curr jitter:     -11(536870.911) Prev Jitter:     341(  0.043) New Jitter:     330(  0.041)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16248 Arrival sec: 374.948  Arrival ts:    2999583  RX ts:    2939616 Transit samp:  59967 Last transit samp:  60127 d:  160 Curr jitter:     -11(536870.911) Prev Jitter:     330(  0.041) New Jitter:     319(  0.040)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16249 Arrival sec: 374.948  Arrival ts:    2999584  RX ts:    2939776 Transit samp:  59808 Last transit samp:  59967 d:  159 Curr jitter:     -10(536870.911) Prev Jitter:     319(  0.040) New Jitter:     309(  0.039)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16250 Arrival sec: 374.948  Arrival ts:    2999584  RX ts:    2939936 Transit samp:  59648 Last transit samp:  59808 d:  160 Curr jitter:      -9(536870.911) Prev Jitter:     309(  0.039) New Jitter:     300(  0.037)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16251 Arrival sec: 374.948  Arrival ts:    2999585  RX ts:    2940096 Transit samp:  59489 Last transit samp:  59648 d:  159 Curr jitter:      -9(536870.911) Prev Jitter:     300(  0.037) New Jitter:     291(  0.036)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16252 Arrival sec: 374.948  Arrival ts:    2999585  RX ts:    2940256 Transit samp:  59329 Last transit samp:  59489 d:  160 Curr jitter:      -8(536870.911) Prev Jitter:     291(  0.036) New Jitter:     283(  0.035)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16253 Arrival sec: 374.948  Arrival ts:    2999586  RX ts:    2940416 Transit samp:  59170 Last transit samp:  59329 d:  159 Curr jitter:      -8(536870.911) Prev Jitter:     283(  0.035) New Jitter:     275(  0.034)
[Mar 24 16:54:00] DEBUG[1220447]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: asterisk-call-f4df6d4d7-clwdl-1711298862.57: pkt: 16254 Arrival sec: 374.948  Arrival ts:    2999586  RX ts:    2940576 Transit samp:  59010 Last transit samp:  59170 d:  160 Curr jitter:      -7(536870.911) Prev Jitter:     275(  0.034) New Jitter:     268(  0.033)
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220446]: audiohook.c:340 audiohook_read_frame_both: Failed to get 160 samples from write factory 0x7ce85003dee8
[Mar 24 16:54:00] DEBUG[1220409]: res_rtp_asterisk.c:5725 calc_rxstamp_and_jitter: c5b626b0-9008-48df-968a-6f01b6cbac6f: pkt: 20851 Arrival sec: 416.879  Arrival ts:    3335031  RX ts:  327220283 Transit samp: -323885252 Last transit samp: -323886664 d: 1412 Curr jitter:      75(  0.009) Prev Jitter:     214(  0.027) New Jitter:     289(  0.036)

2 nodes(Asterisk, simple echo program) are running in the different machines but in the same network.
I can see them sending/receiving the data each other using the rtp set deug on.

Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024365, ts 907552, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024366, ts 907712, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024367, ts 907872, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024368, ts 908032, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024369, ts 908192, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024370, ts 908352, len 000160)
Got  RTP packet from    10.96.2.167:47358 (type 00, seq 024371, ts 908512, len 000160)
Sent RTP packet to      10.96.2.167:10000 (type 00, seq 024385, ts 911392, len 000160)
Sent RTP packet to      10.96.2.167:10000 (type 00, seq 024386, ts 911552, len 000160)
Sent RTP packet to      10.96.2.167:10000 (type 00, seq 024387, ts 911712, len 000160)
Sent RTP packet to      10.96.2.167:10000 (type 00, seq 024388, ts 911872, len 000160)
Sent RTP packet to      10.96.2.167:10000 (type 00, seq 024389, ts 912032, len 000160)```

I figured out the reason why it didn’t work and added a comment for other visitors.

While implementing this, I utilized a snoop channel along with the bridge and external media channel. The setup appeared as follows:

PJSIP channel <-----> Snoop Channel <------> Bridge <-----------> External Media Channel

Initially, outgoing media from Asterisk to the External target functioned properly.

However, the issue arose with media reception due to the presence of the Snoop channel. Although the exact reason behind the malfunction caused by the snoop channel remained elusive, removing it from the configuration resolved all issues.

The revised configuration looks like this:

PJSIP channel <—> Bridge <—> External media channel

1 Like

Hi pchero. Did I understand correctly that you managed to inject an RTP stream from the external media server into the call’s channel? Would you please share some more details about it?
Best,
Anthony