From e1f018f274274d7574ebadd27659098453d8d1b5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 30 Aug 2012 12:43:09 +0200 Subject: [PATCH] fix linphone_core_find_payload_type wildcard mode --- coreapi/linphonecore.c | 11 +++-------- coreapi/linphonecore.h | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index de91532c..47f8a61a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -4808,20 +4808,15 @@ static PayloadType* find_payload_type_from_list(const char* type, int rate, int for(elem=from;elem!=NULL;elem=elem->next){ PayloadType *pt=(PayloadType*)elem->data; if ((strcasecmp((char*)type, payload_type_get_mime(pt)) == 0) - && (rate == -1 || rate==pt->clock_rate) - && (channels == 0 || channels==pt->channels)) { + && (rate == LINPHONE_FIND_PAYLOAD_IGNORE_RATE || rate==pt->clock_rate) + && (channels == LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS || channels==pt->channels)) { return pt; } } return NULL; } -/** - * Get payload type from mime type and clock rate - * @ingroup media_parameters - * This function searches in audio and video codecs for the given payload type name and clockrate. - * Returns NULL if not found. - */ + PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) { PayloadType* result = find_payload_type_from_list(type, rate, channels, linphone_core_get_audio_codecs(lc)); if (result) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 4d5f5fd5..4895ccb9 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -928,6 +928,26 @@ bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *p int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable); +/** + * Wildcard value used by #linphone_core_find_payload_type to ignore rate in search algirithm + * @ingroup media_parameters + */ +#define LINPHONE_FIND_PAYLOAD_IGNORE_RATE -1 +/** + * Wildcard value used by #linphone_core_find_payload_type to ignore channel in search algirithm + * @ingroup media_parameters + */ +#define LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS -1 +/** + * Get payload type from mime type and clock rate + * @ingroup media_parameters + * This function searches in audio and video codecs for the given payload type name and clockrate. + * @param lc #LinphoneCore object + * @param type payload mime type (I.E SPEEX, PCMU, VP8) + * @param rate, can be #LINPHONE_FIND_PAYLOAD_IGNORE_RATE + * @param channels, number of channels, can be #LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS + * @return Returns NULL if not found. + */ PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) ; int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); -- 2.39.2