From a693fd1d8738a302082bb8e453c0fe69679f4c46 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Fri, 13 Jul 2012 16:49:40 +0000 Subject: Add support for parsing SDP attributes, generating SDP attributes, and passing it through. This support includes codecs such as H.263, H.264, SILK, and CELT. You are able to set up a call and have attribute information pass. This should help considerably with video calls. Review: https://reviewboard.asterisk.org/r/2005/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370055 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/format.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ main/translate.c | 14 ++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) (limited to 'main') diff --git a/main/format.c b/main/format.c index 96afd3e18..2d37eb458 100644 --- a/main/format.c +++ b/main/format.c @@ -119,6 +119,51 @@ static int has_interface(const struct ast_format *format) return 1; } +int ast_format_sdp_parse(struct ast_format *format, const char *attributes) +{ + struct interface_ao2_wrapper *wrapper; + int res; + + if (!(wrapper = find_interface(format))) { + return 0; + } + + ao2_rdlock(wrapper); + if (!(wrapper->interface || !wrapper->interface->format_attr_sdp_parse)) { + ao2_unlock(wrapper); + ao2_ref(wrapper, -1); + return 0; + } + + res = wrapper->interface->format_attr_sdp_parse(&format->fattr, attributes); + + ao2_unlock(wrapper); + ao2_ref(wrapper, -1); + + return res; +} + +void ast_format_sdp_generate(const struct ast_format *format, unsigned int payload, struct ast_str **str) +{ + struct interface_ao2_wrapper *wrapper; + + if (!(wrapper = find_interface(format))) { + return; + } + + ao2_rdlock(wrapper); + if (!(wrapper->interface || !wrapper->interface->format_attr_sdp_generate)) { + ao2_unlock(wrapper); + ao2_ref(wrapper, -1); + return; + } + + wrapper->interface->format_attr_sdp_generate(&format->fattr, payload, str); + + ao2_unlock(wrapper); + ao2_ref(wrapper, -1); +} + /*! \internal * \brief set format attributes using an interface */ diff --git a/main/translate.c b/main/translate.c index 607fee77b..ce430ce97 100644 --- a/main/translate.c +++ b/main/translate.c @@ -1286,12 +1286,22 @@ unsigned int ast_translate_path_steps(struct ast_format *dst_format, struct ast_ void ast_translate_available_formats(struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result) { struct ast_format tmp_fmt; - struct ast_format cur_src; + struct ast_format cur_dest, cur_src; int src_audio = 0; int src_video = 0; int index; - ast_format_cap_copy(result, dest); + ast_format_cap_iter_start(dest); + while (!ast_format_cap_iter_next(dest, &cur_dest)) { + /* We give preference to a joint format structure if possible */ + if (ast_format_cap_get_compatible_format(src, &cur_dest, &tmp_fmt)) { + ast_format_cap_add(result, &tmp_fmt); + } else { + /* Otherwise we just use the destination format */ + ast_format_cap_add(result, &cur_dest); + } + } + ast_format_cap_iter_end(dest); /* if we don't have a source format, we just have to try all possible destination formats */ -- cgit v1.2.3