summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-09-13 10:38:11 -0400
committerSean Bright <sean.bright@gmail.com>2017-09-13 09:40:38 -0500
commit8ab2dcb4b044e0bcd21d6131d125e51c08591cff (patch)
tree24a13b2134ea4dc8edd8ae3cc4165c257d83c46a
parentcadc96c04bf8350bd8052e8228d84550ed2c4899 (diff)
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
-rw-r--r--channels/chan_rtp.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/channels/chan_rtp.c b/channels/chan_rtp.c
index d671706b2..2ab841480 100644
--- a/channels/chan_rtp.c
+++ b/channels/chan_rtp.c
@@ -119,6 +119,22 @@ static int rtp_hangup(struct ast_channel *ast)
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)
{
@@ -173,7 +189,7 @@ static struct ast_channel *multicast_rtp_request(const char *type, struct ast_fo
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",
@@ -300,7 +316,7 @@ static struct ast_channel *unicast_rtp_request(const char *type, struct ast_form
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);