Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members  

outchannels.h

Go to the documentation of this file.
00001 /* MuSE - Multiple Streaming Engine
00002  * Copyright (C) 2000-2002 Denis Rojo aka jaromil <jaromil@dyne.org>
00003  *
00004  * This source code is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Public License as published 
00006  * by the Free Software Foundation; either version 2 of the License,
00007  * or (at your option) any later version.
00008  *
00009  * This source code is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00012  * Please refer to the GNU Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Public License along with
00015  * this source code; if not, write to:
00016  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  *
00018  * "$Id: outchannels.h,v 1.5 2004/12/15 18:18:06 jaromil Exp $"
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   // SHOUTERS
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   // end of Shouters
00161 
00162 
00163 
00165   // ENCODER SETTINGS HERE
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   // DUMP TO FILE
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   // end of the OutChannel public interface
00228 
00229 
00231   // IF YOU ARE DEALING WITH A GUI
00232   //  YOU ARE NOT INTERESTED IN WHAT
00233   // COMES NEXT TO HERE
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   /* pthread methods */
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   /* pthread properties and private methods */
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

Generated on Thu Dec 16 12:28:21 2004 for MuSE by doxygen1.3