[Asterisk-code-review] chan rtp: Use μ-law by default instead of signed linear (asterisk[master])

Jenkins2 asteriskteam at digium.com
Thu Sep 14 12:37:43 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6490 )

Change subject: chan_rtp: Use μ-law by default instead of signed linear
......................................................................

chan_rtp: Use μ-law by default instead of signed linear

Multicast/Unicast RTP do not use SDP so we need to use a format that
cleanly maps to one of the static RTP payload types. Without this
change, an Originate to a Multicast or Unicast channel without a format
specified would produce no audio on the receiving device.

ASTERISK-21399 #close
Reported by: Tzafrir Cohen

Change-Id: I97e332b566e85da04b0004b9b0daae746cfca0e3
---
M channels/chan_rtp.c
1 file changed, 18 insertions(+), 2 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/channels/chan_rtp.c b/channels/chan_rtp.c
index 6eec91e..e1c29a2 100644
--- a/channels/chan_rtp.c
+++ b/channels/chan_rtp.c
@@ -117,6 +117,22 @@
 	return 0;
 }
 
+static struct ast_format *derive_format_from_cap(struct ast_format_cap *cap)
+{
+	struct ast_format *fmt = ast_format_cap_get_format(cap, 0);
+
+	if (ast_format_cap_count(cap) == 1 && fmt == ast_format_slin) {
+		/*
+		 * Because we have no SDP, we must use one of the static RTP payload
+		 * assignments. Signed linear @ 8kHz does not map, so if that is our
+		 * only capability, we force μ-law instead.
+		 */
+		fmt = ast_format_ulaw;
+	}
+
+	return fmt;
+}
+
 /*! \brief Function called when we should prepare to call the multicast destination */
 static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 {
@@ -171,7 +187,7 @@
 
 	fmt = ast_multicast_rtp_options_get_format(mcast_options);
 	if (!fmt) {
-		fmt = ast_format_cap_get_format(cap, 0);
+		fmt = derive_format_from_cap(cap);
 	}
 	if (!fmt) {
 		ast_log(LOG_ERROR, "No codec available for sending RTP to '%s'\n",
@@ -298,7 +314,7 @@
 			goto failure;
 		}
 	} else {
-		fmt = ast_format_cap_get_format(cap, 0);
+		fmt = derive_format_from_cap(cap);
 		if (!fmt) {
 			ast_log(LOG_ERROR, "No codec available for sending RTP to '%s'\n",
 				args.destination);

-- 
To view, visit https://gerrit.asterisk.org/6490
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I97e332b566e85da04b0004b9b0daae746cfca0e3
Gerrit-Change-Number: 6490
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170914/891cbf7a/attachment.html>


More information about the asterisk-code-review mailing list