Changeset 752:6c5818bde02d in mediastreamer2


Ignore:
Timestamp:
Oct 27, 2009 10:01:14 PM (4 years ago)
Author:
smorlat <smorlat@…>
Branch:
default
Message:

linphonec patches from Peter Meerwald - bugfix and new 'codec' command.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@740 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linphone/console/commands.c

    r602 r752  
    3333#include <linphonecore.h> 
    3434#include "linphonec.h" 
     35#include "private.h" 
    3536 
    3637#ifndef WIN32 
     
    7071static int lpc_cmd_ports(LinphoneCore *lc, char *args); 
    7172static int lpc_cmd_speak(LinphoneCore *lc, char *args); 
     73static int lpc_cmd_codec(LinphoneCore *lc, char *args); 
    7274 
    7375/* Command handler helpers */ 
     
    8688#endif 
    8789static int linphonec_friend_delete(LinphoneCore *lc, int num); 
     90static int linphonec_friend_delete(LinphoneCore *lc, int num); 
     91static void linphonec_codec_list(LinphoneCore *lc); 
     92static void linphonec_codec_enable(LinphoneCore *lc, int index); 
     93static void linphonec_codec_disable(LinphoneCore *lc, int index); 
    8894 
    8995 
     
    108114        { "help", lpc_cmd_help, "Print commands help", NULL }, 
    109115        { "call", lpc_cmd_call, "Call a SIP uri", 
    110                 "'call <sip-url>' or 'c <sip-url>' " 
     116                "'call <sip-url>' " 
    111117                ": initiate a call to the specified destination." 
    112118                }, 
     
    192198                        "Example for english voice: 'speak default Hello my friend !'" 
    193199        }, 
     200    { "codec", lpc_cmd_codec, "Codec configuration", 
     201            "'codec list' : list codecs\n"   
     202            "'codec enable <index>' : enable available codec\n"   
     203            "'codec disable <index>' : disable codecs" },  
     204 
    194205        { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } 
    195206}; 
     
    13421353        LinphoneProxyConfig *cfg; 
    13431354        const MSList *elem; 
     1355    if (!args) return 0; 
    13441356        passwd[0]=proxy[0]=identity[0]='\0'; 
    13451357        sscanf(args,"%s %s %s",identity,proxy,passwd); 
     
    14891501        int status; 
    14901502        FILE *file; 
     1503    if (!args) return 0; 
    14911504        memset(voice,0,sizeof(voice)); 
    14921505        sscanf(args,"%s63",voice); 
     
    15121525} 
    15131526 
     1527static int lpc_cmd_codec(LinphoneCore *lc, char *args){ 
     1528        char *arg1 = args; 
     1529        char *arg2 = NULL; 
     1530        char *ptr = args; 
     1531 
     1532        if (!args) return 0; 
     1533 
     1534        /* Isolate first and second arg */ 
     1535        while(*ptr && !isspace(*ptr)) ++ptr; 
     1536        if ( *ptr ) 
     1537        { 
     1538                *ptr='\0'; 
     1539                arg2=ptr+1; 
     1540                while(*arg2 && isspace(*arg2)) ++arg2; 
     1541        } 
     1542 
     1543        if (strcmp(arg1,"enable")==0) 
     1544        { 
     1545#ifdef HAVE_READLINE 
     1546                rl_inhibit_completion=1; 
     1547#endif 
     1548        if (!strcmp(arg2,"all")) linphonec_codec_enable(lc,-1); 
     1549        else linphonec_codec_enable(lc,atoi(arg2)); 
     1550#ifdef HAVE_READLINE 
     1551                rl_inhibit_completion=0; 
     1552#endif 
     1553        } 
     1554        else if (strcmp(arg1,"list")==0) 
     1555        { 
     1556                linphonec_codec_list(lc); 
     1557        } 
     1558        else if (strcmp(arg1,"disable")==0) 
     1559        { 
     1560        if (!strcmp(arg2,"all")) linphonec_codec_disable(lc,-1); 
     1561        else linphonec_codec_disable(lc,atoi(arg2)); 
     1562        } 
     1563        else 
     1564        { 
     1565                return 0; /* syntax error */ 
     1566        } 
     1567 
     1568        return 1; 
     1569} 
     1570 
     1571static void linphonec_codec_list(LinphoneCore *lc){ 
     1572        PayloadType *pt; 
     1573    codecs_config_t *config=&lc->codecs_conf; 
     1574        int index=0; 
     1575        MSList *node; 
     1576        for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){ 
     1577                pt=(PayloadType*)(node->data); 
     1578        linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, payload_type_enabled(pt) ? "enabled" : "disabled"); 
     1579                index++; 
     1580        } 
     1581} 
     1582 
     1583static void linphonec_codec_enable(LinphoneCore *lc, int sel_index){ 
     1584        PayloadType *pt; 
     1585    codecs_config_t *config=&lc->codecs_conf; 
     1586        int index=0; 
     1587        MSList *node; 
     1588    for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){ 
     1589        if (index == sel_index || sel_index == -1) { 
     1590                    pt=(PayloadType*)(node->data); 
     1591            pt->flags|=PAYLOAD_TYPE_ENABLED; 
     1592            linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled"); 
     1593        } 
     1594                index++; 
     1595        } 
     1596} 
     1597 
     1598static void linphonec_codec_disable(LinphoneCore *lc, int sel_index){ 
     1599        PayloadType *pt; 
     1600    codecs_config_t *config=&lc->codecs_conf; 
     1601        int index=0; 
     1602        MSList *node; 
     1603        for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){ 
     1604        if (index == sel_index || sel_index == -1) { 
     1605                pt=(PayloadType*)(node->data); 
     1606            pt->flags&=~PAYLOAD_TYPE_ENABLED; 
     1607            linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled"); 
     1608        } 
     1609                index++; 
     1610        } 
     1611} 
     1612 
    15141613/*************************************************************************** 
    15151614 * 
Note: See TracChangeset for help on using the changeset viewer.