00001 /*------------------------------------------------------------------------------ 00002 00003 Copyright (c) 2000 Tyrell Corporation. All rights reserved. 00004 00005 Tyrell DarkIce 00006 00007 File : DarkIce.h 00008 Version : $Revision: 1.15 $ 00009 Author : $Author: darkeye $ 00010 Location : $Source: /cvsroot/darkice/darkice/src/DarkIce.h,v $ 00011 00012 Copyright notice: 00013 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 ------------------------------------------------------------------------------*/ 00029 #ifndef DARK_ICE_H 00030 #define DARK_ICE_H 00031 00032 #ifndef __cplusplus 00033 #error This is a C++ include file 00034 #endif 00035 00036 00037 /* ============================================================ include files */ 00038 00039 #ifdef HAVE_CONFIG_H 00040 #include "config.h" 00041 #endif 00042 00043 #ifdef HAVE_UNISTD_H 00044 #include <unistd.h> 00045 #else 00046 #error need unistd.h 00047 #endif 00048 00049 #include <iostream> 00050 00051 #include "Referable.h" 00052 #include "Reporter.h" 00053 #include "Exception.h" 00054 #include "Ref.h" 00055 #include "AudioSource.h" 00056 #include "BufferedSink.h" 00057 #include "Connector.h" 00058 #include "AudioEncoder.h" 00059 #include "TcpSocket.h" 00060 #include "CastSink.h" 00061 #include "DarkIceConfig.h" 00062 00063 00064 /* ================================================================ constants */ 00065 00066 00067 /* =================================================================== macros */ 00068 00069 00070 /* =============================================================== data types */ 00071 00078 class DarkIce : public virtual Referable, public virtual Reporter 00079 { 00080 private: 00081 00086 static const unsigned int maxOutput = 4 * 7; 00087 00091 typedef struct { 00092 Ref<AudioEncoder> encoder; 00093 Ref<TcpSocket> socket; 00094 Ref<CastSink> server; 00095 } Output; 00096 00100 Output audioOuts[maxOutput]; 00101 00105 unsigned int noAudioOuts; 00106 00110 unsigned int duration; 00111 00115 Ref<AudioSource> dsp; 00116 00120 Ref<Connector> encConnector; 00121 00125 int origSchedPolicy; 00126 00130 int origSchedPriority; 00131 00139 void 00140 init ( const Config & config ) throw ( Exception ); 00141 00151 void 00152 configIceCast ( const Config & config, 00153 unsigned int bufferSecs ) throw ( Exception ); 00154 00164 void 00165 configIceCast2 ( const Config & config, 00166 unsigned int bufferSecs ) throw ( Exception ); 00167 00177 void 00178 configShoutCast ( const Config & config, 00179 unsigned int bufferSecs ) throw ( Exception ); 00180 00189 void 00190 configFileCast ( const Config & config ) 00191 throw ( Exception ); 00192 00199 void 00200 setRealTimeScheduling ( void ) throw ( Exception ); 00201 00208 void 00209 setOriginalScheduling ( void ) throw ( Exception ); 00210 00218 bool 00219 encode ( void ) throw ( Exception ); 00220 00228 bool 00229 shout ( unsigned int ) throw ( Exception ); 00230 00231 00232 protected: 00233 00239 inline 00240 DarkIce ( void ) throw ( Exception ) 00241 { 00242 throw Exception( __FILE__, __LINE__); 00243 } 00244 00245 00246 public: 00247 00255 inline 00256 DarkIce ( const Config & config ) throw ( Exception ) 00257 { 00258 init( config); 00259 } 00260 00266 inline virtual 00267 ~DarkIce ( void ) throw ( Exception ) 00268 { 00269 } 00270 00271 /* TODO 00272 00273 inline 00274 DarkIce ( const DarkIce & di ) throw ( Exception ) 00275 { 00276 } 00277 00278 00279 inline DarkIce & 00280 operator= ( const DarkIce * di ) throw ( Exception ) 00281 { 00282 } 00283 */ 00284 00291 virtual int 00292 run ( void ) throw ( Exception ); 00293 00294 }; 00295 00296 00297 /* ================================================= external data structures */ 00298 00299 00300 /* ====================================================== function prototypes */ 00301 00302 00303 00304 #endif /* DARK_ICE_H */ 00305 00306 00307 /*------------------------------------------------------------------------------ 00308 00309 $Source: /cvsroot/darkice/darkice/src/DarkIce.h,v $ 00310 00311 $Log: DarkIce.h,v $ 00312 Revision 1.15 2005/04/04 08:36:17 darkeye 00313 commited changes to enable Jack support 00314 thanks to Nicholas J. Humfrey, njh@ecs.soton.ac.uk 00315 00316 Revision 1.14 2002/05/28 12:35:41 darkeye 00317 code cleanup: compiles under gcc-c++ 3.1, using -pedantic option 00318 00319 Revision 1.13 2002/02/28 09:49:25 darkeye 00320 added possibility to save the encoded stream to a local file only 00321 (no streaming server needed) 00322 00323 Revision 1.12 2001/09/14 19:31:06 darkeye 00324 added IceCast2 / vorbis support 00325 00326 Revision 1.11 2001/09/11 15:05:21 darkeye 00327 added Solaris support 00328 00329 Revision 1.10 2001/09/09 11:27:31 darkeye 00330 added support for ShoutCast servers 00331 00332 Revision 1.9 2001/08/30 17:25:56 darkeye 00333 renamed configure.h to config.h 00334 00335 Revision 1.8 2001/08/26 20:44:30 darkeye 00336 removed external command-line encoder support 00337 replaced it with a shared-object support for lame with the possibility 00338 of static linkage 00339 00340 Revision 1.7 2000/12/20 12:36:47 darkeye 00341 added POSIX real-time scheduling 00342 00343 Revision 1.6 2000/11/15 18:08:43 darkeye 00344 added multiple verbosity-level event reporting and verbosity command 00345 line option 00346 00347 Revision 1.5 2000/11/13 19:38:55 darkeye 00348 moved command line parameter parsing from DarkIce.cpp to main.cpp 00349 00350 Revision 1.4 2000/11/13 18:46:50 darkeye 00351 added kdoc-style documentation comments 00352 00353 Revision 1.3 2000/11/10 20:16:21 darkeye 00354 first real tests with multiple streaming 00355 00356 Revision 1.2 2000/11/09 22:09:46 darkeye 00357 added multiple outputs 00358 added configuration reading 00359 added command line processing 00360 00361 Revision 1.1.1.1 2000/11/05 10:05:50 darkeye 00362 initial version 00363 00364 00365 ------------------------------------------------------------------------------*/ 00366