/** Count matching media lines in SDP. */ unsigned sdp_media_count_with(sdp_session_t const *sdp, sdp_media_t const *m0) { unsigned count = 0; sdp_media_t const *m; if (sdp != NULL) for (m = sdp->sdp_media; m; m = m->m_next) count += sdp_media_match_with(m, m0); return count; }
/** Find first matching media in table @a mm. * * - if allow_rtp_mismatch == 0, search for a matching codec * - if allow_rtp_mismatch == 1, prefer m=line with matching codec * - if allow_rtp_mismatch > 1, ignore codecs */ static int soa_sdp_matching_mindex(soa_session_t *ss, sdp_media_t *mm[], sdp_media_t const *with, int *return_codec_mismatch) { int i, j = -1; soa_static_session_t *sss = (soa_static_session_t *)ss; int rtp = sdp_media_uses_rtp(with), dummy; char const *auxiliary = NULL; if (return_codec_mismatch == NULL) return_codec_mismatch = &dummy; if (with->m_type == sdp_media_audio) { auxiliary = sss->sss_audio_aux; /* Looking for a single codec */ if (with->m_rtpmaps && with->m_rtpmaps->rm_next == NULL) auxiliary = NULL; } for (i = 0; mm[i]; i++) { if (mm[i] == SDP_MEDIA_NONE) continue; if (!sdp_media_match_with(mm[i], with)) continue; if (!rtp) break; if (soa_sdp_media_matching_rtpmap(with->m_rtpmaps, mm[i]->m_rtpmaps, auxiliary)) break; if (j == -1) j = i; } if (mm[i]) return *return_codec_mismatch = 0, i; else return *return_codec_mismatch = 1, j; }