3 Copyright (C) 2010 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 /* Linphone Sound Daemon: is a lightweight utility to play sounds to speaker during a conversation.
21 This is useful for embedded platforms, where sound apis are not performant enough to allow
22 simultaneous sound access.
24 This file is a test program that plays several sound files and places a call simultatenously.
27 #include "linphonecore_utils.h"
29 static void play_finished(LsdPlayer *p){
30 const char *filename=(const char *)lsd_player_get_user_pointer (p);
31 ms_message("Playing of %s is finished.",filename);
32 if (!lsd_player_loop_enabled (p)){
33 linphone_sound_daemon_release_player (lsd_player_get_daemon(p),p);
37 static void wait_a_bit(LinphoneCore *lc, int seconds){
38 time_t orig=time(NULL);
39 while(time(NULL)-orig<seconds){
40 /* we need to call iterate to receive notifications */
41 linphone_core_iterate(lc);
46 int main(int argc, char *argv[]){
48 LinphoneCoreVTable vtable={0};
49 LinphoneSoundDaemon *lsd;
52 linphone_core_enable_logs(stdout);
53 lc=linphone_core_new(&vtable,NULL,NULL,NULL);
54 lsd=linphone_sound_daemon_new (NULL);
56 linphone_core_use_sound_daemon(lc,lsd);
59 p=linphone_sound_daemon_get_player(lsd);
60 lsd_player_set_callback (p,play_finished);
61 lsd_player_set_user_pointer (p,"share/hello8000.wav");
62 lsd_player_play (p,"share/hello8000.wav");
65 /*start another one */
66 p=linphone_sound_daemon_get_player(lsd);
67 lsd_player_set_callback (p,play_finished);
68 lsd_player_set_user_pointer (p,"share/hello16000.wav");
69 lsd_player_enable_loop (p,TRUE);
70 lsd_player_play (p,"share/hello16000.wav");
72 /* after a few seconds decrease the volume */
74 lsd_player_set_gain (p,0.3);
77 /*now play some stereo music*/
78 p=linphone_sound_daemon_get_player(lsd);
79 lsd_player_set_callback (p,play_finished);
80 lsd_player_set_user_pointer (p,"share/rings/rock.wav");
81 lsd_player_play(p,"share/rings/rock.wav");
84 /*now play some stereo music at 22khz in order to test
86 p=linphone_sound_daemon_get_player(lsd);
87 lsd_player_set_callback (p,play_finished);
88 lsd_player_set_user_pointer (p,"share/rings/bigben.wav");
89 lsd_player_play(p,"share/rings/bigben.wav");
92 /* now place an outgoing call if sip address argument is given */
94 linphone_core_invite(lc,argv[1]);
96 linphone_core_terminate_call(lc,NULL);
98 linphone_core_use_sound_daemon(lc,NULL);
99 linphone_sound_daemon_destroy(lsd);
100 linphone_core_destroy(lc);