Changeset 758:f399374c9a31 in mediastreamer2


Ignore:
Timestamp:
Nov 4, 2009 10:06:51 AM (4 years ago)
Author:
smorlat <smorlat@…>
Branch:
default
Message:

merge patch to add an echo canceler command.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linphone/console/commands.c

    r752 r758  
    3434#include "linphonec.h" 
    3535#include "private.h" 
     36#include "lpconfig.h" 
    3637 
    3738#ifndef WIN32 
     
    7273static int lpc_cmd_speak(LinphoneCore *lc, char *args); 
    7374static int lpc_cmd_codec(LinphoneCore *lc, char *args); 
     75static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args); 
    7476 
    7577/* Command handler helpers */ 
     
    202204            "'codec enable <index>' : enable available codec\n"   
    203205            "'codec disable <index>' : disable codecs" },  
    204  
     206    { "ec", lpc_cmd_echocancellation, "Echo cancellation", 
     207            "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n" 
     208            "'ec off' : turn echo cancellation (EC) off\n" 
     209            "'ec show' : show EC status" }, 
    205210        { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } 
    206211}; 
     
    16111616} 
    16121617 
     1618static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){ 
     1619        char *arg1 = args; 
     1620        char *arg2 = NULL; 
     1621        char *ptr = args; 
     1622 
     1623        if (!args) return 0; 
     1624 
     1625        /* Isolate first and second arg */ 
     1626        while(*ptr && !isspace(*ptr)) ++ptr; 
     1627        if ( *ptr ) 
     1628        { 
     1629                *ptr='\0'; 
     1630                arg2=ptr+1; 
     1631                while(*arg2 && isspace(*arg2)) ++arg2; 
     1632        } 
     1633 
     1634        if (strcmp(arg1,"on")==0){ 
     1635        int delay, tail_len, frame_size; 
     1636        int n; 
     1637 
     1638        linphone_core_enable_echo_cancelation(lc,1); 
     1639 
     1640        if (arg2 != 0) { 
     1641            n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size); 
     1642 
     1643            if (n == 1) {    
     1644                lp_config_set_int(lc->config,"sound","ec_delay",delay); 
     1645            } 
     1646            else if (n == 2) { 
     1647                lp_config_set_int(lc->config,"sound","ec_delay",delay); 
     1648                lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len); 
     1649            } 
     1650            else if (n == 3) { 
     1651                lp_config_set_int(lc->config,"sound","ec_delay",delay); 
     1652                lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len); 
     1653                lp_config_set_int(lc->config,"sound","ec_framesize",frame_size); 
     1654            } 
     1655        } 
     1656    } 
     1657    else if (strcmp(arg1,"off")==0){ 
     1658        linphone_core_enable_echo_cancelation(lc,0); 
     1659    } 
     1660    else if (strcmp(arg1,"show")==0){ 
     1661        linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",  
     1662            linphone_core_echo_cancelation_enabled(lc) ? "on" : "off", 
     1663            lp_config_get_int(lc->config,"sound","ec_delay",0), 
     1664            lp_config_get_int(lc->config,"sound","ec_tail_len",0), 
     1665            lp_config_get_int(lc->config,"sound","ec_framesize",0));         
     1666    } 
     1667    else { 
     1668        return 0; 
     1669    } 
     1670 
     1671    return 1; 
     1672} 
     1673 
    16131674/*************************************************************************** 
    16141675 * 
Note: See TracChangeset for help on using the changeset viewer.