nettoyage du repertoire debian/
[asterisk-app-conference.git] / cli.c
CommitLineData
c575c500
TN
1
2// $Id: cli.c 884 2007-06-27 14:56:21Z sbalea $
3
4/*
5 * app_conference
6 *
7 * A channel independent conference application for Asterisk
8 *
9 * Copyright (C) 2002, 2003 Junghanns.NET GmbH
10 * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
11 * Copyright (C) 2005, 2006 HorizonWimba, Inc.
12 * Copyright (C) 2007 Wimba, Inc.
13 *
14 * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
15 *
16 * Video Conferencing support added by
17 * Neil Stratford <neils@vipadia.com>
18 * Copyright (C) 2005, 2005 Vipadia Limited
19 *
20 * VAD driven video conferencing, text message support
21 * and miscellaneous enhancements added by
22 * Mihai Balea <mihai at hates dot ms>
23 *
24 * This program may be modified and distributed under the
25 * terms of the GNU General Public License. You should have received
26 * a copy of the GNU General Public License along with this
27 * program; if not, write to the Free Software Foundation, Inc.
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */
30
31#include "asterisk/autoconfig.h"
32#include "cli.h"
33
34static char conference_restart_usage[] =
35 "usage: conference restart\n"
36 " kick all users in all conferences\n"
37;
38
39static struct ast_cli_entry cli_restart = {
40 { "conference", "restart", NULL },
41 conference_restart,
42 "restart a conference",
43 conference_restart_usage
44} ;
45
46
47int conference_restart( int fd, int argc, char *argv[] )
48{
49 if ( argc < 2 )
50 return RESULT_SHOWUSAGE ;
51
52 kick_all();
53 return RESULT_SUCCESS ;
54}
55
56
57//
58// debug functions
59//
60
61static char conference_debug_usage[] =
62 "usage: conference debug <conference_name> [ on | off ]\n"
63 " enable debugging for a conference\n"
64;
65
66static struct ast_cli_entry cli_debug = {
67 { "conference", "debug", NULL },
68 conference_debug,
69 "enable debugging for a conference",
70 conference_debug_usage
71} ;
72
73
74int conference_debug( int fd, int argc, char *argv[] )
75{
76 if ( argc < 3 )
77 return RESULT_SHOWUSAGE ;
78
79 // get the conference name
80 const char* name = argv[2] ;
81
82 // get the new state
83 int state = 0 ;
84
85 if ( argc == 3 )
86 {
87 // no state specified, so toggle it
88 state = -1 ;
89 }
90 else
91 {
92 if ( strncasecmp( argv[3], "on", 4 ) == 0 )
93 state = 1 ;
94 else if ( strncasecmp( argv[3], "off", 3 ) == 0 )
95 state = 0 ;
96 else
97 return RESULT_SHOWUSAGE ;
98 }
99
100 int new_state = set_conference_debugging( name, state ) ;
101
102 if ( new_state == 1 )
103 {
104 ast_cli( fd, "enabled conference debugging, name => %s, new_state => %d\n",
105 name, new_state ) ;
106 }
107 else if ( new_state == 0 )
108 {
109 ast_cli( fd, "disabled conference debugging, name => %s, new_state => %d\n",
110 name, new_state ) ;
111 }
112 else
113 {
114 // error setting state
115 ast_cli( fd, "\nunable to set debugging state, name => %s\n\n", name ) ;
116 }
117
118 return RESULT_SUCCESS ;
119}
120
121//
122// stats functions
123//
124
125static char conference_show_stats_usage[] =
126 "usage: conference show stats\n"
127 " display stats for active conferences.\n"
128;
129
130static struct ast_cli_entry cli_show_stats = {
131 { "conference", "show", "stats", NULL },
132 conference_show_stats,
133 "show conference stats",
134 conference_show_stats_usage
135} ;
136
137int conference_show_stats( int fd, int argc, char *argv[] )
138{
139 if ( argc < 3 )
140 return RESULT_SHOWUSAGE ;
141
142 // get count of active conferences
143 int count = get_conference_count() ;
144
145 ast_cli( fd, "\n\nCONFERENCE STATS, ACTIVE( %d )\n\n", count ) ;
146
147 // if zero, go no further
148 if ( count <= 0 )
149 return RESULT_SUCCESS ;
150
151 //
152 // get the conference stats
153 //
154
155 // array of stats structs
156 ast_conference_stats stats[ count ] ;
157
158 // get stats structs
159 count = get_conference_stats( stats, count ) ;
160
161 // make sure we were able to fetch some
162 if ( count <= 0 )
163 {
164 ast_cli( fd, "!!! error fetching conference stats, available => %d !!!\n", count ) ;
165 return RESULT_SUCCESS ;
166 }
167
168 //
169 // output the conference stats
170 //
171
172 // output header
173 ast_cli( fd, "%-20.20s %-40.40s\n", "Name", "Stats") ;
174 ast_cli( fd, "%-20.20s %-40.40s\n", "----", "-----") ;
175
176 ast_conference_stats* s = NULL ;
177
178 int i;
179
180 for ( i = 0 ; i < count ; ++i )
181 {
182 s = &(stats[i]) ;
183
184 // output this conferences stats
185 ast_cli( fd, "%-20.20s\n", (char*)( &(s->name) )) ;
186 }
187
188 ast_cli( fd, "\n" ) ;
189
190 //
191 // drill down to specific stats
192 //
193
194 if ( argc == 4 )
195 {
196 // show stats for a particular conference
197 conference_show_stats_name( fd, argv[3] ) ;
198 }
199
200 return RESULT_SUCCESS ;
201}
202
203int conference_show_stats_name( int fd, const char* name )
204{
205 // not implemented yet
206 return RESULT_SUCCESS ;
207}
208
209static char conference_list_usage[] =
210 "usage: conference list {<conference_name>}\n"
211 " list members of a conference\n"
212;
213
214static struct ast_cli_entry cli_list = {
215 { "conference", "list", NULL },
216 conference_list,
217 "list members of a conference",
218 conference_list_usage
219} ;
220
221
222
223int conference_list( int fd, int argc, char *argv[] )
224{
225 int index;
226
227 if ( argc < 2 )
228 return RESULT_SHOWUSAGE ;
229
230 if (argc >= 3)
231 {
232 for (index = 2; index < argc; index++)
233 {
234 // get the conference name
235 const char* name = argv[index] ;
236 show_conference_list( fd, name );
237 }
238 }
239 else
240 {
241 show_conference_stats(fd);
242 }
243 return RESULT_SUCCESS ;
244}
245
246
247int conference_kick( int fd, int argc, char *argv[] )
248{
249 if ( argc < 4 )
250 return RESULT_SHOWUSAGE ;
251
252 // get the conference name
253 const char* name = argv[2] ;
254
255 int member_id;
256 sscanf(argv[3], "%d", &member_id);
257
258 int res = kick_member( name, member_id );
259
260 if (res) ast_cli( fd, "User #: %d kicked\n", member_id) ;
261
262 return RESULT_SUCCESS ;
263}
264
265static char conference_kick_usage[] =
266 "usage: conference kick <conference> <member id>\n"
267 " kick member <member id> from conference <conference>\n"
268;
269
270static struct ast_cli_entry cli_kick = {
271 { "conference", "kick", NULL },
272 conference_kick,
273 "kick member from a conference",
274 conference_kick_usage
275} ;
276
277int conference_kickchannel( int fd, int argc, char *argv[] )
278{
279 if ( argc < 4 )
280 return RESULT_SHOWUSAGE ;
281
282 const char *name = argv[2] ;
283 const char *channel = argv[3];
284
285 int res = kick_channel( name, channel );
286
287 if ( !res )
288 {
289 ast_cli( fd, "Cannot kick channel %s in conference %s\n", channel, name);
290 return RESULT_FAILURE;
291 }
292
293 return RESULT_SUCCESS ;
294}
295
296static char conference_kickchannel_usage[] =
297 "usage: conference kickchannel <conference_name> <channel>\n"
298 " kick channel from conference\n"
299;
300
301static struct ast_cli_entry cli_kickchannel = {
302 { "conference", "kickchannel", NULL },
303 conference_kickchannel,
304 "kick channel from conference",
305 conference_kickchannel_usage
306} ;
307
308int conference_mute( int fd, int argc, char *argv[] )
309{
310 if ( argc < 4 )
311 return RESULT_SHOWUSAGE ;
312
313 // get the conference name
314 const char* name = argv[2] ;
315
316 int member_id;
317 sscanf(argv[3], "%d", &member_id);
318
319 int res = mute_member( name, member_id );
320
321 if (res) ast_cli( fd, "User #: %d muted\n", member_id) ;
322
323 return RESULT_SUCCESS ;
324}
325
326static char conference_mute_usage[] =
327 "usage: conference mute <conference_name> <member id>\n"
328 " mute member in a conference\n"
329;
330
331static struct ast_cli_entry cli_mute = {
332 { "conference", "mute", NULL },
333 conference_mute,
334 "mute member in a conference",
335 conference_mute_usage
336} ;
337
338int conference_mutechannel( int fd, int argc, char *argv[] )
339{
340 struct ast_conf_member *member;
341 char *channel;
342
343 if ( argc < 3 )
344 return RESULT_SHOWUSAGE ;
345
346 channel = argv[2];
347
348 member = find_member(channel, 1);
349 if(!member) {
350 ast_cli(fd, "Member %s not found\n", channel);
351 return RESULT_FAILURE;
352 }
353
354 member->mute_audio = 1;
355 ast_mutex_unlock( &member->lock ) ;
356
357 ast_cli( fd, "Channel #: %s muted\n", argv[2]) ;
358
359 return RESULT_SUCCESS ;
360}
361
362static char conference_mutechannel_usage[] =
363 "usage: conference mutechannel <channel>\n"
364 " mute channel in a conference\n"
365;
366
367static struct ast_cli_entry cli_mutechannel = {
368 { "conference", "mutechannel", NULL },
369 conference_mutechannel,
370 "mute channel in a conference",
371 conference_mutechannel_usage
372} ;
373
374int conference_viewstream( int fd, int argc, char *argv[] )
375{
376 int res;
377
378 if ( argc < 5 )
379 return RESULT_SHOWUSAGE ;
380
381 // get the conference name
382 const char* switch_name = argv[2] ;
383
384 int member_id, viewstream_id;
385 sscanf(argv[3], "%d", &member_id);
386 sscanf(argv[4], "%d", &viewstream_id);
387
388 res = viewstream_switch( switch_name, member_id, viewstream_id );
389
390 if (res) ast_cli( fd, "User #: %d viewing %d\n", member_id, viewstream_id) ;
391
392 return RESULT_SUCCESS ;
393}
394
395static char conference_viewstream_usage[] =
396 "usage: conference viewstream <conference_name> <member id> <stream no>\n"
397 " member <member id> will receive video stream <stream no>\n"
398;
399
400static struct ast_cli_entry cli_viewstream = {
401 { "conference", "viewstream", NULL },
402 conference_viewstream,
403 "switch view in a conference",
404 conference_viewstream_usage
405} ;
406
407int conference_viewchannel( int fd, int argc, char *argv[] )
408{
409 int res;
410
411 if ( argc < 5 )
412 return RESULT_SHOWUSAGE ;
413
414 // get the conference name
415 const char* switch_name = argv[2] ;
416
417 res = viewchannel_switch( switch_name, argv[3], argv[4] );
418
419 if (res) ast_cli( fd, "Channel #: %s viewing %s\n", argv[3], argv[4]) ;
420
421 return RESULT_SUCCESS ;
422}
423
424static char conference_viewchannel_usage[] =
425 "usage: conference viewchannel <conference_name> <dest channel> <src channel>\n"
426 " channel <dest channel> will receive video stream <src channel>\n"
427;
428
429static struct ast_cli_entry cli_viewchannel = {
430 { "conference", "viewchannel", NULL },
431 conference_viewchannel,
432 "switch channel in a conference",
433 conference_viewchannel_usage
434} ;
435
436int conference_unmute( int fd, int argc, char *argv[] )
437{
438 if ( argc < 4 )
439 return RESULT_SHOWUSAGE ;
440
441 // get the conference name
442 const char* name = argv[2] ;
443
444 int member_id;
445 sscanf(argv[3], "%d", &member_id);
446
447 int res = unmute_member( name, member_id );
448
449 if (res) ast_cli( fd, "User #: %d unmuted\n", member_id) ;
450
451 return RESULT_SUCCESS ;
452}
453
454static char conference_unmute_usage[] =
455 "usage: conference unmute <conference_name> <member id>\n"
456 " unmute member in a conference\n"
457;
458
459static struct ast_cli_entry cli_unmute = {
460 { "conference", "unmute", NULL },
461 conference_unmute,
462 "unmute member in a conference",
463 conference_unmute_usage
464} ;
465
466int conference_unmutechannel( int fd, int argc, char *argv[] )
467{
468 struct ast_conf_member *member;
469 char *channel;
470
471 if ( argc < 3 )
472 return RESULT_SHOWUSAGE ;
473
474 channel = argv[2];
475
476 member = find_member(channel, 1);
477 if(!member) {
478 ast_cli(fd, "Member %s not found\n", channel);
479 return RESULT_FAILURE;
480 }
481
482 member->mute_audio = 0;
483 ast_mutex_unlock( &member->lock ) ;
484
485 ast_cli( fd, "Channel #: %s unmuted\n", argv[2]) ;
486
487 return RESULT_SUCCESS ;
488}
489
490static char conference_unmutechannel_usage[] =
491 "usage: conference unmutechannel <channel>\n"
492 " unmute channel in a conference\n"
493;
494
495static struct ast_cli_entry cli_unmutechannel = {
496 { "conference", "unmutechannel", NULL },
497 conference_unmutechannel,
498 "unmute channel in a conference",
499 conference_unmutechannel_usage
500} ;
501
502//
503// play sound
504//
505static char conference_play_sound_usage[] =
506 "usage: conference play sound <channel-id> <sound-file> [mute]\n"
507 " play sound <sound-file> to conference member <channel-id>.\n"
508 " If mute is specified, all other audio is muted while the sound is played back.\n"
509;
510
511static struct ast_cli_entry cli_play_sound = {
512 { "conference", "play", "sound", NULL },
513 conference_play_sound,
514 "play a sound to a conference member",
515 conference_play_sound_usage
516} ;
517
518int conference_play_sound( int fd, int argc, char *argv[] )
519{
520 char *channel, *file;
521 int mute = 0;
522
523 if ( argc < 5 )
524 return RESULT_SHOWUSAGE ;
525
526 channel = argv[3];
527 file = argv[4];
528
529 if(argc > 5 && !strcmp(argv[5], "mute"))
530 mute = 1;
531
532 int res = play_sound_channel(fd, channel, file, mute);
533
534 if ( !res )
535 {
536 ast_cli(fd, "Sound playback failed failed\n");
537 return RESULT_FAILURE;
538 }
539 return RESULT_SUCCESS ;
540}
541
542//
543// stop sounds
544//
545
546static char conference_stop_sounds_usage[] =
547 "usage: conference stop sounds <channel-id>\n"
548 " stop sounds for conference member <channel-id>.\n"
549;
550
551static struct ast_cli_entry cli_stop_sounds = {
552 { "conference", "stop", "sounds", NULL },
553 conference_stop_sounds,
554 "stop sounds for a conference member",
555 conference_stop_sounds_usage
556} ;
557
558int conference_stop_sounds( int fd, int argc, char *argv[] )
559{
560 char *channel;
561
562 if ( argc < 4 )
563 return RESULT_SHOWUSAGE ;
564
565 channel = argv[3];
566
567 int res = stop_sound_channel(fd, channel);
568
569 if ( !res )
570 {
571 ast_cli(fd, "Sound stop failed failed\n");
572 return RESULT_FAILURE;
573 }
574 return RESULT_SUCCESS ;
575}
576
577//
578// end conference
579//
580
581static char conference_end_usage[] =
582 "usage: conference end <conference name>\n"
583 " ends a conference.\n"
584;
585
586static struct ast_cli_entry cli_end = {
587 { "conference", "end", NULL },
588 conference_end,
589 "stops a conference",
590 conference_end_usage
591} ;
592
593int conference_end( int fd, int argc, char *argv[] )
594{
595 // check the args length
596 if ( argc < 3 )
597 return RESULT_SHOWUSAGE ;
598
599 // conference name
600 const char* name = argv[2] ;
601
602 // get the conference
603 if ( end_conference( name, 1 ) != 0 )
604 {
605 ast_cli( fd, "unable to end the conference, name => %s\n", name ) ;
606 return RESULT_SHOWUSAGE ;
607 }
608
609 return RESULT_SUCCESS ;
610}
611
612//
613// E.BUU - Manager conference end. Additional option to just kick everybody out
614// without hangin up channels
615//
616int manager_conference_end(struct mansession *s, const struct message *m)
617{
618 const char *confname = astman_get_header(m,"Conference");
619 int hangup = 1;
620
621 const char * h = astman_get_header(m, "Hangup");
622 if (h)
623 {
624 hangup = atoi(h);
625 }
626
627 ast_log( LOG_NOTICE, "Terminating conference %s on manager's request. Hangup: %s.\n", confname, hangup?"YES":"NO" );
628 if ( end_conference( confname, hangup ) != 0 )
629 {
630 ast_log( LOG_ERROR, "manager end conf: unable to terminate conference %s.\n", confname );
631 astman_send_error(s, m, "Failed to terminate\r\n");
632 return RESULT_FAILURE;
633 }
634
635 astman_send_ack(s, m, "Conference terminated");
636 return RESULT_SUCCESS;
637}
638//
639// lock conference to a video source
640//
641static char conference_lock_usage[] =
642 "usage: conference lock <conference name> <member id>\n"
643 " locks incoming video stream for conference <conference name> to member <member id>\n"
644;
645
646static struct ast_cli_entry cli_lock = {
647 { "conference", "lock", NULL },
648 conference_lock,
649 "locks incoming video to a member",
650 conference_lock_usage
651} ;
652
653int conference_lock( int fd, int argc, char *argv[] )
654{
655 // check args
656 if ( argc < 4 )
657 return RESULT_SHOWUSAGE;
658
659 const char *conference = argv[2];
660 int member;
661 sscanf(argv[3], "%d", &member);
662
663 int res = lock_conference(conference, member);
664
665 if ( !res )
666 {
667 ast_cli(fd, "Locking failed\n");
668 return RESULT_FAILURE;
669 }
670
671 return RESULT_SUCCESS;
672}
673
674//
675// lock conference to a video source channel
676//
677static char conference_lockchannel_usage[] =
678 "usage: conference lockchannel <conference name> <channel>\n"
679 " locks incoming video stream for conference <conference name> to channel <channel>\n"
680;
681
682static struct ast_cli_entry cli_lockchannel = {
683 { "conference", "lockchannel", NULL },
684 conference_lockchannel,
685 "locks incoming video to a channel",
686 conference_lockchannel_usage
687} ;
688
689int conference_lockchannel( int fd, int argc, char *argv[] )
690{
691 // check args
692 if ( argc < 4 )
693 return RESULT_SHOWUSAGE;
694
695 const char *conference = argv[2];
696 const char *channel = argv[3];
697
698 int res = lock_conference_channel(conference, channel);
699
700 if ( !res )
701 {
702 ast_cli(fd, "Locking failed\n");
703 return RESULT_FAILURE;
704 }
705
706 return RESULT_SUCCESS;
707}
708
709//
710// unlock conference
711//
712static char conference_unlock_usage[] =
713 "usage: conference unlock <conference name>\n"
714 " unlocks conference <conference name>\n"
715;
716
717static struct ast_cli_entry cli_unlock = {
718 { "conference", "unlock", NULL },
719 conference_unlock,
720 "unlocks conference",
721 conference_unlock_usage
722} ;
723
724int conference_unlock( int fd, int argc, char *argv[] )
725{
726 // check args
727 if ( argc < 3 )
728 return RESULT_SHOWUSAGE;
729
730
731 const char *conference = argv[2];
732
733 int res = unlock_conference(conference);
734
735 if ( !res )
736 {
737 ast_cli(fd, "Unlocking failed\n");
738 return RESULT_FAILURE;
739 }
740
741 return RESULT_SUCCESS;
742}
743
744//
745// Set conference default video source
746//
747static char conference_set_default_usage[] =
748 "usage: conference set default <conference name> <member id>\n"
749 " sets the default video source for conference <conference name> to member <member id>\n"
750 " Use a negative value for member if you want to clear the default\n"
751;
752
753static struct ast_cli_entry cli_set_default = {
754 { "conference", "set", "default", NULL },
755 conference_set_default,
756 "sets default video source",
757 conference_set_default_usage
758} ;
759
760int conference_set_default(int fd, int argc, char *argv[] )
761{
762 // check args
763 if ( argc < 5 )
764 return RESULT_SHOWUSAGE;
765
766 const char *conference = argv[3];
767 int member;
768 sscanf(argv[4], "%d", &member);
769
770 int res = set_default_id(conference, member);
771
772 if ( !res )
773 {
774 ast_cli(fd, "Setting default video id failed\n");
775 return RESULT_FAILURE;
776 }
777
778 return RESULT_SUCCESS;
779}
780
781//
782// Set conference default video source channel
783//
784static char conference_set_defaultchannel_usage[] =
785 "usage: conference set defaultchannel <conference name> <channel>\n"
786 " sets the default video source channel for conference <conference name> to channel <channel>\n"
787;
788
789static struct ast_cli_entry cli_set_defaultchannel = {
790 { "conference", "set", "defaultchannel", NULL },
791 conference_set_defaultchannel,
792 "sets default video source channel",
793 conference_set_defaultchannel_usage
794} ;
795
796int conference_set_defaultchannel(int fd, int argc, char *argv[] )
797{
798 // check args
799 if ( argc < 5 )
800 return RESULT_SHOWUSAGE;
801
802 const char *conference = argv[3];
803 const char *channel = argv[4];
804
805 int res = set_default_channel(conference, channel);
806
807 if ( !res )
808 {
809 ast_cli(fd, "Setting default video id failed\n");
810 return RESULT_FAILURE;
811 }
812
813 return RESULT_SUCCESS;
814}
815
816//
817// Mute video from a member
818//
819static char conference_video_mute_usage[] =
820 "usage: conference video mute <conference name> <member id>\n"
821 " mutes video from member <member id> in conference <conference name>\n"
822;
823
824static struct ast_cli_entry cli_video_mute = {
825 { "conference", "video", "mute", NULL },
826 conference_video_mute,
827 "mutes video from a member",
828 conference_video_mute_usage
829} ;
830
831int conference_video_mute(int fd, int argc, char *argv[] )
832{
833 // check args
834 if ( argc < 5 )
835 return RESULT_SHOWUSAGE;
836
837 const char *conference = argv[3];
838 int member;
839 sscanf(argv[4], "%d", &member);
840
841 int res = video_mute_member(conference, member);
842
843 if ( !res )
844 {
845 ast_cli(fd, "Muting video from member %d failed\n", member);
846 return RESULT_FAILURE;
847 }
848
849 return RESULT_SUCCESS;
850}
851
852//
853// Unmute video from a member
854//
855static char conference_video_unmute_usage[] =
856 "usage: conference video unmute <conference name> <member id>\n"
857 " unmutes video from member <member id> in conference <conference name>\n"
858;
859
860static struct ast_cli_entry cli_video_unmute = {
861 { "conference", "video", "unmute", NULL },
862 conference_video_unmute,
863 "unmutes video from a member",
864 conference_video_unmute_usage
865} ;
866
867int conference_video_unmute(int fd, int argc, char *argv[] )
868{
869 // check args
870 if ( argc < 5 )
871 return RESULT_SHOWUSAGE;
872
873 const char *conference = argv[3];
874 int member;
875 sscanf(argv[4], "%d", &member);
876
877 int res = video_unmute_member(conference, member);
878
879 if ( !res )
880 {
881 ast_cli(fd, "Unmuting video from member %d failed\n", member);
882 return RESULT_FAILURE;
883 }
884
885 return RESULT_SUCCESS;
886}
887
888//
889// Mute video from a channel
890//
891static char conference_video_mutechannel_usage[] =
892 "usage: conference video mutechannel <conference name> <channel>\n"
893 " mutes video from channel <channel> in conference <conference name>\n"
894;
895
896static struct ast_cli_entry cli_video_mutechannel = {
897 { "conference", "video", "mutechannel", NULL },
898 conference_video_mutechannel,
899 "mutes video from a channel",
900 conference_video_mutechannel_usage
901} ;
902
903int conference_video_mutechannel(int fd, int argc, char *argv[] )
904{
905 // check args
906 if ( argc < 5 )
907 return RESULT_SHOWUSAGE;
908
909 const char *conference = argv[3];
910 const char *channel = argv[4];
911
912 int res = video_mute_channel(conference, channel);
913
914 if ( !res )
915 {
916 ast_cli(fd, "Muting video from channel %s failed\n", channel);
917 return RESULT_FAILURE;
918 }
919
920 return RESULT_SUCCESS;
921}
922
923//
924// Unmute video from a channel
925//
926static char conference_video_unmutechannel_usage[] =
927 "usage: conference video unmutechannel <conference name> <channel>\n"
928 " unmutes video from channel <channel> in conference <conference name>\n"
929;
930
931static struct ast_cli_entry cli_video_unmutechannel = {
932 { "conference", "video", "unmutechannel", NULL },
933 conference_video_unmutechannel,
934 "unmutes video from a channel",
935 conference_video_unmutechannel_usage
936} ;
937
938int conference_video_unmutechannel(int fd, int argc, char *argv[] )
939{
940 // check args
941 if ( argc < 5 )
942 return RESULT_SHOWUSAGE;
943
944 const char *conference = argv[3];
945 const char *channel = argv[4];
946
947 int res = video_unmute_channel(conference, channel);
948
949 if ( !res )
950 {
951 ast_cli(fd, "Unmuting video from channel %s failed\n", channel);
952 return RESULT_FAILURE;
953 }
954
955 return RESULT_SUCCESS;
956}
957
958
959//
960// Text message functions
961// Send a text message to a member
962//
963static char conference_text_usage[] =
964 "usage: conference text <conference name> <member id> <text>\n"
965 " Sends text message <text> to member <member id> in conference <conference name>\n"
966;
967
968static struct ast_cli_entry cli_text = {
969 { "conference", "text", NULL },
970 conference_text,
971 "sends a text message to a member",
972 conference_text_usage
973} ;
974
975int conference_text(int fd, int argc, char *argv[] )
976{
977 // check args
978 if ( argc < 5 )
979 return RESULT_SHOWUSAGE;
980
981 const char *conference = argv[2];
982 int member;
983 sscanf(argv[3], "%d", &member);
984 const char *text = argv[4];
985
986 int res = send_text(conference, member, text);
987
988 if ( !res )
989 {
990 ast_cli(fd, "Sending a text message to member %d failed\n", member);
991 return RESULT_FAILURE;
992 }
993
994 return RESULT_SUCCESS;
995}
996
997//
998// Send a text message to a channel
999//
1000static char conference_textchannel_usage[] =
1001 "usage: conference textchannel <conference name> <channel> <text>\n"
1002 " Sends text message <text> to channel <channel> in conference <conference name>\n"
1003;
1004
1005static struct ast_cli_entry cli_textchannel = {
1006 { "conference", "textchannel", NULL },
1007 conference_textchannel,
1008 "sends a text message to a channel",
1009 conference_textchannel_usage
1010} ;
1011
1012int conference_textchannel(int fd, int argc, char *argv[] )
1013{
1014 // check args
1015 if ( argc < 5 )
1016 return RESULT_SHOWUSAGE;
1017
1018 const char *conference = argv[2];
1019 const char *channel = argv[3];
1020 const char *text = argv[4];
1021
1022 int res = send_text_channel(conference, channel, text);
1023
1024 if ( !res )
1025 {
1026 ast_cli(fd, "Sending a text message to channel %s failed\n", channel);
1027 return RESULT_FAILURE;
1028 }
1029
1030 return RESULT_SUCCESS;
1031}
1032
1033//
1034// Send a text message to all members in a conference
1035//
1036static char conference_textbroadcast_usage[] =
1037 "usage: conference textbroadcast <conference name> <text>\n"
1038 " Sends text message <text> to all members in conference <conference name>\n"
1039;
1040
1041static struct ast_cli_entry cli_textbroadcast = {
1042 { "conference", "textbroadcast", NULL },
1043 conference_textbroadcast,
1044 "sends a text message to all members in a conference",
1045 conference_textbroadcast_usage
1046} ;
1047
1048int conference_textbroadcast(int fd, int argc, char *argv[] )
1049{
1050 // check args
1051 if ( argc < 4 )
1052 return RESULT_SHOWUSAGE;
1053
1054 const char *conference = argv[2];
1055 const char *text = argv[3];
1056
1057 int res = send_text_broadcast(conference, text);
1058
1059 if ( !res )
1060 {
1061 ast_cli(fd, "Sending a text broadcast to conference %s failed\n", conference);
1062 return RESULT_FAILURE;
1063 }
1064
1065 return RESULT_SUCCESS;
1066}
1067
1068//
1069// Associate two members
1070// Audio from the source member will drive VAD based video switching for the destination member
1071// If the destination member is missing or negative, break any existing association
1072//
1073static char conference_drive_usage[] =
1074 "usage: conference drive <conference name> <source member> [destination member]\n"
1075 " Drives VAD video switching of <destination member> using audio from <source member> in conference <conference name>\n"
1076 " If destination is missing or negative, break existing association\n"
1077;
1078
1079static struct ast_cli_entry cli_drive = {
1080 { "conference", "drive", NULL },
1081 conference_drive,
1082 "pairs two members to drive VAD-based video switching",
1083 conference_drive_usage
1084} ;
1085
1086int conference_drive(int fd, int argc, char *argv[] )
1087{
1088 // check args
1089 if ( argc < 4 )
1090 return RESULT_SHOWUSAGE;
1091
1092 const char *conference = argv[2];
1093 int src_member = -1;
1094 int dst_member = -1;
1095 sscanf(argv[3], "%d", &src_member);
1096 if ( argc > 4 )
1097 sscanf(argv[4], "%d", &dst_member);
1098
1099 int res = drive(conference, src_member, dst_member);
1100
1101 if ( !res )
1102 {
1103 ast_cli(fd, "Pairing members %d and %d failed\n", src_member, dst_member);
1104 return RESULT_FAILURE;
1105 }
1106
1107 return RESULT_SUCCESS;
1108}
1109
1110//
1111// Associate two channels
1112// Audio from the source channel will drive VAD based video switching for the destination channel
1113// If the destination channel is missing, break any existing association
1114//
1115static char conference_drivechannel_usage[] =
1116 "usage: conference drive <conference name> <source channel> [destination channel]\n"
1117 " Drives VAD video switching of <destination member> using audio from <source channel> in conference <conference channel>\n"
1118 " If destination is missing, break existing association\n"
1119;
1120
1121static struct ast_cli_entry cli_drivechannel = {
1122 { "conference", "drivechannel", NULL },
1123 conference_drivechannel,
1124 "pairs two channels to drive VAD-based video switching",
1125 conference_drivechannel_usage
1126} ;
1127
1128int conference_drivechannel(int fd, int argc, char *argv[] )
1129{
1130 // check args
1131 if ( argc < 4 )
1132 return RESULT_SHOWUSAGE;
1133
1134 const char *conference = argv[2];
1135 const char *src_channel = argv[3];
1136 const char *dst_channel = NULL;
1137 if ( argc > 4 )
1138 dst_channel = argv[4];
1139
1140 int res = drive_channel(conference, src_channel, dst_channel);
1141
1142 if ( !res )
1143 {
1144 ast_cli(fd, "Pairing channels %s and %s failed\n", src_channel, dst_channel);
1145 return RESULT_FAILURE;
1146 }
1147
1148 return RESULT_SUCCESS;
1149}
1150
1151
1152//
1153// cli initialization function
1154//
1155
1156void register_conference_cli( void )
1157{
1158 ast_cli_register( &cli_restart );
1159 ast_cli_register( &cli_debug ) ;
1160 ast_cli_register( &cli_show_stats ) ;
1161 ast_cli_register( &cli_list );
1162 ast_cli_register( &cli_kick );
1163 ast_cli_register( &cli_kickchannel );
1164 ast_cli_register( &cli_mute );
1165 ast_cli_register( &cli_mutechannel );
1166 ast_cli_register( &cli_viewstream );
1167 ast_cli_register( &cli_viewchannel );
1168 ast_cli_register( &cli_unmute );
1169 ast_cli_register( &cli_unmutechannel );
1170 ast_cli_register( &cli_play_sound ) ;
1171 ast_cli_register( &cli_stop_sounds ) ;
1172 ast_cli_register( &cli_end );
1173 ast_cli_register( &cli_lock );
1174 ast_cli_register( &cli_lockchannel );
1175 ast_cli_register( &cli_unlock );
1176 ast_cli_register( &cli_set_default );
1177 ast_cli_register( &cli_set_defaultchannel );
1178 ast_cli_register( &cli_video_mute ) ;
1179 ast_cli_register( &cli_video_unmute ) ;
1180 ast_cli_register( &cli_video_mutechannel ) ;
1181 ast_cli_register( &cli_video_unmutechannel ) ;
1182 ast_cli_register( &cli_text );
1183 ast_cli_register( &cli_textchannel );
1184 ast_cli_register( &cli_textbroadcast );
1185 ast_cli_register( &cli_drive );
1186 ast_cli_register( &cli_drivechannel );
1187 ast_manager_register( "ConferenceList", 0, manager_conference_list, "Conference List" );
1188 ast_manager_register( "ConferenceEnd", EVENT_FLAG_CALL, manager_conference_end, "Terminate a conference" );
1189
1190}
1191
1192void unregister_conference_cli( void )
1193{
1194 ast_cli_unregister( &cli_restart );
1195 ast_cli_unregister( &cli_debug ) ;
1196 ast_cli_unregister( &cli_show_stats ) ;
1197 ast_cli_unregister( &cli_list );
1198 ast_cli_unregister( &cli_kick );
1199 ast_cli_unregister( &cli_kickchannel );
1200 ast_cli_unregister( &cli_mute );
1201 ast_cli_unregister( &cli_mutechannel );
1202 ast_cli_unregister( &cli_viewstream );
1203 ast_cli_unregister( &cli_viewchannel );
1204 ast_cli_unregister( &cli_unmute );
1205 ast_cli_unregister( &cli_unmutechannel );
1206 ast_cli_unregister( &cli_play_sound ) ;
1207 ast_cli_unregister( &cli_stop_sounds ) ;
1208 ast_cli_unregister( &cli_end );
1209 ast_cli_unregister( &cli_lock );
1210 ast_cli_unregister( &cli_lockchannel );
1211 ast_cli_unregister( &cli_unlock );
1212 ast_cli_unregister( &cli_set_default );
1213 ast_cli_unregister( &cli_set_defaultchannel );
1214 ast_cli_unregister( &cli_video_mute ) ;
1215 ast_cli_unregister( &cli_video_unmute ) ;
1216 ast_cli_unregister( &cli_video_mutechannel ) ;
1217 ast_cli_unregister( &cli_video_unmutechannel ) ;
1218 ast_cli_unregister( &cli_text );
1219 ast_cli_unregister( &cli_textchannel );
1220 ast_cli_unregister( &cli_textbroadcast );
1221 ast_cli_unregister( &cli_drive );
1222 ast_cli_unregister( &cli_drivechannel );
1223 ast_manager_unregister( "ConferenceList" );
1224 ast_manager_unregister( "ConferenceEnd" );
1225}