[asterisk-commits] file: branch file/media-attrib-sdp r368851 - in /team/file/media-attrib-sdp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 13 09:07:53 CDT 2012


Author: file
Date: Wed Jun 13 09:07:49 2012
New Revision: 368851

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368851
Log:
Import format SDP changes thus far.

Modified:
    team/file/media-attrib-sdp/channels/chan_sip.c
    team/file/media-attrib-sdp/include/asterisk/format.h
    team/file/media-attrib-sdp/main/format.c

Modified: team/file/media-attrib-sdp/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/channels/chan_sip.c?view=diff&rev=368851&r1=368850&r2=368851
==============================================================================
--- team/file/media-attrib-sdp/channels/chan_sip.c (original)
+++ team/file/media-attrib-sdp/channels/chan_sip.c Wed Jun 13 09:07:49 2012
@@ -10045,6 +10045,12 @@
 			unsigned int bit_rate;
 			int val = 0;
 
+			if (!ast_format_sdp_parse(format, fmtp_string)) {
+				found = TRUE;
+			} else {
+				ast_rtp_codecs_payloads_unset(newaudiortp, NULL, codec);
+			}
+
 			switch ((int) format->id) {
 			case AST_FORMAT_SIREN7:
 				if (sscanf(fmtp_string, "bitrate=%30u", &bit_rate) == 1) {
@@ -10105,6 +10111,7 @@
 	char mimeSubtype[128];
 	unsigned int sample_rate;
 	int debug = sip_debug_test_pvt(p);
+	char fmtp_string[64];
 
 	if (sscanf(a, "rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {
 		/* We have a rtpmap to handle */
@@ -10126,6 +10133,16 @@
 		} else {
 			if (debug)
 				ast_verbose("Discarded description format %s for ID %d\n", mimeSubtype, codec);
+		}
+	} else if (sscanf(a, "fmtp: %30u %63s", &codec, fmtp_string) == 2) {
+		struct ast_format *format;
+
+		if ((format = ast_rtp_codecs_get_payload_format(newvideortp, codec))) {
+			if (!ast_format_sdp_parse(format, fmtp_string)) {
+				found = TRUE;
+			} else {
+				ast_rtp_codecs_payloads_unset(newvideortp, NULL, codec);
+			}
 		}
 	}
 
@@ -11520,6 +11537,8 @@
 		rtp_code,
 		ast_rtp_lookup_mime_subtype2(1, format, 0, ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0),
 		ast_rtp_lookup_sample_rate2(1, format, 0));
+
+	ast_format_sdp_generate(format, rtp_code, a_buf);
 
 	switch ((int) format->id) {
 	case AST_FORMAT_G729A:
@@ -11593,7 +11612,8 @@
 	ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code,
 		       ast_rtp_lookup_mime_subtype2(1, format, 0, 0),
 		       ast_rtp_lookup_sample_rate2(1, format, 0));
-	/* Add fmtp code here */
+
+	ast_format_sdp_generate(format, rtp_code, a_buf);
 }
 
 /*! \brief Add text codec offer to SDP offer/answer body in INVITE or 200 OK */

Modified: team/file/media-attrib-sdp/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/include/asterisk/format.h?view=diff&rev=368851&r1=368850&r2=368851
==============================================================================
--- team/file/media-attrib-sdp/include/asterisk/format.h (original)
+++ team/file/media-attrib-sdp/include/asterisk/format.h Wed Jun 13 09:07:49 2012
@@ -219,7 +219,45 @@
 	 * \retval -1 failure, Value was either not found, or not allowed to be accessed.
 	 */
 	int (* const format_attr_get_val)(const struct ast_format_attr *format_attr, int key, void *val);
-};
+
+	/*
+	 * \brief Parse SDP attribute information, interpret it, and store it in ast_format_attr structure.
+	 *
+	 * \retval 0 Success, values were valid
+	 * \retval -1 Failure, some values were not acceptable
+	 */
+	int (* const format_attr_sdp_parse)(struct ast_format_attr *format_attr, const char *attributes);
+
+	/*!
+	 * \brief Generate SDP attribute information from an ast_format_attr structure.
+	 *
+	 * \note This callback should generate a full fmtp line using the provided payload number.
+	 */
+	void (* const format_attr_sdp_generate)(const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str);
+};
+
+/*!
+ * \brief This function is used to have a media format aware module parse and interpret
+ * SDP attribute information. Once interpreted this information is stored on the format
+ * itself using Asterisk format attributes.
+ *
+ * \param format to set
+ * \param attributes string containing the fmtp line from the SDP
+ *
+ * \retval 0 success, attribute values were valid
+ * \retval -1 failure, values were not acceptable
+ */
+int ast_format_sdp_parse(struct ast_format *format, const char *attributes);
+
+/*!
+ * \brief This function is used to produce an fmtp SDP line for an Asterisk format. The
+ * attributes present on the Asterisk format are translated into the SDP equivalent.
+ *
+ * \param format to generate an fmtp line for
+ * \param payload numerical payload for the fmtp line
+ * \param str structure that the fmtp line will be appended to
+ */
+void ast_format_sdp_generate(const struct ast_format *format, unsigned int payload, struct ast_str **str);
 
 /*!
  * \brief This function is used to set an ast_format object to represent a media format

Modified: team/file/media-attrib-sdp/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/main/format.c?view=diff&rev=368851&r1=368850&r2=368851
==============================================================================
--- team/file/media-attrib-sdp/main/format.c (original)
+++ team/file/media-attrib-sdp/main/format.c Wed Jun 13 09:07:49 2012
@@ -113,6 +113,51 @@
 	}
 	ao2_ref(wrapper, -1);
 	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




More information about the asterisk-commits mailing list