OPAL  Version 3.18.8
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 
28 
29 #ifndef OPAL_OPAL_AUDIORECORD_H
30 #define OPAL_OPAL_AUDIORECORD_H
31 
32 
33 #include <opal_config.h>
34 
35 #if OPAL_HAS_MIXER
36 
37 #include <ptlib/vconvert.h>
38 #include <ptlib/pfactory.h>
39 
40 
41 class OpalMediaFormat;
42 class RTP_DataFrame;
43 
44 
49 class OpalRecordManager : public PObject
50 {
51  PCLASSINFO(OpalRecordManager, PObject);
52  public:
58  typedef PFactory<OpalRecordManager, PFilePathString> Factory;
59 
60 #if OPAL_VIDEO
61  enum VideoMode {
80  };
81 #endif
82 
83  // Options for recording calls.
84  struct Options {
85  bool m_stereo;
87  PString m_audioFormat;
95 #if OPAL_VIDEO
97  PString m_videoFormat;
102  unsigned m_videoWidth;
103  unsigned m_videoHeight;
104  unsigned m_videoRate;
106 #endif
108 
110  bool stereo = true,
111 #if OPAL_VIDEO
112  VideoMode videoMixing = eSideBySideLetterbox,
113 #endif
114  const char * audioFormat = NULL,
115 #if OPAL_VIDEO
116  const char * videoFormat = NULL,
117  unsigned width = PVideoFrameInfo::CIFWidth,
118  unsigned height = PVideoFrameInfo::CIFHeight,
119  unsigned rate = 15,
120 #endif
121  bool pushThreads = true
122  ) : m_stereo(stereo)
123  , m_audioFormat(audioFormat)
124  , m_audioBufferSize(0)
125 #if OPAL_VIDEO
126  , m_videoMixing(videoMixing)
127  , m_videoFormat(videoFormat)
128  , m_videoWidth(width)
129  , m_videoHeight(height)
130  , m_videoRate(rate)
131 #endif
132  , m_pushThreads(pushThreads)
133  {
134  }
135  };
136 
139  bool Open(const PFilePath & fn);
140 
143  bool Open(const PFilePath & fn, bool mono); // For backward compatibility
144 
147  bool Open(const PFilePath & fn, const Options & options);
148 
151  virtual bool IsOpen() const = 0;
152 
157  virtual bool Close() = 0;
158 
161  virtual bool OpenStream(
162  const PString & strmId,
163  const OpalMediaFormat & format
164  ) = 0;
165 
168  virtual bool CloseStream(
169  const PString & strmId
170  ) = 0;
171 
174  virtual bool OnPushAudio() = 0;
175  virtual unsigned GetPushAudioPeriodMS() const = 0;
176 
179  virtual bool WriteAudio(
180  const PString & strmId,
181  const RTP_DataFrame & rtp
182  ) = 0;
183 
184 #if OPAL_VIDEO
185 
187  virtual bool OnPushVideo() = 0;
188  virtual unsigned GetPushVideoPeriodMS() const = 0;
189 
192  virtual bool WriteVideo(
193  const PString & strmId,
194  const RTP_DataFrame & rtp
195  ) = 0;
196 #endif
197 
200  const Options & GetOptions() const { return m_options; }
201 
204  void SetOptions(const Options & options)
205  {
206  m_options = options;
207  }
208 
209  protected:
210  virtual bool OpenFile(const PFilePath & fn) = 0;
211 
213 };
214 
215 #endif // OPAL_HAS_MIXER
216 
217 #endif // OPAL_OPAL_AUDIORECORD_H
VideoMode
Definition: recording.h:61
VideoMode m_videoMixing
Mode for how incoming video is mixed.
Definition: recording.h:96
bool m_pushThreads
Indicate push threads are to be started an operate in background.
Definition: recording.h:107
Definition: recording.h:74
virtual bool IsOpen() const =0
Definition: recording.h:70
unsigned m_videoHeight
Video mixer buffer heigth. Inputs are scaled accordingly.
Definition: recording.h:103
Options(bool stereo=true, VideoMode videoMixing=eSideBySideLetterbox, const char *audioFormat=NULL, const char *videoFormat=NULL, unsigned width=PVideoFrameInfo::CIFWidth, unsigned height=PVideoFrameInfo::CIFHeight, unsigned rate=15, bool pushThreads=true)
Definition: recording.h:109
virtual bool OnPushVideo()=0
bool Open(const PFilePath &fn)
virtual bool Close()=0
Definition: recording.h:62
Definition: recording.h:79
virtual unsigned GetPushAudioPeriodMS() const =0
PString m_videoFormat
Definition: recording.h:97
Definition: rtp.h:540
Definition: mediafmt.h:806
Options m_options
Definition: recording.h:212
virtual bool CloseStream(const PString &strmId)=0
virtual unsigned GetPushVideoPeriodMS() const =0
unsigned m_videoWidth
Video mixer buffer width. Inputs are scaled accordingly.
Definition: recording.h:102
const Options & GetOptions() const
Definition: recording.h:200
PFactory< OpalRecordManager, PFilePathString > Factory
Definition: recording.h:58
PINDEX m_audioBufferSize
Definition: recording.h:92
PString m_audioFormat
Definition: recording.h:87
void SetOptions(const Options &options)
Definition: recording.h:204
Unsupported.
Definition: recording.h:78
Definition: recording.h:49
virtual bool WriteVideo(const PString &strmId, const RTP_DataFrame &rtp)=0
Definition: recording.h:66
virtual bool OpenFile(const PFilePath &fn)=0
bool m_stereo
Definition: recording.h:85
virtual bool OnPushAudio()=0
unsigned m_videoRate
Definition: recording.h:104
Definition: recording.h:84
virtual bool WriteAudio(const PString &strmId, const RTP_DataFrame &rtp)=0
virtual bool OpenStream(const PString &strmId, const OpalMediaFormat &format)=0