MPF_DECLARE(mpf_codec_t*) mpf_codec_manager_codec_get(const mpf_codec_manager_t *codec_manager, mpf_codec_descriptor_t *descriptor, apr_pool_t *pool) { int i; mpf_codec_t *codec; if(!descriptor) { return NULL; } for(i=0; i<codec_manager->codec_arr->nelts; i++) { codec = APR_ARRAY_IDX(codec_manager->codec_arr,i,mpf_codec_t*); if(mpf_codec_descriptor_match_by_attribs(descriptor,codec->static_descriptor,codec->attribs) == TRUE) { return mpf_codec_clone(codec,pool); } } return NULL; }
MPF_DECLARE(mpf_codec_t*) mpf_codec_manager_codec_get(const mpf_codec_manager_t *codec_manager, mpf_codec_descriptor_t *descriptor, apr_pool_t *pool) { int i; mpf_codec_t *codec = NULL; mpf_codec_t *ret_codec = NULL; if(!descriptor) { return NULL; } for(i=0; i<codec_manager->codec_arr->nelts; i++) { codec = ((mpf_codec_t**)codec_manager->codec_arr->elts)[i]; if(descriptor->payload_type < 96) { if(codec->static_descriptor && codec->static_descriptor->payload_type == descriptor->payload_type) { descriptor->name = codec->static_descriptor->name; descriptor->sampling_rate = codec->static_descriptor->sampling_rate; descriptor->channel_count = codec->static_descriptor->channel_count; break; } } else { if(apt_string_compare(&codec->attribs->name,&descriptor->name) == TRUE) { /* sampling rate must be checked as well */ break; } } } if(i == codec_manager->codec_arr->nelts) { /* no match found */ return NULL; } if(codec) { ret_codec = mpf_codec_clone(codec,pool); ret_codec->descriptor = descriptor; } return ret_codec; }