r3391 - in trunk/libminisip: . include include/libminisip/media/soundcard source/subsystem_media source/subsystem_media/soundcard
erik at minisip.org
erik at minisip.org
Wed Aug 22 23:17:53 CEST 2007
Author: erik
Date: 2007-08-22 23:17:53 +0200 (Wed, 22 Aug 2007)
New Revision: 3391
Added:
trunk/libminisip/include/libminisip/media/soundcard/FileSoundDevice.h
trunk/libminisip/include/libminisip/media/soundcard/FileSoundDriver.h
Removed:
trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.h
trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.h
Modified:
trunk/libminisip/Makefile.am
trunk/libminisip/include/Makefile.am
trunk/libminisip/source/subsystem_media/CallRecorder.cxx
trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.cxx
trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.cxx
trunk/libminisip/source/subsystem_media/soundcard/SoundDriverRegistry.cxx
Log:
* In MSVS, I need to include FileSoundDevice.h from CallRecorder.h
I therefoce have to move FileSoundDevice.h from the source
directory to the include one.
I would rather have kept the header files where they were if I could
since I don't think they need to be part of the API.
Modified: trunk/libminisip/Makefile.am
===================================================================
--- trunk/libminisip/Makefile.am 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/Makefile.am 2007-08-22 21:17:53 UTC (rev 3391)
@@ -187,9 +187,7 @@
source/subsystem_media/soundcard/SoundSource.cxx \
${RESAMPLER_SRC} \
${AUDIOMIXER_SRC} \
- source/subsystem_media/soundcard/FileSoundDevice.h \
source/subsystem_media/soundcard/FileSoundDevice.cxx \
- source/subsystem_media/soundcard/FileSoundDriver.h \
source/subsystem_media/soundcard/FileSoundDriver.cxx \
source/subsystem_media/soundcard/FileSoundSource.cxx \
source/subsystem_media/soundcard/SoundDevice.cxx \
Modified: trunk/libminisip/include/Makefile.am
===================================================================
--- trunk/libminisip/include/Makefile.am 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/include/Makefile.am 2007-08-22 21:17:53 UTC (rev 3391)
@@ -82,6 +82,8 @@
libminisip/media/soundcard/AudioMixer.h \
libminisip/media/soundcard/SoundSource.h \
libminisip/media/soundcard/FileSoundSource.h \
+ libminisip/media/soundcard/FileSoundDevice.h \
+ libminisip/media/soundcard/FileSoundDriver.h \
libminisip/media/soundcard/AudioMixerSpatial.h \
libminisip/media/soundcard/OssSoundDevice.h \
libminisip/media/soundcard/SoundDevice.h \
Copied: trunk/libminisip/include/libminisip/media/soundcard/FileSoundDevice.h (from rev 3379, trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.h)
===================================================================
--- trunk/libminisip/include/libminisip/media/soundcard/FileSoundDevice.h (rev 0)
+++ trunk/libminisip/include/libminisip/media/soundcard/FileSoundDevice.h 2007-08-22 21:17:53 UTC (rev 3391)
@@ -0,0 +1,217 @@
+/*
+ Copyright (C) 2004-2006 the Minisip Team
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* Copyright (C) 2004
+ *
+ * Authors: Erik Eliasson <eliasson at it.kth.se>
+ * Johan Bilien <jobi at via.ecp.fr>
+ * Cesc Santasusana <c e s c DOT s a n t a [AT} g m a i l DOT c o m>
+*/
+
+#ifndef FILESOUNDDEVICE_H
+#define FILESOUNDDEVICE_H
+
+#include<libminisip/libminisip_config.h>
+
+#ifdef _MSC_VER
+# include<io.h>
+# undef open
+# undef close
+# undef read
+# undef write
+#else
+# include<sys/time.h>
+# include<unistd.h>
+#endif
+
+#include<libminisip/media/soundcard/SoundDevice.h>
+
+#include<stdio.h>
+#include <fcntl.h>
+#include<iostream>
+
+
+#define FILESOUND_TYPE_RAW 0
+#define FILESOUND_TYPE_WAV 1
+#define FILESOUND_TYPE_MP3 2
+
+/**
+SoundDevice which reads from/to files, simulating a synchronous
+access to the soundcard.
+The deviceId needs to be such:
+file:RECORDFILE,PLAYBACKFILE
+where
+- RECORDFILE is a readable file, from where we extract audio samples
+ and send them to the callee. If the file was a soundcard,
+ this would be the microphone.
+ Example: /tmp/minisip.audio.mic
+- PLAYBACKFILE is a writable file, where we dump all the received
+ audio.
+ Example: /tmp/minisip.audio.dump
+
+When opened from the SoundIO class, it will be opened using the
+same parameters as any other soundcard, this means
+ samplingRate = 48000
+ numberChannels = 2
+ format = 2 bytes per sample, unsigned
+NOTE: i know it needs/generates huge files ... but hey, they are
+ in a very good audio quality ;)
+
+TODO: implement other filetypes, not just RAW. Interesting would be
+ at least WAV (like RAW but with header) and MP3 (to save space).
+
+NOTE: The output/input of this device for now is RAW. This means that
+ to play it or record it you most probably need to first create
+ a WAV or MP3 file and then convert it to RAW (use the linux
+ tool SOX, for example).
+ sox somemp3.mp3 -r 48000 -c 2 -s -w minisip.play.sw
+*/
+class LIBMINISIP_API FileSoundDevice: public SoundDevice{
+ public:
+ FileSoundDevice(std::string in_file="",
+ std::string out_file="",
+ int32_t filetype=FILESOUND_TYPE_RAW );
+
+ /**
+ We need to add a blocking behavior to the reading of the file,
+ plus looping.
+ Thus, we some specific code, but still call the SoundDevice::read function
+ */
+ virtual int read( byte_t * buffer, uint32_t nSamples );
+
+ /**
+ Read from the "record" file, that is, this file is read
+ and the audio samples are to be processed (i.e, to send to
+ the network).
+ */
+ virtual int readFromDevice( byte_t * buffer, uint32_t nSamples );
+
+ /**
+ We need to add a blocking behavior to the writing of the file
+ (only if SoundDevice::sleepTime == 0 --> device playback open in blocking mode).
+ Thus, we some specific code, but still call the SoundDevice::write function
+ */
+ virtual int write( byte_t * buffer, uint32_t nSamples );
+
+ /**
+ Write to the "playback" file, that is, the file where the
+ "received" audio is stored for later playback.
+ */
+ virtual int writeToDevice( byte_t * buffer, uint32_t nSamples );
+
+ virtual int readError( int errcode, byte_t * buffer, uint32_t nSamples );
+ virtual int writeError( int errcode, byte_t * buffer, uint32_t nSamples );
+
+ virtual int openPlayback( int32_t samplingRate, int nChannels, int format=SOUND_S16LE );
+ virtual int openRecord( int32_t samplingRate, int nChannels, int format=SOUND_S16LE );
+
+ virtual int closePlayback();
+ virtual int closeRecord();
+
+ /**
+ Set/get functions for the looping of the record file (the one played to the
+ other peer).
+ If set to true, the file is looped for as long as the call is active.
+ */
+ bool getLoopRecord() { return loopRecord; };
+ void setLoopRecord( bool loop ) { loopRecord = loop; };
+
+ virtual void sync();
+
+ virtual std::string getMemObjectType() const { return "FileSoundDevice";};
+
+ protected:
+
+ void setAudioParams( int nChannels_, int filetype_ );
+
+ /**
+ File type of this device. For now, we can only open the same type
+ for reading and writing ...
+ //FIXME the above ...
+ */
+ int fileType;
+
+ /**
+ Filenames
+ - inFile is the "record" file, to read from
+ - outFile is the "playback" file, to write to
+ */
+ std::string inFilename;
+ std::string outFilename;
+
+ /**
+ File descriptors
+ */
+ int in_fd;
+ int out_fd;
+
+ /**
+ During a single execution of minisip, the sound device is started
+ and stopped several times.
+ If it is the first time we open for playback (dump audio to a file),
+ we create the file with filesize = 0. If it is not the first time
+ we open the sound device in the current run of minisip, we do not
+ create it, we open it in APPEND mode.
+ */
+ bool isFirstTimeOpenWrite;
+
+ /**
+ Whether to loop or not the record file, that is, if the other peer
+ will receive the same message over and over.
+ */
+ bool loopRecord;
+
+ /**
+ Print the "errno" variables ... for debug
+ */
+ void printError( std::string func );
+
+
+ /**
+ Do not reuse the sleepTime variable in SoundDevice ... for now
+ (as long as the audio playback is still blocking).
+ */
+ uint32_t fileSoundBlockSleep;
+
+ /**
+ Implements a sleep function, used to synchronize the writing of
+ audio samples. It sleeps for sleepTime miliseconds.
+ */
+ void writeSleep( );
+
+ /**
+ State variable, used in writeSleep()
+ */
+ uint64_t lastTimeWrite;
+
+ /**
+ Implements a sleep function, used to synchronize the reading of
+ audio samples. It sleeps for sleepTime miliseconds.
+ */
+ void readSleep( );
+
+ /**
+ State variable, used in readSleep()
+ */
+ uint64_t lastTimeRead;
+
+ int getFileSize( int fd );
+};
+
+
+#endif
Copied: trunk/libminisip/include/libminisip/media/soundcard/FileSoundDriver.h (from rev 3379, trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.h)
===================================================================
--- trunk/libminisip/include/libminisip/media/soundcard/FileSoundDriver.h (rev 0)
+++ trunk/libminisip/include/libminisip/media/soundcard/FileSoundDriver.h 2007-08-22 21:17:53 UTC (rev 3391)
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2006 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/* Copyright (C) 2006
+ *
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef FILESOUNDDRIVER_H
+#define FILESOUNDDRIVER_H
+
+#include<libminisip/libminisip_config.h>
+
+#include<string>
+#include<libmutil/MemObject.h>
+
+#include<libminisip/media/soundcard/SoundDriver.h>
+
+
+class FileSoundDriver: public SoundDriver{
+ public:
+ FileSoundDriver( MRef<Library*> lib );
+ virtual ~FileSoundDriver();
+ virtual MRef<SoundDevice*> createDevice( std::string deviceId );
+ virtual std::string getDescription() const { return "FileSound sound driver"; };
+
+ virtual std::vector<SoundDeviceName> getDeviceNames() const;
+
+ virtual std::string getName() const {
+ return "FileSound";
+ }
+
+ virtual std::string getMemObjectType() const { return getName(); }
+
+ virtual uint32_t getVersion() const;
+};
+
+#endif // FILESOUNDDRIVER_H
Modified: trunk/libminisip/source/subsystem_media/CallRecorder.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/CallRecorder.cxx 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/CallRecorder.cxx 2007-08-22 21:17:53 UTC (rev 3391)
@@ -26,7 +26,7 @@
#include<libminisip/media/CallRecorder.h>
#include<libminisip/media/AudioMedia.h>
-#include"soundcard/FileSoundDevice.h"
+#include<libminisip/media/soundcard/FileSoundDevice.h>
#include<libmutil/stringutils.h>
#include<libmutil/Mutex.h>
Modified: trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.cxx 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.cxx 2007-08-22 21:17:53 UTC (rev 3391)
@@ -25,7 +25,7 @@
#include<config.h>
-#include"FileSoundDevice.h"
+#include<libminisip/media/soundcard/FileSoundDevice.h>
#include<sys/types.h>
#include<sys/stat.h>
Deleted: trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.h
===================================================================
--- trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.h 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/soundcard/FileSoundDevice.h 2007-08-22 21:17:53 UTC (rev 3391)
@@ -1,217 +0,0 @@
-/*
- Copyright (C) 2004-2006 the Minisip Team
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Copyright (C) 2004
- *
- * Authors: Erik Eliasson <eliasson at it.kth.se>
- * Johan Bilien <jobi at via.ecp.fr>
- * Cesc Santasusana <c e s c DOT s a n t a [AT} g m a i l DOT c o m>
-*/
-
-#ifndef FILESOUNDDEVICE_H
-#define FILESOUNDDEVICE_H
-
-#include<libminisip/libminisip_config.h>
-
-#ifdef _MSC_VER
-# include<io.h>
-# undef open
-# undef close
-# undef read
-# undef write
-#else
-# include<sys/time.h>
-# include<unistd.h>
-#endif
-
-#include<libminisip/media/soundcard/SoundDevice.h>
-
-#include<stdio.h>
-#include <fcntl.h>
-#include<iostream>
-
-
-#define FILESOUND_TYPE_RAW 0
-#define FILESOUND_TYPE_WAV 1
-#define FILESOUND_TYPE_MP3 2
-
-/**
-SoundDevice which reads from/to files, simulating a synchronous
-access to the soundcard.
-The deviceId needs to be such:
-file:RECORDFILE,PLAYBACKFILE
-where
-- RECORDFILE is a readable file, from where we extract audio samples
- and send them to the callee. If the file was a soundcard,
- this would be the microphone.
- Example: /tmp/minisip.audio.mic
-- PLAYBACKFILE is a writable file, where we dump all the received
- audio.
- Example: /tmp/minisip.audio.dump
-
-When opened from the SoundIO class, it will be opened using the
-same parameters as any other soundcard, this means
- samplingRate = 48000
- numberChannels = 2
- format = 2 bytes per sample, unsigned
-NOTE: i know it needs/generates huge files ... but hey, they are
- in a very good audio quality ;)
-
-TODO: implement other filetypes, not just RAW. Interesting would be
- at least WAV (like RAW but with header) and MP3 (to save space).
-
-NOTE: The output/input of this device for now is RAW. This means that
- to play it or record it you most probably need to first create
- a WAV or MP3 file and then convert it to RAW (use the linux
- tool SOX, for example).
- sox somemp3.mp3 -r 48000 -c 2 -s -w minisip.play.sw
-*/
-class LIBMINISIP_API FileSoundDevice: public SoundDevice{
- public:
- FileSoundDevice(std::string in_file="",
- std::string out_file="",
- int32_t filetype=FILESOUND_TYPE_RAW );
-
- /**
- We need to add a blocking behavior to the reading of the file,
- plus looping.
- Thus, we some specific code, but still call the SoundDevice::read function
- */
- virtual int read( byte_t * buffer, uint32_t nSamples );
-
- /**
- Read from the "record" file, that is, this file is read
- and the audio samples are to be processed (i.e, to send to
- the network).
- */
- virtual int readFromDevice( byte_t * buffer, uint32_t nSamples );
-
- /**
- We need to add a blocking behavior to the writing of the file
- (only if SoundDevice::sleepTime == 0 --> device playback open in blocking mode).
- Thus, we some specific code, but still call the SoundDevice::write function
- */
- virtual int write( byte_t * buffer, uint32_t nSamples );
-
- /**
- Write to the "playback" file, that is, the file where the
- "received" audio is stored for later playback.
- */
- virtual int writeToDevice( byte_t * buffer, uint32_t nSamples );
-
- virtual int readError( int errcode, byte_t * buffer, uint32_t nSamples );
- virtual int writeError( int errcode, byte_t * buffer, uint32_t nSamples );
-
- virtual int openPlayback( int32_t samplingRate, int nChannels, int format=SOUND_S16LE );
- virtual int openRecord( int32_t samplingRate, int nChannels, int format=SOUND_S16LE );
-
- virtual int closePlayback();
- virtual int closeRecord();
-
- /**
- Set/get functions for the looping of the record file (the one played to the
- other peer).
- If set to true, the file is looped for as long as the call is active.
- */
- bool getLoopRecord() { return loopRecord; };
- void setLoopRecord( bool loop ) { loopRecord = loop; };
-
- virtual void sync();
-
- virtual std::string getMemObjectType() const { return "FileSoundDevice";};
-
- protected:
-
- void setAudioParams( int nChannels_, int filetype_ );
-
- /**
- File type of this device. For now, we can only open the same type
- for reading and writing ...
- //FIXME the above ...
- */
- int fileType;
-
- /**
- Filenames
- - inFile is the "record" file, to read from
- - outFile is the "playback" file, to write to
- */
- std::string inFilename;
- std::string outFilename;
-
- /**
- File descriptors
- */
- int in_fd;
- int out_fd;
-
- /**
- During a single execution of minisip, the sound device is started
- and stopped several times.
- If it is the first time we open for playback (dump audio to a file),
- we create the file with filesize = 0. If it is not the first time
- we open the sound device in the current run of minisip, we do not
- create it, we open it in APPEND mode.
- */
- bool isFirstTimeOpenWrite;
-
- /**
- Whether to loop or not the record file, that is, if the other peer
- will receive the same message over and over.
- */
- bool loopRecord;
-
- /**
- Print the "errno" variables ... for debug
- */
- void printError( std::string func );
-
-
- /**
- Do not reuse the sleepTime variable in SoundDevice ... for now
- (as long as the audio playback is still blocking).
- */
- uint32_t fileSoundBlockSleep;
-
- /**
- Implements a sleep function, used to synchronize the writing of
- audio samples. It sleeps for sleepTime miliseconds.
- */
- void writeSleep( );
-
- /**
- State variable, used in writeSleep()
- */
- uint64_t lastTimeWrite;
-
- /**
- Implements a sleep function, used to synchronize the reading of
- audio samples. It sleeps for sleepTime miliseconds.
- */
- void readSleep( );
-
- /**
- State variable, used in readSleep()
- */
- uint64_t lastTimeRead;
-
- int getFileSize( int fd );
-};
-
-
-#endif
Modified: trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.cxx 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.cxx 2007-08-22 21:17:53 UTC (rev 3391)
@@ -27,8 +27,8 @@
#include<libminisip/media/soundcard/SoundDriverRegistry.h>
#include<libmutil/MPlugin.h>
-#include"FileSoundDriver.h"
-#include"FileSoundDevice.h"
+#include<libminisip/media/soundcard/FileSoundDriver.h>
+#include<libminisip/media/soundcard/FileSoundDevice.h>
using namespace std;
Deleted: trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.h
===================================================================
--- trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.h 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/soundcard/FileSoundDriver.h 2007-08-22 21:17:53 UTC (rev 3391)
@@ -1,53 +0,0 @@
-/*
- Copyright (C) 2006 Mikael Magnusson
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-/* Copyright (C) 2006
- *
- * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
- */
-
-#ifndef FILESOUNDDRIVER_H
-#define FILESOUNDDRIVER_H
-
-#include<libminisip/libminisip_config.h>
-
-#include<string>
-#include<libmutil/MemObject.h>
-
-#include<libminisip/media/soundcard/SoundDriver.h>
-
-
-class FileSoundDriver: public SoundDriver{
- public:
- FileSoundDriver( MRef<Library*> lib );
- virtual ~FileSoundDriver();
- virtual MRef<SoundDevice*> createDevice( std::string deviceId );
- virtual std::string getDescription() const { return "FileSound sound driver"; };
-
- virtual std::vector<SoundDeviceName> getDeviceNames() const;
-
- virtual std::string getName() const {
- return "FileSound";
- }
-
- virtual std::string getMemObjectType() const { return getName(); }
-
- virtual uint32_t getVersion() const;
-};
-
-#endif // FILESOUNDDRIVER_H
Modified: trunk/libminisip/source/subsystem_media/soundcard/SoundDriverRegistry.cxx
===================================================================
--- trunk/libminisip/source/subsystem_media/soundcard/SoundDriverRegistry.cxx 2007-08-22 21:12:57 UTC (rev 3390)
+++ trunk/libminisip/source/subsystem_media/soundcard/SoundDriverRegistry.cxx 2007-08-22 21:17:53 UTC (rev 3391)
@@ -26,7 +26,7 @@
#include<libminisip/media/soundcard/SoundDriverRegistry.h>
#include<libmutil/dbg.h>
-#include"FileSoundDriver.h"
+#include<libminisip/media/soundcard/FileSoundDriver.h>
// #ifdef PORTAUDIO_SUPPORT
// #include<libminisip/media/soundcard/PortAudioDriver.h>
More information about the Minisip-devel
mailing list