recording.h

Go to the documentation of this file.
00001 /*
00002  * audiorecord.h
00003  *
00004  * OPAL audio record manager
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (C) 2007 Post Increment
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Post Increment
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Revision: 27110 $
00028  * $Author: rjongbloed $
00029  * $Date: 2012-03-04 22:12:36 -0600 (Sun, 04 Mar 2012) $
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     // Options for recording calls.
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) // For backward compatibility
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 // Force linking of modules
00210 PFACTORY_LOAD(OpalWAVRecordManager);
00211 #if OPAL_VIDEO && P_VFW_CAPTURE
00212 PFACTORY_LOAD(OpalAVIRecordManager);
00213 #endif
00214 
00215 #endif // OPAL_HAS_MIXER
00216 
00217 
00218 #endif // OPAL_OPAL_AUDIORECORD_H

Generated on 14 Aug 2013 for OPAL by  doxygen 1.4.7