00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #ifndef __OUTCHANNELS_H__
00029 #define __OUTCHANNELS_H__
00030
00031 #include <pthread.h>
00032 #include <shouter.h>
00033 #include <pipe.h>
00034 #include <linklist.h>
00035 #include <generic.h>
00036 #include <resample/samplerate.h>
00037
00038 #define ENCBUFFER_SIZE 128000 // 65536 // we have ram, isn't it?
00039
00040
00041
00045 enum codec {
00046 MP3,
00047 OGG
00048 };
00049
00058 class OutChannel: public Entry {
00059
00090 public:
00095 OutChannel(char *myname);
00096
00097 virtual ~OutChannel();
00098
00099
00100 char name[128];
00101 char version[128];
00102 enum codec tipo;
00103
00104 bool quit;
00105 bool running;
00106 bool initialized;
00107
00108
00110
00112
00117 int create_ice();
00118
00123 bool delete_ice(int iceid);
00124
00130 Shouter *get_ice(int iceid);
00131
00140 bool apply_ice(int iceid);
00141
00149 bool connect_ice(int iceid, bool on);
00150
00156 Linklist icelist;
00157
00159
00161
00162
00163
00165
00167
00168 INT_SET(bps,_bps);
00169
00170 INT_SET(freq,_freq);
00171
00172 INT_SET(channels,_channels);
00173
00174 INT_SET(lowpass,_lowpass);
00175
00176 INT_SET(highpass,_highpass);
00177
00188 char *quality(float in);
00189 float _quality;
00190 char quality_desc[256];
00191
00196 unsigned int get_bitrate() { return bitrate; };
00197
00198
00199
00201
00203
00215 bool dump_start(char *file);
00220 bool dump_stop();
00221
00222 FILE *fd;
00223 char fd_name[MAX_PATH_SIZE];
00224
00225
00226
00228
00229
00231
00232
00233
00235
00236
00250 virtual bool apply_profile() =0;
00251
00252
00253 virtual bool init() = 0;
00254 virtual int encode() =0;
00255 virtual void flush() =0;
00256
00257
00258
00259 int shout();
00260 bool dump();
00261
00271 void push(void *data, int len);
00272 Pipe *erbapipa;
00273 bool encoding;
00274
00275
00276 void start();
00277 void run();
00278 void lock()
00279 { pthread_mutex_lock(&_mutex); };
00280 void unlock() { pthread_mutex_unlock(&_mutex); };
00281 void wait() { pthread_cond_wait(&_cond,&_mutex); };
00282 void signal() { pthread_cond_signal(&_cond); };
00283 void lock_ice() { pthread_mutex_lock(&_mutex_ice); };
00284 void unlock_ice() { pthread_mutex_unlock(&_mutex_ice); };
00285 void destroy() { _thread_destroy(); };
00287
00288
00289 int16_t buffer[ENC_BUFFER];
00290
00291 private:
00292
00293
00294
00295 void _thread_init();
00296 void _thread_destroy();
00297 bool _thread_initialized;
00298
00299 pthread_t _thread;
00300 pthread_attr_t _attr;
00301 pthread_mutex_t _mutex;
00302 pthread_mutex_t _mutex_ice;
00303 pthread_cond_t _cond;
00304
00305
00306 int idseed;
00307
00308 protected:
00309
00310 static void* kickoff(void *arg) { ((OutChannel *) arg)->run(); return NULL; };
00312
00313 bool calc_bitrate(int enc);
00314 int encoded;
00315 int bitrate;
00316 double now;
00317 double prev;
00318 unsigned int bytes_accu;
00319
00320 };
00321
00322
00323
00324 #endif