1 /*
2  * Copyright (C) 2002-2003 Fhg Fokus
3  *
4  * This file is part of SEMS, a free SIP media server.
5  *
6  * SEMS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version. This program is released under
10  * the GPL with the additional exemption that compiling, linking,
11  * and/or using OpenSSL is allowed.
12  *
13  * For a license to use the SEMS software under conditions
14  * other than those described here, or to purchase support for this
15  * software, please contact iptel.org by e-mail at the following addresses:
16  *    info@iptel.org
17  *
18  * SEMS is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26  */
27 /** @file AmConferenceChannel.h */
28 #ifndef AmConferenceChannel_h
29 #define AmConferenceChannel_h
30 
31 #include "AmAudio.h"
32 #include "AmConferenceStatus.h"
33 
34 #include "sip/async_file.h"
35 class ChannelWritingFile : public async_file
36 {
37   FILE* fp;
38  public:
39   ChannelWritingFile(const char* path);
40   ~ChannelWritingFile();
41 
42   int write_to_file(const void* buf, unsigned int len);
43 
44   void on_flushed();
45 
46   AmCondition<bool> finished;
47 };
48 
49 /**
50  * \brief one channel of a conference
51  *
52  * A ConferenceChannel is one channel, i.e. to/from one
53  * participant, in a conference.
54  */
55 class AmConferenceChannel: public AmAudio
56 {
57   bool                own_channel;
58   int                 channel_id;
59   string              channel_tag;
60   string              conf_id;
61   AmConferenceStatus* status;
62 
63   string in_file_name;
64   string out_file_name;
65   bool have_in_sr;
66   bool have_out_sr;
67   ChannelWritingFile* in_file;
68   ChannelWritingFile* out_file;
69 
70  protected:
71   // Fake implement AmAudio's pure virtual methods
72   // this avoids to copy the samples locally by implementing only get/put
read(unsigned int user_ts,unsigned int size)73   int read(unsigned int user_ts, unsigned int size){ return -1; }
write(unsigned int user_ts,unsigned int size)74   int write(unsigned int user_ts, unsigned int size){ return -1; }
75 
76   // override AmAudio
77   int get(unsigned long long system_ts, unsigned char* buffer,
78 	  int output_sample_rate, unsigned int nb_samples);
79   int put(unsigned long long system_ts, unsigned char* buffer,
80 	  int input_sample_rate, unsigned int size);
81 
82  public:
83   AmConferenceChannel(AmConferenceStatus* status,
84 		      int channel_id, string channel_tag, bool own_channel);
85 
86   ~AmConferenceChannel();
87 
getConfID()88   string getConfID() { return conf_id; }
89 };
90 
91 #endif
92