OPAL  Version 3.14.3
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: 32351 $
28  * $Author: rjongbloed $
29  * $Date: 2014-07-14 14:36:59 +1000 (Mon, 14 Jul 2014) $
30  */
31 
32 
33 #ifndef OPAL_OPAL_AUDIORECORD_H
34 #define OPAL_OPAL_AUDIORECORD_H
35 
36 
37 #include <opal_config.h>
38 
39 #if OPAL_HAS_MIXER
40 
41 class OpalMediaFormat;
42 class RTP_DataFrame;
43 
44 
50 {
51  public:
57  typedef PFactory<OpalRecordManager, PCaselessString> Factory;
58 
59 #if OPAL_VIDEO
60  enum VideoMode {
79  };
80 #endif
81 
82  // Options for recording calls.
83  struct Options {
84  bool m_stereo;
86  PString m_audioFormat;
92 #if OPAL_VIDEO
94  PString m_videoFormat;
99  unsigned m_videoWidth;
100  unsigned m_videoHeight;
101  unsigned m_videoRate;
103 #endif
104 
106  bool stereo = true,
107 #if OPAL_VIDEO
108  VideoMode videoMixing = eSideBySideLetterbox,
109 #endif
110  const char * audioFormat = NULL
111 #if OPAL_VIDEO
112  ,
113  const char * videoFormat = NULL,
114  unsigned width = PVideoFrameInfo::CIFWidth,
115  unsigned height = PVideoFrameInfo::CIFHeight,
116  unsigned rate = 15
117 #endif
118  ) : m_stereo(stereo)
119  , m_audioFormat(audioFormat)
120 #if OPAL_VIDEO
121  , m_videoMixing(videoMixing)
122  , m_videoFormat(videoFormat)
123  , m_videoWidth(width)
124  , m_videoHeight(height)
125  , m_videoRate(rate)
126 #endif
127  {
128  }
129  };
130 
131  virtual ~OpalRecordManager() { }
132 
135  bool Open(const PFilePath & fn)
136  {
137  return OpenFile(fn);
138  }
139 
142  bool Open(const PFilePath & fn, bool mono) // For backward compatibility
143  {
144  m_options.m_stereo = !mono;
145  return OpenFile(fn);
146  }
147 
150  bool Open(const PFilePath & fn, const Options & options)
151  {
152  m_options = options;
153  return Open(fn);
154  }
155 
158  virtual bool IsOpen() const = 0;
159 
164  virtual bool Close() = 0;
165 
168  virtual bool OpenStream(
169  const PString & strmId,
170  const OpalMediaFormat & format
171  ) = 0;
172 
175  virtual bool CloseStream(
176  const PString & strmId
177  ) = 0;
178 
181  virtual bool WriteAudio(
182  const PString & strmId,
183  const RTP_DataFrame & rtp
184  ) = 0;
185 
186 #if OPAL_VIDEO
187 
189  virtual bool WriteVideo(
190  const PString & strmId,
191  const RTP_DataFrame & rtp
192  ) = 0;
193 #endif
194 
197  const Options & GetOptions() const { return m_options; }
198 
201  void SetOptions(const Options & options)
202  {
203  m_options = options;
204  }
205 
206  protected:
207  virtual bool OpenFile(const PFilePath & fn) = 0;
208 
210 };
211 
212 // Force linking of modules
213 
214 #ifdef P_WAVFILE
215 PFACTORY_LOAD(OpalWAVRecordManager);
216 #endif
217 
218 #if OPAL_VIDEO && P_VFW_CAPTURE
219 PFACTORY_LOAD(OpalAVIRecordManager);
220 #endif
221 
222 #endif // OPAL_HAS_MIXER
223 
224 
225 #endif // OPAL_OPAL_AUDIORECORD_H