[asterisk-dev] The MulticastRTP channel needs more control of output

John R. Covert asterisk-dev at covert.org
Fri Sep 16 19:19:12 CDT 2011

Snom phones support multicast streaming audio for paging, which
makes it theoretically possible to have a paging extension which
speaks out of every single phone in a facility.  I have a possible
client who currently has a Meridian system which does just this,
which is very important to him, and I need to make this work in
Asterisk.  Multicast RTP is the way to go -- the "Page" application
with unicast and autoanswer doesn't scale to a large number of
phones: bringing 50-100 phones into a MeetMe conference would be
a very bad idea.

As currently implemented in 1.8, a simple Dial(MulticastRTP/...)
command doesn't set the codec to something negotiated as the
"least common denominator" of all the listening phones, and I
wouldn't expect it to -- that's precisely what doesn't scale.
It will even leave the channel in signed linear in some cases.

The patch below (to svn head in trunk) makes the Dialplan example
given below in the trace do what's needed, as long as the call
comes in from a SIP or IAX2 channel. You set MULTICAST_RTP_CODEC
to ulaw (or whatever your phones support), and away you go.

However, there's another thing that needs to be set when the call
isn't from a SIP or IAX2 channel.  If you want to page using a
canned announcement, you need to be able to set the RTP packet
size. I haven't figured out how to easily set it in the
MulticastRTP channel yet.  Given a hint, I'll add that to my
patch as "MULTICAST_RTP_PAYLOAD_SIZE" and submit it along with
the codec patch below to the issue tracker.

Here are some examples (8729 is my paging extension):

Packet header when you dial "8729" from a phone:

(tos 0x0, ttl 1, id 18319, offset 0, flags [none], proto UDP (17), length 200)

Works just fine.

Packet header when you issue the following command:
originate local/8729 at station application Playback asterisk-friend

(tos 0x0, ttl 1, id 19842, offset 0, flags [none], proto UDP (17), length 360)

On my Snom 820, the length 360 packet results in horribly choppy
sound.  My Snom 300 is happy with it.  The Snom documentation
says that as of firmware version 8.6.6 you'll be able to set some
of these parameters, but 8.6.6 hasn't been released yet.

Please have a look at the patch below, and please give me a hint on how
to set the payload size to a value of 200, and I'll add that to the


-- Executing [8726 at dialstation:1] Wait("SIP/x37-0000000e", "1") in new stack
-- Executing [8726 at dialstation:2] Set("SIP/x37-0000000e", "MULTICAST_RTP_CODEC=ulaw") in new stack
-- Executing [8726 at dialstation:3] Dial("SIP/x37-0000000e", "MulticastRTP/basic/") in new stack
-- MulticastRTP set codec to ulaw
-- Called basic/
-- MulticastRTP/0x1cc0644 answered SIP/x37-0000000e

--- channels/chan_multicast_rtp.c.328209        2011-09-16 16:54:24.000000000 -0400
+++ channels/chan_multicast_rtp.c       2011-09-16 17:47:24.000000000 -0400
@@ -118,7 +118,15 @@
        struct ast_sockaddr control_address;
        struct ast_sockaddr destination_address;
        struct ast_channel *chan;
-       format_t fmt = ast_best_codec(format);
+       format_t fmt = 0;
+       const char *codec;
+       if (requestor && (codec = pbx_builtin_getvar_helper((struct ast_channel *)requestor, "MULTICAST_RTP_CODEC"))) {
+               fmt = ast_getformatbyname(codec);
+               ast_verb(3, "MulticastRTP set codec to %s\n",codec);
+       }
+       if (!fmt)
+               fmt = ast_best_codec(format);

More information about the asterisk-dev mailing list