OPAL  Version 3.10.10
call.h
Go to the documentation of this file.
1 /*
2  * call.h
3  *
4  * Telephone call management
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence 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: 28690 $
28  * $Author: rjongbloed $
29  * $Date: 2012-12-18 20:47:15 -0600 (Tue, 18 Dec 2012) $
30  */
31 
32 #ifndef OPAL_OPAL_CALL_H
33 #define OPAL_OPAL_CALL_H
34 
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38 
39 #include <opal/buildopts.h>
40 
41 #include <opal/connection.h>
42 #include <opal/recording.h>
43 #include <opal/guid.h>
44 
45 #include <ptlib/safecoll.h>
46 
47 
48 class OpalManager;
49 
50 
65 class OpalCall : public PSafeObject
66 {
67  PCLASSINFO(OpalCall, PSafeObject);
68  public:
73  OpalCall(
75  );
76 
79  ~OpalCall();
81 
88  void PrintOn(
89  ostream & strm
90  ) const;
92 
97  PBoolean IsEstablished() const { return isEstablished; }
98 
107  virtual void OnEstablishedCall();
108 
118 
122 
127  void SetCallEndReason(
129  );
130 
139  void Clear(
141  PSyncPoint * sync = NULL
142  );
143 
149  virtual void OnCleared();
151 
159  virtual void OnNewConnection(
160  OpalConnection & connection
161  );
162 
168  virtual PBoolean OnSetUp(
169  OpalConnection & connection
170  );
171 
186  virtual void OnProceeding(
187  OpalConnection & connection
188  );
189 
206  virtual PBoolean OnAlerting(
207  OpalConnection & connection
208  );
209 
227  OpalConnection & connection,
228  const PString & caller
229  );
230 
242  virtual PBoolean OnConnected(
243  OpalConnection & connection
244  );
245 
260  virtual PBoolean OnEstablished(
261  OpalConnection & connection
262  );
263 
269  virtual void OnReleased(
270  OpalConnection & connection
271  );
272 
279  virtual void OnHold(
280  OpalConnection & connection,
281  bool fromRemote,
282  bool onHold
283  );
284 
290  PSafePtr<OpalConnection> GetOtherPartyConnection(
291  const OpalConnection & connection
292  ) const;
293 
296  PSafePtr<OpalConnection> GetConnection(
297  PINDEX idx,
298  PSafetyMode mode = PSafeReference
299  ) { return connectionsActive.GetAt(idx, mode); }
300 
304  template <class ConnClass>
305  PSafePtr<ConnClass> GetConnectionAs(
306  PINDEX count = 0,
307  PSafetyMode mode = PSafeReadWrite
308  )
309  {
310  PSafePtr<ConnClass> connection;
311  for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
312  if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) {
313  if (!connection.SetSafetyMode(mode))
314  connection.SetNULL();
315  break;
316  }
317  }
318  return connection;
319  }
320 
325  bool Hold();
326 
331  bool Retrieve();
332 
337  bool IsOnHold() const;
338 
371  bool Transfer(
372  const PString & address,
373  OpalConnection * connection = NULL
374  );
376 
388  const OpalConnection & connection
389  );
390 
399  virtual void AdjustMediaFormats(
400  bool local,
401  const OpalConnection & connection,
402  OpalMediaFormatList & mediaFormats
403  ) const;
404 
414  virtual bool OpenSourceMediaStreams(
415  OpalConnection & connection,
416  const OpalMediaType & mediaType,
417  unsigned sessionID = 0,
418  const OpalMediaFormat & preselectedFormat = OpalMediaFormat()
419 #if OPAL_VIDEO
421 #endif
422  );
423 
428  virtual bool SelectMediaFormats(
429  const OpalMediaType & mediaType,
430  const OpalMediaFormatList & srcFormats,
431  const OpalMediaFormatList & dstFormats,
432  const OpalMediaFormatList & allFormats,
433  OpalMediaFormat & srcFormat,
434  OpalMediaFormat & dstFormat
435  ) const;
436 
444  virtual void OnRTPStatistics(
445  const OpalConnection & connection,
446  const RTP_Session & session
447  );
448 
451  virtual void StartMediaStreams();
452 
455  virtual void CloseMediaStreams();
456 
459  virtual PBoolean IsMediaBypassPossible(
460  const OpalConnection & connection,
461  unsigned sessionID
462  ) const;
464 
472  virtual void OnUserInputString(
473  OpalConnection & connection,
474  const PString & value
475  );
476 
485  virtual void OnUserInputTone(
486  OpalConnection & connection,
487  char tone,
488  int duration
489  );
491 
496  OpalManager & GetManager() const { return manager; }
497 
500  const PString & GetToken() const { return myToken; }
501 
506  const PString & GetPartyA() const { return m_partyA; }
507 
513  const PString & GetPartyB() const { return m_partyB; }
514 
520  void SetPartyB(
521  const PString & b
522  ) { m_partyB = b; }
523 
528  bool IsNetworkOriginated() const;
529 
532  const PTime & GetStartTime() const { return startTime; }
534 
535 #if OPAL_HAS_MIXER
536 
541  bool StartRecording(
542  const PFilePath & filename,
543  const OpalRecordManager::Options & options = false
544  );
545 
548  bool IsRecording() const;
549 
553  void StopRecording();
554 
557  virtual bool OnStartRecording(
558  const PString & streamId,
559  const OpalMediaFormat & format
560  );
561 
564  virtual void OnStopRecording(
565  const PString & streamId
566  );
567 
570  virtual void OnRecordAudio(
571  const PString & streamId,
572  const RTP_DataFrame & frame
573  );
574 
575 #if OPAL_VIDEO
576 
578  virtual void OnRecordVideo(
579  const PString & streamId,
580  const RTP_DataFrame & frame
581  );
582 #endif
583 #endif // OPAL_HAS_MIXER
584 
585  void InternalOnClear();
586 
587  void SetPartyNames();
588 
589  protected:
591  PSafePtr<OpalConnection> & connection,
592  PSafetyMode mode,
593  const OpalConnection * skipConnection = NULL
594  ) const;
595 
597 
598  PString myToken;
599 
600  PString m_partyA;
601  PString m_partyB;
602  PTime startTime;
605  PAtomicBoolean m_isCleared;
606 
608  std::list<PSyncPoint *> m_endCallSyncPoint;
609 
610  PSafeList<OpalConnection> connectionsActive;
611 
612 #if OPAL_HAS_MIXER
614 #endif
615 
616  //use to add the connection to the call's connection list
617  friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
618  //use to remove the connection from the call's connection list
620 };
621 
622 
623 #endif // OPAL_OPAL_CALL_H
624 
625 
626 // End of File ///////////////////////////////////////////////////////////////