sipxmediaadapterlib  Version 3.3
CpMediaInterfaceFactoryImpl.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-2021 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2008 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 #ifndef _CpMediaInterfaceFactoryImpl_h_
15 #define _CpMediaInterfaceFactoryImpl_h_
16 
17 // SYSTEM INCLUDES
18 
19 // APPLICATION INCLUDES
20 #include "os/OsDefs.h"
21 #include "os/OsStatus.h"
22 #include "utl/UtlDefs.h"
23 #include "utl/UtlString.h"
24 #include "sdp/SdpCodecList.h"
25 #include "utl/UtlSList.h"
26 #include "os/OsMutex.h"
27 
28 
29 // DEFINES
30 // MACROS
31 // EXTERNAL FUNCTIONS
32 // EXTERNAL VARIABLES
33 // CONSTANTS
34 // STRUCTS
35 // TYPEDEFS
36 
37 typedef enum MEDIA_AEC_MODE
38 {
44 
46 {
52 
53 // FORWARD DECLARATIONS
54 class CpMediaInterface ;
55 class SdpCodec ;
56 class OsMsgDispatcher ;
57 
62 {
63 /* //////////////////////////// PUBLIC //////////////////////////////////// */
64 public:
65 
66 /* ============================ CREATORS ================================== */
67 
70 
71 /* =========================== DESTRUCTORS ================================ */
72 
73 protected:
76 public:
77 
79  virtual void release();
80 
81 /* ============================ MANIPULATORS ============================== */
82 
84  virtual CpMediaInterface* createMediaInterface(const char* publicAddress,
85  const char* localAddress,
86  int numCodecs,
87  SdpCodec* sdpCodecArray[],
88  const char* locale,
89  int expeditedIpTos,
90  const char* szStunServer,
91  int iStunPort,
92  int iStunKeepAliveSecs,
93  const char* szTurnServer,
94  int iTurnPort,
95  const char* szTurnUsername,
96  const char* szTurnPassword,
97  int iTurnKeepAliveSecs,
98  UtlBoolean bEnableICE,
99  uint32_t samplesPerSec,
100  OsMsgDispatcher* pDispatcher
101  ) = 0 ;
102 
104  virtual OsStatus setSpeakerVolume(int iVolume) = 0 ;
105 
107  virtual OsStatus setSpeakerDevice(const UtlString& device) = 0 ;
108 
110  virtual OsStatus setMicrophoneGain(int iGain) = 0 ;
111 
113  virtual OsStatus setMicrophoneDevice(const UtlString& device) = 0 ;
114 
115 
117  virtual OsStatus muteMicrophone(UtlBoolean bMute) = 0 ;
118 
120  virtual OsStatus setAudioAECMode(const MEDIA_AEC_MODE mode)
121  {
122  return OS_NOT_SUPPORTED ;
123  }
124 
125 
128  {
129  return OS_NOT_SUPPORTED ;
130  }
131 
132 
134  virtual OsStatus enableAGC(UtlBoolean bEnable)
135  {
136  return OS_NOT_SUPPORTED ;
137  }
138 
139 
141  virtual OsStatus enableOutOfBandDTMF(UtlBoolean enable)
142  {
143  return OS_NOT_SUPPORTED ;
144  }
145 
147  virtual OsStatus enableInBandDTMF(UtlBoolean enable)
148  {
149  return OS_NOT_SUPPORTED ;
150  }
151 
152 
154  virtual OsStatus enableRTCP(UtlBoolean bEnable)
155  {
156  return OS_NOT_SUPPORTED ;
157  }
158 
160  virtual OsStatus setRTCPName(const char* szName)
161  {
162  return OS_NOT_SUPPORTED ;
163  }
164 
166  virtual OsStatus buildCodecFactory(SdpCodecList *pFactory,
167  const UtlString& sAudioPreferences,
168  const UtlString& sVideoPreferences,
169  int videoFormat,
170  int* iRejected) = 0;
171 
173  virtual OsStatus setVideoPreviewDisplay(void* pDisplay)
174  {
175  return OS_NOT_SUPPORTED ;
176  }
177 
178 
180  virtual OsStatus setVideoQuality(int quality)
181  {
182  return OS_NOT_SUPPORTED ;
183  }
184 
185 
187  virtual OsStatus setVideoParameters(int bitRate, int frameRate)
188  {
189  return OS_NOT_SUPPORTED ;
190  }
191 
192  virtual OsStatus setVideoBitrate(int bitrate)
193  {
194  return OS_NOT_SUPPORTED ;
195  }
196 
197  virtual OsStatus setVideoFramerate(int framerate)
198  {
199  return OS_NOT_SUPPORTED ;
200  }
201 
203  virtual OsStatus setVideoCpuValue(int cpuValue)
204  {
205  return OS_NOT_SUPPORTED ;
206  }
207 
209  virtual OsStatus updateVideoPreviewWindow(void* displayContext)
210  {
211  return OS_NOT_SUPPORTED ;
212  }
213 
214 
216  virtual void setRtpPortRange(int startRtpPort, int lastRtpPort) ;
217 
219  virtual OsStatus getNextRtpPort(const char* bindAddress, int &rtpPort);
225  virtual OsStatus releaseRtpPort(const int rtpPort) ;
227 
229  virtual OsStatus setConnectionIdleTimeout(const int idleTimeout)
230  {
231  return OS_NOT_SUPPORTED ;
232  }
233 
235  static OsStatus addCodecPaths(const size_t nCodecPaths,
236  const UtlString codecPaths[]);
237 
239  static void clearCodecPaths();
240 
241 
242 /* ============================ ACCESSORS ================================= */
243 
245  virtual void setDispatcher(OsMsgDispatcher* dispatcher) = 0;
246 
248  virtual OsStatus getSpeakerVolume(int& iVolume) const = 0 ;
249 
251  virtual OsStatus getSpeakerDevice(UtlString& device) const = 0 ;
252 
254  virtual OsStatus getMicrophoneGain(int& iVolume) const = 0 ;
255 
257  virtual OsStatus getMicrophoneDevice(UtlString& device) const = 0 ;
258 
260  virtual OsStatus getLocalAudioConnectionId(int& connectionId) const = 0;
261 
262 #ifdef VIDEO
263  virtual OsStatus getVideoCaptureDevices(UtlSList& videoDevices) const
265  {
266  return OS_NOT_SUPPORTED ;
267  }
268 
269 
271  virtual OsStatus getVideoCaptureDevice(UtlString& videoDevice)
272  {
273  return OS_NOT_SUPPORTED ;
274  }
275 
276 
278  virtual OsStatus setVideoCaptureDevice(const UtlString& videoDevice)
279  {
280  return OS_NOT_SUPPORTED ;
281  }
282 
283 
285  virtual OsStatus getVideoQuality(int& quality) const
286  {
287  return OS_NOT_SUPPORTED ;
288  }
289 
290 
292  virtual OsStatus getVideoBitRate(int& bitRate) const
293  {
294  return OS_NOT_SUPPORTED ;
295  }
296 
297 
299  virtual OsStatus getVideoFrameRate(int& frameRate) const
300  {
301  return OS_NOT_SUPPORTED ;
302  }
303 
304 
306  virtual OsStatus getVideoCpuValue(int& cpuValue) const = 0;
307 #endif // VIDEO
308 
310  virtual OsStatus getConnectionIdleTimeout(int& idleTimeout) const
311  {
312  return OS_NOT_SUPPORTED ;
313  }
314 
316  virtual void setConfiguredIpAddress(const UtlString& configuredIpAddress);
317 
318 /* ============================ INQUIRY =================================== */
319 
321  virtual OsStatus getAudioAECMode(MEDIA_AEC_MODE& mode) const
322  {
323  return OS_NOT_SUPPORTED ;
324  }
325 
326 
329  {
330  return OS_NOT_SUPPORTED ;
331  }
332 
333 
335  virtual OsStatus isAGCEnabled(UtlBoolean& bEnable) const
336  {
337  return OS_NOT_SUPPORTED ;
338  }
339 
340 
342  virtual OsStatus isOutOfBandDTMFEnabled(UtlBoolean& enabled) const
343  {
344  return OS_NOT_SUPPORTED ;
345  }
346 
347 
349  virtual OsStatus isInBandDTMFEnabled(UtlBoolean& enabled) const
350  {
351  return OS_NOT_SUPPORTED ;
352  }
353 
354 
355 /* //////////////////////////// PROTECTED ///////////////////////////////// */
356 protected:
358  int miGain ;
362  UtlSList mlistFreePorts ;
363  UtlSList mlistBusyPorts ;
364  OsMutex mlockList ;
367  static size_t mnAllocCodecPaths;
368  static size_t mnCodecPaths;
369  static UtlString* mpCodecPaths;
370 
371 
374  UtlBoolean isAddressPortBusy(const char* bindAddress, int iPort, int checkTimeMS) ;
384  static OsStatus ensureCapacityCodecPaths(size_t newSize);
399 /* //////////////////////////// PRIVATE /////////////////////////////////// */
400 private:
401 
404  rCpMediaInterfaceFactoryImpl);
405 
408 };
409 
410 /* ============================ INLINE METHODS ============================ */
411 
412 #endif // _CpMediaInterfaceFactoryImpl_h_
virtual OsStatus isOutOfBandDTMFEnabled(UtlBoolean &enabled) const
Return status of out-of-band DTMF.
Definition: CpMediaInterfaceFactoryImpl.h:342
virtual OsStatus setSpeakerVolume(int iVolume)=0
Set the speaker volume. Valid range includes 0 to 50.
virtual void setConfiguredIpAddress(const UtlString &configuredIpAddress)
Set IP address to use in SDP (spoofed address)
Definition: CpMediaInterfaceFactoryImpl.cpp:271
int miGain
Definition: CpMediaInterfaceFactoryImpl.h:358
virtual OsStatus getSpeakerVolume(int &iVolume) const =0
Get the speaker volume.
static size_t mnCodecPaths
Number of codec paths stored.
Definition: CpMediaInterfaceFactoryImpl.h:368
virtual OsStatus setMicrophoneDevice(const UtlString &device)=0
Set the Microphone device.
static void clearCodecPaths()
Clear the static codec path list.
Definition: CpMediaInterfaceFactoryImpl.cpp:257
virtual OsStatus setMicrophoneGain(int iGain)=0
Set the microphone gain. Valid range includes 0 to 10.
virtual OsStatus getAudioNoiseReductionMode(MEDIA_NOISE_REDUCTION_MODE &mode) const
Return status of noise reduction.
Definition: CpMediaInterfaceFactoryImpl.h:328
Definition: CpMediaInterfaceFactoryImpl.h:48
virtual OsStatus setSpeakerDevice(const UtlString &device)=0
Set the speaker device.
MEDIA_NOISE_REDUCTION_MODE
Definition: CpMediaInterfaceFactoryImpl.h:45
Definition: CpMediaInterfaceFactoryImpl.h:50
virtual OsStatus setVideoFramerate(int framerate)
Definition: CpMediaInterfaceFactoryImpl.h:197
OsMutex mlockList
Definition: CpMediaInterfaceFactoryImpl.h:364
virtual OsStatus enableAGC(UtlBoolean bEnable)
Enable AGC Status.
Definition: CpMediaInterfaceFactoryImpl.h:134
static OsStatus ensureCapacityCodecPaths(size_t newSize)
Ensure that there is enough capacity in our codec paths array.
Definition: CpMediaInterfaceFactoryImpl.cpp:329
virtual void setRtpPortRange(int startRtpPort, int lastRtpPort)
Sets the RTP port range for this factory.
Definition: CpMediaInterfaceFactoryImpl.cpp:74
virtual void release()
Public interface for destroying this media interface.
Definition: CpMediaInterfaceFactoryImpl.cpp:66
virtual OsStatus setVideoQuality(int quality)
Set the global video quality.
Definition: CpMediaInterfaceFactoryImpl.h:180
MEDIA_AEC_MODE
Definition: CpMediaInterfaceFactoryImpl.h:37
virtual void setDispatcher(OsMsgDispatcher *dispatcher)=0
Set the dispatcher for flowgraph independent media events/messages.
Definition: CpMediaInterfaceFactoryImpl.h:39
virtual OsStatus buildCodecFactory(SdpCodecList *pFactory, const UtlString &sAudioPreferences, const UtlString &sVideoPreferences, int videoFormat, int *iRejected)=0
Populate the codec factory, return number of rejected codecs.
virtual OsStatus setVideoCpuValue(int cpuValue)
Set the global CPU usage.
Definition: CpMediaInterfaceFactoryImpl.h:203
virtual OsStatus isAGCEnabled(UtlBoolean &bEnable) const
Return status of AGC.
Definition: CpMediaInterfaceFactoryImpl.h:335
virtual OsStatus setAudioAECMode(const MEDIA_AEC_MODE mode)
Enable/Disable echo cancellation.
Definition: CpMediaInterfaceFactoryImpl.h:120
virtual OsStatus getAudioAECMode(MEDIA_AEC_MODE &mode) const
Return status of echo cancellation.
Definition: CpMediaInterfaceFactoryImpl.h:321
int miLastRtpPort
Definition: CpMediaInterfaceFactoryImpl.h:360
Definition: CpMediaInterfaceFactoryImpl.h:41
Abstract media control interface.
Definition: CpMediaInterface.h:96
virtual CpMediaInterface * createMediaInterface(const char *publicAddress, const char *localAddress, int numCodecs, SdpCodec *sdpCodecArray[], const char *locale, int expeditedIpTos, const char *szStunServer, int iStunPort, int iStunKeepAliveSecs, const char *szTurnServer, int iTurnPort, const char *szTurnUsername, const char *szTurnPassword, int iTurnKeepAliveSecs, UtlBoolean bEnableICE, uint32_t samplesPerSec, OsMsgDispatcher *pDispatcher)=0
Create a media interface given the designated parameters.
virtual OsStatus muteMicrophone(UtlBoolean bMute)=0
Mute the microphone.
Definition: CpMediaInterfaceFactoryImpl.h:47
virtual OsStatus getConnectionIdleTimeout(int &idleTimeout) const
Get the connection idle timeout.
Definition: CpMediaInterfaceFactoryImpl.h:310
Definition: CpMediaInterfaceFactoryImpl.h:40
Definition: CpMediaInterfaceFactoryImpl.h:49
static size_t mnAllocCodecPaths
Number of slots allocated in codec path array.
Definition: CpMediaInterfaceFactoryImpl.h:367
virtual OsStatus releaseRtpPort(const int rtpPort)
Release the rtp port back to the pool of available RTP ports.
Definition: CpMediaInterfaceFactoryImpl.cpp:182
int miNextRtpPort
Definition: CpMediaInterfaceFactoryImpl.h:361
virtual ~CpMediaInterfaceFactoryImpl()
Destructor.
Definition: CpMediaInterfaceFactoryImpl.cpp:53
virtual OsStatus setRTCPName(const char *szName)
Set name send as part of RTCP reports.
Definition: CpMediaInterfaceFactoryImpl.h:160
UtlSList mlistBusyPorts
Definition: CpMediaInterfaceFactoryImpl.h:363
Definition: CpMediaInterfaceFactoryImpl.h:42
virtual OsStatus setVideoPreviewDisplay(void *pDisplay)
Set the global video preview window.
Definition: CpMediaInterfaceFactoryImpl.h:173
virtual OsStatus updateVideoPreviewWindow(void *displayContext)
Update the video preview window given the specified display context.
Definition: CpMediaInterfaceFactoryImpl.h:209
virtual OsStatus getLocalAudioConnectionId(int &connectionId) const =0
Get the connection id for the local audio connection.
UtlString mConfiguredIpAddress
Definition: CpMediaInterfaceFactoryImpl.h:365
UtlSList mlistFreePorts
Definition: CpMediaInterfaceFactoryImpl.h:362
int miStartRtpPort
Definition: CpMediaInterfaceFactoryImpl.h:359
virtual OsStatus enableOutOfBandDTMF(UtlBoolean enable)
Enable/Disable sending DTMF tones inband.
Definition: CpMediaInterfaceFactoryImpl.h:141
static UtlString * mpCodecPaths
dynamic array of paths to use when loading codecs.
Definition: CpMediaInterfaceFactoryImpl.h:369
virtual OsStatus getNextRtpPort(const char *bindAddress, int &rtpPort)
Gets the next available rtp port.
Definition: CpMediaInterfaceFactoryImpl.cpp:89
CpMediaInterfaceFactoryImpl()
Default constructor.
Definition: CpMediaInterfaceFactoryImpl.cpp:43
int miInterfaceId
Definition: CpMediaInterfaceFactoryImpl.h:357
virtual OsStatus isInBandDTMFEnabled(UtlBoolean &enabled) const
Return status of in band DTMF.
Definition: CpMediaInterfaceFactoryImpl.h:349
static OsStatus addCodecPaths(const size_t nCodecPaths, const UtlString codecPaths[])
Add directory paths to the codec search path.
Definition: CpMediaInterfaceFactoryImpl.cpp:219
virtual OsStatus getMicrophoneGain(int &iVolume) const =0
Get the microphone gain.
CpMediaInterfaceFactoryImpl & operator=(const CpMediaInterfaceFactoryImpl &rhs)
Disabled equals operator.
virtual OsStatus enableRTCP(UtlBoolean bEnable)
Enable/Disable RTCP reports.
Definition: CpMediaInterfaceFactoryImpl.h:154
Definition: CpMediaInterfaceFactoryImpl.h:61
virtual OsStatus setVideoParameters(int bitRate, int frameRate)
Set the global video parameters.
Definition: CpMediaInterfaceFactoryImpl.h:187
UtlBoolean isAddressPortBusy(const char *bindAddress, int iPort, int checkTimeMS)
Bind the the specified port and see if any data is ready to read for the designated check time...
Definition: CpMediaInterfaceFactoryImpl.cpp:280
virtual OsStatus getSpeakerDevice(UtlString &device) const =0
Get the speaker device.
virtual OsStatus setAudioNoiseReductionMode(const MEDIA_NOISE_REDUCTION_MODE mode)
Enable/Disable Noise Reduction.
Definition: CpMediaInterfaceFactoryImpl.h:127
virtual OsStatus setConnectionIdleTimeout(const int idleTimeout)
Set the connection idle timeout.
Definition: CpMediaInterfaceFactoryImpl.h:229
virtual OsStatus enableInBandDTMF(UtlBoolean enable)
Enable/Disable sending DTMF tones inband.
Definition: CpMediaInterfaceFactoryImpl.h:147
virtual OsStatus getMicrophoneDevice(UtlString &device) const =0
Get the microphone device.
virtual OsStatus setVideoBitrate(int bitrate)
Definition: CpMediaInterfaceFactoryImpl.h:192