[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301132 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 7 21:49:42 UTC 2011


Author: dvossel
Date: Fri Jan  7 15:49:38 2011
New Revision: 301132

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301132
Log:
update slinfactory.c and rtp_engine.c for ast_format conversion

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h
    team/dvossel/fixtheworld_phase1_step3/main/format.c
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c
    team/dvossel/fixtheworld_phase1_step3/main/slinfactory.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h Fri Jan  7 15:49:38 2011
@@ -138,7 +138,7 @@
 	 *
 	 * \retval ast_format_cmp_res representing the result of comparing fattr1 and fattr2.
 	 */
-	enum ast_format_cmp_res (* const format_attr_cmp)(struct ast_format_attr *fattr1, struct ast_format_attr *fattr2);
+	enum ast_format_cmp_res (* const format_attr_cmp)(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2);
 
 	/*! \brief Get joint attributes of same format type if they exist.
 	 *
@@ -177,6 +177,11 @@
 struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, int set_attributes, ... );
 
 /*!
+ * \brief Clears the format stucture.
+ */
+void ast_format_clear(struct ast_format *format);
+
+/*!
  * \brief This function is used to set an ast_format object to represent a media format
  * with optional capability attributes represented by format specific key value pairs.
  *
@@ -193,7 +198,7 @@
  *
  * \retval ast_format_cmp_res representing the result of comparing format1 and format2.
  */
-enum ast_format_cmp_res ast_format_cmp(struct ast_format *format1, struct ast_format *format2);
+enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2);
 
 /*!
  * \brief Find joint format attributes of two ast_format

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Fri Jan  7 15:49:38 2011
@@ -79,6 +79,14 @@
 struct ast_cap *ast_cap_copy(struct ast_cap *cap);
 
 /*!
+ * \brief determine if a capabilities structure is empty or not
+ *
+ * \retval 1, true is empty
+ * \retval 0, false, not empty
+ */
+int ast_cap_is_empty(struct ast_cap *cap);
+
+/*!
  * \brief Remove format capability from capability structure.
  *
  * \Note format must match Exactly to format in ast_cap object in order

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/rtp_engine.h Fri Jan  7 15:49:38 2011
@@ -227,8 +227,12 @@
 struct ast_rtp_payload_type {
 	/*! Is this an Asterisk value */
 	int asterisk_format;
-	/*! Actual internal value of the payload */
-	format_t code;
+	/*! If asterisk_format is set, this is the internal
+	 * asterisk format represented by the payload */
+	struct ast_format format;
+	/*! Actual internal RTP specific value of the payload */
+	int rtp_code;
+
 };
 
 /*! Structure that represents statistics from an RTP instance */
@@ -335,8 +339,8 @@
 	void *(*extended_prop_get)(struct ast_rtp_instance *instance, int property);
 	/*! Callback for setting an RTP property */
 	void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
-	/*! Callback for setting a payload */
-	void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, format_t format);
+	/*! Callback for setting a payload.  If asterisk  is to be used, asterisk_format will be set, otherwise value in code is used. */
+	void (*payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code);
 	/*! Callback for setting packetization preferences */
 	void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
 	/*! Callback for setting the remote address that RTP is to be sent to */
@@ -360,9 +364,9 @@
 	/*! Callback to locally bridge two RTP instances */
 	int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
 	/*! Callback to set the read format */
-	int (*set_read_format)(struct ast_rtp_instance *instance, format_t format);
+	int (*set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format);
 	/*! Callback to set the write format */
-	int (*set_write_format)(struct ast_rtp_instance *instance, format_t format);
+	int (*set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format);
 	/*! Callback to make two instances compatible */
 	int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
 	/*! Callback to see if two instances are compatible with DTMF */
@@ -371,8 +375,8 @@
 	int (*activate)(struct ast_rtp_instance *instance);
 	/*! Callback to request that the RTP engine send a STUN BIND request */
 	void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
-	/*! Callback to get the transcodeable formats supported */
-	int (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
+	/*! Callback to get the transcodeable formats supported. result returned in ast_cap *result */
+	void (*available_formats)(struct ast_rtp_instance *instance, struct ast_cap *to_endpoint, struct ast_cap *to_asterisk, struct ast_cap *result);
 	/*! Linked list information */
 	AST_RWLIST_ENTRY(ast_rtp_engine) entry;
 };
@@ -407,9 +411,9 @@
 	 */
 	enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
 	/*! Callback for updating the destination that the remote side should send RTP to */
-	int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
-	/*! Callback for retrieving codecs that the channel can do */
-	format_t (*get_codec)(struct ast_channel *chan);
+	int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, const struct ast_cap *cap, int nat_active);
+	/*! Callback for retrieving codecs that the channel can do.  Result returned in result_cap*/
+	void (*get_codec)(struct ast_channel *chan, struct ast_cap *result_cap);
 	/*! Linked list information */
 	AST_RWLIST_ENTRY(ast_rtp_glue) entry;
 };
