OPAL  Version 3.14.3
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  * $Revision: 32531 $
28  * $Author: rjongbloed $
29  * $Date: 2014-08-15 14:46:03 +1000 (Fri, 15 Aug 2014) $
30  */
31 
32 #ifndef OPAL_OPAL_LOCALEP_H
33 #define OPAL_OPAL_LOCALEP_H
34 
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38 
39 #include <opal_config.h>
40 
41 #include <opal/endpoint.h>
42 
43 
45 class OpalH224Handler;
47 
48 
49 #define OPAL_LOCAL_PREFIX "local"
50 
51 
57 {
58  PCLASSINFO(OpalLocalEndPoint, OpalEndPoint);
59  public:
66  const char * prefix = OPAL_LOCAL_PREFIX,
67  bool useCallbacks = true
68  );
69 
74 
87  virtual OpalMediaFormatList GetMediaFormats() const;
88 
118  virtual PSafePtr<OpalConnection> MakeConnection(
119  OpalCall & call,
120  const PString & party,
121  void * userData = NULL,
122  unsigned int options = 0,
123  OpalConnection::StringOptions * stringOptions = NULL
124  );
126 
135  PSafePtr<OpalLocalConnection> GetLocalConnectionWithLock(
136  const PString & token,
137  PSafetyMode mode = PSafeReadWrite
138  ) { return GetConnectionWithLockAs<OpalLocalConnection>(token, mode); }
139 
144  OpalCall & call,
145  void * userData,
146  unsigned options,
147  OpalConnection::StringOptions * stringOptions
148  );
149 
155  virtual bool OnOutgoingSetUp(
156  const OpalLocalConnection & connection
157  );
158 
164  virtual bool OnOutgoingCall(
165  const OpalLocalConnection & connection
166  );
167 
176  virtual bool OnIncomingCall(
177  OpalLocalConnection & connection
178  );
179 
184  virtual bool AlertingIncomingCall(
185  const PString & token,
186  OpalConnection::StringOptions * options = NULL,
187  bool withMedia = false
188  );
189 
194  virtual bool AcceptIncomingCall(
195  const PString & token,
196  OpalConnection::StringOptions * options = NULL
197  );
198 
203  virtual bool RejectIncomingCall(
204  const PString & token,
205  const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied
206  );
207 
213  virtual bool OnUserInput(
214  const OpalLocalConnection & connection,
215  const PString & indication
216  );
218 
221 
222  P_DECLARE_BITWISE_ENUM(CallbackUsage, 2, (NoCallbacks, UseSourceCallback, UseSinkCallback));
223 
225  typedef map<OpalMediaType, CallbackUsage> CallbackMap;
226 
228  bool UseCallback(
229  const OpalMediaFormat & mediaFormat,
230  bool isSource
231  ) const;
232 
234  bool SetCallbackUsage(
235  const OpalMediaType & mediaType,
236  CallbackUsage usage
237  );
238 
247  virtual bool OnReadMediaFrame(
248  const OpalLocalConnection & connection,
249  const OpalMediaStream & mediaStream,
250  RTP_DataFrame & frame
251  );
252 
264  virtual bool OnWriteMediaFrame(
265  const OpalLocalConnection & connection,
266  const OpalMediaStream & mediaStream,
267  RTP_DataFrame & frame
268  );
269 
278  virtual bool OnReadMediaData(
279  const OpalLocalConnection & connection,
280  const OpalMediaStream & mediaStream,
281  void * data,
282  PINDEX size,
283  PINDEX & length
284  );
285 
303  virtual bool OnWriteMediaData(
304  const OpalLocalConnection & connection,
305  const OpalMediaStream & mediaStream,
306  const void * data,
307  PINDEX length,
308  PINDEX & written
309  );
310 
311 #if OPAL_VIDEO
312 
314  virtual bool CreateVideoInputDevice(
315  const OpalConnection & connection,
316  const OpalMediaFormat & mediaFormat,
317  PVideoInputDevice * & device,
318  bool & autoDelete
319  );
320 
324  virtual bool CreateVideoOutputDevice(
325  const OpalConnection & connection,
326  const OpalMediaFormat & mediaFormat,
327  bool preview,
328  PVideoOutputDevice * & device,
329  bool & autoDelete
330  );
331 #endif
332 
358  };
359 
369  const OpalMediaFormat & mediaFormat,
370  bool isSource
371  ) const;
373 
379 
383 
387 
391 
394  bool IsDeferredAlerting() const { return m_deferredAlerting; }
395 
398  void SetDeferredAlerting(bool defer) { m_deferredAlerting = defer; }
399 
402  bool IsDeferredAnswer() const { return m_deferredAnswer; }
403 
406  void SetDeferredAnswer(bool defer) { m_deferredAnswer = defer; }
407 
412 
417 
418 #if OPAL_HAS_H281
419 
421 
424 
426  void SetFarEndCameraActionNotifier(const PNotifier & notifier) { m_farEndCameraActionNotifier = notifier; }
427 
429  const PNotifier & GetFarEndCameraActionNotifier() const { return m_farEndCameraActionNotifier; }
430 #endif // OPAL_HAS_H281
431 
432 
433  protected:
437 
439 
442 
443 #if OPAL_HAS_H281
446 #endif // OPAL_HAS_H281
447 
448  private:
449  P_REMOVE_VIRTUAL(OpalLocalConnection *, CreateConnection(OpalCall &, void *), 0);
450  P_REMOVE_VIRTUAL(bool, IsSynchronous() const, false);
451 };
452 
453 
459 {
460  PCLASSINFO(OpalLocalConnection, OpalConnection);
461  public:
467  OpalCall & call,
469  void * userData,
470  unsigned options,
471  OpalConnection::StringOptions * stringOptions,
472  char tokenPrefix = 'L'
473  );
474 
479 
507  virtual PBoolean OnIncomingConnection(unsigned int options, OpalConnection::StringOptions * stringOptions);
508 
517  virtual PBoolean IsNetworkConnection() const { return false; }
518 
520  virtual void OnApplyStringOptions();
521 
531  virtual PBoolean SetUpConnection();
532 
543  virtual PBoolean SetAlerting(
544  const PString & calleeName,
545  PBoolean withMedia
546  );
547 
558  virtual PBoolean SetConnected();
559 
574  virtual bool HoldRemote(
575  bool placeOnHold
576  );
577 
593  const OpalMediaFormat & mediaFormat,
594  unsigned sessionID,
595  PBoolean isSource
596  );
597 
601  const OpalMediaFormat & mediaFormat,
602  unsigned sessionID,
603  bool isSource
604  );
605 
610  virtual void OnClosedMediaStream(
611  const OpalMediaStream & stream
612  );
613 
621  virtual PBoolean SendUserInputString(
622  const PString & value
623  );
625 
634  virtual bool OnOutgoingSetUp();
635 
642  virtual bool OnOutgoing();
643 
652  virtual bool OnIncoming();
653 
656  virtual void AlertingIncoming(
657  bool withMedia = false
658  );
659 
662  virtual void AcceptIncoming();
663 
664 
675  virtual bool OnReadMediaFrame(
676  const OpalMediaStream & mediaStream,
677  RTP_DataFrame & frame
678  );
679 
691  virtual bool OnWriteMediaFrame(
692  const OpalMediaStream & mediaStream,
693  RTP_DataFrame & frame
694  );
695 
704  virtual bool OnReadMediaData(
705  const OpalMediaStream & mediaStream,
706  void * data,
707  PINDEX size,
708  PINDEX & length
709  );
710 
728  virtual bool OnWriteMediaData(
729  const OpalMediaStream & mediaStream,
730  const void * data,
731  PINDEX length,
732  PINDEX & written
733  );
734 
744  const OpalMediaFormat & mediaFormat,
745  bool isSource
746  ) const;
747 
748 #if OPAL_VIDEO
749 
751  virtual bool CreateVideoInputDevice(
752  const OpalMediaFormat & mediaFormat,
753  PVideoInputDevice * & device,
754  bool & autoDelete
755  );
756 
760  virtual bool CreateVideoOutputDevice(
761  const OpalMediaFormat & mediaFormat,
762  bool preview,
763  PVideoOutputDevice * & device,
764  bool & autoDelete
765  );
766 
769  virtual bool ChangeVideoInputDevice(
770  const PVideoDevice::OpenArgs & device,
771  unsigned sessionID = 0
772  );
773 
777  virtual bool ChangeVideoOutputDevice(
778  const PVideoDevice::OpenArgs & device,
779  unsigned sessionID = 0,
780  bool preview = false
781  );
782 #endif // OPAL_VIDEO
783 
784 #if OPAL_HAS_H281
785 
800  bool FarEndCameraControl(
801  PVideoControlInfo::Types what,
802  int direction = 0,
803  const PTimeInterval & duration = 0
804  );
805 
807  void SetFarEndCameraCapabilityChangedNotifier(const PNotifier & notifier);
808 
810  void SetFarEndCameraActionNotifier(const PNotifier & notifier);
811 #endif // OPAL_HAS_H281
812 
813 
816 
817  void * GetUserData() const { return m_userData; }
818 
820  void SetUserData(void * v) { m_userData = v; }
822 
823  protected:
824  friend class PSafeWorkNoArg<OpalLocalConnection>;
825  void InternalAcceptIncoming();
826 
828  void * m_userData;
829 
830 #if OPAL_HAS_H224
832 #endif
833 #if OPAL_HAS_H281
835 #endif
836 };
837 
838 
844 {
846  public:
852  OpalLocalConnection & conn,
853  const OpalMediaFormat & mediaFormat,
854  unsigned sessionID,
855  bool isSource,
856  OpalLocalEndPoint::Synchronicity synchronicity
857  );
859 
867  virtual PBoolean ReadPacket(
868  RTP_DataFrame & packet
869  );
870 
876  virtual PBoolean WritePacket(
877  RTP_DataFrame & packet
878  );
879 
883  virtual PBoolean ReadData(
884  BYTE * data,
885  PINDEX size,
886  PINDEX & length
887  );
888 
892  virtual PBoolean WriteData(
893  const BYTE * data,
894  PINDEX length,
895  PINDEX & written
896  );
897 
901  virtual PBoolean IsSynchronous() const;
903 
904  protected:
905  virtual void InternalClose() { }
906 
909  PBYTEArray m_silence;
910 };
911 
912 
913 #endif // OPAL_OPAL_LOCALEP_H
914 
915 
916 // End of File ///////////////////////////////////////////////////////////////