~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to mediastreamer/test.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2004-06-30 13:58:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040630135816-wwx75gdlodkqbabb
Tags: upstream-0.12.2
ImportĀ upstreamĀ versionĀ 0.12.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  The mediastreamer library aims at providing modular media processing and I/O
 
3
        for linphone, but also for any telephony application.
 
4
  Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
 
5
                                                                                
 
6
  This library is free software; you can redistribute it and/or
 
7
  modify it under the terms of the GNU Lesser General Public
 
8
  License as published by the Free Software Foundation; either
 
9
  version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
  This library is distributed in the hope that it will be useful,
 
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
  Lesser General Public License for more details.
 
15
 
 
16
  You should have received a copy of the GNU Lesser General Public
 
17
  License along with this library; if not, write to the Free Software
 
18
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
*/
 
20
 
 
21
#include "ms.h"
 
22
 
 
23
#include "msringplayer.h"
 
24
#include "msosswrite.h"
 
25
#include "msossread.h"
 
26
#include "mscopy.h"
 
27
#include "mstimer.h"
 
28
#include <unistd.h>
 
29
#include <signal.h>
 
30
 
 
31
#define READFILE "../share/rings/orig.wav"
 
32
#define WRITEFILE "/tmp/mediaout"
 
33
 
 
34
static int cond=1;
 
35
 
 
36
void stop_handler(int signum)
 
37
{
 
38
        cond=0;
 
39
}
 
40
 
 
41
 
 
42
int main(int argc, char *argv[])
 
43
{
 
44
        MSFilter *play,*copy,*rec;
 
45
        MSSync *timer;
 
46
        int i=0;
 
47
        int tmp;
 
48
        char *ring;
 
49
 
 
50
        ms_init();
 
51
 
 
52
        if (argc>1){
 
53
                ring=argv[1];
 
54
        }else ring= READFILE;
 
55
        
 
56
        play=ms_ring_player_new(ring,2);
 
57
        //play=ms_oss_read_new(0);
 
58
        rec=snd_card_create_write_filter(snd_card_manager_get_card(snd_card_manager,1));
 
59
        copy=ms_copy_new();
 
60
 
 
61
        ms_filter_get_property(play,MS_FILTER_PROPERTY_FREQ,&tmp);
 
62
        g_message("Playing at rate %i.",tmp);
 
63
        ms_filter_set_property(rec,MS_FILTER_PROPERTY_FREQ,&tmp);
 
64
        ms_filter_get_property(play,MS_FILTER_PROPERTY_CHANNELS,&tmp);
 
65
        g_message("Playing with %i channels",tmp);
 
66
        ms_filter_set_property(rec,MS_FILTER_PROPERTY_CHANNELS,&tmp);
 
67
        
 
68
        timer=ms_timer_new();
 
69
        ms_sync_start(timer);
 
70
 
 
71
        ms_filter_add_link(play,copy);
 
72
        ms_filter_add_link(copy,rec);
 
73
        ms_sync_attach(timer,play);
 
74
 
 
75
        
 
76
        while(cond)
 
77
        {
 
78
                sleep(1);
 
79
        }
 
80
        ms_sync_detach(timer,play);
 
81
        ms_sync_stop(timer);
 
82
        ms_sync_destroy(timer);
 
83
 
 
84
        ms_filter_remove_links(play,copy);
 
85
        ms_filter_remove_links(copy,rec);
 
86
        ms_filter_destroy(play);
 
87
        ms_filter_destroy(copy);
 
88
        ms_filter_destroy(rec);
 
89
        
 
90
        return 0;
 
91
}