@@ -1046,26 +1050,28 @@
 /*!
  * \brief Get the sample rate associated with known RTP payload types
  *
- * \param asterisk_format True if the value in the 'code' parameter is an AST_FORMAT value
- * \param code Format code, either from AST_FORMAT list or from AST_RTP list
+ * \param asterisk_format True if the value in format is to be used.
+ * \param An asterisk format
+ * \param code from AST_RTP list
  *
  * \return the sample rate if the format was found, zero if it was not found
  *
  * \since 1.8
  */
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code);
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, struct ast_format *format, int code);
 
 /*!
  * \brief Retrieve all formats that were found
  *
  * \param codecs Codecs structure to look in
- * \param astformats An integer to put the Asterisk formats in
+ * \param astformats A capabilities structure to put the Asterisk formats in.
  * \param nonastformats An integer to put the non-Asterisk formats in
  *
  * Example usage:
  *
  * \code
- * int astformats, nonastformats;
+ * struct ast_cap *astformats = ast_cap_alloc()
+ * int nonastformats;
  * ast_rtp_codecs_payload_Formats(&codecs, &astformats, &nonastformats);
  * \endcode
  *
@@ -1074,13 +1080,14 @@
  *
  * \since 1.8
  */
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats);
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_cap *astformats, int *nonastformats);
 
 /*!
  * \brief Retrieve a payload based on whether it is an Asterisk format and the code
  *
  * \param codecs Codecs structure to look in
- * \param asterisk_format Non-zero if the given code is an Asterisk format value
+ * \param asterisk_format Non-zero if the given asterisk format is present
+ * \param format Asterisk format to look for
  * \param code The format to look for
  *
  * \retval Numerical payload
@@ -1088,20 +1095,21 @@
  * Example usage:
  *
  * \code
- * int payload = ast_rtp_codecs_payload_code(&codecs, 1, AST_FORMAT_ULAW);
+ * int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0);
  * \endcode
  *
  * This looks for the numerical payload for ULAW in the codecs structure.
  *
  * \since 1.8
  */
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code);
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code);
 
 /*!
  * \brief Retrieve mime subtype information on a payload
  *
- * \param asterisk_format Non-zero if the given code is an Asterisk format value
- * \param code Format to look up
+ * \param asterisk_format Non-zero to look up using Asterisk format
+ * \param format Asterisk format to look up
+ * \param code RTP code to look up
  * \param options Additional options that may change the result
  *
  * \retval Mime subtype success
@@ -1110,21 +1118,22 @@
  * Example usage:
  *
  * \code
- * const char *subtype = ast_rtp_lookup_mime_subtype2(1, AST_FORMAT_ULAW, 0);
+ * const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0);
  * \endcode
  *
  * This looks up the mime subtype for the ULAW format.
  *
  * \since 1.8
  */
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options);
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options);
 
 /*!
  * \brief Convert formats into a string and put them into a buffer
  *
  * \param buf Buffer to put the mime output into
- * \param capability Formats that we are looking up
- * \param asterisk_format Non-zero if the given capability are Asterisk format capabilities
+ * \param ast_capability Asterisk Formats we are looking up.
+ * \param rtp_capability RTP codes that we are looking up
+ * \param asterisk_format Non-zero if the ast_capability structure is to be used, 0 if rtp_capability is to be used
  * \param options Additional options that may change the result
  *
  * \retval non-NULL success
@@ -1134,14 +1143,19 @@
  *
  * \code
  * char buf[256] = "";
- * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), AST_FORMAT_ULAW | AST_FORMAT_ALAW, 1, 0);
+ * struct ast_format tmp_fmt;
+ * struct ast_cap *cap = ast_cap_alloc();
+ * ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
+ * ast_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
+ * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
+ * ast_cap_destroy(cap);
  * \endcode
  *
  * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
  *
  * \since 1.8
  */
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options);
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_cap *ast_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options);
 
 /*!
  * \brief Set codec packetization preferences
@@ -1535,14 +1549,15 @@
  * Example usage:
  *
  * \code
- * ast_rtp_instance_set_read_format(instance, AST_FORMAT_ULAW);
+ * struct ast_format tmp_fmt;
+ * ast_rtp_instance_set_read_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
  * \endcode
  *
  * This requests that the RTP engine provide audio frames in the ULAW format.
  *
  * \since 1.8
  */
-int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format);
+int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format);
 
 /*!
  * \brief Tell underlying RTP engine that audio frames will be provided in a specific format
@@ -1556,14 +1571,15 @@
  * Example usage:
  *
  * \code
- * ast_rtp_instance_set_write_format(instance, AST_FORMAT_ULAW);
+ * struct ast_format tmp_fmt;
+ * ast_rtp_instance_set_write_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
  * \endcode
  *
  * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
  *
  * \since 1.8
  */
-int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format);
+int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format);
 
 /*!
  * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
@@ -1592,20 +1608,19 @@
  * \param instance The RTP instance
  * \param to_endpoint Formats being sent/received towards the endpoint
  * \param to_asterisk Formats being sent/received towards Asterisk
- *
- * \retval supported formats
- *
- * Example usage:
- *
- * \code
- * ast_rtp_instance_available_formats(instance, AST_FORMAT_ULAW, AST_FORMAT_SLINEAR);
+ * \param result capabilities structure to store and return supported formats in.
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);
  * \endcode
  *
  * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
  *
  * \since 1.8
  */
