00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef OPAL_OPAL_AUDIORECORD_H
00034 #define OPAL_OPAL_AUDIORECORD_H
00035
00036
00037 #include <opal/buildopts.h>
00038
00039 #if OPAL_HAS_MIXER
00040
00041
00046 class OpalRecordManager
00047 {
00048 public:
00054 typedef PFactory<OpalRecordManager, PCaselessString> Factory;
00055
00056 #if OPAL_VIDEO
00057 enum VideoMode {
00058 eSideBySideLetterbox,
00062 eSideBySideScaled,
00066 eStackedPillarbox,
00070 eStackedScaled,
00074 eSeparateStreams,
00075 NumVideoMixingModes
00076 };
00077 #endif
00078
00079
00080 struct Options {
00081 bool m_stereo;
00083 PString m_audioFormat;
00089 #if OPAL_VIDEO
00090 VideoMode m_videoMixing;
00091 PString m_videoFormat;
00096 unsigned m_videoWidth;
00097 unsigned m_videoHeight;
00098 unsigned m_videoRate;
00100 #endif
00101
00102 Options(
00103 bool stereo = true,
00104 #if OPAL_VIDEO
00105 VideoMode videoMixing = eSideBySideLetterbox,
00106 #endif
00107 const char * audioFormat = NULL
00108 #if OPAL_VIDEO
00109 ,
00110 const char * videoFormat = NULL,
00111 unsigned width = PVideoFrameInfo::CIFWidth,
00112 unsigned height = PVideoFrameInfo::CIFHeight,
00113 unsigned rate = 15
00114 #endif
00115 ) : m_stereo(stereo)
00116 , m_audioFormat(audioFormat)
00117 #if OPAL_VIDEO
00118 , m_videoMixing(videoMixing)
00119 , m_videoFormat(videoFormat)
00120 , m_videoWidth(width)
00121 , m_videoHeight(height)
00122 , m_videoRate(rate)
00123 #endif
00124 {
00125 }
00126 };
00127
00128 virtual ~OpalRecordManager() { }
00129
00132 bool Open(const PFilePath & fn)
00133 {
00134 return OpenFile(fn);
00135 }
00136
00139 bool Open(const PFilePath & fn, bool mono)
00140 {
00141 m_options.m_stereo = !mono;
00142 return OpenFile(fn);
00143 }
00144
00147 bool Open(const PFilePath & fn, const Options & options)
00148 {
00149 m_options = options;
00150 return Open(fn);
00151 }
00152
00155 virtual bool IsOpen() const = 0;
00156
00161 virtual bool Close() = 0;
00162
00165 virtual bool OpenStream(
00166 const PString & strmId,
00167 const OpalMediaFormat & format
00168 ) = 0;
00169
00172 virtual bool CloseStream(
00173 const PString & strmId
00174 ) = 0;
00175
00178 virtual bool WriteAudio(
00179 const PString & strmId,
00180 const RTP_DataFrame & rtp
00181 ) = 0;
00182
00183 #if OPAL_VIDEO
00184
00186 virtual bool WriteVideo(
00187 const PString & strmId,
00188 const RTP_DataFrame & rtp
00189 ) = 0;
00190 #endif
00191
00194 const Options & GetOptions() const { return m_options; }
00195
00198 void SetOptions(const Options & options)
00199 {
00200 m_options = options;
00201 }
00202
00203 protected:
00204 virtual bool OpenFile(const PFilePath & fn) = 0;
00205
00206 Options m_options;
00207 };
00208
00209
00210
00211 #ifdef P_WAVFILE
00212 PFACTORY_LOAD(OpalWAVRecordManager);
00213 #endif
00214
00215 #if OPAL_VIDEO && P_VFW_CAPTURE
00216 PFACTORY_LOAD(OpalAVIRecordManager);
00217 #endif
00218
00219 #endif // OPAL_HAS_MIXER
00220
00221
00222 #endif // OPAL_OPAL_AUDIORECORD_H