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"
30 static void play_finished(LsdPlayer *p){
31 const char *filename=(const char *)lsd_player_get_user_pointer (p);
32 ms_message("Playing of %s is finished.",filename);
33 if (!lsd_player_loop_enabled (p)){
34 linphone_sound_daemon_release_player (lsd_player_get_daemon(p),p);
38 static void wait_a_bit(LinphoneCore *lc, int seconds){
39 time_t orig=ms_time(NULL);
40 while(ms_time(NULL)-orig<seconds){
41 /* we need to call iterate to receive notifications */
42 linphone_core_iterate(lc);
47 int main(int argc, char *argv[]){
49 LinphoneCoreVTable vtable={0};
50 LinphoneSoundDaemon *lsd;
53 linphone_core_enable_logs(stdout);
54 lc=linphone_core_new(&vtable,NULL,NULL,NULL);
55 lsd=linphone_sound_daemon_new (NULL,44100,1);
57 linphone_core_use_sound_daemon(lc,lsd);
60 p=linphone_sound_daemon_get_player(lsd);
61 lsd_player_set_callback (p,play_finished);
62 lsd_player_set_user_pointer (p,"share/hello8000.wav");
63 lsd_player_play (p,"share/hello8000.wav");
66 /*start another one */
67 p=linphone_sound_daemon_get_player(lsd);
68 lsd_player_set_callback (p,play_finished);
69 lsd_player_set_user_pointer (p,"share/hello16000.wav");
70 lsd_player_enable_loop (p,TRUE);
71 lsd_player_play (p,"share/hello16000.wav");
73 /* after a few seconds decrease the volume */
75 lsd_player_set_gain (p,0.3);
78 /*now play some stereo music*/
79 p=linphone_sound_daemon_get_player(lsd);
80 lsd_player_set_callback (p,play_finished);
81 lsd_player_set_user_pointer (p,"share/rings/rock.wav");
82 lsd_player_play(p,"share/rings/rock.wav");
85 /*now play some stereo music at 22khz in order to test
87 p=linphone_sound_daemon_get_player(lsd);
88 lsd_player_set_callback (p,play_finished);
89 lsd_player_set_user_pointer (p,"share/rings/bigben.wav");
90 lsd_player_play(p,"share/rings/bigben.wav");
93 /* now place an outgoing call if sip address argument is given */
95 linphone_core_invite(lc,argv[1]);
97 linphone_core_terminate_call(lc,NULL);
99 linphone_core_use_sound_daemon(lc,NULL);
100 linphone_sound_daemon_destroy(lsd);
101 linphone_core_destroy(lc);