OPAL  Version 3.12.9
recording.h
Go to the documentation of this file.
1 /*
2  * audiorecord.h
3  *
4  * OPAL audio record manager
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (C) 2007 Post Increment
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Post Increment
24  *
25  * Contributor(s): ______________________________________.
26  *
27  * $Revision: 27136 $
28  * $Author: rjongbloed $
29  * $Date: 2012-03-07 11:29:13 +1100 (Wed, 07 Mar 2012) $
30  */
31 
32 
33 #ifndef OPAL_OPAL_AUDIORECORD_H
34 #define OPAL_OPAL_AUDIORECORD_H
35 
36 
37 #include <opal/buildopts.h>
38 
39 #if OPAL_HAS_MIXER
40 
41 
47 {
48  public:
54  typedef PFactory<OpalRecordManager, PCaselessString> Factory;
55 
56 #if OPAL_VIDEO
57  enum VideoMode {
76  };
77 #endif
78 
79  // Options for recording calls.
80  struct Options {
81  bool m_stereo;
83  PString m_audioFormat;
89 #if OPAL_VIDEO
91  PString m_videoFormat;
96  unsigned m_videoWidth;
97  unsigned m_videoHeight;
98  unsigned m_videoRate;
100 #endif
101 
103  bool stereo = true,
104 #if OPAL_VIDEO
105  VideoMode videoMixing = eSideBySideLetterbox,
106 #endif
107  const char * audioFormat = NULL
108 #if OPAL_VIDEO
109  ,
110  const char * videoFormat = NULL,
111  unsigned width = PVideoFrameInfo::CIFWidth,
112  unsigned height = PVideoFrameInfo::CIFHeight,
113  unsigned rate = 15
114 #endif
115  ) : m_stereo(stereo)
116  , m_audioFormat(audioFormat)
117 #if OPAL_VIDEO
118  , m_videoMixing(videoMixing)
119  , m_videoFormat(videoFormat)
120  , m_videoWidth(width)
121  , m_videoHeight(height)
122  , m_videoRate(rate)
123 #endif
124  {
125  }
126  };
127 
128  virtual ~OpalRecordManager() { }
129 
132  bool Open(const PFilePath & fn)
133  {
134  return OpenFile(fn);
135  }
136 
139  bool Open(const PFilePath & fn, bool mono) // For backward compatibility
140  {
141  m_options.m_stereo = !mono;
142  return OpenFile(fn);
143  }
144 
147  bool Open(const PFilePath & fn, const Options & options)
148  {
149  m_options = options;
150  return Open(fn);
151  }
152 
155  virtual bool IsOpen() const = 0;
156 
161  virtual bool Close() = 0;
162 
165  virtual bool OpenStream(
166  const PString & strmId,
167  const OpalMediaFormat & format
168  ) = 0;
169 
172  virtual bool CloseStream(
173  const PString & strmId
174  ) = 0;
175 
178  virtual bool WriteAudio(
179  const PString & strmId,
180  const RTP_DataFrame & rtp
181  ) = 0;
182 
183 #if OPAL_VIDEO
184 
186  virtual bool WriteVideo(
187  const PString & strmId,
188  const RTP_DataFrame & rtp
189  ) = 0;
190 #endif
191 
194  const Options & GetOptions() const { return m_options; }
195 
198  void SetOptions(const Options & options)
199  {
200  m_options = options;
201  }
202 
203  protected:
204  virtual bool OpenFile(const PFilePath & fn) = 0;
205 
207 };
208 
209 // Force linking of modules
210 
211 #ifdef P_WAVFILE
212 PFACTORY_LOAD(OpalWAVRecordManager);
213 #endif
214 
215 #if OPAL_VIDEO && P_VFW_CAPTURE
216 PFACTORY_LOAD(OpalAVIRecordManager);
217 #endif
218 
219 #endif // OPAL_HAS_MIXER
220 
221 
222 #endif // OPAL_OPAL_AUDIORECORD_H