diff --git a/darkice/trunk/man/darkice.cfg.5 b/darkice/trunk/man/darkice.cfg.5 index f433dbf..8ed8856 100644 --- a/darkice/trunk/man/darkice.cfg.5 +++ b/darkice/trunk/man/darkice.cfg.5 @@ -156,6 +156,11 @@ Dump the same mp3 data sent to the .B IceCast server to this local file. .TP +.I fileAddDate +"yes" or "no" if you want to automaticaly insert a date string in +the file name before his extension or at the end of file name if file name +doens't have an extension. +.TP .I lowpass Lowpass filter setting for the lame encoder. If not set or set to 0, the encoder's default behaviour is used. If set to -1, the filter is @@ -256,7 +261,11 @@ Genre of the stream Dump the same Ogg Vorbis data sent to the .B IceCast2 server to this local file. - +.TP +.I fileAddDate +"yes" or "no" if you want to automaticaly insert a date string in +the file name before his extension or at the end of file name if file name +doens't have an extension. .PP .B [shoutcast-x] @@ -347,7 +356,11 @@ disabled. Dump the same mp3 data sent to the .B ShoutCast server to this local file. - +.TP +.I fileAddDate +"yes" or "no" if you want to automaticaly insert a date string in +the file name before his extension or at the end of file name if file name +doens't have an extension. .PP .B [file-x] @@ -450,6 +463,7 @@ genre = live public = no remoteDumpFile = /tmp/server-dump.mp3 localDumpFile = /tmp/encoder-dump.mp3 +fileAddDate = no .fi diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index b3aab70..e9f2f7d 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -220,6 +220,7 @@ DarkIce :: configIceCast ( const Config & config, int highpass = 0; const char * localDumpName = 0; FileSink * localDumpFile = 0; + bool fileAddDate = false; str = cs->get( "sampleRate"); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); @@ -282,6 +283,8 @@ DarkIce :: configIceCast ( const Config & config, lowpass = str ? Util::strToL( str) : 0; str = cs->get( "highpass"); highpass = str ? Util::strToL( str) : 0; + str = cs->get("fileAddDate"); + fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; localDumpName = cs->get( "localDumpFile"); @@ -289,6 +292,10 @@ DarkIce :: configIceCast ( const Config & config, // check for and create the local dump file if needed if ( localDumpName != 0 ) { + + if (fileAddDate) + localDumpName = Util::fileAddDate(localDumpName); + localDumpFile = new FileSink( localDumpName); if ( !localDumpFile->exists() ) { if ( !localDumpFile->create() ) { @@ -298,7 +305,6 @@ DarkIce :: configIceCast ( const Config & config, } } } - // streaming related stuff audioOuts[u].socket = new TcpSocket( server, port); audioOuts[u].server = new IceCast( audioOuts[u].socket.get(), @@ -375,6 +381,7 @@ DarkIce :: configIceCast2 ( const Config & config, bool isPublic = false; const char * localDumpName = 0; FileSink * localDumpFile = 0; + bool fileAddDate = false; str = cs->getForSure( "format", " missing in section ", stream); if ( Util::strEq( str, "vorbis") ) { @@ -439,12 +446,19 @@ DarkIce :: configIceCast2 ( const Config & config, genre = cs->get( "genre"); str = cs->get( "public"); isPublic = str ? (Util::strEq( str, "yes") ? true : false) : false; + str = cs->get("fileAddDate"); + fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + localDumpName = cs->get( "localDumpFile"); // go on and create the things // check for and create the local dump file if needed if ( localDumpName != 0 ) { + + if (fileAddDate) + localDumpName = Util::fileAddDate(localDumpName); + localDumpFile = new FileSink( localDumpName); if ( !localDumpFile->exists() ) { if ( !localDumpFile->create() ) { @@ -454,7 +468,6 @@ DarkIce :: configIceCast2 ( const Config & config, } } } - // streaming related stuff audioOuts[u].socket = new TcpSocket( server, port); audioOuts[u].server = new IceCast2( audioOuts[u].socket.get(), @@ -572,6 +585,7 @@ DarkIce :: configShoutCast ( const Config & config, const char * icq = 0; const char * localDumpName = 0; FileSink * localDumpFile = 0; + bool fileAddDate = false; str = cs->get( "sampleRate"); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); @@ -632,12 +646,20 @@ DarkIce :: configShoutCast ( const Config & config, irc = cs->get( "irc"); aim = cs->get( "aim"); icq = cs->get( "icq"); + str = cs->get("fileAddDate"); + fileAddDate = str ? (Util::strEq( str, "yes") ? true : false) : false; + + localDumpName = cs->get( "localDumpFile"); // go on and create the things // check for and create the local dump file if needed if ( localDumpName != 0 ) { + + if (fileAddDate) + localDumpName = Util::fileAddDate(localDumpName); + localDumpFile = new FileSink( localDumpName); if ( !localDumpFile->exists() ) { if ( !localDumpFile->create() ) { @@ -965,6 +987,9 @@ DarkIce :: run ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.33 2002/11/20 16:52:05 wandereq + added fileAddDate function + Revision 1.32 2002/10/19 12:24:55 darkeye anged internals so that now each encoding/server connection is a separate thread diff --git a/darkice/trunk/src/Util.cpp b/darkice/trunk/src/Util.cpp index c8311a1..dbb45bc 100644 --- a/darkice/trunk/src/Util.cpp +++ b/darkice/trunk/src/Util.cpp @@ -260,6 +260,44 @@ Util :: strToD( const char * str ) throw ( Exception ) return val; } +/*------------------------------------------------------------------------------ + * insert date between 2 string pointers + *----------------------------------------------------------------------------*/ + +char * +Util :: fileAddDate ( const char * str ) throw ( Exception ) +{ + unsigned int size; + char * s; + char * strdate; + char * last; + time_t now; + + if ( !str ) { + throw Exception( __FILE__, __LINE__, "no str"); + } + + + strdate = new char[128]; + now = time(NULL); + strftime(strdate,128,"[%m-%d-%Y-%H-%M-%S]",localtime (&now)); + + last = strrchr (str,'.'); + if (last == NULL) + last = (char *) str + strlen (str); + + size = strlen (str) + strlen (strdate) + 1; + + s = new char [size]; + + memcpy (s, str, strlen (str)-strlen(last)); + memcpy (s + strlen(str) - strlen(last), strdate, strlen (strdate)); + memcpy (s + strlen(str) - strlen(last) + strlen(strdate), last,strlen(last)); + s[size-1]='\0'; + + delete strdate; + return s; +} /*------------------------------------------------------------------------------ * Convert an unsigned char buffer holding 8 or 16 bit PCM values with @@ -449,6 +487,9 @@ Util :: conv16 ( unsigned char * pcmBuffer, $Source$ $Log$ + Revision 1.10 2002/11/20 16:52:07 wandereq + added fileAddDate function + Revision 1.9 2002/08/20 18:39:14 darkeye added HTTP Basic authentication for icecast2 logins diff --git a/darkice/trunk/src/Util.h b/darkice/trunk/src/Util.h index 189dd0f..ca3bf14 100644 --- a/darkice/trunk/src/Util.h +++ b/darkice/trunk/src/Util.h @@ -202,6 +202,18 @@ class Util static double strToD ( const char * str ) throw ( Exception ); + /** + * Add a date to a string + * + * @param str the string to convert (file name). + * @return the new string with the date appended before + * extension of the file name + * @exception Exception + */ + + static char * + fileAddDate ( const char * str) throw ( Exception ); + /** * Convert a string into base64 encoding. * base64 is described in RFC 2045, section 6.8 @@ -307,6 +319,9 @@ class Util $Source$ $Log$ + Revision 1.8 2002/11/20 16:52:08 wandereq + added fileAddDate function + Revision 1.7 2002/08/20 18:39:14 darkeye added HTTP Basic authentication for icecast2 logins