-format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
+void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_cap *to_endpoint, struct ast_cap *to_asterisk, struct ast_cap *result);
 
 /*!
  * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance

Modified: team/dvossel/fixtheworld_phase1_step3/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format.c?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format.c Fri Jan  7 15:49:38 2011
@@ -126,6 +126,13 @@
 	return format;
 }
 
+
+void ast_format_clear(struct ast_format *format)
+{
+	format->id = 0;
+	memset(&format->fattr, 0, sizeof(format->fattr));
+}
+
 /*! \internal
  * \brief determine if a list of attribute key value pairs are set on a format
  */
@@ -184,7 +191,7 @@
 /*! \internal
  * \brief cmp format attributes using an interface
  */
-static enum ast_format_cmp_res format_cmp_helper(struct ast_format *format1, struct ast_format *format2)
+static enum ast_format_cmp_res format_cmp_helper(const struct ast_format *format1, const struct ast_format *format2)
 {
 	enum ast_format_cmp_res res = AST_FORMAT_CMP_EQUAL;
 	struct interface_ao2_wrapper *wrapper;
@@ -214,7 +221,7 @@
 	return res;
 }
 
-enum ast_format_cmp_res ast_format_cmp(struct ast_format *format1, struct ast_format *format2)
+enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
 {
 	if (format1->id != format2->id) {
 		return AST_FORMAT_CMP_NOT_EQUAL;

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Fri Jan  7 15:49:38 2011
@@ -149,6 +149,11 @@
 	return copy;
 }
 
+int ast_cap_is_empty(struct ast_cap *cap)
+{
+	return ao2_container_count(cap->formats) > 0 ? 1 : 0;
+}
+
 static int find_exact_cb(void *obj, void *arg, int flag)
 {
 	struct ast_format *format1 = (struct ast_format *) arg;

Modified: team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c?view=diff&rev=301132&r1=301131&r2=301132
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/rtp_engine.c Fri Jan  7 15:49:38 2011
@@ -89,43 +89,43 @@
 	char *subtype;
 	unsigned int sample_rate;
 } ast_rtp_mime_types[] = {
-	{{1, AST_FORMAT_G723_1}, "audio", "G723", 8000},
-	{{1, AST_FORMAT_GSM}, "audio", "GSM", 8000},
-	{{1, AST_FORMAT_ULAW}, "audio", "PCMU", 8000},
-	{{1, AST_FORMAT_ULAW}, "audio", "G711U", 8000},
-	{{1, AST_FORMAT_ALAW}, "audio", "PCMA", 8000},
-	{{1, AST_FORMAT_ALAW}, "audio", "G711A", 8000},
-	{{1, AST_FORMAT_G726}, "audio", "G726-32", 8000},
-	{{1, AST_FORMAT_ADPCM}, "audio", "DVI4", 8000},
-	{{1, AST_FORMAT_SLINEAR}, "audio", "L16", 8000},
-	{{1, AST_FORMAT_SLINEAR16}, "audio", "L16", 16000},
-	{{1, AST_FORMAT_LPC10}, "audio", "LPC", 8000},
-	{{1, AST_FORMAT_G729A}, "audio", "G729", 8000},
-	{{1, AST_FORMAT_G729A}, "audio", "G729A", 8000},
-	{{1, AST_FORMAT_G729A}, "audio", "G.729", 8000},
-	{{1, AST_FORMAT_SPEEX}, "audio", "speex", 8000},
-	{{1, AST_FORMAT_SPEEX16}, "audio", "speex", 16000},
-	{{1, AST_FORMAT_ILBC}, "audio", "iLBC", 8000},
+	{{1, {.id = AST_FORMAT_G723_1}, 0}, "audio", "G723", 8000},
+	{{1, {.id = AST_FORMAT_GSM}, 0}, "audio", "GSM", 8000},
+	{{1, {.id = AST_FORMAT_ULAW}, 0}, "audio", "PCMU", 8000},
+	{{1, {.id = AST_FORMAT_ULAW}, 0}, "audio", "G711U", 8000},
+	{{1, {.id = AST_FORMAT_ALAW}, 0}, "audio", "PCMA", 8000},
+	{{1, {.id = AST_FORMAT_ALAW}, 0}, "audio", "G711A", 8000},
+	{{1, {.id = AST_FORMAT_G726}, 0}, "audio", "G726-32", 8000},
+	{{1, {.id = AST_FORMAT_ADPCM}, 0}, "audio", "DVI4", 8000},
+	{{1, {.id = AST_FORMAT_SLINEAR}, 0}, "audio", "L16", 8000},
+	{{1, {.id = AST_FORMAT_SLINEAR16}, 0}, "audio", "L16", 16000},
+	{{1, {.id = AST_FORMAT_LPC10}, 0}, "audio", "LPC", 8000},
+	{{1, {.id = AST_FORMAT_G729A}, 0}, "audio", "G729", 8000},
+	{{1, {.id = AST_FORMAT_G729A}, 0}, "audio", "G729A", 8000},
+	{{1, {.id = AST_FORMAT_G729A}, 0}, "audio", "G.729", 8000},
+	{{1, {.id = AST_FORMAT_SPEEX}, 0}, "audio", "speex", 8000},
+	{{1, {.id = AST_FORMAT_SPEEX16}, 0},  "audio", "speex", 16000},
+	{{1, {.id = AST_FORMAT_ILBC}, 0}, "audio", "iLBC", 8000},
 	/* this is the sample rate listed in the RTP profile for the G.722
 	              codec, *NOT* the actual sample rate of the media stream
 	*/
-	{{1, AST_FORMAT_G722}, "audio", "G722", 8000},
-	{{1, AST_FORMAT_G726_AAL2}, "audio", "AAL2-G726-32", 8000},
-	{{0, AST_RTP_DTMF}, "audio", "telephone-event", 8000},
-	{{0, AST_RTP_CISCO_DTMF}, "audio", "cisco-telephone-event", 8000},
-	{{0, AST_RTP_CN}, "audio", "CN", 8000},
-	{{1, AST_FORMAT_JPEG}, "video", "JPEG", 90000},
-	{{1, AST_FORMAT_PNG}, "video", "PNG", 90000},
-	{{1, AST_FORMAT_H261}, "video", "H261", 90000},
-	{{1, AST_FORMAT_H263}, "video", "H263", 90000},
-	{{1, AST_FORMAT_H263_PLUS}, "video", "h263-1998", 90000},
-	{{1, AST_FORMAT_H264}, "video", "H264", 90000},
-	{{1, AST_FORMAT_MP4_VIDEO}, "video", "MP4V-ES", 90000},
-	{{1, AST_FORMAT_T140RED}, "text", "RED", 1000},
-	{{1, AST_FORMAT_T140}, "text", "T140", 1000},
-	{{1, AST_FORMAT_SIREN7}, "audio", "G7221", 16000},
-	{{1, AST_FORMAT_SIREN14}, "audio", "G7221", 32000},
-	{{1, AST_FORMAT_G719}, "audio", "G719", 48000},
+	{{1, {.id = AST_FORMAT_G722}, 0}, "audio", "G722", 8000},
+	{{1, {.id = AST_FORMAT_G726_AAL2}, 0}, "audio", "AAL2-G726-32", 8000},
+	{{0, {.id = 0}, AST_RTP_DTMF}, "audio", "telephone-event", 8000},
+	{{0, {.id = 0}, AST_RTP_CISCO_DTMF}, "audio", "cisco-telephone-event", 8000},
+	{{0, {.id = 0}, AST_RTP_CN}, "audio", "CN", 8000},
+	{{1, {.id = AST_FORMAT_JPEG}, 0}, "video", "JPEG", 90000},
+	{{1, {.id = AST_FORMAT_PNG}, 0}, "video", "PNG", 90000},
+	{{1, {.id = AST_FORMAT_H261}, 0}, "video", "H261", 90000},
+	{{1, {.id = AST_FORMAT_H263}, 0}, "video", "H263", 90000},
+	{{1, {.id = AST_FORMAT_H263_PLUS}, 0}, "video", "h263-1998", 90000},
+	{{1, {.id = AST_FORMAT_H264}, 0}, "video", "H264", 90000},
+	{{1, {.id = AST_FORMAT_MP4_VIDEO}, 0}, "video", "MP4V-ES", 90000},
+	{{1, {.id = AST_FORMAT_T140RED}, 0}, "text", "RED", 1000},
+	{{1, {.id = AST_FORMAT_T140}, 0}, "text", "T140", 1000},
+	{{1, {.id = AST_FORMAT_SIREN7}, 0}, "audio", "G7221", 16000},
+	{{1, {.id = AST_FORMAT_SIREN14}, 0}, "audio", "G7221", 32000},
+	{{1, {.id = AST_FORMAT_G719}, 0}, "audio", "G719", 48000},
 };
 
 /*!
@@ -139,44 +139,44 @@
  * assigned values
  */
 static const struct ast_rtp_payload_type static_RTP_PT[AST_RTP_MAX_PT] = {
-	[0] = {1, AST_FORMAT_ULAW},
+	[0] = {1, {.id = AST_FORMAT_ULAW}, 0},
 	#ifdef USE_DEPRECATED_G726
-	[2] = {1, AST_FORMAT_G726}, /* Technically this is G.721, but if Cisco can do it, so can we... */
+	[2] = {1, {.id = AST_FORMAT_G726}, 0},/* Technically this is G.721, but if Cisco can do it, so can we... */
 	#endif
-	[3] = {1, AST_FORMAT_GSM},
-	[4] = {1, AST_FORMAT_G723_1},
-	[5] = {1, AST_FORMAT_ADPCM}, /* 8 kHz */
-	[6] = {1, AST_FORMAT_ADPCM}, /* 16 kHz */
-	[7] = {1, AST_FORMAT_LPC10},
-	[8] = {1, AST_FORMAT_ALAW},
-	[9] = {1, AST_FORMAT_G722},
-	[10] = {1, AST_FORMAT_SLINEAR}, /* 2 channels */
-	[11] = {1, AST_FORMAT_SLINEAR}, /* 1 channel */
-	[13] = {0, AST_RTP_CN},
-	[16] = {1, AST_FORMAT_ADPCM}, /* 11.025 kHz */
-	[17] = {1, AST_FORMAT_ADPCM}, /* 22.050 kHz */
-	[18] = {1, AST_FORMAT_G729A},
-	[19] = {0, AST_RTP_CN},         /* Also used for CN */
-	[26] = {1, AST_FORMAT_JPEG},
-	[31] = {1, AST_FORMAT_H261},
-	[34] = {1, AST_FORMAT_H263},
-	[97] = {1, AST_FORMAT_ILBC},
-	[98] = {1, AST_FORMAT_H263_PLUS},
-	[99] = {1, AST_FORMAT_H264},
-	[101] = {0, AST_RTP_DTMF},
-	[102] = {1, AST_FORMAT_SIREN7},
-	[103] = {1, AST_FORMAT_H263_PLUS},
-	[104] = {1, AST_FORMAT_MP4_VIDEO},
-	[105] = {1, AST_FORMAT_T140RED},   /* Real time text chat (with redundancy encoding) */
-	[106] = {1, AST_FORMAT_T140},      /* Real time text chat */
-	[110] = {1, AST_FORMAT_SPEEX},
-	[111] = {1, AST_FORMAT_G726},
-	[112] = {1, AST_FORMAT_G726_AAL2},
-	[115] = {1, AST_FORMAT_SIREN14},
-	[116] = {1, AST_FORMAT_G719},
-	[117] = {1, AST_FORMAT_SPEEX16},
-	[118] = {1, AST_FORMAT_SLINEAR16}, /* 16 Khz signed linear */
-	[121] = {0, AST_RTP_CISCO_DTMF},   /* Must be type 121 */
+	[3] = {1, {.id = AST_FORMAT_GSM}, 0},
+	[4] = {1, {.id = AST_FORMAT_G723_1}, 0},
+	[5] = {1, {.id = AST_FORMAT_ADPCM}, 0},/* 8 kHz */
+	[6] = {1, {.id = AST_FORMAT_ADPCM}, 0}, /* 16 kHz */
+	[7] = {1, {.id = AST_FORMAT_LPC10}, 0},
+	[8] = {1, {.id = AST_FORMAT_ALAW}, 0},
+	[9] = {1, {.id = AST_FORMAT_G722}, 0},
+	[10] = {1, {.id = AST_FORMAT_SLINEAR}, 0}, /* 2 channels */
+	[11] = {1, {.id = AST_FORMAT_SLINEAR}, 0}, /* 1 channel */
+	[13] = {0, {.id = 0}, AST_RTP_CN},
+	[16] = {1, {.id = AST_FORMAT_ADPCM}, 0}, /* 11.025 kHz */
+	[17] = {1, {.id = AST_FORMAT_ADPCM}, 0}, /* 22.050 kHz */
+	[18] = {1, {.id = AST_FORMAT_G729A}, 0},
+	[19] = {0, {.id = 0}, AST_RTP_CN},         /* Also used for CN */
+	[26] = {1, {.id = AST_FORMAT_JPEG}, 0},
+	[31] = {1, {.id = AST_FORMAT_H261}, 0},
+	[34] = {1, {.id = AST_FORMAT_H263}, 0},
+	[97] = {1, {.id = AST_FORMAT_ILBC}, 0},
+	[98] = {1, {.id = AST_FORMAT_H263_PLUS}, 0},
+	[99] = {1, {.id = AST_FORMAT_H264}, 0},
+	[101] = {0, {.id = 0}, AST_RTP_DTMF},
+	[102] = {1, {.id = AST_FORMAT_SIREN7}, 0},
+	[103] = {1, {.id = AST_FORMAT_H263_PLUS}, 0},
+	[104] = {1, {.id = AST_FORMAT_MP4_VIDEO}, 0},
+	[105] = {1, {.id = AST_FORMAT_T140RED}, 0},   /* Real time text chat (with redundancy encoding) */
+	[106] = {1, {.id = AST_FORMAT_T140}, 0},      /* Real time text chat */
+	[110] = {1, {.id = AST_FORMAT_SPEEX}, 0},
+	[111] = {1, {.id = AST_FORMAT_G726}, 0},
+	[112] = {1, {.id = AST_FORMAT_G726_AAL2}, 0},
+	[115] = {1, {.id = AST_FORMAT_SIREN14}, 0},
+	[116] = {1, {.id = AST_FORMAT_G719}, 0},
+	[117] = {1, {.id = AST_FORMAT_SPEEX16}, 0},
+	[118] = {1, {.id = AST_FORMAT_SLINEAR16}, 0}, /* 16 Khz signed linear */
+	[121] = {0, {.id = 0}, AST_RTP_CISCO_DTMF},   /* Must be type 121 */
 };
 
 int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
@@ -485,9 +485,10 @@
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
 		codecs->payloads[i].asterisk_format = 0;
-		codecs->payloads[i].code = 0;
+		codecs->payloads[i].rtp_code = 0;
+		ast_format_clear(&codecs->payloads[i].format);
 		if (instance && instance->engine && instance->engine->payload_set) {
-			instance->engine->payload_set(instance, i, 0, 0);
+			instance->engine->payload_set(instance, i, 0, NULL, 0);
 		}
 	}
 }
