Changeset 752:6c5818bde02d in mediastreamer2
- Timestamp:
- Oct 27, 2009 10:01:14 PM (4 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
linphone/console/commands.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/console/commands.c
r602 r752 33 33 #include <linphonecore.h> 34 34 #include "linphonec.h" 35 #include "private.h" 35 36 36 37 #ifndef WIN32 … … 70 71 static int lpc_cmd_ports(LinphoneCore *lc, char *args); 71 72 static int lpc_cmd_speak(LinphoneCore *lc, char *args); 73 static int lpc_cmd_codec(LinphoneCore *lc, char *args); 72 74 73 75 /* Command handler helpers */ … … 86 88 #endif 87 89 static int linphonec_friend_delete(LinphoneCore *lc, int num); 90 static int linphonec_friend_delete(LinphoneCore *lc, int num); 91 static void linphonec_codec_list(LinphoneCore *lc); 92 static void linphonec_codec_enable(LinphoneCore *lc, int index); 93 static void linphonec_codec_disable(LinphoneCore *lc, int index); 88 94 89 95 … … 108 114 { "help", lpc_cmd_help, "Print commands help", NULL }, 109 115 { "call", lpc_cmd_call, "Call a SIP uri", 110 "'call <sip-url>' or 'c <sip-url>'"116 "'call <sip-url>' " 111 117 ": initiate a call to the specified destination." 112 118 }, … … 192 198 "Example for english voice: 'speak default Hello my friend !'" 193 199 }, 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 194 205 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } 195 206 }; … … 1342 1353 LinphoneProxyConfig *cfg; 1343 1354 const MSList *elem; 1355 if (!args) return 0; 1344 1356 passwd[0]=proxy[0]=identity[0]='\0'; 1345 1357 sscanf(args,"%s %s %s",identity,proxy,passwd); … … 1489 1501 int status; 1490 1502 FILE *file; 1503 if (!args) return 0; 1491 1504 memset(voice,0,sizeof(voice)); 1492 1505 sscanf(args,"%s63",voice); … … 1512 1525 } 1513 1526 1527 static 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 1571 static 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 1583 static 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 1598 static 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 1514 1613 /*************************************************************************** 1515 1614 *
Note: See TracChangeset
for help on using the changeset viewer.
