[asterisk-commits] kmoore: branch group/media_formats-reviewed-trunk r418346 - in /team/group/me...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 10 11:42:03 CDT 2014
Author: kmoore
Date: Thu Jul 10 11:41:57 2014
New Revision: 418346
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418346
Log:
Media Formats: Fix crash bugs
This resolves several crash bugs involved in getting pjsip channels up and functional.
* channel.c: The set format helper functions were not actually setting
the newly chosen formats resulting in no audio.
* sorcery.c: The codec retrieval code was using the wrong level of
indirection for ast_format_cap structures resuting in a crash for
"pjsip show endpoint x".
* translate.c: The chosen codecs were being set backward on set vs
native for what was actually desired causing incorrect codecs to be
chosen.
* res_pjsip_sdp_rtp.c: An ast_rtp_codecs struct was not being
initialized properly causing a crash.
ASTERISK-23960
Review: https://reviewboard.asterisk.org/r/3736/
Modified:
team/group/media_formats-reviewed-trunk/main/channel.c
team/group/media_formats-reviewed-trunk/main/sorcery.c
team/group/media_formats-reviewed-trunk/main/translate.c
team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
Modified: team/group/media_formats-reviewed-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/channel.c?view=diff&rev=418346&r1=418345&r2=418346
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/channel.c (original)
+++ team/group/media_formats-reviewed-trunk/main/channel.c Thu Jul 10 11:41:57 2014
@@ -5307,10 +5307,6 @@
return 0;
}
- rawformat = ao2_bump(best_native_fmt);
- /* User perspective is fmt */
- format = ao2_bump(best_set_fmt);
-
/* Free any translation we have right now */
trans_pvt = trans->get(chan);
if (trans_pvt) {
@@ -5319,7 +5315,7 @@
}
/* Build a translation path from the raw format to the desired format */
- if (ast_format_cmp(format, rawformat) != AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cmp(best_set_fmt, best_native_fmt) != AST_FORMAT_CMP_NOT_EQUAL) {
/*
* If we were able to swap the native format to the format that
* has been requested, then there is no need to try to build
@@ -5329,29 +5325,39 @@
} else {
if (!direction) {
/* reading */
- trans_pvt = ast_translator_build_path(format, rawformat);
+ trans_pvt = ast_translator_build_path(best_set_fmt, best_native_fmt);
} else {
/* writing */
- trans_pvt = ast_translator_build_path(rawformat, format);
+ trans_pvt = ast_translator_build_path(best_native_fmt, best_set_fmt);
}
trans->set(chan, trans_pvt);
res = trans_pvt ? 0 : -1;
}
+
+ if (!res) {
+ if (!direction) {
+ /* reading */
+ ast_channel_set_readformat(chan, best_set_fmt);
+ ast_channel_set_rawreadformat(chan, best_native_fmt);
+ } else {
+ /* writing */
+ ast_channel_set_writeformat(chan, best_set_fmt);
+ ast_channel_set_rawwriteformat(chan, best_native_fmt);
+ }
+
+ ast_debug(1, "Set channel %s to %s format %s\n",
+ ast_channel_name(chan),
+ direction ? "write" : "read",
+ ast_format_get_name(best_set_fmt));
+ }
+
ast_channel_unlock(chan);
-
- ast_debug(1, "Set channel %s to %s format %s\n",
- ast_channel_name(chan),
- direction ? "write" : "read",
- ast_format_get_name(best_set_fmt));
/* If there is a generator on the channel, it needs to know about this
* change if it is the write format. */
if (direction && ast_channel_generatordata(chan)) {
generator_write_format_change(chan);
}
-
- ao2_cleanup(rawformat);
- ao2_cleanup(format);
return res;
}
Modified: team/group/media_formats-reviewed-trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/sorcery.c?view=diff&rev=418346&r1=418345&r2=418346
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/sorcery.c (original)
+++ team/group/media_formats-reviewed-trunk/main/sorcery.c Thu Jul 10 11:41:57 2014
@@ -233,8 +233,8 @@
static int codec_handler_fn(const void *obj, const intptr_t *args, char **buf)
{
struct ast_str *codec_buf = ast_str_alloca(64);
- struct ast_format_cap *cap = (struct ast_format_cap *)(obj + args[0]);
- return !(*buf = ast_strdup(ast_format_cap_get_names(cap, &codec_buf)));
+ struct ast_format_cap **cap = (struct ast_format_cap **)(obj + args[0]);
+ return !(*buf = ast_strdup(ast_format_cap_get_names(*cap, &codec_buf)));
}
static sorcery_field_handler sorcery_field_default_handler(enum aco_option_type type)
Modified: team/group/media_formats-reviewed-trunk/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/translate.c?view=diff&rev=418346&r1=418345&r2=418346
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/translate.c (original)
+++ team/group/media_formats-reviewed-trunk/main/translate.c Thu Jul 10 11:41:57 2014
@@ -1360,8 +1360,8 @@
* ast_translator_best_choice but ao2_replace causes undefined variable
* access (reported by valgrind).
*/
- ao2_replace(*dst_fmt_out, best);
- ao2_replace(*src_fmt_out, bestdst);
+ ao2_replace(*dst_fmt_out, bestdst);
+ ao2_replace(*src_fmt_out, best);
ao2_ref(best, -1);
ao2_ref(bestdst, -1);
return 0;
Modified: team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c?view=diff&rev=418346&r1=418345&r2=418346
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c Thu Jul 10 11:41:57 2014
@@ -216,7 +216,7 @@
RAII_VAR(struct ast_format_cap *, peer, NULL, ao2_cleanup);
RAII_VAR(struct ast_format_cap *, joint, NULL, ao2_cleanup);
enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
- struct ast_rtp_codecs codecs;
+ struct ast_rtp_codecs codecs = AST_RTP_CODECS_NULL_INIT;
int fmts = 0;
int direct_media_enabled = !ast_sockaddr_isnull(&session_media->direct_media_addr) &&
ast_format_cap_count(session->direct_media_cap);
More information about the asterisk-commits
mailing list