@@ -497,11 +498,13 @@
 	int i;
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
-		if (static_RTP_PT[i].code) {
+		if (static_RTP_PT[i].rtp_code || static_RTP_PT[i].asterisk_format) {
+
 			codecs->payloads[i].asterisk_format = static_RTP_PT[i].asterisk_format;
-			codecs->payloads[i].code = static_RTP_PT[i].code;
+			codecs->payloads[i].rtp_code = static_RTP_PT[i].rtp_code;
+			ast_format_copy(&static_RTP_PT[i].format, &codecs->payloads[i].format);
 			if (instance && instance->engine && instance->engine->payload_set) {
-				instance->engine->payload_set(instance, i, codecs->payloads[i].asterisk_format, codecs->payloads[i].code);
+				instance->engine->payload_set(instance, i, codecs->payloads[i].asterisk_format, &codecs->payloads[i].format, codecs->payloads[i].rtp_code);
 			}
 		}
 	}
@@ -512,12 +515,13 @@
 	int i;
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
-		if (src->payloads[i].code) {
+		if (src->payloads[i].rtp_code || src->payloads[i].asterisk_format) {
 			ast_debug(2, "Copying payload %d from %p to %p\n", i, src, dest);
 			dest->payloads[i].asterisk_format = src->payloads[i].asterisk_format;
-			dest->payloads[i].code = src->payloads[i].code;
+			dest->payloads[i].rtp_code = src->payloads[i].rtp_code;
+			ast_format_copy(&src->payloads[i].format, &dest->payloads[i].format);
 			if (instance && instance->engine && instance->engine->payload_set) {
-				instance->engine->payload_set(instance, i, dest->payloads[i].asterisk_format, dest->payloads[i].code);
+				instance->engine->payload_set(instance, i, dest->payloads[i].asterisk_format, &dest->payloads[i].format, dest->payloads[i].rtp_code);
 			}
 		}
 	}
