[asterisk-commits] seanbright: branch group/pimp_my_sip r388698 - in /team/group/pimp_my_sip: in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 14 13:34:01 CDT 2013
Author: seanbright
Date: Tue May 14 13:33:58 2013
New Revision: 388698
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388698
Log:
DRY: Add ast_sip_is_content_type function
Modified:
team/group/pimp_my_sip/include/asterisk/res_sip.h
team/group/pimp_my_sip/res/res_sip.c
team/group/pimp_my_sip/res/res_sip.exports.in
team/group/pimp_my_sip/res/res_sip_dtmf_info.c
team/group/pimp_my_sip/res/res_sip_messaging.c
team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
Modified: team/group/pimp_my_sip/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip.h?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip.h Tue May 14 13:33:58 2013
@@ -1106,4 +1106,19 @@
*/
void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths);
+/*!
+ * \brief Checks if the given content type matches type/subtype.
+ *
+ * Compares the pjsip_media_type with the passed type and subtype and
+ * returns the result of that comparison. The media type parameters are
+ * ignored.
+ *
+ * \param content_type The pjsip_media_type structure to compare
+ * \param type The media type to compare
+ * \param subtype The media subtype to compare
+ * \retval 0 No match
+ * \retval -1 Match
+ */
+int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype);
+
#endif /* _RES_SIP_H */
Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Tue May 14 13:33:58 2013
@@ -709,6 +709,19 @@
dest[chars_to_copy] = '\0';
}
+int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
+{
+ pjsip_media_type compare;
+
+ if (!content_type) {
+ return 0;
+ }
+
+ pjsip_media_type_init2(&compare, type, subtype);
+
+ return pjsip_media_type_cmp(content_type, &compare, 0) ? -1 : 0;
+}
+
pj_caching_pool caching_pool;
pj_pool_t *memory_pool;
pj_thread_t *monitor_thread;
Modified: team/group/pimp_my_sip/res/res_sip.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.exports.in?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.exports.in (original)
+++ team/group/pimp_my_sip/res/res_sip.exports.in Tue May 14 13:33:58 2013
@@ -47,6 +47,7 @@
LINKER_SYMBOL_PREFIXast_sip_dialog_get_endpoint;
LINKER_SYMBOL_PREFIXast_sip_retrieve_auths;
LINKER_SYMBOL_PREFIXast_sip_cleanup_auths;
+ LINKER_SYMBOL_PREFIXast_sip_is_content_type;
local:
*;
};
Modified: team/group/pimp_my_sip/res/res_sip_dtmf_info.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_dtmf_info.c?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_dtmf_info.c (original)
+++ team/group/pimp_my_sip/res/res_sip_dtmf_info.c Tue May 14 13:33:58 2013
@@ -46,12 +46,7 @@
char event = '\0';
unsigned int duration = 0;
- if (!&body->content_type) {
- return 0;
- }
-
- if (pj_strcmp2(&body->content_type.type, "application") ||
- pj_strcmp2(&body->content_type.subtype, "dtmf-relay")) {
+ if (!ast_sip_is_content_type(&body->content_type, "application", "dtmf-relay")) {
return 0;
}
Modified: team/group/pimp_my_sip/res/res_sip_messaging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_messaging.c?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_messaging.c (original)
+++ team/group/pimp_my_sip/res/res_sip_messaging.c Tue May 14 13:33:58 2013
@@ -80,15 +80,13 @@
*/
static enum pjsip_status_code check_content_type(const pjsip_rx_data *rdata)
{
- if (!&rdata->msg_info.msg->body->content_type) {
+ if (ast_sip_is_content_type(&rdata->msg_info.msg->body->content_type,
+ "text",
+ "plain")) {
+ return PJSIP_SC_OK;
+ } else {
return PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
}
-
- if (pj_strcmp2(&rdata->msg_info.msg->body->content_type.type, "text") ||
- pj_strcmp2(&rdata->msg_info.msg->body->content_type.subtype, "plain")) {
- return PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
- }
- return PJSIP_SC_OK;
}
/*!
Modified: team/group/pimp_my_sip/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_sdp_rtp.c?view=diff&rev=388698&r1=388697&r2=388698
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_sdp_rtp.c (original)
+++ team/group/pimp_my_sip/res/res_sip_sdp_rtp.c Tue May 14 13:33:58 2013
@@ -921,13 +921,9 @@
struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
pjsip_tx_data *tdata;
- if (!&rdata->msg_info.msg->body->content_type) {
- return 0;
- }
-
- if (pj_strcmp2(&rdata->msg_info.msg->body->content_type.type, "application") ||
- pj_strcmp2(&rdata->msg_info.msg->body->content_type.subtype, "media_control+xml")) {
-
+ if (!ast_sip_is_content_type(&rdata->msg_info.msg->body->content_type,
+ "application",
+ "media_control+xml")) {
return 0;
}
More information about the asterisk-commits
mailing list