OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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: 26676 $
28 * $Author: rjongbloed $
29 * $Date: 2011-11-21 15:59:53 -0600 (Mon, 21 Nov 2011) $
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
46 class OpalRecordManager
47 {
48 public:
49 typedef PFactory<OpalRecordManager, PCaselessString> Factory;
50
51 #if OPAL_VIDEO
52 enum VideoMode {
53 eSideBySideLetterbox,
57 eSideBySideScaled,
61 eStackedPillarbox,
65 eStackedScaled,
69 eSeparateStreams,
70 NumVideoMixingModes
71 };
72 #endif
73
74 struct Options {
75 bool m_stereo;
76 PString m_audioFormat;
77
78 #if OPAL_VIDEO
79 VideoMode m_videoMixing;
80 PString m_videoFormat;
81 unsigned m_videoWidth;
82 unsigned m_videoHeight;
83 unsigned m_videoRate;
84 #endif
85
86 Options(
87 bool stereo = true,
88 #if OPAL_VIDEO
89 VideoMode videoMixing = eSideBySideLetterbox,
90 #endif
91 const char * audioFormat = NULL
92 #if OPAL_VIDEO
93 ,
94 const char * videoFormat = NULL,
95 unsigned width = PVideoFrameInfo::CIFWidth,
96 unsigned height = PVideoFrameInfo::CIFHeight,
97 unsigned rate = 15
98 #endif
99 ) : m_stereo(stereo)
100 , m_audioFormat(audioFormat)
101 #if OPAL_VIDEO
102 , m_videoMixing(videoMixing)
103 , m_videoFormat(videoFormat)
104 , m_videoWidth(width)
105 , m_videoHeight(height)
106 , m_videoRate(rate)
107 #endif
108 {
109 }
110 };
111
112 virtual ~OpalRecordManager() { }
113
116 bool Open(const PFilePath & fn)
117 {
118 return OpenFile(fn);
119 }
120
123 bool Open(const PFilePath & fn, bool mono) // For backward compatibility
124 {
125 m_options.m_stereo = !mono;
126 return OpenFile(fn);
127 }
128
131 bool Open(const PFilePath & fn, const Options & options)
132 {
133 m_options = options;
134 return Open(fn);
135 }
136
139 virtual bool IsOpen() const = 0;
140
145 virtual bool Close() = 0;
146
149 virtual bool OpenStream(
150 const PString & strmId,
151 const OpalMediaFormat & format
152 ) = 0;
153
156 virtual bool CloseStream(
157 const PString & strmId
158 ) = 0;
159
162 virtual bool WriteAudio(
163 const PString & strmId,
164 const RTP_DataFrame & rtp
165 ) = 0;
166
167 #if OPAL_VIDEO
168
170 virtual bool WriteVideo(
171 const PString & strmId,
172 const RTP_DataFrame & rtp
173 ) = 0;
174 #endif
175
178 const Options & GetOptions() const { return m_options; }
179
182 void SetOptions(const Options & options)
183 {
184 m_options = options;
185 }
186
187 protected:
188 virtual bool OpenFile(const PFilePath & fn) = 0;
189
190 Options m_options;
191 };
192
193 // Force linking of modules
194 PFACTORY_LOAD(OpalWAVRecordManager);
195 #if OPAL_VIDEO && P_VFW_CAPTURE
196 PFACTORY_LOAD(OpalAVIRecordManager);
197 #endif
198
199 #endif // OPAL_HAS_MIXER
200
201
202 #endif // OPAL_OPAL_AUDIORECORD_H