@@ -525,17 +529,18 @@
 
 void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
 {
-	if (payload < 0 || payload >= AST_RTP_MAX_PT || !static_RTP_PT[payload].code) {
+	if (payload < 0 || payload >= AST_RTP_MAX_PT || (!static_RTP_PT[payload].rtp_code && !static_RTP_PT[payload].asterisk_format)) {
 		return;
 	}
 
 	codecs->payloads[payload].asterisk_format = static_RTP_PT[payload].asterisk_format;
-	codecs->payloads[payload].code = static_RTP_PT[payload].code;
+	codecs->payloads[payload].rtp_code = static_RTP_PT[payload].rtp_code;
+	ast_format_copy(&static_RTP_PT[payload].format, &codecs->payloads[payload].format);
 
 	ast_debug(1, "Setting payload %d based on m type on %p\n", payload, codecs);
 
 	if (instance && instance->engine && instance->engine->payload_set) {
-		instance->engine->payload_set(instance, payload, codecs->payloads[payload].asterisk_format, codecs->payloads[payload].code);
+		instance->engine->payload_set(instance, payload, codecs->payloads[payload].asterisk_format, &codecs->payloads[payload].format, codecs->payloads[payload].rtp_code);
 	}
 }
 
@@ -572,14 +577,12 @@
 		found = 1;
 		codecs->payloads[pt] = t->payload_type;
 
-		if ((t->payload_type.code == AST_FORMAT_G726) &&
-		                        t->payload_type.asterisk_format &&
-		    (options & AST_RTP_OPT_G726_NONSTANDARD)) {
-			codecs->payloads[pt].code = AST_FORMAT_G726_AAL2;
+		if ((t->payload_type.format.id == AST_FORMAT_G726) && t->payload_type.asterisk_format && (options & AST_RTP_OPT_G726_NONSTANDARD)) {
+			ast_format_set(&codecs->payloads[pt].format, AST_FORMAT_G726_AAL2, 0);
 		}
 
 		if (instance && instance->engine && instance->engine->payload_set) {
-			instance->engine->payload_set(instance, pt, codecs->payloads[i].asterisk_format, codecs->payloads[i].code);
+			instance->engine->payload_set(instance, pt, codecs->payloads[i].asterisk_format, &codecs->payloads[i].format, codecs->payloads[i].rtp_code);
 		}
 
 		break;
@@ -602,10 +605,11 @@
 	ast_debug(2, "Unsetting payload %d on %p\n", payload, codecs);
 
 	codecs->payloads[payload].asterisk_format = 0;
-	codecs->payloads[payload].code = 0;
+	codecs->payloads[payload].rtp_code = 0;
+	ast_format_clear(&codecs->payloads[payload].format);
 
 	if (instance && instance->engine && instance->engine->payload_set) {
-		instance->engine->payload_set(instance, payload, 0, 0);
+		instance->engine->payload_set(instance, payload, 0, NULL, 0);
 	}
 }
 
@@ -618,98 +622,129 @@
 	}
 
 	result.asterisk_format = codecs->payloads[payload].asterisk_format;
