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: 23695 $
00028  * $Author: rjongbloed $
00029  * $Date: 2009-10-21 22:21:13 -0500 (Wed, 21 Oct 2009) $
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:
00049     typedef PFactory<OpalRecordManager, PCaselessString> Factory;
00050 
00051 #if OPAL_VIDEO
00052     enum VideoMode {
00053       eSideBySideLetterbox, 
00057       eSideBySideScaled,    
00061       eStackedPillarbox,    
00065       eStackedScaled,       
00069       eSeparateStreams,     
00070       NumVideoMixingModes
00071     };
00072 #endif
00073 
00074     struct Options {
00075       bool      m_stereo;
00076       PString   m_audioFormat;
00077 
00078 #if OPAL_VIDEO
00079       VideoMode m_videoMixing;
00080       PString   m_videoFormat;
00081       unsigned  m_videoWidth;
00082       unsigned  m_videoHeight;
00083       unsigned  m_videoRate;
00084 #endif
00085 
00086       Options(
00087         bool         stereo = true,
00088 #if OPAL_VIDEO
00089         VideoMode    videoMixing = eSideBySideLetterbox,
00090 #endif
00091         const char * audioFormat = NULL
00092 #if OPAL_VIDEO
00093         ,
00094         const char * videoFormat = NULL,
00095         unsigned width = PVideoFrameInfo::CIFWidth,
00096         unsigned height = PVideoFrameInfo::CIFHeight,
00097         unsigned rate = 15
00098 #endif
00099       ) : m_stereo(stereo)
00100         , m_audioFormat(audioFormat)
00101 #if OPAL_VIDEO
00102         , m_videoMixing(videoMixing)
00103         , m_videoFormat(videoFormat)
00104         , m_videoWidth(width)
00105         , m_videoHeight(height)
00106         , m_videoRate(rate)
00107 #endif
00108       {
00109       }
00110     };
00111 
00112     virtual ~OpalRecordManager() { }
00113 
00116     bool Open(const PFilePath & fn)
00117     {
00118       return OpenFile(fn);
00119     }
00120 
00123     bool Open(const PFilePath & fn, bool mono) // For backward compatibility
00124     {
00125       m_options.m_stereo = !mono;
00126       return OpenFile(fn);
00127     }
00128 
00131     bool Open(const PFilePath & fn, const Options & options)
00132     {
00133       m_options = options;
00134       return Open(fn);
00135     }
00136 
00139     virtual bool IsOpen() const = 0;
00140 
00145     virtual bool Close() = 0;
00146 
00149     virtual bool OpenStream(
00150       const PString & strmId,         
00151       const OpalMediaFormat & format  
00152     ) = 0;
00153 
00156     virtual bool CloseStream(
00157       const PString & strmId  
00158     ) = 0;
00159 
00162     virtual bool WriteAudio(
00163       const PString & strmId,     
00164       const RTP_DataFrame & rtp   
00165     ) = 0;
00166 
00167 #if OPAL_VIDEO
00168 
00170     virtual bool WriteVideo(
00171       const PString & strmId,     
00172       const RTP_DataFrame & rtp   
00173     ) = 0;
00174 #endif
00175 
00178     const Options & GetOptions() const { return m_options; }
00179 
00182     void SetOptions(const Options & options)
00183     {
00184       m_options = options;
00185     }
00186 
00187   protected:
00188     virtual bool OpenFile(const PFilePath & fn) = 0;
00189 
00190     Options m_options;
00191 };
00192 
00193 // Force linking of modules
00194 PFACTORY_LOAD(OpalWAVRecordManager);
00195 #ifdef P_VFW_CAPTURE
00196 PFACTORY_LOAD(OpalAVIRecordManager);
00197 #endif
00198 
00199 #endif // OPAL_HAS_MIXER
00200 
00201 
00202 #endif // OPAL_OPAL_AUDIORECORD_H

Generated on Mon Feb 21 20:19:21 2011 for OPAL by  doxygen 1.4.7