OPAL  Version 3.18.8
localep.h
Go to the documentation of this file.
1 /*
2  * localep.h
3  *
4  * Local EndPoint/Connection.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2008 Vox Lucida Pty. Ltd.
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 Equivalence Pty. Ltd.
24  *
25  * Contributor(s): ______________________________________.
26  */
27 
28 #ifndef OPAL_OPAL_LOCALEP_H
29 #define OPAL_OPAL_LOCALEP_H
30 
31 #ifdef P_USE_PRAGMA
32 #pragma interface
33 #endif
34 
35 #include <opal_config.h>
36 
37 #include <opal/endpoint.h>
38 
39 
41 class OpalH224Handler;
43 
44 
45 #define OPAL_LOCAL_PREFIX "local"
46 
56 #define OPAL_OPT_EXPLICIT_ALERTING "Explicit-Alerting"
57 
58 
64 {
65  PCLASSINFO(OpalLocalEndPoint, OpalEndPoint);
66  public:
72  OpalManager & manager,
73  const char * prefix = OPAL_LOCAL_PREFIX,
74  bool useCallbacks = true
75  );
76 
81 
94  virtual OpalMediaFormatList GetMediaFormats() const;
95 
125  virtual PSafePtr<OpalConnection> MakeConnection(
126  OpalCall & call,
127  const PString & party,
128  void * userData = NULL,
129  unsigned int options = 0,
130  OpalConnection::StringOptions * stringOptions = NULL
131  );
133 
142  PSafePtr<OpalLocalConnection> GetLocalConnectionWithLock(
143  const PString & token,
144  PSafetyMode mode = PSafeReadWrite
145  ) { return GetConnectionWithLockAs<OpalLocalConnection>(token, mode); }
146 
151  OpalCall & call,
152  void * userData,
153  unsigned options,
154  OpalConnection::StringOptions * stringOptions
155  );
156 
162  virtual bool OnOutgoingSetUp(
163  const OpalLocalConnection & connection
164  );
165 
171  virtual bool OnOutgoingCall(
172  const OpalLocalConnection & connection
173  );
174 
183  virtual bool OnIncomingCall(
184  OpalLocalConnection & connection
185  );
186 
191  virtual bool AlertingIncomingCall(
192  const PString & token,
193  OpalConnection::StringOptions * options = NULL,
194  bool withMedia = false
195  );
196 
201  virtual bool AcceptIncomingCall(
202  const PString & token,
203  OpalConnection::StringOptions * options = NULL
204  );
205 
210  virtual bool RejectIncomingCall(
211  const PString & token,
212  const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied
213  );
214 
220  virtual bool OnUserInput(
221  const OpalLocalConnection & connection,
222  const PString & indication
223  );
225 
228  P_DECLARE_BITWISE_ENUM(CallbackUsage, 2, (NoCallbacks, UseSourceCallback, UseSinkCallback));
230 
232  typedef map<OpalMediaType, CallbackUsage> CallbackMap;
233 
235  bool UseCallback(
236  const OpalMediaFormat & mediaFormat,
237  bool isSource
238  ) const;
239 
241  bool SetCallbackUsage(
242  const OpalMediaType & mediaType,
243  CallbackUsage usage
244  );
245 
254  virtual bool OnReadMediaFrame(
255  const OpalLocalConnection & connection,
256  const OpalMediaStream & mediaStream,
257  RTP_DataFrame & frame
258  );
259 
271  virtual bool OnWriteMediaFrame(
272  const OpalLocalConnection & connection,
273  const OpalMediaStream & mediaStream,
274  RTP_DataFrame & frame
275  );
276 
285  virtual bool OnReadMediaData(
286  OpalLocalConnection & connection,
287  OpalMediaStream & mediaStream,
288  void * data,
289  PINDEX size,
290  PINDEX & length
291  );
292 
310  virtual bool OnWriteMediaData(
311  const OpalLocalConnection & connection,
312  const OpalMediaStream & mediaStream,
313  const void * data,
314  PINDEX length,
315  PINDEX & written
316  );
317 
318 #if OPAL_VIDEO
319 
321  virtual bool CreateVideoInputDevice(
322  const OpalConnection & connection,
323  const OpalMediaFormat & mediaFormat,
324  PVideoInputDevice * & device,
325  bool & autoDelete
326  );
327 
331  virtual bool CreateVideoOutputDevice(
332  const OpalConnection & connection,
333  const OpalMediaFormat & mediaFormat,
334  bool preview,
335  PVideoOutputDevice * & device,
336  bool & autoDelete
337  );
338 #endif
339 
365  };
366 
376  const OpalMediaFormat & mediaFormat,
377  bool isSource
378  ) const;
380 
386 
390 
391 #if OPAL_VIDEO
392 
395 
399 #endif // OPAL_VIDEO
400 
403  bool IsDeferredAlerting() const { return m_deferredAlerting; }
404 
407  void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
408 
411  bool IsDeferredAnswer() const { return m_deferredAnswer; }
412 
415  void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
416 
421 
426 
427 #if OPAL_HAS_H281
428  void SetFarEndCameraCapabilityChangedNotifier(const PNotifier & notifier) { m_farEndCameraCapabilityChangedNotifier = notifier; }
430 
433 
435  void SetFarEndCameraActionNotifier(const PNotifier & notifier) { m_farEndCameraActionNotifier = notifier; }
436 
438  const PNotifier & GetFarEndCameraActionNotifier() const { return m_farEndCameraActionNotifier; }
439 #endif // OPAL_HAS_H281
440 
441 
442  protected:
446 
448 
450 #if OPAL_VIDEO
452 #endif // OPAL_VIDEO
453 
454 #if OPAL_HAS_H281
457 #endif // OPAL_HAS_H281
458 
459  private:
460  P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
461  P_REMOVE_VIRTUAL(bool, IsSynchronous() const, false);
462 };
463 
464 
470 {
471  PCLASSINFO(OpalLocalConnection, OpalConnection);
472  public:
478  OpalCall & call,
479  OpalLocalEndPoint & endpoint,
480  void * userData,
481  unsigned options,
482  OpalConnection::StringOptions * stringOptions,
483  char tokenPrefix = 'L'
484  );
485 
490 
518  virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
519 
528  virtual PBoolean IsNetworkConnection() const { return false; }
529 
531  virtual void OnApplyStringOptions();
532 
542  virtual PBoolean SetUpConnection();
543 
554  virtual PBoolean SetAlerting(
555  const PString & calleeName,
556  PBoolean withMedia
557  );
558 
569  virtual PBoolean SetConnected();
570 
585  virtual bool HoldRemote(
586  bool placeOnHold
587  );
588 
604  const OpalMediaFormat & mediaFormat,
605  unsigned sessionID,
606  PBoolean isSource
607  );
608 
613  virtual void OnClosedMediaStream(
614  const OpalMediaStream & stream
615  );
616 
624  virtual PBoolean SendUserInputString(
625  const PString & value
626  );
628 
637  virtual bool OnOutgoingSetUp();
638 
645  virtual bool OnOutgoing();
646 
655  virtual bool OnIncoming();
656 
659  virtual void AlertingIncoming(
660  bool withMedia = false
661  );
662 
665  virtual void AcceptIncoming();
666 
667 
678  virtual bool OnReadMediaFrame(
679  const OpalMediaStream & mediaStream,
680  RTP_DataFrame & frame
681  );
682 
694  virtual bool OnWriteMediaFrame(
695  const OpalMediaStream & mediaStream,
696  RTP_DataFrame & frame
697  );
698 
707  virtual bool OnReadMediaData(
708  OpalMediaStream & mediaStream,
709  void * data,
710  PINDEX size,
711  PINDEX & length
712  );
713 
731  virtual bool OnWriteMediaData(
732  const OpalMediaStream & mediaStream,
733  const void * data,
734  PINDEX length,
735  PINDEX & written
736  );
737 
747  const OpalMediaFormat & mediaFormat,
748  bool isSource
749  ) const;
750 
751 #if OPAL_VIDEO
752 
754  virtual bool CreateVideoInputDevice(
755  const OpalMediaFormat & mediaFormat,
756  PVideoInputDevice * & device,
757  bool & autoDelete
758  );
759 
763  virtual bool CreateVideoOutputDevice(
764  const OpalMediaFormat & mediaFormat,
765  bool preview,
766  PVideoOutputDevice * & device,
767  bool & autoDelete
768  );
769 
772  virtual bool ChangeVideoInputDevice(
773  const PVideoDevice::OpenArgs & device,
774  unsigned sessionID = 0
775  );
776 
780  virtual bool ChangeVideoOutputDevice(
781  const PVideoDevice::OpenArgs & device,
782  unsigned sessionID = 0,
783  bool preview = false
784  );
785 #endif // OPAL_VIDEO
786 
787 #if OPAL_HAS_H281
788 
803  bool FarEndCameraControl(
804  PVideoControlInfo::Types what,
805  int direction = 0,
806  const PTimeInterval & duration = 0
807  );
808 
810  void SetFarEndCameraCapabilityChangedNotifier(const PNotifier & notifier);
811 
813  void SetFarEndCameraActionNotifier(const PNotifier & notifier);
814 #endif // OPAL_HAS_H281
815 
816 
819  void * GetUserData() const { return m_userData; }
821 
823  void SetUserData(void * v) { m_userData = v; }
825 
826  protected:
827  friend class PSafeWorkNoArg<OpalLocalConnection>;
828  void InternalAcceptIncoming();
829 
831  void * m_userData;
832 
833 #if OPAL_HAS_H224
835 #endif
836 #if OPAL_HAS_H281
838 #endif
839 };
840 
841 
847 {
849  public:
855  OpalLocalConnection & conn,
856  const OpalMediaFormat & mediaFormat,
857  unsigned sessionID,
858  bool isSource,
859  OpalLocalEndPoint::Synchronicity synchronicity
860  );
862 
870  virtual PBoolean ReadPacket(
871  RTP_DataFrame & packet
872  );
873 
879  virtual PBoolean WritePacket(
880  RTP_DataFrame & packet
881  );
882 
886  virtual PBoolean ReadData(
887  BYTE * data,
888  PINDEX size,
889  PINDEX & length
890  );
891 
895  virtual PBoolean WriteData(
896  const BYTE * data,
897  PINDEX length,
898  PINDEX & written
899  );
900 
904  virtual PBoolean IsSynchronous() const;
906 
907  protected:
908  virtual void InternalClose() { }
909 
912  PBYTEArray m_silence;
913  PTRACE_THROTTLE(m_readLogThrottle, 3, 60000, 5);
914  PTRACE_THROTTLE(m_writeLogThrottle, 3, 60000, 5);
915 };
916 
917 
918 #endif // OPAL_OPAL_LOCALEP_H
919 
920 
921 // End of File ///////////////////////////////////////////////////////////////
virtual void OnClosedMediaStream(const OpalMediaStream &stream)
virtual PBoolean SetAlerting(const PString &calleeName, PBoolean withMedia)
Functions will block for correct real time.
Definition: localep.h:362
void SetDefaultVideoSourceSynchronicity(Synchronicity sync)
Definition: localep.h:398
#define OPAL_LOCAL_PREFIX
Definition: localep.h:45
Definition: manager.h:150
Definition: endpoint.h:65
OpalLocalMediaStream(OpalLocalConnection &conn, const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource, OpalLocalEndPoint::Synchronicity synchronicity)
bool IsDeferredAlerting() const
Definition: localep.h:403
Definition: h224handler.h:130
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
virtual bool OnReadMediaFrame(const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
void SetFarEndCameraCapabilityChangedNotifier(const PNotifier &notifier)
Set a callback for when the far end camera control capabilities change.
Synchronicity
Definition: localep.h:361
OpalLocalEndPoint::Synchronicity m_synchronicity
Definition: localep.h:911
virtual bool OnWriteMediaData(const OpalLocalConnection &connection, const OpalMediaStream &mediaStream, const void *data, PINDEX length, PINDEX &written)
virtual void OnApplyStringOptions()
Call back for connection to act on changed string options.
OpalLocalConnection(OpalCall &call, OpalLocalEndPoint &endpoint, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions, char tokenPrefix= 'L')
map< OpalMediaType, CallbackUsage > CallbackMap
Map for indicating if a media type is to use callback virtual functions.
Definition: localep.h:232
PSafePtr< OpalLocalConnection > GetLocalConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: localep.h:142
Definition: localep.h:469
bool IsDeferredAnswer() const
Definition: localep.h:411
void SetDeferredAlerting(bool defer)
Definition: localep.h:407
void SetPauseTransmitMediaOnHold(bool pause)
Definition: localep.h:425
virtual bool OnReadMediaFrame(const OpalLocalConnection &connection, const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
PNotifier m_farEndCameraActionNotifier
Definition: localep.h:456
virtual bool HoldRemote(bool placeOnHold)
Definition: mediatype.h:66
virtual void AlertingIncoming(bool withMedia=false)
void SetFarEndCameraActionNotifier(const PNotifier &notifier)
Set a callback for when a far end camera control action comes from remote.
P_DECLARE_BITWISE_ENUM(CallbackUsage, 2,(NoCallbacks, UseSourceCallback, UseSinkCallback))
Enumeration for usage of media callback direction in CallbackMap.
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)
Definition: localep.h:846
OpalLocalEndPoint & m_endpoint
Definition: localep.h:830
virtual bool RejectIncomingCall(const PString &token, const OpalConnection::CallEndReason &reason=OpalConnection::EndedByAnswerDenied)
Definition: h281handler.h:228
OpalLocalEndPoint(OpalManager &manager, const char *prefix=OPAL_LOCAL_PREFIX, bool useCallbacks=true)
OpalFarEndCameraControl * m_farEndCameraControl
Definition: localep.h:837
virtual bool OnReadMediaData(OpalLocalConnection &connection, OpalMediaStream &mediaStream, void *data, PINDEX size, PINDEX &length)
void SetUserData(void *v)
Set user data pointer.
Definition: localep.h:823
virtual PBoolean IsNetworkConnection() const
Definition: localep.h:528
PTRACE_THROTTLE(m_readLogThrottle, 3, 60000, 5)
PNotifier m_farEndCameraCapabilityChangedNotifier
Definition: localep.h:455
virtual bool OnIncomingCall(OpalLocalConnection &connection)
virtual bool ChangeVideoOutputDevice(const PVideoDevice::OpenArgs &device, unsigned sessionID=0, bool preview=false)
Definition: mediafmt.h:112
Synchronicity m_defaultAudioSynchronicity
Definition: localep.h:449
virtual bool CreateVideoOutputDevice(const OpalMediaFormat &mediaFormat, bool preview, PVideoOutputDevice *&device, bool &autoDelete)
Definition: connection.h:530
Functions will not block, and do not require any real time handling.
Definition: localep.h:363
virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions *stringOptions)
PBYTEArray m_silence
Definition: localep.h:912
Definition: rtp.h:540
Definition: localep.h:63
bool UseCallback(const OpalMediaFormat &mediaFormat, bool isSource) const
Indicate media type and direction is to use virtual callback functions.
virtual PBoolean SetUpConnection()
Definition: mediafmt.h:806
virtual bool AlertingIncomingCall(const PString &token, OpalConnection::StringOptions *options=NULL, bool withMedia=false)
void SetDeferredAnswer(bool defer)
Definition: localep.h:415
virtual PBoolean WritePacket(RTP_DataFrame &packet)
void * m_userData
Definition: localep.h:831
Definition: call.h:62
CallbackMap m_useCallback
Definition: localep.h:447
virtual bool OnReadMediaData(OpalMediaStream &mediaStream, void *data, PINDEX size, PINDEX &length)
bool m_pauseTransmitMediaOnHold
Definition: localep.h:445
virtual OpalMediaFormatList GetMediaFormats() const
virtual bool OnWriteMediaFrame(const OpalLocalConnection &connection, const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
void SetFarEndCameraActionNotifier(const PNotifier &notifier)
Set a callback for when a far end camera control action comes from remote.
Definition: localep.h:435
virtual bool ChangeVideoInputDevice(const PVideoDevice::OpenArgs &device, unsigned sessionID=0)
virtual OpalLocalEndPoint::Synchronicity GetSynchronicity(const OpalMediaFormat &mediaFormat, bool isSource) const
const PNotifier & GetFarEndCameraActionNotifier() const
Get a callback for when a far end camera control action comes from remote.
Definition: localep.h:438
virtual bool CreateVideoInputDevice(const OpalConnection &connection, const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, bool &autoDelete)
Definition: mediastrm.h:498
void SetFarEndCameraCapabilityChangedNotifier(const PNotifier &notifier)
Set a callback for when the far end camera control capabilities change.
Definition: localep.h:429
virtual bool OnIncoming()
bool FarEndCameraControl(PVideoControlInfo::Types what, int direction=0, const PTimeInterval &duration=0)
virtual PBoolean SetConnected()
OpalH224Handler * m_h224Handler
Definition: localep.h:834
virtual PBoolean SendUserInputString(const PString &value)
Definition: connection.h:462
virtual bool OnOutgoingSetUp()
virtual void InternalClose()
Definition: localep.h:908
virtual bool OnWriteMediaData(const OpalMediaStream &mediaStream, const void *data, PINDEX length, PINDEX &written)
virtual bool OnOutgoing()
virtual PBoolean IsSynchronous() const
bool m_deferredAnswer
Definition: localep.h:444
Definition: mediastrm.h:110
virtual bool OnOutgoingSetUp(const OpalLocalConnection &connection)
const PNotifier & GetFarEndCameraCapabilityChangedNotifier() const
Get a callback for when the far end camera control capabilities change.
Definition: localep.h:432
void SetDefaultAudioSynchronicity(Synchronicity sync)
Definition: localep.h:389
virtual bool OnOutgoingCall(const OpalLocalConnection &connection)
Synchronicity GetDefaultAudioSynchronicity() const
Definition: localep.h:385
Definition: connection.h:415
OpalLocalConnection & m_connection
Definition: localep.h:910
virtual OpalLocalConnection * CreateConnection(OpalCall &call, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions)
virtual PBoolean WriteData(const BYTE *data, PINDEX length, PINDEX &written)
virtual bool OnUserInput(const OpalLocalConnection &connection, const PString &indication)
virtual PBoolean ReadPacket(RTP_DataFrame &packet)
bool m_deferredAlerting
Definition: localep.h:443
void InternalAcceptIncoming()
Synchronicity GetDefaultVideoSourceSynchronicity() const
Definition: localep.h:394
virtual bool CreateVideoInputDevice(const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, bool &autoDelete)
Synchronicity m_defaultVideoSourceSynchronicity
Definition: localep.h:451
virtual Synchronicity GetSynchronicity(const OpalMediaFormat &mediaFormat, bool isSource) const
virtual PBoolean ReadData(BYTE *data, PINDEX size, PINDEX &length)
bool SetCallbackUsage(const OpalMediaType &mediaType, CallbackUsage usage)
Set callback usage for media type.
virtual bool OnWriteMediaFrame(const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
virtual bool AcceptIncomingCall(const PString &token, OpalConnection::StringOptions *options=NULL)
Functions wlll not block, but do require real time handling.
Definition: localep.h:364
void * GetUserData() const
Get user data pointer.
Definition: localep.h:820
virtual void AcceptIncoming()
virtual bool CreateVideoOutputDevice(const OpalConnection &connection, const OpalMediaFormat &mediaFormat, bool preview, PVideoOutputDevice *&device, bool &autoDelete)
bool WillPauseTransmitMediaOnHold() const
Definition: localep.h:420