-	result.code = codecs->payloads[payload].code;
-
-	if (!result.code) {
+	result.rtp_code = codecs->payloads[payload].rtp_code;
+	ast_format_copy(&codecs->payloads[payload].format, &result.format);
+
+	if (!result.rtp_code && !result.asterisk_format) {
 		result = static_RTP_PT[payload];
 	}
 
 	return result;
 }
 
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats)
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_cap *astformats, int *nonastformats)
 {
 	int i;
 
-	*astformats = *nonastformats = 0;
+	ast_cap_remove_all(astformats);
+	*nonastformats = 0;
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
-		if (codecs->payloads[i].code) {
+		if (codecs->payloads[i].rtp_code || codecs->payloads[i].asterisk_format) {
 			ast_debug(1, "Incorporating payload %d on %p\n", i, codecs);
 		}
 		if (codecs->payloads[i].asterisk_format) {
-			*astformats |= codecs->payloads[i].code;
+			ast_cap_add(astformats, &codecs->payloads[i].format);
 		} else {
-			*nonastformats |= codecs->payloads[i].code;
-		}
-	}
-}
-
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
+			*nonastformats |= codecs->payloads[i].rtp_code;
+		}
+	}
+}
+
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
 {
 	int i;
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
-		if (codecs->payloads[i].asterisk_format == asterisk_format && codecs->payloads[i].code == code) {
+		if (codecs->payloads[i].asterisk_format && asterisk_format &&
+			(ast_format_cmp(&codecs->payloads[i].format, format) == AST_FORMAT_CMP_EQUAL)) {
 			return i;
+		} else if (!codecs->payloads[i].asterisk_format && !asterisk_format &&
+			(codecs->payloads[i].rtp_code == code)) {
+			return i;
 		}
 	}
 
 	for (i = 0; i < AST_RTP_MAX_PT; i++) {
-		if (static_RTP_PT[i].asterisk_format == asterisk_format && static_RTP_PT[i].code == code) {
+		if (static_RTP_PT[i].asterisk_format && asterisk_format &&
+			(ast_format_cmp(&static_RTP_PT[i].format, format) == AST_FORMAT_CMP_EQUAL)) {
 			return i;
+		} else if (!static_RTP_PT[i].asterisk_format && !asterisk_format &&
+			(static_RTP_PT[i].rtp_code == code)) {
+			return i;
 		}
 	}
 
 	return -1;
 }
 
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options)
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options)
 {
 	int i;
 
 	for (i = 0; i < ARRAY_LEN(ast_rtp_mime_types); i++) {
-		if (ast_rtp_mime_types[i].payload_type.code == code && ast_rtp_mime_types[i].payload_type.asterisk_format == asterisk_format) {
-			if (asterisk_format && (code == AST_FORMAT_G726_AAL2) && (options & AST_RTP_OPT_G726_NONSTANDARD)) {
+		if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format &&
+			(ast_format_cmp(&ast_rtp_mime_types[i].payload_type.format, format) == AST_FORMAT_CMP_EQUAL)) {
+			if ((format->id == AST_FORMAT_G726_AAL2) && (options & AST_RTP_OPT_G726_NONSTANDARD)) {
 				return "G726-32";
 			} else {
 				return ast_rtp_mime_types[i].subtype;
 			}
+		} else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
+			ast_rtp_mime_types[i].payload_type.rtp_code == code) {
+
+			return ast_rtp_mime_types[i].subtype;
 		}
 	}
 
 	return "";
 }
 
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code)
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, struct ast_format *format, int code)
 {
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_LEN(ast_rtp_mime_types); ++i) {
-		if ((ast_rtp_mime_types[i].payload_type.code == code) && (ast_rtp_mime_types[i].payload_type.asterisk_format == asterisk_format)) {
+		if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format &&
+			(ast_format_cmp(&ast_rtp_mime_types[i].payload_type.format, format) == AST_FORMAT_CMP_EQUAL)) {
 			return ast_rtp_mime_types[i].sample_rate;
+		} else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
+			ast_rtp_mime_types[i].payload_type.rtp_code == code) {
+			return ast_rtp_mime_types[i].sample_rate;
 		}
 	}
 
 	return 0;
 }
 
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options)
-{
-	format_t format;
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_cap *ast_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options)
+{
 	int found = 0;
-
+	const char *name;
 	if (!buf) {
 		return NULL;
 	}
 
-	ast_str_append(&buf, 0, "0x%llx (", (unsigned long long) capability);
-
-	for (format = 1; format < AST_RTP_MAX; format <<= 1) {
-		if (capability & format) {
-			const char *name = ast_rtp_lookup_mime_subtype2(asterisk_format, format, options);
+
+	if (asterisk_format) {
+		struct ast_format tmp_fmt;
+		ast_cap_iter_start(ast_capability);
+		while (!ast_cap_iter_next(ast_capability, &tmp_fmt)) {
+			name = ast_rtp_lookup_mime_subtype2(asterisk_format, &tmp_fmt, 0, options);
 			ast_str_append(&buf, 0, "%s|", name);
 			found = 1;
+		}
+		ast_cap_iter_end(ast_capability);
+
+	} else {
+		int x;
+		ast_str_append(&buf, 0, "0x%x (", (unsigned int) rtp_capability);
+		for (x = 1; x < AST_RTP_MAX; x <<= 1) {
+			if (rtp_capability & x) {
+				name = ast_rtp_lookup_mime_subtype2(asterisk_format, NULL, x, options);
+				ast_str_append(&buf, 0, "%s|", name);
+				found = 1;
+			}
 		}
 	}
 
@@ -842,7 +877,8 @@
 	cs[2] = NULL;
 	for (;;) {
 		/* If the underlying formats have changed force this bridge to break */
-		if ((c0->rawreadformat != c1->rawwriteformat) || (c1->rawreadformat != c0->rawwriteformat)) {
+		if ((ast_format_cmp(&c0->rawreadformat, &c1->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
+			(ast_format_cmp(&c1->rawreadformat, &c0->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL)) {
 			ast_debug(1, "rtp-engine-local-bridge: Oooh, formats changed, backing out\n");
 			res = AST_BRIDGE_FAILED_NOWARN;
 			break;
@@ -969,20 +1005,38 @@
 	return res;
 }
 
-static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1,
-						 struct ast_rtp_instance *vinstance0, struct ast_rtp_instance *vinstance1, struct ast_rtp_instance *tinstance0,
-						 struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, format_t codec0, format_t codec1, int timeoutms,
-						 int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1)
+static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
+	struct ast_channel *c1,
+	struct ast_rtp_instance *instance0,
+	struct ast_rtp_instance *instance1,
+	struct ast_rtp_instance *vinstance0,
+	struct ast_rtp_instance *vinstance1,
+	struct ast_rtp_instance *tinstance0,
+	struct ast_rtp_instance *tinstance1,
+	struct ast_rtp_glue *glue0,
+	struct ast_rtp_glue *glue1,
+	struct ast_cap *cap0,
+	struct ast_cap *cap1,
+	int timeoutms,
+	int flags,
+	struct ast_frame **fo,
+	struct ast_channel **rc,
+	void *pvt0,
+	void *pvt1)
 {
 	enum ast_bridge_result res = AST_BRIDGE_FAILED;
 	struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, };
-	format_t oldcodec0 = codec0, oldcodec1 = codec1;
+	struct ast_cap *oldcap0 = ast_cap_copy(cap0);
+	struct ast_cap *oldcap1 = ast_cap_copy(cap1);
 	struct ast_sockaddr ac1 = {{0,}}, vac1 = {{0,}}, tac1 = {{0,}}, ac0 = {{0,}}, vac0 = {{0,}}, tac0 = {{0,}};
 	struct ast_sockaddr t1 = {{0,}}, vt1 = {{0,}}, tt1 = {{0,}}, t0 = {{0,}}, vt0 = {{0,}}, tt0 = {{0,}};
 	struct ast_frame *fr = NULL;
 
+	if (!oldcap0 || oldcap1) {
+		goto remote_bridge_cleanup;
+	}
 	/* Test the first channel */
-	if (!(glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0))) {
+	if (!(glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0))) {
 		ast_rtp_instance_get_remote_address(instance1, &ac1);
 		if (vinstance1) {
 			ast_rtp_instance_get_remote_address(vinstance1, &vac1);
@@ -995,7 +1049,7 @@
 	}
 
 	/* Test the second channel */
-	if (!(glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0))) {
+	if (!(glue1->update_peer(c1, instance0, vinstance0, tinstance0, cap0, 0))) {
 		ast_rtp_instance_get_remote_address(instance0, &ac0);
 		if (vinstance0) {
 			ast_rtp_instance_get_remote_address(instance0, &vac0);
@@ -1039,7 +1093,8 @@
 			ast_rtp_instance_get_remote_address(tinstance1, &tt1);
 		}
 		if (glue1->get_codec) {
-			codec1 = glue1->get_codec(c1);
+			ast_cap_remove_all(cap1);
+			glue1->get_codec(c1, cap1);
 		}
 
 		ast_rtp_instance_get_remote_address(instance0, &t0);
@@ -1050,63 +1105,68 @@
 			ast_rtp_instance_get_remote_address(tinstance0, &tt0);
 		}
 		if (glue0->get_codec) {
-			codec0 = glue0->get_codec(c0);
+			ast_cap_remove_all(cap0);
+			glue0->get_codec(c0, cap0);
 		}
 
 		if ((ast_sockaddr_cmp(&t1, &ac1)) ||
 		    (vinstance1 && ast_sockaddr_cmp(&vt1, &vac1)) ||
 		    (tinstance1 && ast_sockaddr_cmp(&tt1, &tac1)) ||
-		    (codec1 != oldcodec1)) {
+		    (!ast_cap_identical(cap1, oldcap1))) {
+			char tmp_buf[512] = { 0, };
 			ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n",
 				  c1->name, ast_sockaddr_stringify(&t1),
-				  ast_getformatname(codec1));
+				  ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), cap1));
 			ast_debug(1, "Oooh, '%s' changed end vaddress to %s (format %s)\n",
 				  c1->name, ast_sockaddr_stringify(&vt1),

[... 384 lines stripped ...]



More information about the asterisk-commits mailing list