mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
api rationalisation of payload type.
This commit is contained in:
parent
92f082ab04
commit
f5c4c989ad
7 changed files with 44 additions and 34 deletions
|
|
@ -1591,7 +1591,8 @@ static void linphonec_codec_list(LinphoneCore *lc){
|
|||
MSList *node;
|
||||
for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){
|
||||
pt=(PayloadType*)(node->data);
|
||||
linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, payload_type_enabled(pt) ? "enabled" : "disabled");
|
||||
linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
|
||||
linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ lib_LTLIBRARIES=liblinphone.la
|
|||
|
||||
liblinphone_la_SOURCES=\
|
||||
linphonecore.c linphonecore.h private.h\
|
||||
exevents.c exevents.h \
|
||||
offeranswer.c offeranswer.h\
|
||||
sal.c sal.h \
|
||||
sal_eXosip2.c sal_eXosip2.h\
|
||||
sal_eXosip2_sdp.c \
|
||||
sal_eXosip2_presence.c \
|
||||
callbacks.c \
|
||||
exevents.c sdphandler.c\
|
||||
misc.c \
|
||||
address.c \
|
||||
enum.c enum.h \
|
||||
sdphandler.c sdphandler.h \
|
||||
presence.c \
|
||||
proxy.c \
|
||||
friend.c \
|
||||
|
|
|
|||
|
|
@ -464,7 +464,8 @@ int linphone_set_audio_offer(sdp_context_t *ctx)
|
|||
elem=lc->codecs_conf.audio_codecs;
|
||||
while(elem!=NULL){
|
||||
codec=(PayloadType*) elem->data;
|
||||
if (linphone_core_check_payload_type_usability(lc,codec) && payload_type_enabled(codec)){
|
||||
if (linphone_core_check_payload_type_usability(lc,codec) &&
|
||||
linphone_core_payload_type_enabled(lc,codec)){
|
||||
sdp_payload_init(&payload);
|
||||
payload.a_rtpmap=ortp_strdup_printf("%s/%i/1",codec->mime_type,codec->clock_rate);
|
||||
payload.pt=rtp_profile_get_payload_number_from_rtpmap(lc->local_profile,payload.a_rtpmap);
|
||||
|
|
@ -535,7 +536,8 @@ int linphone_set_video_offer(sdp_context_t *ctx)
|
|||
|
||||
for(elem=lc->codecs_conf.video_codecs;elem!=NULL;elem=ms_list_next(elem)){
|
||||
codec=(PayloadType*) elem->data;
|
||||
if (linphone_core_check_payload_type_usability(lc,codec) && payload_type_enabled(codec)){
|
||||
if (linphone_core_check_payload_type_usability(lc,codec) &&
|
||||
linphone_core_payload_type_enabled(lc,codec)){
|
||||
sdp_payload_t payload;
|
||||
sdp_payload_init(&payload);
|
||||
payload.line=1;
|
||||
|
|
@ -587,7 +589,7 @@ SupportLevel linphone_payload_is_supported(LinphoneCore *lc, sdp_payload_t *payl
|
|||
ms_warning("payload %s is not usable",rtppayload->mime_type);
|
||||
return Unsupported;
|
||||
}
|
||||
if ( !payload_type_enabled(rtppayload)) {
|
||||
if ( !linphone_core_payload_type_enabled(lc,rtppayload)) {
|
||||
ms_warning("payload %s is not enabled.",rtppayload->mime_type);
|
||||
return Unsupported;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3390,7 +3390,7 @@ void codecs_config_uninit(LinphoneCore *lc)
|
|||
sprintf(key,"audio_codec_%i",index);
|
||||
lp_config_set_string(lc->config,key,"mime",pt->mime_type);
|
||||
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
|
||||
lp_config_set_int(lc->config,key,"enabled",payload_type_enabled(pt));
|
||||
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
|
||||
index++;
|
||||
}
|
||||
index=0;
|
||||
|
|
@ -3399,7 +3399,7 @@ void codecs_config_uninit(LinphoneCore *lc)
|
|||
sprintf(key,"video_codec_%i",index);
|
||||
lp_config_set_string(lc->config,key,"mime",pt->mime_type);
|
||||
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
|
||||
lp_config_set_int(lc->config,key,"enabled",payload_type_enabled(pt));
|
||||
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
|
||||
lp_config_set_string(lc->config,key,"recv_fmtp",pt->recv_fmtp);
|
||||
index++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,6 @@ extern "C" {
|
|||
struct _MSSndCard;
|
||||
struct _LinphoneCore;
|
||||
|
||||
bool_t payload_type_enabled(struct _PayloadType *pt);
|
||||
void payload_type_set_enable(struct _PayloadType *pt,int value);
|
||||
const char *payload_type_get_description(struct _PayloadType *pt);
|
||||
int payload_type_get_bitrate(PayloadType *pt);
|
||||
const char *payload_type_get_mime(PayloadType *pt);
|
||||
int payload_type_get_rate(PayloadType *pt);
|
||||
|
||||
|
||||
struct _LpConfig;
|
||||
|
||||
typedef struct sip_config
|
||||
|
|
@ -726,6 +718,12 @@ const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);
|
|||
|
||||
int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
|
||||
|
||||
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);
|
||||
|
||||
int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable);
|
||||
|
||||
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt);
|
||||
|
||||
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
|
||||
|
||||
int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
|
||||
|
|
|
|||
|
|
@ -170,33 +170,42 @@ void check_sound_device(LinphoneCore *lc)
|
|||
#define RTP_HDR_SZ 12
|
||||
#define IP4_HDR_SZ 20 /*20 is the minimum, but there may be some options*/
|
||||
|
||||
const char *payload_type_get_description(PayloadType *pt){
|
||||
return _((const char *)pt->user_data);
|
||||
}
|
||||
|
||||
void payload_type_set_enable(PayloadType *pt,int value)
|
||||
static void payload_type_set_enable(PayloadType *pt,int value)
|
||||
{
|
||||
if ((value)!=0) payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); \
|
||||
else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED);
|
||||
}
|
||||
|
||||
|
||||
bool_t payload_type_enabled(PayloadType *pt) {
|
||||
static bool_t payload_type_enabled(PayloadType *pt) {
|
||||
return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0);
|
||||
}
|
||||
|
||||
int payload_type_get_bitrate(PayloadType *pt)
|
||||
{
|
||||
return pt->normal_bitrate;
|
||||
}
|
||||
const char *payload_type_get_mime(PayloadType *pt){
|
||||
return pt->mime_type;
|
||||
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt){
|
||||
if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){
|
||||
return payload_type_enabled(pt);
|
||||
}
|
||||
ms_error("Getting enablement status of codec not in audio or video list of PayloadType !");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int payload_type_get_rate(PayloadType *pt){
|
||||
return pt->clock_rate;
|
||||
int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enabled){
|
||||
if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){
|
||||
payload_type_set_enable(pt,enabled);
|
||||
return 0;
|
||||
}
|
||||
ms_error("Enabling codec not in audio or video list of PayloadType !");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt){
|
||||
if (ms_filter_codec_supported(pt->mime_type)){
|
||||
MSFilterDesc *desc=ms_filter_get_encoder(pt->mime_type);
|
||||
return desc->text;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*this function makes a special case for speex/8000.
|
||||
This codec is variable bitrate. The 8kbit/s mode is interesting when having a low upload bandwidth, but its quality
|
||||
is not very good. We 'd better use its 15kbt/s mode when we have enough bandwidth*/
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ static void linphone_gtk_show_codecs(GtkTreeView *listview, const MSList *codecl
|
|||
gchar *color;
|
||||
const char *params="";
|
||||
struct _PayloadType *pt=(struct _PayloadType *)elem->data;
|
||||
if (payload_type_enabled(pt)) status=_("Enabled");
|
||||
if (linphone_core_payload_type_enabled(linphone_gtk_get_core(),pt)) status=_("Enabled");
|
||||
else status=_("Disabled");
|
||||
if (linphone_core_check_payload_type_usability(linphone_gtk_get_core(),pt)) color="blue";
|
||||
else color="red";
|
||||
|
|
@ -311,7 +311,7 @@ static void linphone_gtk_show_codecs(GtkTreeView *listview, const MSList *codecl
|
|||
CODEC_PARAMS,params,
|
||||
CODEC_PRIVDATA,(gpointer)pt,
|
||||
CODEC_COLOR,(gpointer)color,
|
||||
CODEC_INFO,(gpointer)payload_type_get_description(pt),
|
||||
CODEC_INFO,(gpointer)linphone_core_get_payload_type_description(linphone_gtk_get_core(),pt),
|
||||
-1);
|
||||
}
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ static void linphone_gtk_codec_set_enable(GtkWidget *button, gboolean enabled){
|
|||
if (gtk_tree_selection_get_selected(sel,&mod,&iter)){
|
||||
store=GTK_LIST_STORE(mod);
|
||||
gtk_tree_model_get(mod,&iter,CODEC_PRIVDATA,&pt,-1);
|
||||
payload_type_set_enable(pt,enabled);
|
||||
linphone_core_enable_payload_type(linphone_gtk_get_core(),pt,enabled);
|
||||
gtk_list_store_set(store,&iter,CODEC_STATUS, enabled ? _("Enabled") : _("Disabled"), -1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue