OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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: 25336 $
28 * $Author: rjongbloed $
29 * $Date: 2011-03-16 03:51:39 -0500 (Wed, 16 Mar 2011) $
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(
74 OpalManager & manager
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
117 OpalConnection::CallEndReason GetCallEndReason() const { return callEndReason; }
118
121 PString GetCallEndReasonText() const { return OpalConnection::GetCallEndReasonText(callEndReason); }
122
127 void SetCallEndReason(
128 OpalConnection::CallEndReason reason
129 );
130
139 void Clear(
140 OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
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
226 virtual OpalConnection::AnswerCallResponse OnAnswerCall(
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
387 virtual OpalMediaFormatList GetMediaFormats(
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
420 , OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole
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 protected:
588 void SetPartyNames();
589
590 bool EnumerateConnections(
591 PSafePtr<OpalConnection> & connection,
592 PSafetyMode mode,
593 const OpalConnection * skipConnection = NULL
594 ) const;
595
596 OpalManager & manager;
597
598 PString myToken;
599
600 PString m_partyA;
601 PString m_partyB;
602 PTime startTime;
603 bool isEstablished;
604 bool isClearing;
605
606 OpalConnection::CallEndReason callEndReason;
607 PSyncPoint * endCallSyncPoint;
608
609 PSafeList<OpalConnection> connectionsActive;
610
611 #if OPAL_HAS_MIXER
612 OpalRecordManager * m_recordManager;
613 #endif
614
615 //use to add the connection to the call's connection list
616 friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
617 //use to remove the connection from the call's connection list
618 friend OpalConnection::~OpalConnection();
619 };
620
621
622 #endif // OPAL_OPAL_CALL_H
623
624
625 // End of File ///////////////////////////////////////////////////////////////