diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-11-30 10:48:13 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-11-30 10:48:13 -0600 |
commit | eec82c6221935ebcc88da8c606481258d3322ad5 (patch) | |
tree | 18b3d9bad2a7ac06e313478345a9b5bf5c8d719d /main/channel.c | |
parent | 3d43e5ed3c95a2ea8ad8b66f79d664a3f294b1b2 (diff) | |
parent | cf6d13180effc92a2483dccc68f2f188689a40fa (diff) |
Merge "chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no" into 13
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c index 54b91307e..ac99dd6a2 100644 --- a/main/channel.c +++ b/main/channel.c @@ -5476,6 +5476,42 @@ int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_fo return 0; } +int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format) +{ + struct ast_trans_pvt *trans_old; + struct ast_trans_pvt *trans_new; + + if (ast_format_cmp(ast_channel_rawwriteformat(chan), raw_format) == AST_FORMAT_CMP_EQUAL + && ast_format_cmp(ast_channel_writeformat(chan), core_format) == AST_FORMAT_CMP_EQUAL) { + /* Nothing to setup */ + return 0; + } + + ast_debug(1, "Channel %s setting write format path: %s -> %s\n", + ast_channel_name(chan), + ast_format_get_name(core_format), + ast_format_get_name(raw_format)); + + /* Setup new translation path. */ + if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) { + trans_new = ast_translator_build_path(raw_format, core_format); + if (!trans_new) { + return -1; + } + } else { + /* No translation needed. */ + trans_new = NULL; + } + trans_old = ast_channel_writetrans(chan); + if (trans_old) { + ast_translator_free_path(trans_old); + } + ast_channel_writetrans_set(chan, trans_new); + ast_channel_set_rawwriteformat(chan, raw_format); + ast_channel_set_writeformat(chan, core_format); + return 0; +} + struct set_format_access { const char *direction; struct ast_trans_pvt *(*get_trans)(const struct ast_channel *chan); |