OPAL  Version 3.18.8
sockep.h
Go to the documentation of this file.
1 /*
2  * sockep.h
3  *
4  * Media from socket endpoint.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  *
8  * Copyright (c) 2018 Vox Lucida Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open Phone Abstraction Library.
21  *
22  * The Initial Developer of the Original Code is Vox Lucdia Pty. Ltd.
23  *
24  * Contributor(s): Robert Jongbleod robertj@voxlucida.com.au.
25  */
26 
27 #ifndef OPAL_OPAL_SOCKEP_H
28 #define OPAL_OPAL_SOCKEP_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 
35 #include <opal_config.h>
36 
37 #include <ep/localep.h>
38 
39 
40 class OpalSocketConnection;
41 
42 #define OPAL_SOCK_PREFIX "sock"
43 
44 #define OPAL_OPT_SOCK_EP_AUDIO_IP "audio-ip"
45 #define OPAL_OPT_SOCK_EP_AUDIO_PORT "audio-port"
46 #define OPAL_OPT_SOCK_EP_AUDIO_PROTO "audio-proto"
47 #define OPAL_OPT_SOCK_EP_AUDIO_CODEC "audio-codec"
48 
49 #if OPAL_VIDEO
50 
51 #define OPAL_OPT_SOCK_EP_VIDEO_IP "video-ip"
52 #define OPAL_OPT_SOCK_EP_VIDEO_PORT "video-port"
53 #define OPAL_OPT_SOCK_EP_VIDEO_PROTO "video-proto"
54 #define OPAL_OPT_SOCK_EP_VIDEO_CODEC "video"
55 #define OPAL_OPT_SOCK_EP_FRAME_RATE "frame-rate"
56 
57 #endif // OPAL_VIDEO
58 
59 
64 {
66  public:
72  OpalManager & manager,
73  const char * prefix = OPAL_SOCK_PREFIX
74  );
75 
80 
112  virtual PSafePtr<OpalConnection> MakeConnection(
113  OpalCall & call,
114  const PString & party,
115  void * userData = NULL,
116  unsigned int options = 0,
117  OpalConnection::StringOptions * stringOptions = NULL
118  );
119 
120 
125  OpalCall & call,
126  void * userData,
127  unsigned options,
128  OpalConnection::StringOptions * stringOptions
129  );
131 };
132 
133 
138 {
140  public:
146  OpalCall & call,
147  OpalSockEndPoint & endpoint,
148  void * userData,
149  unsigned options = 0,
150  OpalConnection::StringOptions * stringOptions = NULL
151  );
152 
157 
170  virtual OpalMediaFormatList GetMediaFormats() const;
171 
189  virtual void OnReleased();
190 
197  virtual bool TransferConnection(
198  const PString & remoteParty
199  );
200 
206  virtual bool OnMediaCommand(
207  OpalMediaStream & stream,
208  const OpalMediaCommand & command
209  );
211 
220  virtual bool OnOutgoing();
221 
230  virtual bool OnIncoming();
231 
240  virtual bool OnReadMediaData(
241  OpalMediaStream & mediaStream,
242  void * data,
243  PINDEX size,
244  PINDEX & length
245  );
246 
264  virtual bool OnWriteMediaData(
265  const OpalMediaStream & mediaStream,
266  const void * data,
267  PINDEX length,
268  PINDEX & written
269  );
271 
272 
273 #pragma pack(1)
274 
276  struct MediaHeader {
277  uint8_t m_headerSize;
278  enum {
279  Marker = 0x01,
280  Update = 0x02,
281  Bitrate = 0x04
282  };
283  uint8_t m_flags;
284  PUInt16b m_length; // Big endian
285  };
286 
288  PUInt32b rate;
289  };
290 #pragma pack()
291 
292 
293  protected:
294  bool OpenMediaSockets();
295  bool OpenMediaSocket(
296  PIPSocket * & socket,
297  const PString & addrKey,
298  const PString & portKey,
299  const PCaselessString & protoKey
300  );
301 
303  PIPSocket * m_audioSocket;
304 #if OPAL_VIDEO
305  PIPSocket * m_videoSocket;
306  PDECLARE_MUTEX(m_writeMutex);
307 #endif
308 };
309 
310 #endif // OPAL_OPAL_SOCKEP_H
PIPSocket * m_videoSocket
Definition: sockep.h:305
Definition: manager.h:150
PDECLARE_MUTEX(m_writeMutex)
PIPSocket * m_audioSocket
Definition: sockep.h:303
virtual void OnReleased()
Definition: mediacmd.h:43
Definition: localep.h:469
uint8_t m_headerSize
Definition: sockep.h:277
virtual bool TransferConnection(const PString &remoteParty)
Definition: mediafmt.h:112
virtual bool OnOutgoing()
uint8_t m_flags
Definition: sockep.h:283
Definition: connection.h:530
OpalSockEndPoint(OpalManager &manager, const char *prefix=OPAL_SOCK_PREFIX)
Definition: localep.h:63
Definition: call.h:62
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)
#define OPAL_SOCK_PREFIX
Definition: sockep.h:42
Definition: sockep.h:137
virtual OpalMediaFormatList GetMediaFormats() const
bool OpenMediaSocket(PIPSocket *&socket, const PString &addrKey, const PString &portKey, const PCaselessString &protoKey)
Definition: sockep.h:276
virtual bool OnWriteMediaData(const OpalMediaStream &mediaStream, const void *data, PINDEX length, PINDEX &written)
OpalSockEndPoint & m_endpoint
Definition: sockep.h:302
Definition: mediastrm.h:110
Definition: sockep.h:63
virtual bool OnReadMediaData(OpalMediaStream &mediaStream, void *data, PINDEX size, PINDEX &length)
virtual bool OnMediaCommand(OpalMediaStream &stream, const OpalMediaCommand &command)
PUInt16b m_length
Definition: sockep.h:284
Definition: sockep.h:287
virtual bool OnIncoming()
PUInt32b rate
Definition: sockep.h:288
OpalSockConnection(OpalCall &call, OpalSockEndPoint &endpoint, void *userData, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
virtual OpalLocalConnection * CreateConnection(OpalCall &call, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions)