@ -144,28 +144,53 @@ const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec) {
return NULL ;
}
bool rtp_payload_type_eq ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( ! rtp_payload_type_eq_nf ( a , b ) )
// helper function: matches only basic params, without matching payload type number
static bool rtp_payload_type_fmt_eq_nf ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( a - > clock_rate ! = b - > clock_rate )
return false ;
if ( a - > channels ! = b - > channels )
return false ;
if ( str_casecmp_str ( & a - > encoding , & b - > encoding ) )
return false ;
return true ;
}
// matches basic params and format params, but not payload type number
// returns matching val as per format_cmp_f
int rtp_payload_type_fmt_eq ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( ! rtp_payload_type_fmt_eq_nf ( a , b ) )
return - 1 ;
if ( a - > codec_def & & a - > codec_def = = b - > codec_def ) {
if ( a - > codec_def - > format_cmp )
return a - > codec_def - > format_cmp ( a , b ) = = 0 ;
return a - > codec_def - > format_cmp ( a , b ) ;
}
if ( ! a - > codec_def ) // ignore format of codecs we don't know
return true ;
return 0 ;
if ( str_cmp_str ( & a - > format_parameters , & b - > format_parameters ) )
return false ;
return true ;
return - 1 ;
return 0 ;
}
bool rtp_payload_type_fmt_eq_exact ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
return rtp_payload_type_fmt_eq ( a , b ) = = 0 ;
}
bool rtp_payload_type_fmt_eq_compat ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
return rtp_payload_type_fmt_eq ( a , b ) > = 0 ;
}
bool rtp_payload_type_eq_nf ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
bool rtp_payload_type_eq_ exact ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( a - > payload_type ! = b - > payload_type )
return false ;
if ( a - > clock_rate ! = b - > clock_rate )
return false ;
if ( a - > channels ! = b - > channels )
return rtp_payload_type_fmt_eq ( a , b ) = = 0 ;
}
bool rtp_payload_type_eq_compat ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( a - > payload_type ! = b - > payload_type )
return false ;
if ( str_casecmp_str ( & a - > encoding , & b - > encoding ) )
return rtp_payload_type_fmt_eq ( a , b ) > = 0 ;
}
// same as rtp_payload_type_fmt_eq_nf plus matching payload type number
bool rtp_payload_type_eq_nf ( const struct rtp_payload_type * a , const struct rtp_payload_type * b ) {
if ( a - > payload_type ! = b - > payload_type )
return false ;
return true ;
return rtp_payload_type_fmt_eq_nf ( a , b ) ;
}