1 /****************************************************************************
3 * $Id: commands.c,v 1.39 2008/07/03 15:08:34 smorlat Exp $
5 * Copyright (C) 2006-2009 Sandro Santilli <strk@keybit.net>
6 * Copyright (C) 2004 Simon MORLAT <simon.morlat@linphone.org>
8 ****************************************************************************
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ****************************************************************************/
35 #include <linphonecore.h>
36 #include "linphonec.h"
47 /***************************************************************************
49 * Forward declarations
51 ***************************************************************************/
53 extern char *lpc_strip_blanks(char *input);
55 /* Command handlers */
56 static int lpc_cmd_help(LinphoneCore *, char *);
57 static int lpc_cmd_proxy(LinphoneCore *, char *);
58 static int lpc_cmd_call(LinphoneCore *, char *);
59 static int lpc_cmd_chat(LinphoneCore *, char *);
60 static int lpc_cmd_answer(LinphoneCore *, char *);
61 static int lpc_cmd_autoanswer(LinphoneCore *, char *);
62 static int lpc_cmd_terminate(LinphoneCore *, char *);
63 static int lpc_cmd_call_logs(LinphoneCore *, char *);
64 static int lpc_cmd_ipv6(LinphoneCore *, char *);
65 static int lpc_cmd_refer(LinphoneCore *, char *);
66 static int lpc_cmd_quit(LinphoneCore *, char *);
67 static int lpc_cmd_nat(LinphoneCore *, char *);
68 static int lpc_cmd_stun(LinphoneCore *, char *);
69 static int lpc_cmd_firewall(LinphoneCore *, char *);
70 static int lpc_cmd_friend(LinphoneCore *, char*);
71 static int lpc_cmd_soundcard(LinphoneCore *, char *);
72 static int lpc_cmd_webcam(LinphoneCore *, char *);
73 static int lpc_cmd_staticpic(LinphoneCore *, char *);
74 static int lpc_cmd_play(LinphoneCore *, char *);
75 static int lpc_cmd_record(LinphoneCore *, char *);
76 static int lpc_cmd_register(LinphoneCore *, char *);
77 static int lpc_cmd_unregister(LinphoneCore *, char *);
78 static int lpc_cmd_duration(LinphoneCore *lc, char *args);
79 static int lpc_cmd_status(LinphoneCore *lc, char *args);
80 static int lpc_cmd_ports(LinphoneCore *lc, char *args);
81 static int lpc_cmd_speak(LinphoneCore *lc, char *args);
82 static int lpc_cmd_acodec(LinphoneCore *lc, char *args);
83 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args);
84 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args);
85 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args);
86 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args);
87 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args);
88 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args);
90 /* Command handler helpers */
91 static void linphonec_proxy_add(LinphoneCore *lc);
92 static void linphonec_proxy_display(LinphoneProxyConfig *lc);
93 static void linphonec_proxy_list(LinphoneCore *lc);
94 static void linphonec_proxy_remove(LinphoneCore *lc, int index);
95 static int linphonec_proxy_use(LinphoneCore *lc, int index);
96 static void linphonec_proxy_show(LinphoneCore *lc,int index);
97 static void linphonec_friend_display(LinphoneFriend *fr);
98 static int linphonec_friend_list(LinphoneCore *lc, char *arg);
99 static void linphonec_display_command_help(LPC_COMMAND *cmd);
100 static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
102 static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
104 static int linphonec_friend_delete(LinphoneCore *lc, int num);
105 static int linphonec_friend_delete(LinphoneCore *lc, int num);
106 static void linphonec_codec_list(int type, LinphoneCore *lc);
107 static void linphonec_codec_enable(int type, LinphoneCore *lc, int index);
108 static void linphonec_codec_disable(int type, LinphoneCore *lc, int index);
112 /* Command table management */
113 static LPC_COMMAND *lpc_find_command(const char *name);
115 void linphonec_out(const char *fmt,...);
119 /***************************************************************************
123 ***************************************************************************/
128 LPC_COMMAND commands[] = {
129 { "help", lpc_cmd_help, "Print commands help", NULL },
130 { "call", lpc_cmd_call, "Call a SIP uri",
132 ": initiate a call to the specified destination."
134 { "chat", lpc_cmd_chat, "Chat with a SIP uri",
135 "'chat <sip-url> \"message\"' "
136 ": send a chat message \"message\" to the specified destination."
138 { "terminate", lpc_cmd_terminate, "Terminate the current call",
140 { "answer", lpc_cmd_answer, "Answer a call",
141 "Accept an incoming call."
143 { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
144 "'autoanswer' \t: show current autoanswer mode\n"
145 "'autoanswer enable'\t: enable autoanswer mode\n"
146 "'autoanswer disable'\t: disable autoanswer modeĀ \n"},
147 { "proxy", lpc_cmd_proxy, "Manage proxies",
148 "'proxy list' : list all proxy setups.\n"
149 "'proxy add' : add a new proxy setup.\n"
150 "'proxy remove <index>' : remove proxy setup with number index.\n"
151 "'proxy use <index>' : use proxy with number index as default proxy.\n"
152 "'proxy unuse' : don't use a default proxy.\n"
153 "'proxy show <index>' : show configuration and status of the proxy numbered by index.\n"
154 "'proxy show default' : show configuration and status of the default proxy.\n"
156 { "soundcard", lpc_cmd_soundcard, "Manage soundcards",
157 "'soundcard list' : list all sound devices.\n"
158 "'soundcard show' : show current sound devices configuration.\n"
159 "'soundcard use <index>' : select a sound device.\n"
160 "'soundcard use files' : use .wav files instead of soundcard\n"
162 { "webcam", lpc_cmd_webcam, "Manage webcams",
163 "'webcam list' : list all known devices.\n"
164 "'webcam use <index>' : select a video device.\n"
166 { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
167 "'staticpic set' : Set path to picture that should be used.\n"
169 { "ipv6", lpc_cmd_ipv6, "Use IPV6",
170 "'ipv6 status' : show ipv6 usage status.\n"
171 "'ipv6 enable' : enable the use of the ipv6 network.\n"
172 "'ipv6 disable' : do not use ipv6 network."
174 { "refer", lpc_cmd_refer,
175 "Refer the current call to the specified destination.",
176 "'refer <sip-url>' or 'r <sip-url>' "
177 ": refer the current call to the specified destination."
179 { "nat", lpc_cmd_nat, "Set nat address",
180 "'nat' : show nat settings.\n"
181 "'nat <addr>' : set nat address.\n"
183 { "stun", lpc_cmd_stun, "Set stun server address",
184 "'stun' : show stun settings.\n"
185 "'stun <addr>' : set stun server address.\n"
187 { "firewall", lpc_cmd_firewall, "Set firewall policy",
188 "'firewall' : show current firewall policy.\n"
189 "'firewall none' : use direct connection.\n"
190 "'firewall nat' : use nat address given with the 'nat' command.\n"
191 "'firewall stun' : use stun server given with the 'stun' command.\n"
193 { "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
194 { "friend", lpc_cmd_friend, "Manage friends",
195 "'friend list [<pattern>]' : list friends.\n"
196 "'friend call <index>' : call a friend.\n"
197 "'friend add <name> <addr>' : add friend, <name> must be quoted to include\n"
198 " spaces, <addr> has \"sip:\" added if it isn't\n"
199 " there. Don't use '<' '>' around <addr>.\n"
200 "'friend delete <index>' : remove friend, 'all' removes all\n"
202 { "play", lpc_cmd_play, "play from a wav file",
203 "This feature is available only in file mode (see 'help soundcard')\n"
204 "'play <wav file>' : play a wav file."
206 { "record", lpc_cmd_record, "record to a wav file",
207 "This feature is available only in file mode (see 'help soundcard')\n"
208 "'record <wav file>' : record into wav file."
210 { "quit", lpc_cmd_quit, "Exit linphonec", NULL },
211 { "register", lpc_cmd_register, "Register in one line to a proxy" , "register <sip identity> <sip proxy> <password>"},
212 { "unregister", lpc_cmd_unregister, "Unregister from default proxy", NULL },
213 { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL },
214 { "status", lpc_cmd_status, "Print various status information",
215 "'status register' \t: print status concerning registration\n"
216 "'status autoanswer'\t: tell whether autoanswer mode is enabled\n"
217 "'status hook' \t: print hook status\n" },
218 { "ports", lpc_cmd_ports, "Network ports configuration",
219 "'ports' \t: prints current used ports.\n"
220 "'ports sip <port number>'\t: Sets the sip port.\n" },
221 { "speak", lpc_cmd_speak, "Speak a sentence using espeak TTS engine",
222 "This feature is available only in file mode. (see 'help soundcard')\n"
223 "'speak <voice name> <sentence>' : speak a text using the specified espeak voice.\n"
224 "Example for english voice: 'speak default Hello my friend !'"
226 { "codec", lpc_cmd_acodec, "Audio codec configuration",
227 "'codec list' : list audio codecs\n"
228 "'codec enable <index>' : enable available audio codec\n"
229 "'codec disable <index>' : disable audio codec" },
230 { "vcodec", lpc_cmd_vcodec, "Video codec configuration",
231 "'vcodec list' : list video codecs\n"
232 "'vcodec enable <index>' : enable available video codec\n"
233 "'vcodec disable <index>' : disable video codec" },
234 { "ec", lpc_cmd_echocancellation, "Echo cancellation",
235 "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
236 "'ec off' : turn echo cancellation (EC) off\n"
237 "'ec show' : show EC status" },
238 { "mute", lpc_cmd_mute_mic,
239 "Mute microphone and suspend voice transmission."},
240 { "unmute", lpc_cmd_unmute_mic,
241 "Unmute microphone and resume voice transmission."},
242 { "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute,
243 "Set the rtp_no_xmit_on_audio_mute configuration parameter",
244 " If set to 1 then rtp transmission will be muted when\n"
245 " audio is muted , otherwise rtp is always sent."},
246 { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
249 /***************************************************************************
253 ***************************************************************************/
256 * Main command dispatcher.
257 * WARNING: modifies second argument!
259 * Always return 1 currently.
262 linphonec_parse_command_line(LinphoneCore *lc, char *cl)
268 /* Isolate first word and args */
269 while(*ptr && !isspace(*ptr)) ++ptr;
273 /* set args to first nonblank */
275 while(*args && isspace(*args)) ++args;
279 if ( isdigit(*cl) || *cl == '#' || *cl == '*' )
281 while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
283 linphone_core_send_dtmf(lc, *cl);
284 linphone_core_play_dtmf (lc,*cl,100);
285 ms_sleep(1); // be nice
289 // discard spurious trailing chars
293 /* Handle other kind of commands */
294 cmd=lpc_find_command(cl);
297 linphonec_out("'%s': Cannot understand this.\n", cl);
301 if ( ! cmd->func(lc, args) )
303 linphonec_out("Syntax error.\n");
304 linphonec_display_command_help(cmd);
311 * Generator function for command completion.
312 * STATE let us know whether to start from scratch;
313 * without any state (STATE==0), then we start at the
317 linphonec_command_generator(const char *text, int state)
319 static int index, len;
329 * Return the next name which partially matches
330 * from the commands list
332 while ((name=commands[index].name))
334 ++index; /* so next call get next command */
336 if (strncmp(name, text, len) == 0)
338 return ortp_strdup(name);
346 /***************************************************************************
350 ***************************************************************************/
353 lpc_cmd_help(LinphoneCore *lc, char *arg)
360 linphonec_out("Commands are:\n");
361 linphonec_out("---------------------------\n");
363 while (commands[i].help)
365 linphonec_out("%10.10s\t%s\n", commands[i].name,
370 linphonec_out("---------------------------\n");
371 linphonec_out("Type 'help <command>' for more details.\n");
376 cmd=lpc_find_command(arg);
379 linphonec_out("No such command.\n");
383 linphonec_display_command_help(cmd);
388 static char callee_name[256]={0};
389 static char caller_name[256]={0};
392 lpc_cmd_call(LinphoneCore *lc, char *args)
394 if ( ! args || ! *args )
399 if ( lc->call != NULL )
401 linphonec_out("Terminate current call first.\n");
405 if ( -1 == linphone_core_invite(lc, args) )
407 linphonec_out("Error from linphone_core_invite.\n");
411 snprintf(callee_name,sizeof(callee_name),"%s",args);
418 lpc_cmd_chat(LinphoneCore *lc, char *args)
426 /* Isolate first and second arg */
427 while(*ptr && !isspace(*ptr)) ++ptr;
432 while(*arg2 && isspace(*arg2)) ++arg2;
436 /* missing one parameter */
439 LinphoneChatRoom *cr = linphone_core_create_chat_room(lc,arg1);
440 linphone_chat_room_send_message(cr,arg2);
441 linphone_chat_room_destroy(cr);
446 const char *linphonec_get_callee(){
450 const char *linphonec_get_caller(){
454 void linphonec_set_caller(const char *caller){
455 snprintf(caller_name,sizeof(caller_name)-1,"%s",caller);
459 lpc_cmd_refer(LinphoneCore *lc, char *args)
462 linphone_core_refer(lc, args);
464 linphonec_out("refer needs an argument\n");
470 lpc_cmd_terminate(LinphoneCore *lc, char *args)
472 if ( -1 == linphone_core_terminate_call(lc, NULL) )
474 linphonec_out("No active call.\n");
480 lpc_cmd_answer(LinphoneCore *lc, char *args)
482 if ( -1 == linphone_core_accept_call(lc, NULL) )
484 linphonec_out("No incoming call.\n");
490 lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
494 if ( linphonec_get_autoanswer() ) {
495 linphonec_out("Auto answer is enabled. Use 'autoanswer disable' to disable.\n");
497 linphonec_out("Auto answer is disabled. Use 'autoanswer enable' to enable.\n");
502 if (strstr(args,"enable")){
503 linphonec_set_autoanswer(TRUE);
504 linphonec_out("Auto answer enabled.\n");
505 }else if (strstr(args,"disable")){
506 linphonec_set_autoanswer(FALSE);
507 linphonec_out("Auto answer disabled.\n");
513 lpc_cmd_quit(LinphoneCore *lc, char *args)
515 linphonec_main_loop_exit();
520 lpc_cmd_nat(LinphoneCore *lc, char *args)
525 if ( args ) args=lpc_strip_blanks(args);
529 linphone_core_set_nat_address(lc, args);
530 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS); */
533 nat = linphone_core_get_nat_address(lc);
534 use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_NAT_ADDRESS;
535 linphonec_out("Nat address: %s%s\n", nat ? nat : "unspecified" , use ? "" : " (disabled - use 'firewall nat' to enable)");
541 lpc_cmd_stun(LinphoneCore *lc, char *args)
546 if ( args ) args=lpc_strip_blanks(args);
550 linphone_core_set_stun_server(lc, args);
551 /* linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN); */
554 stun = linphone_core_get_stun_server(lc);
555 use = linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_STUN;
556 linphonec_out("Stun server: %s%s\n", stun ? stun : "unspecified" , use? "" : " (disabled - use 'firewall stun' to enable)");
562 lpc_cmd_firewall(LinphoneCore *lc, char *args)
564 const char* setting=NULL;
566 if ( args ) args=lpc_strip_blanks(args);
570 if (strcmp(args,"none")==0)
572 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_NO_FIREWALL);
574 else if (strcmp(args,"stun")==0)
576 setting = linphone_core_get_stun_server(lc);
579 linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
582 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_STUN);
584 else if (strcmp(args,"nat")==0)
586 setting = linphone_core_get_nat_address(lc);
589 linphonec_out("No nat address is defined, use 'nat <address>' first");
592 linphone_core_set_firewall_policy(lc,LINPHONE_POLICY_USE_NAT_ADDRESS);
596 switch(linphone_core_get_firewall_policy(lc))
598 case LINPHONE_POLICY_NO_FIREWALL:
599 linphonec_out("No firewall\n");
601 case LINPHONE_POLICY_USE_STUN:
602 linphonec_out("Using stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
604 case LINPHONE_POLICY_USE_NAT_ADDRESS:
605 linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
612 /* Helper function for processing freind names */
614 lpc_friend_name(char **args, char **name)
616 /* Use space as a terminator unless quoted */
617 if (('"' == **args) || ('\'' == **args)){
622 while ((delim != *end) && ('\0' != *end)) end++;
624 fprintf(stderr, "Mismatched quotes\n");
631 *name = strsep(args, " ");
633 if (NULL == *args) { /* Means there was no separator */
634 fprintf(stderr, "Either name or address is missing\n");
637 if (NULL == *name) return 0;
644 lpc_cmd_friend(LinphoneCore *lc, char *args)
648 if ( args ) args=lpc_strip_blanks(args);
650 if ( ! args || ! *args ) return 0;
652 if ( !strncmp(args, "list", 4) )
654 return linphonec_friend_list(lc, args+4);
657 else if ( !strncmp(args, "call", 4) )
660 if ( ! *args ) return 0;
661 friend_num = strtol(args, NULL, 10);
663 if ( errno == ERANGE ) {
664 linphonec_out("Invalid friend number\n");
667 #endif /*_WIN32_WCE*/
668 linphonec_friend_call(lc, friend_num);
671 else if ( !strncmp(args, "delete", 6) )
674 if ( ! *args ) return 0;
675 while (*args == ' ') args++;
676 if ( ! *args ) return 0;
677 if (!strncmp(args, "all", 3))
683 friend_num = strtol(args, NULL, 10);
685 if ( errno == ERANGE ) {
686 linphonec_out("Invalid friend number\n");
689 #endif /*_WIN32_WCE*/
691 linphonec_friend_delete(lc, friend_num);
694 else if ( !strncmp(args, "add", 3) )
703 if ( ! *args ) return 0;
704 while (*args == ' ') args++;
705 if ( ! *args ) return 0;
707 if (!lpc_friend_name(&args, &name)) return 0;
709 while (*args == ' ') args++;
710 if ( ! *args ) return 0;
711 if (isdigit(*args)) {
712 strcpy (addr, "sip:");
713 addr_p = addr + strlen("sip:");
715 addr_orig = strsep(&args, " ");
716 if (1 >= strlen(addr_orig)) {
717 fprintf(stderr, "A single-digit address is not valid\n");
720 strcpy(addr_p, addr_orig);
721 linphonec_friend_add(lc, name, addr);
723 LinphoneFriend *new_friend;
724 new_friend = linphone_friend_new_with_addr(args);
725 linphone_core_add_friend(lc, new_friend);
732 static int lpc_cmd_play(LinphoneCore *lc, char *args){
733 if ( args ) args=lpc_strip_blanks(args);
734 if ( ! args || ! *args ) return 0;
735 linphone_core_set_play_file(lc,args);
739 static int lpc_cmd_record(LinphoneCore *lc, char *args){
740 if ( args ) args=lpc_strip_blanks(args);
741 if ( ! args || ! *args ) return 0;
742 linphone_core_set_record_file(lc,args);
750 lpc_cmd_proxy(LinphoneCore *lc, char *args)
757 if ( ! arg1 ) return 0;
759 /* Isolate first and second arg */
760 while(*ptr && !isspace(*ptr)) ++ptr;
765 while(*arg2 && isspace(*arg2)) ++arg2;
768 if (strcmp(arg1,"add")==0)
771 rl_inhibit_completion=1;
773 linphonec_proxy_add(lc);
775 rl_inhibit_completion=0;
778 else if (strcmp(arg1,"list")==0)
780 linphonec_proxy_list(lc);
782 else if (strcmp(arg1,"remove")==0)
784 linphonec_proxy_remove(lc,atoi(arg2));
786 else if (strcmp(arg1,"use")==0)
791 if ( linphonec_proxy_use(lc, proxynum) )
792 linphonec_out("Default proxy set to %d.\n", proxynum);
796 proxynum=linphone_core_get_default_proxy(lc, NULL);
797 if ( proxynum == -1 ) linphonec_out("No default proxy.\n");
798 else linphonec_out("Current default proxy is %d.\n", proxynum);
800 }else if (strcmp(arg1, "unuse")==0){
801 linphone_core_set_default_proxy(lc, NULL);
802 linphonec_out("Use no proxy.\n");
805 else if (strcmp(arg1, "show")==0)
809 if (strstr(arg2,"default"))
811 proxynum=linphone_core_get_default_proxy(lc, NULL);
812 if ( proxynum < 0 ) {
813 linphonec_out("No default proxy defined\n");
816 linphonec_proxy_show(lc,proxynum);
820 linphonec_proxy_show(lc, atoi(arg2));
823 else return 0; /* syntax error */
828 return 0; /* syntax error */
835 lpc_cmd_call_logs(LinphoneCore *lc, char *args)
837 const MSList *elem=linphone_core_get_call_logs(lc);
838 for (;elem!=NULL;elem=ms_list_next(elem))
840 LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
841 char *str=linphone_call_log_to_str(cl);
842 linphonec_out("%s\n",str);
849 lpc_cmd_ipv6(LinphoneCore *lc, char *arg1)
853 return 0; /* syntax error */
856 if (strcmp(arg1,"status")==0)
858 linphonec_out("ipv6 use enabled: %s\n",linphone_core_ipv6_enabled(lc) ? "true":"false");
860 else if (strcmp(arg1,"enable")==0)
862 linphone_core_enable_ipv6(lc,TRUE);
863 linphonec_out("ipv6 use enabled.\n");
865 else if (strcmp(arg1,"disable")==0)
867 linphone_core_enable_ipv6(lc,FALSE);
868 linphonec_out("ipv6 use disabled.\n");
872 return 0; /* syntax error */
877 static int devname_to_index(LinphoneCore *lc, const char *devname){
880 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
881 if (strcmp(devname,*p)==0) return i;
886 static const char *index_to_devname(LinphoneCore *lc, int index){
889 for(i=0,p=linphone_core_get_sound_devices(lc);*p!=NULL;++p,++i){
890 if (i==index) return *p;
895 static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
903 if (!args) return 0; /* syntax error */
905 /* Isolate first and second arg */
906 while(*ptr && !isspace(*ptr)) ++ptr;
911 while(*arg2 && isspace(*arg2)) ++arg2;
914 if (strcmp(arg1, "list")==0)
916 dev=linphone_core_get_sound_devices(lc);
917 for(i=0; dev[i]!=NULL; ++i){
918 linphonec_out("%i: %s\n",i,dev[i]);
923 if (strcmp(arg1, "show")==0)
925 linphonec_out("Ringer device: %s\n",
926 linphone_core_get_ringer_device(lc));
927 linphonec_out("Playback device: %s\n",
928 linphone_core_get_playback_device(lc));
929 linphonec_out("Capture device: %s\n",
930 linphone_core_get_capture_device(lc));
934 if (strcmp(arg1, "use")==0 && arg2)
936 if (strcmp(arg2, "files")==0)
938 linphonec_out("Using wav files instead of soundcard.\n");
939 linphone_core_use_files(lc,TRUE);
943 dev=linphone_core_get_sound_devices(lc);
944 index=atoi(arg2); /* FIXME: handle not-a-number */
945 for(i=0;dev[i]!=NULL;i++)
947 if (i!=index) continue;
949 linphone_core_set_ringer_device(lc,dev[i]);
950 linphone_core_set_playback_device(lc,dev[i]);
951 linphone_core_set_capture_device(lc,dev[i]);
952 linphonec_out("Using sound device %s\n",dev[i]);
955 linphonec_out("No such sound device\n");
958 if (strcmp(arg1, "capture")==0)
960 const char *devname=linphone_core_get_capture_device(lc);
962 linphonec_out("Using capture device #%i (%s)\n",
963 devname_to_index(lc,devname),devname);
965 index=atoi(arg2); /* FIXME: handle not-a-number */
966 devname=index_to_devname(lc,index);
968 linphone_core_set_capture_device(lc,devname);
969 linphonec_out("Using capture sound device %s\n",devname);
972 linphonec_out("No such sound device\n");
976 if (strcmp(arg1, "playback")==0)
978 const char *devname=linphone_core_get_playback_device(lc);
980 linphonec_out("Using playback device #%i (%s)\n",
981 devname_to_index(lc,devname),devname);
983 index=atoi(arg2); /* FIXME: handle not-a-number */
984 devname=index_to_devname(lc,index);
986 linphone_core_set_playback_device(lc,devname);
987 linphonec_out("Using playback sound device %s\n",devname);
990 linphonec_out("No such sound device\n");
994 if (strcmp(arg1, "ring")==0)
996 const char *devname=linphone_core_get_ringer_device(lc);
998 linphonec_out("Using ring device #%i (%s)\n",
999 devname_to_index(lc,devname),devname);
1001 index=atoi(arg2); /* FIXME: handle not-a-number */
1002 devname=index_to_devname(lc,index);
1004 linphone_core_set_ringer_device(lc,devname);
1005 linphonec_out("Using ring sound device %s\n",devname);
1008 linphonec_out("No such sound device\n");
1012 return 0; /* syntax error */
1015 static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
1023 if (!args) return 0; /* syntax error */
1025 /* Isolate first and second arg */
1026 while(*ptr && !isspace(*ptr)) ++ptr;
1031 while(*arg2 && isspace(*arg2)) ++arg2;
1034 if (strcmp(arg1, "list")==0)
1036 dev=linphone_core_get_video_devices(lc);
1037 for(i=0; dev[i]!=NULL; ++i){
1038 linphonec_out("%i: %s\n",i,dev[i]);
1043 if (strcmp(arg1, "use")==0 && arg2)
1045 dev=linphone_core_get_video_devices(lc);
1046 index=atoi(arg2); /* FIXME: handle not-a-number */
1047 for(i=0;dev[i]!=NULL;i++)
1049 if (i!=index) continue;
1051 linphone_core_set_video_device(lc, dev[i]);
1052 linphonec_out("Using video device %s\n",dev[i]);
1055 linphonec_out("No such video device\n");
1058 return 0; /* syntax error */
1062 lpc_cmd_staticpic(LinphoneCore *lc, char *args)
1068 if (!args) return 0; /* Syntax error */
1070 /* Isolate first and second arg */
1071 while(*ptr && !isspace(*ptr)) ++ptr;
1076 while(*arg2 && isspace(*arg2)) ++arg2;
1079 if (strcmp(arg1, "set")==0 && arg2) {
1080 linphone_core_set_static_picture(lc, arg2);
1084 return 0; /* Syntax error */
1089 /***************************************************************************
1091 * Commands helper functions
1093 ***************************************************************************/
1097 linphonec_proxy_add(LinphoneCore *lc)
1099 bool_t enable_register=FALSE;
1100 LinphoneProxyConfig *cfg;
1102 linphonec_out("Adding new proxy setup. Hit ^D to abort.\n");
1109 char *input=linphonec_readline("Enter proxy sip address: ");
1113 linphonec_out("Aborted.\n");
1118 clean=lpc_strip_blanks(input);
1124 cfg=linphone_proxy_config_new();
1125 if (linphone_proxy_config_set_server_addr(cfg,clean)<0)
1127 linphonec_out("Invalid sip address (sip:sip.domain.tld).\n");
1129 linphone_proxy_config_destroy(cfg);
1137 * SIP Proxy identity
1141 char *input=linphonec_readline("Your identity for this proxy: ");
1145 linphonec_out("Aborted.\n");
1146 linphone_proxy_config_destroy(cfg);
1151 clean=lpc_strip_blanks(input);
1157 linphone_proxy_config_set_identity(cfg, clean);
1158 if ( ! cfg->reg_identity )
1160 linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
1169 * SIP Proxy enable register
1173 char *input=linphonec_readline("Do you want to register on this proxy (yes/no): ");
1177 linphonec_out("Aborted.\n");
1178 linphone_proxy_config_destroy(cfg);
1183 clean=lpc_strip_blanks(input);
1189 if ( ! strcmp(clean, "yes") ) enable_register=TRUE;
1190 else if ( ! strcmp(clean, "no") ) enable_register=FALSE;
1192 linphonec_out("Please answer with 'yes' or 'no'\n");
1196 linphone_proxy_config_enableregister(cfg, enable_register);
1202 * SIP Proxy registration expiration
1204 if ( enable_register==TRUE )
1209 char *input=linphonec_readline("Specify register expiration time"
1210 " in seconds (default is 600): ");
1213 linphonec_out("Aborted.\n");
1214 linphone_proxy_config_destroy(cfg);
1218 expires=strtol(input, (char **)NULL, 10);
1219 if ( expires == LONG_MIN || expires == LONG_MAX )
1221 linphonec_out("Invalid value: %s\n", strerror(errno));
1226 linphone_proxy_config_expires(cfg, expires);
1227 linphonec_out("Expiration: %d seconds\n", cfg->expires);
1239 char *input=linphonec_readline("Specify route if needed: ");
1243 linphonec_out("Aborted.\n");
1244 linphone_proxy_config_destroy(cfg);
1249 clean=lpc_strip_blanks(input);
1252 linphonec_out("No route specified.\n");
1256 linphone_proxy_config_set_route(cfg, clean);
1257 if ( ! cfg->reg_route )
1259 linphonec_out("Invalid route.\n");
1269 * Final confirmation
1276 linphonec_out("--------------------------------------------\n");
1277 linphonec_proxy_display(cfg);
1278 linphonec_out("--------------------------------------------\n");
1279 input=linphonec_readline("Accept the above proxy configuration (yes/no) ?: ");
1283 linphonec_out("Aborted.\n");
1284 linphone_proxy_config_destroy(cfg);
1289 clean=lpc_strip_blanks(input);
1295 if ( ! strcmp(clean, "yes") ) break;
1296 else if ( ! strcmp(clean, "no") )
1298 linphonec_out("Declined.\n");
1299 linphone_proxy_config_destroy(cfg);
1304 linphonec_out("Please answer with 'yes' or 'no'\n");
1310 linphone_core_add_proxy_config(lc,cfg);
1312 /* automatically set the last entered proxy as the default one */
1313 linphone_core_set_default_proxy(lc,cfg);
1315 linphonec_out("Proxy added.\n");
1319 linphonec_proxy_display(LinphoneProxyConfig *cfg)
1321 linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
1323 (cfg->reg_route!=NULL)?cfg->reg_route:"",
1324 (cfg->reg_identity!=NULL)?cfg->reg_identity:"",
1325 (cfg->reg_sendregister)?"yes":"no",
1327 linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
1330 static void linphonec_proxy_show(LinphoneCore *lc, int index)
1334 for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){
1336 LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)elem->data;
1337 linphonec_proxy_display(cfg);
1341 linphonec_out("No proxy with index %i\n", index);
1345 linphonec_proxy_list(LinphoneCore *lc)
1347 const MSList *proxies;
1349 int def=linphone_core_get_default_proxy(lc,NULL);
1351 proxies=linphone_core_get_proxy_config_list(lc);
1352 for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){
1354 linphonec_out("****** Proxy %i - this is the default one - *******\n",n);
1356 linphonec_out("****** Proxy %i *******\n",n);
1357 linphonec_proxy_display((LinphoneProxyConfig*)proxies->data);
1359 if ( ! n ) linphonec_out("No proxies defined\n");
1363 linphonec_proxy_remove(LinphoneCore *lc, int index)
1365 const MSList *proxies;
1366 LinphoneProxyConfig *cfg;
1367 proxies=linphone_core_get_proxy_config_list(lc);
1368 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1370 linphonec_out("No such proxy.\n");
1373 linphone_core_remove_proxy_config(lc,cfg);
1374 linphonec_out("Proxy %s removed.\n", cfg->reg_proxy);
1375 linphone_proxy_config_destroy(cfg);
1379 linphonec_proxy_use(LinphoneCore *lc, int index)
1381 const MSList *proxies;
1382 LinphoneProxyConfig *cfg;
1383 proxies=linphone_core_get_proxy_config_list(lc);
1384 cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index);
1386 linphonec_out("No such proxy (try 'proxy list').");
1389 linphone_core_set_default_proxy(lc,cfg);
1394 linphonec_friend_display(LinphoneFriend *fr)
1396 LinphoneAddress *uri=linphone_address_clone(linphone_friend_get_address(fr));
1399 linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
1400 linphone_address_set_display_name(uri,NULL);
1401 str=linphone_address_as_string(uri);
1402 linphonec_out("address: %s\n", str);
1406 linphonec_friend_list(LinphoneCore *lc, char *pat)
1408 const MSList *friend;
1412 pat=lpc_strip_blanks(pat);
1413 if (!*pat) pat = NULL;
1416 friend = linphone_core_get_friend_list(lc);
1417 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1420 const char *name = linphone_address_get_display_name(
1421 linphone_friend_get_address((LinphoneFriend*)friend->data));
1422 if (name && ! strstr(name, pat) ) continue;
1424 linphonec_out("****** Friend %i *******\n",n);
1425 linphonec_friend_display((LinphoneFriend*)friend->data);
1432 linphonec_friend_call(LinphoneCore *lc, unsigned int num)
1434 const MSList *friend = linphone_core_get_friend_list(lc);
1438 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1443 addr = linphone_address_as_string(linphone_friend_get_address((LinphoneFriend*)friend->data));
1444 ret=lpc_cmd_call(lc, addr);
1449 linphonec_out("No such friend %u\n", num);
1455 linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr)
1457 LinphoneFriend *newFriend;
1461 snprintf(url, PATH_MAX, "%s <%s>", name, addr);
1462 newFriend = linphone_friend_new_with_addr(url);
1463 linphone_core_add_friend(lc, newFriend);
1469 linphonec_friend_delete(LinphoneCore *lc, int num)
1471 const MSList *friend = linphone_core_get_friend_list(lc);
1474 for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
1478 linphone_core_remove_friend(lc, friend->data);
1486 for (i = 0 ; i < n ; i++)
1487 linphonec_friend_delete(lc, 0);
1491 linphonec_out("No such friend %u\n", num);
1496 linphonec_display_command_help(LPC_COMMAND *cmd)
1498 if ( cmd->doc ) linphonec_out ("%s\n", cmd->doc);
1499 else linphonec_out("%s\n", cmd->help);
1503 static int lpc_cmd_register(LinphoneCore *lc, char *args){
1507 LinphoneProxyConfig *cfg;
1512 /* it means that you want to register the default proxy */
1513 LinphoneProxyConfig *cfg=NULL;
1514 linphone_core_get_default_proxy(lc,&cfg);
1517 if(!linphone_proxy_config_is_registered(cfg)) {
1518 linphone_proxy_config_enable_register(cfg,TRUE);
1519 linphone_proxy_config_done(cfg);
1521 linphonec_out("default proxy already registered\n");
1524 linphonec_out("we do not have a default proxy\n");
1529 passwd[0]=proxy[0]=identity[0]='\0';
1530 sscanf(args,"%s %s %s",identity,proxy,passwd);
1531 if (proxy[0]=='\0' || identity[0]=='\0'){
1532 linphonec_out("Missing parameters, see help register\n");
1535 if (passwd[0]!='\0'){
1536 LinphoneAddress *from;
1537 LinphoneAuthInfo *info;
1538 if ((from=linphone_address_new(identity))!=NULL){
1540 snprintf(realm,sizeof(realm)-1,"\"%s\"",linphone_address_get_domain(from));
1541 info=linphone_auth_info_new(linphone_address_get_username(from),NULL,passwd,NULL,NULL);
1542 linphone_core_add_auth_info(lc,info);
1543 linphone_address_destroy(from);
1544 linphone_auth_info_destroy(info);
1547 elem=linphone_core_get_proxy_config_list(lc);
1549 cfg=(LinphoneProxyConfig*)elem->data;
1550 linphone_proxy_config_edit(cfg);
1552 else cfg=linphone_proxy_config_new();
1553 linphone_proxy_config_set_identity(cfg,identity);
1554 linphone_proxy_config_set_server_addr(cfg,proxy);
1555 linphone_proxy_config_enable_register(cfg,TRUE);
1556 if (elem) linphone_proxy_config_done(cfg);
1557 else linphone_core_add_proxy_config(lc,cfg);
1558 linphone_core_set_default_proxy(lc,cfg);
1562 static int lpc_cmd_unregister(LinphoneCore *lc, char *args){
1563 LinphoneProxyConfig *cfg=NULL;
1564 linphone_core_get_default_proxy(lc,&cfg);
1565 if (cfg && linphone_proxy_config_is_registered(cfg)) {
1566 linphone_proxy_config_edit(cfg);
1567 linphone_proxy_config_enable_register(cfg,FALSE);
1568 linphone_proxy_config_done(cfg);
1570 linphonec_out("unregistered\n");
1575 static int lpc_cmd_duration(LinphoneCore *lc, char *args){
1576 LinphoneCallLog *cl;
1577 const MSList *elem=linphone_core_get_call_logs(lc);
1578 for(;elem!=NULL;elem=elem->next){
1579 if (elem->next==NULL){
1580 cl=(LinphoneCallLog*)elem->data;
1581 linphonec_out("%i seconds\n",cl->duration);
1587 static int lpc_cmd_status(LinphoneCore *lc, char *args)
1589 LinphoneProxyConfig *cfg;
1591 if ( ! args ) return 0;
1592 linphone_core_get_default_proxy(lc,&cfg);
1593 if (strstr(args,"register"))
1597 if (linphone_proxy_config_is_registered(cfg)){
1598 linphonec_out("registered, identity=%s duration=%i\n",
1599 linphone_proxy_config_get_identity(cfg),
1600 linphone_proxy_config_get_expires(cfg));
1601 }else if (linphone_proxy_config_register_enabled(cfg)){
1602 linphonec_out("registered=-1\n");
1603 }else linphonec_out("registered=0\n");
1605 else linphonec_out("registered=0\n");
1607 else if (strstr(args,"autoanswer"))
1609 if (cfg && linphone_proxy_config_is_registered(cfg))
1610 linphonec_out("autoanswer=%i\n",linphonec_get_autoanswer());
1611 else linphonec_out("unregistered\n");
1613 else if (strstr(args,"hook"))
1615 gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL);
1617 if (!cfg || !linphone_proxy_config_is_registered(cfg)){
1618 linphonec_out("unregistered\n");
1623 case GSTATE_CALL_OUT_INVITE:
1624 linphonec_out("hook=dialing\n");
1626 case GSTATE_CALL_IDLE:
1627 linphonec_out("hook=offhook\n");
1629 case GSTATE_CALL_OUT_CONNECTED:
1630 linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(),
1631 linphone_core_get_current_call_duration(lc),
1632 lc->audio_muted ? "yes" : "no",
1633 linphone_core_is_rtp_muted(lc) ? "yes" : "no");
1635 case GSTATE_CALL_IN_CONNECTED:
1636 linphonec_out("hook=answered duration=%i\n" ,
1637 linphone_core_get_current_call_duration(lc));
1639 case GSTATE_CALL_IN_INVITE:
1640 linphonec_out("Incoming call from %s\n",linphonec_get_caller());
1652 static int lpc_cmd_ports(LinphoneCore *lc, char *args)
1656 linphonec_out("sip port = %i\naudio rtp port = %i\nvideo rtp port = %i\n",
1657 linphone_core_get_sip_port(lc),
1658 linphone_core_get_audio_port(lc),
1659 linphone_core_get_video_port(lc));
1662 if (sscanf(args,"sip %i",&port)==1){
1663 linphonec_out("Setting sip port to %i\n",port);
1664 linphone_core_set_sip_port(lc,port);
1670 static int lpc_cmd_speak(LinphoneCore *lc, char *args){
1679 if (!args) return 0;
1680 memset(voice,0,sizeof(voice));
1681 sscanf(args,"%s63",voice);
1682 sentence=args+strlen(voice);
1683 wavfile=tempnam("/tmp/","linphonec-espeak-");
1684 snprintf(cl,sizeof(cl),"espeak -v %s -s 100 -w %s --stdin",voice,wavfile);
1687 ms_error("Could not open pipe to espeak !");
1690 fprintf(file,"%s",sentence);
1691 status=pclose(file);
1692 if (WEXITSTATUS(status)==0){
1693 linphone_core_set_play_file(lc,wavfile);
1695 linphonec_out("espeak command failed.");
1698 linphonec_out("Sorry, this command is not implemented in windows version.");
1703 static int lpc_cmd_acodec(LinphoneCore *lc, char *args){
1704 return lpc_cmd_codec(AUDIO, lc, args);
1707 static int lpc_cmd_vcodec(LinphoneCore *lc, char *args){
1708 return lpc_cmd_codec(VIDEO, lc, args);
1711 static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){
1716 if (!args) return 0;
1718 /* Isolate first and second arg */
1719 while(*ptr && !isspace(*ptr)) ++ptr;
1724 while(*arg2 && isspace(*arg2)) ++arg2;
1727 if (strcmp(arg1,"enable")==0)
1729 #ifdef HAVE_READLINE
1730 rl_inhibit_completion=1;
1732 if (!strcmp(arg2,"all")) linphonec_codec_enable(type,lc,-1);
1733 else linphonec_codec_enable(type,lc,atoi(arg2));
1734 #ifdef HAVE_READLINE
1735 rl_inhibit_completion=0;
1738 else if (strcmp(arg1,"list")==0)
1740 linphonec_codec_list(type,lc);
1742 else if (strcmp(arg1,"disable")==0)
1744 if (!strcmp(arg2,"all")) linphonec_codec_disable(type,lc,-1);
1745 else linphonec_codec_disable(type,lc,atoi(arg2));
1749 return 0; /* syntax error */
1755 static void linphonec_codec_list(int type, LinphoneCore *lc){
1757 codecs_config_t *config=&lc->codecs_conf;
1761 if (type == AUDIO) {
1762 node=config->audio_codecs;
1763 } else if(type==VIDEO) {
1764 node=config->video_codecs;
1767 for(;node!=NULL;node=ms_list_next(node)){
1768 pt=(PayloadType*)(node->data);
1769 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate,
1770 linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled");
1775 static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
1777 codecs_config_t *config=&lc->codecs_conf;
1781 if (type == AUDIO) {
1782 node=config->audio_codecs;
1783 } else if(type==VIDEO) {
1784 node=config->video_codecs;
1787 for(;node!=NULL;node=ms_list_next(node)){
1788 if (index == sel_index || sel_index == -1) {
1789 pt=(PayloadType*)(node->data);
1790 pt->flags|=PAYLOAD_TYPE_ENABLED;
1791 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
1797 static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){
1799 codecs_config_t *config=&lc->codecs_conf;
1803 if (type == AUDIO) {
1804 node=config->audio_codecs;
1805 } else if(type==VIDEO) {
1806 node=config->video_codecs;
1809 for(;node!=NULL;node=ms_list_next(node)){
1810 if (index == sel_index || sel_index == -1) {
1811 pt=(PayloadType*)(node->data);
1812 pt->flags&=~PAYLOAD_TYPE_ENABLED;
1813 linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
1819 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
1824 if (!args) return 0;
1826 /* Isolate first and second arg */
1827 while(*ptr && !isspace(*ptr)) ++ptr;
1832 while(*arg2 && isspace(*arg2)) ++arg2;
1835 if (strcmp(arg1,"on")==0){
1836 int delay, tail_len, frame_size;
1839 linphone_core_enable_echo_cancellation(lc,1);
1842 n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
1845 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1848 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1849 lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
1852 lp_config_set_int(lc->config,"sound","ec_delay",delay);
1853 lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
1854 lp_config_set_int(lc->config,"sound","ec_framesize",frame_size);
1858 else if (strcmp(arg1,"off")==0){
1859 linphone_core_enable_echo_cancellation(lc,0);
1861 else if (strcmp(arg1,"show")==0){
1862 linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
1863 linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
1864 lp_config_get_int(lc->config,"sound","ec_delay",0),
1865 lp_config_get_int(lc->config,"sound","ec_tail_len",0),
1866 lp_config_get_int(lc->config,"sound","ec_framesize",0));
1875 static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args)
1877 if ( lc->call != NULL )
1878 linphone_core_mute_mic(lc, 1);
1882 static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args)
1884 if ( lc->call != NULL )
1885 linphone_core_mute_mic(lc, 0);
1889 static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args)
1891 bool_t rtp_xmit_off=FALSE;
1893 gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL);
1896 if(strstr(args,"1"))rtp_xmit_off=TRUE;
1897 if(call_state == GSTATE_CALL_IDLE)
1898 linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off);
1900 linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n");
1902 rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc);
1903 if(rtp_xmit_off)status="off";
1905 linphonec_out("rtp transmit %s when audio muted\n",status);
1910 /***************************************************************************
1912 * Command table management funx
1914 ***************************************************************************/
1917 * Find a command given its name
1919 static LPC_COMMAND *
1920 lpc_find_command(const char *name)
1924 for (i=0; commands[i].name; ++i)
1926 if (strcmp(name, commands[i].name) == 0)
1927 return &commands[i];
1930 return (LPC_COMMAND *)NULL;
1934 /****************************************************************************
1936 * $Log: commands.c,v $
1937 * Revision 1.39 2008/07/03 15:08:34 smorlat
1938 * api cleanups, interface in progress.
1940 * Revision 1.38 2008/06/17 20:38:59 smorlat
1941 * added missing file.
1943 * Revision 1.37 2008/04/09 09:26:00 smorlat
1944 * merge various patches
1947 * Revision 1.36 2007/08/01 14:47:53 strk
1948 * * console/commands.c: Clean up commands 'nat', 'stun'
1949 * and 'firewall' to be more intuitive.
1951 * Revision 1.35 2007/06/27 09:01:25 smorlat
1952 * logging improvements.
1954 * Revision 1.34 2007/02/20 10:17:13 smorlat
1955 * linphonec friends patch2
1957 * Revision 1.31 2006/09/22 07:22:47 smorlat
1958 * linphonecore api changes.
1960 * Revision 1.30 2006/09/08 15:32:57 smorlat
1961 * support for using files instead of soundcard (used by linphonec only)
1963 * Revision 1.29 2006/08/28 14:29:07 smorlat
1966 * Revision 1.28 2006/08/21 12:49:59 smorlat
1967 * merged several little patches.
1969 * Revision 1.27 2006/07/17 18:45:00 smorlat
1970 * support for several event queues in ortp.
1971 * glib dependency removed from coreapi/ and console/
1973 * Revision 1.26 2006/04/14 15:16:36 smorlat
1974 * soundcard use did nothing !
1976 * Revision 1.25 2006/04/06 20:09:33 smorlat
1977 * add linphonec command to see and select sound devices.
1979 * Revision 1.24 2006/03/04 11:17:10 smorlat
1980 * mediastreamer2 in progress.
1982 * Revision 1.23 2006/02/20 21:14:01 strk
1983 * Handled syntax errors with 'friend' command
1985 * Revision 1.22 2006/02/20 10:20:29 strk
1986 * Added substring-based filter support for command 'friend list'
1988 * Revision 1.21 2006/02/02 15:39:18 strk
1989 * - Added 'friend list' and 'friend call' commands
1990 * - Allowed for multiple DTFM send in a single line
1991 * - Added status-specific callback (bare version)
1993 * Revision 1.20 2006/01/26 11:54:34 strk
1994 * More robust 'nat' command handler (strip blanks in args)
1996 * Revision 1.19 2006/01/26 09:48:05 strk
1997 * Added limits.h include
1999 * Revision 1.18 2006/01/26 02:18:05 strk
2000 * Added new commands 'nat use' and 'nat unuse'.
2001 * These will required a pending patch to linphonecore.c
2004 * Revision 1.17 2006/01/20 14:12:33 strk
2005 * Added linphonec_init() and linphonec_finish() functions.
2006 * Handled SIGINT and SIGTERM to invoke linphonec_finish().
2007 * Handling of auto-termination (-t) moved to linphonec_finish().
2008 * Reworked main (input read) loop to not rely on 'terminate'
2009 * and 'run' variable (dropped). configfile_name allocated on stack
2010 * using PATH_MAX limit. Changed print_usage signature to allow
2011 * for an exit_status specification.
2013 * Revision 1.16 2006/01/18 09:25:32 strk
2014 * Command completion inhibited in proxy addition and auth request prompts.
2015 * Avoided use of linphonec_readline's internal filename completion.
2017 * Revision 1.15 2006/01/14 13:29:32 strk
2018 * Reworked commands interface to use a table structure,
2019 * used by command line parser and help function.
2020 * Implemented first level of completion (commands).
2021 * Added notification of invalid "answer" and "terminate"
2022 * commands (no incoming call, no active call).
2023 * Forbidden "call" intialization when a call is already active.
2024 * Cleaned up all commands, adding more feedback and error checks.
2026 * Revision 1.14 2006/01/13 13:00:29 strk
2027 * Added linphonec.h. Code layout change (added comments, forward decl,
2028 * globals on top, copyright notices and Logs). Handled out-of-memory
2029 * condition on history management. Removed assumption on sizeof(char).
2030 * Fixed bug in authentication prompt (introduced by linphonec_readline).
2031 * Added support for multiple authentication requests (up to MAX_PENDING_AUTH).
2034 ****************************************************************************/