res_pjsip: Add utils for checking media types

Added two new functions to assist checking media types...

* ast_sip_are_media_types_equal compares two pjsip_media_types.
* ast_sip_is_media_type_in tests if one media type is in a list
  of others.

Added static definitions for commonly used media types to
res_pjsip.h.

Changed several modules to use the new functions and static
definitions.

ASTERISK_29813
(not ready to close)

Change-Id: Ief77675235bd3bf00a6b095d4673fd878d0801b9
This commit is contained in:
George Joseph
2022-01-06 12:05:34 -07:00
committed by Friendly Automation
parent 0d1b9e6baf
commit 921ab52cf3
5 changed files with 97 additions and 7 deletions

View File

@@ -3893,9 +3893,8 @@ static int check_content_disposition(pjsip_rx_data *rdata)
pjsip_ctype_hdr *ctype_hdr = rdata->msg_info.ctype;
if (body && ctype_hdr &&
!pj_stricmp2(&ctype_hdr->media.type, "multipart") &&
(!pj_stricmp2(&ctype_hdr->media.subtype, "mixed") ||
!pj_stricmp2(&ctype_hdr->media.subtype, "alternative"))) {
ast_sip_is_media_type_in(&ctype_hdr->media, &pjsip_media_type_multipart_mixed,
&pjsip_media_type_multipart_alternative, SENTINEL)) {
pjsip_multipart_part *part = pjsip_multipart_get_first_part(body);
while (part != NULL) {
if (check_content_disposition_in_multipart(part)) {
@@ -5488,7 +5487,7 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans
/* SDP produced by us directly will never be multipart */
if (!transport_state || hook || !tdata->msg->body ||
!ast_sip_is_content_type(&tdata->msg->body->content_type, "application", "sdp") ||
!ast_sip_are_media_types_equal(&tdata->msg->body->content_type, &pjsip_media_type_application_sdp) ||
ast_strlen_zero(transport->external_media_address)) {
return;
}