]> sjero.net Git - linphone/commitdiff
api rationalisation of payload type.
authorSimon Morlat <simon.morlat@linphone.org>
Thu, 28 Jan 2010 11:34:21 +0000 (12:34 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Thu, 28 Jan 2010 11:34:21 +0000 (12:34 +0100)
console/commands.c
coreapi/Makefile.am
coreapi/exevents.c
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/misc.c
gtk-glade/propertybox.c

index cb684511cf2a35b8d965a16906656c7c30f27429..08a747e56af520a0db28b2ffe97f16d4c3100b8f 100644 (file)
@@ -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++;
        }
 }
index 16623244825dc0551c80e02a4140dbd7d09f8157..2410f2d4e5d8b2428d6bd0c1ca4ba006c3d41309 100644 (file)
@@ -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 \
index feebb9ea227b295997021cf20b2de22842b4598f..c5428bff615095020831eba6ced848ac780fea83 100644 (file)
@@ -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;
                        }
index 3c46d92a0d0409d31f7f05a13000b26783fda5f0..19b4db9cfcbb9aaeca75edb16806e32e07667212 100644 (file)
@@ -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++;
        }
index 05dd3220310e3ed5e41f0e5cf9c7042754dec0f8..140822f87eb3c8caf94ddc7b7b9356ecd670f670 100644 (file)
@@ -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);
index c2ba262975bb0427396eb0b58a9d46dcaf6276d0..9bdb9042057ac5f495f327c3dc837a1af3868ec4 100644 (file)
@@ -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;
+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;
 }
-const char *payload_type_get_mime(PayloadType *pt){
-       return pt->mime_type;
+
+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;
 }
 
-int payload_type_get_rate(PayloadType *pt){
-       return pt->clock_rate;
+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*/
index cbc7b5c7398e63ab2f305a2605bc61eb5443ef34..09af0709e94df3c61512b30d3fb82ce43a0a209e 100644 (file)
@@ -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);
        }
 }