call.h
Go to the documentation of this file.
/*
* call.h
*
* Telephone call management
*
* Open Phone Abstraction Library (OPAL)
* Formally known as the Open H323 project.
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 28690 $
* $Author: rjongbloed $
* $Date: 2012-12-18 20:47:15 -0600 (Tue, 18 Dec 2012) $
*/
#ifndef OPAL_OPAL_CALL_H
#define OPAL_OPAL_CALL_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#include <opal/connection.h>
#include <opal/recording.h>
#include <opal/guid.h>
#include <ptlib/safecoll.h>
class OpalManager;
class OpalCall : public PSafeObject
{
PCLASSINFO(OpalCall, PSafeObject);
public:
OpalCall(
OpalManager & manager
);
~OpalCall();
void PrintOn(
ostream & strm
) const;
PBoolean IsEstablished() const { return isEstablished; }
virtual void OnEstablishedCall();
OpalConnection::CallEndReason GetCallEndReason() const { return callEndReason; }
PString GetCallEndReasonText() const { return OpalConnection::GetCallEndReasonText(callEndReason); }
void SetCallEndReason(
OpalConnection::CallEndReason reason
);
void Clear(
OpalConnection::CallEndReason reason = OpalConnection::EndedByLocalUser,
PSyncPoint * sync = NULL
);
virtual void OnCleared();
virtual void OnNewConnection(
OpalConnection & connection
);
virtual PBoolean OnSetUp(
OpalConnection & connection
);
virtual void OnProceeding(
OpalConnection & connection
);
virtual PBoolean OnAlerting(
OpalConnection & connection
);
virtual OpalConnection::AnswerCallResponse OnAnswerCall(
OpalConnection & connection,
const PString & caller
);
virtual PBoolean OnConnected(
OpalConnection & connection
);
virtual PBoolean OnEstablished(
OpalConnection & connection
);
virtual void OnReleased(
OpalConnection & connection
);
virtual void OnHold(
OpalConnection & connection,
bool fromRemote,
bool onHold
);
PSafePtr<OpalConnection> GetOtherPartyConnection(
const OpalConnection & connection
) const;
PSafePtr<OpalConnection> GetConnection(
PINDEX idx,
PSafetyMode mode = PSafeReference
) { return connectionsActive.GetAt(idx, mode); }
template <class ConnClass>
PSafePtr<ConnClass> GetConnectionAs(
PINDEX count = 0,
PSafetyMode mode = PSafeReadWrite
)
{
PSafePtr<ConnClass> connection;
for (PSafePtr<OpalConnection> iterConn(connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
if ((connection = PSafePtrCast<OpalConnection, ConnClass>(iterConn)) != NULL && count-- == 0) {
if (!connection.SetSafetyMode(mode))
connection.SetNULL();
break;
}
}
return connection;
}
bool Hold();
bool Retrieve();
bool IsOnHold() const;
bool Transfer(
const PString & address,
OpalConnection * connection = NULL
);
virtual OpalMediaFormatList GetMediaFormats(
const OpalConnection & connection
);
virtual void AdjustMediaFormats(
bool local,
const OpalConnection & connection,
OpalMediaFormatList & mediaFormats
) const;
virtual bool OpenSourceMediaStreams(
OpalConnection & connection,
const OpalMediaType & mediaType,
unsigned sessionID = 0,
const OpalMediaFormat & preselectedFormat = OpalMediaFormat()
#if OPAL_VIDEO
, OpalVideoFormat::ContentRole contentRole = OpalVideoFormat::eNoRole
#endif
);
virtual bool SelectMediaFormats(
const OpalMediaType & mediaType,
const OpalMediaFormatList & srcFormats,
const OpalMediaFormatList & dstFormats,
const OpalMediaFormatList & allFormats,
OpalMediaFormat & srcFormat,
OpalMediaFormat & dstFormat
) const;
virtual void OnRTPStatistics(
const OpalConnection & connection,
const RTP_Session & session
);
virtual void StartMediaStreams();
virtual void CloseMediaStreams();
virtual PBoolean IsMediaBypassPossible(
const OpalConnection & connection,
unsigned sessionID
) const;
virtual void OnUserInputString(
OpalConnection & connection,
const PString & value
);
virtual void OnUserInputTone(
OpalConnection & connection,
char tone,
int duration
);
OpalManager & GetManager() const { return manager; }
const PString & GetToken() const { return myToken; }
const PString & GetPartyA() const { return m_partyA; }
const PString & GetPartyB() const { return m_partyB; }
void SetPartyB(
const PString & b
) { m_partyB = b; }
bool IsNetworkOriginated() const;
const PTime & GetStartTime() const { return startTime; }
#if OPAL_HAS_MIXER
bool StartRecording(
const PFilePath & filename,
const OpalRecordManager::Options & options = false
);
bool IsRecording() const;
void StopRecording();
virtual bool OnStartRecording(
const PString & streamId,
const OpalMediaFormat & format
);
virtual void OnStopRecording(
const PString & streamId
);
virtual void OnRecordAudio(
const PString & streamId,
const RTP_DataFrame & frame
);
#if OPAL_VIDEO
virtual void OnRecordVideo(
const PString & streamId,
const RTP_DataFrame & frame
);
#endif
#endif // OPAL_HAS_MIXER
void InternalOnClear();
void SetPartyNames();
protected:
bool EnumerateConnections(
PSafePtr<OpalConnection> & connection,
PSafetyMode mode,
const OpalConnection * skipConnection = NULL
) const;
OpalManager & manager;
PString myToken;
PString m_partyA;
PString m_partyB;
PTime startTime;
bool isEstablished;
bool isClearing;
PAtomicBoolean m_isCleared;
OpalConnection::CallEndReason callEndReason;
std::list<PSyncPoint *> m_endCallSyncPoint;
PSafeList<OpalConnection> connectionsActive;
#if OPAL_HAS_MIXER
OpalRecordManager * m_recordManager;
#endif
//use to add the connection to the call's connection list
friend OpalConnection::OpalConnection(OpalCall &, OpalEndPoint &, const PString &, unsigned int, OpalConnection::StringOptions *);
//use to remove the connection from the call's connection list
friend OpalConnection::~OpalConnection();
};
#endif // OPAL_OPAL_CALL_H
// End of File ///////////////////////////////////////////////////////////////
OpalCall::IsOnHold
bool IsOnHold() const
OpalCall::OnProceeding
virtual void OnProceeding(OpalConnection &connection)
OpalCall::OnStartRecording
virtual bool OnStartRecording(const PString &streamId, const OpalMediaFormat &format)
OpalCall::m_partyA
PString m_partyA
Definition: call.h:600
OpalManager
Definition: manager.h:74
OpalEndPoint
Definition: endpoint.h:67
OpalCall::m_recordManager
OpalRecordManager * m_recordManager
Definition: call.h:613
OpalCall::OnAnswerCall
virtual OpalConnection::AnswerCallResponse OnAnswerCall(OpalConnection &connection, const PString &caller)
RTP_Session
Definition: rtp.h:502
OpalCall::isClearing
bool isClearing
Definition: call.h:604
connection.h
buildopts.h
OpalConnection::~OpalConnection
~OpalConnection()
OpalCall::GetPartyB
const PString & GetPartyB() const
Definition: call.h:513
OpalCall::Hold
bool Hold()
OpalCall::OnSetUp
virtual PBoolean OnSetUp(OpalConnection &connection)
OpalCall::Transfer
bool Transfer(const PString &address, OpalConnection *connection=NULL)
OpalCall::CloseMediaStreams
virtual void CloseMediaStreams()
OpalCall::GetToken
const PString & GetToken() const
Definition: call.h:500
OpalCall::m_endCallSyncPoint
std::list< PSyncPoint * > m_endCallSyncPoint
Definition: call.h:608
OpalCall::SetPartyB
void SetPartyB(const PString &b)
Definition: call.h:520
OpalCall::EnumerateConnections
bool EnumerateConnections(PSafePtr< OpalConnection > &connection, PSafetyMode mode, const OpalConnection *skipConnection=NULL) const
OpalMediaType
Definition: mediatype.h:57
guid.h
OpalCall::~OpalCall
~OpalCall()
OpalCall::IsNetworkOriginated
bool IsNetworkOriginated() const
OpalVideoFormat::ContentRole
ContentRole
Definition: mediafmt.h:1345
OpalConnection::OpalConnection
OpalConnection(OpalCall &call, OpalEndPoint &endpoint, const PString &token, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
OpalCall::OnRTPStatistics
virtual void OnRTPStatistics(const OpalConnection &connection, const RTP_Session &session)
OpalVideoFormat::eNoRole
Definition: mediafmt.h:1346
OpalCall::GetOtherPartyConnection
PSafePtr< OpalConnection > GetOtherPartyConnection(const OpalConnection &connection) const
OpalCall::AdjustMediaFormats
virtual void AdjustMediaFormats(bool local, const OpalConnection &connection, OpalMediaFormatList &mediaFormats) const
OpalCall::OnConnected
virtual PBoolean OnConnected(OpalConnection &connection)
OpalCall::SetPartyNames
void SetPartyNames()
OpalCall::StartRecording
bool StartRecording(const PFilePath &filename, const OpalRecordManager::Options &options=false)
OpalCall::connectionsActive
PSafeList< OpalConnection > connectionsActive
Definition: call.h:610
OpalMediaFormatList
Definition: mediafmt.h:72
OpalConnection::AnswerCallResponse
AnswerCallResponse
Definition: connection.h:417
OpalConnection::StringOptions
Definition: connection.h:462
OpalCall::GetConnection
PSafePtr< OpalConnection > GetConnection(PINDEX idx, PSafetyMode mode=PSafeReference)
Definition: call.h:296
OpalCall::GetCallEndReasonText
PString GetCallEndReasonText() const
Definition: call.h:121
OpalCall::OpalCall
OpalCall(OpalManager &manager)
RTP_DataFrame
Definition: rtp.h:71
OpalCall::myToken
PString myToken
Definition: call.h:598
OpalConnection::GetCallEndReasonText
PString GetCallEndReasonText() const
Definition: connection.h:569
OpalCall::OpenSourceMediaStreams
virtual bool OpenSourceMediaStreams(OpalConnection &connection, const OpalMediaType &mediaType, unsigned sessionID=0, const OpalMediaFormat &preselectedFormat=OpalMediaFormat(), OpalVideoFormat::ContentRole contentRole=OpalVideoFormat::eNoRole)
OpalMediaFormat
Definition: mediafmt.h:724
OpalCall
Definition: call.h:65
OpalCall::OnEstablishedCall
virtual void OnEstablishedCall()
OpalCall::Retrieve
bool Retrieve()
OpalCall::OnCleared
virtual void OnCleared()
OpalCall::StartMediaStreams
virtual void StartMediaStreams()
OpalCall::IsEstablished
PBoolean IsEstablished() const
Definition: call.h:97
OpalCall::GetPartyA
const PString & GetPartyA() const
Definition: call.h:506
recording.h
OpalCall::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats(const OpalConnection &connection)
OpalCall::PrintOn
void PrintOn(ostream &strm) const
OpalCall::OnRecordAudio
virtual void OnRecordAudio(const PString &streamId, const RTP_DataFrame &frame)
OpalCall::StopRecording
void StopRecording()
OpalCall::InternalOnClear
void InternalOnClear()
OpalCall::manager
OpalManager & manager
Definition: call.h:596
OpalCall::OnEstablished
virtual PBoolean OnEstablished(OpalConnection &connection)
OpalCall::IsRecording
bool IsRecording() const
OpalCall::OnAlerting
virtual PBoolean OnAlerting(OpalConnection &connection)
OpalCall::Clear
void Clear(OpalConnection::CallEndReason reason=OpalConnection::EndedByLocalUser, PSyncPoint *sync=NULL)
OpalConnection::CallEndReason
Definition: connection.h:396
OpalCall::isEstablished
bool isEstablished
Definition: call.h:603
OpalCall::m_partyB
PString m_partyB
Definition: call.h:601
OpalCall::OnUserInputString
virtual void OnUserInputString(OpalConnection &connection, const PString &value)
OpalCall::GetCallEndReason
OpalConnection::CallEndReason GetCallEndReason() const
Definition: call.h:117
OpalRecordManager
Definition: recording.h:46
OpalConnection
Definition: connection.h:353
OpalCall::OnRecordVideo
virtual void OnRecordVideo(const PString &streamId, const RTP_DataFrame &frame)
OpalCall::OnHold
virtual void OnHold(OpalConnection &connection, bool fromRemote, bool onHold)
OpalCall::m_isCleared
PAtomicBoolean m_isCleared
Definition: call.h:605
OpalCall::GetStartTime
const PTime & GetStartTime() const
Definition: call.h:532
OpalCall::IsMediaBypassPossible
virtual PBoolean IsMediaBypassPossible(const OpalConnection &connection, unsigned sessionID) const
OpalCall::GetManager
OpalManager & GetManager() const
Definition: call.h:496
OpalCall::OnUserInputTone
virtual void OnUserInputTone(OpalConnection &connection, char tone, int duration)
OpalCall::OnReleased
virtual void OnReleased(OpalConnection &connection)
OpalCall::SetCallEndReason
void SetCallEndReason(OpalConnection::CallEndReason reason)
OpalCall::OnNewConnection
virtual void OnNewConnection(OpalConnection &connection)
OpalCall::startTime
PTime startTime
Definition: call.h:602
OpalCall::OnStopRecording
virtual void OnStopRecording(const PString &streamId)
OpalCall::GetConnectionAs
PSafePtr< ConnClass > GetConnectionAs(PINDEX count=0, PSafetyMode mode=PSafeReadWrite)
Definition: call.h:305
OpalCall::callEndReason
OpalConnection::CallEndReason callEndReason
Definition: call.h:607
OpalConnection::EndedByLocalUser
Definition: connection.h:362
OpalCall::SelectMediaFormats
virtual bool SelectMediaFormats(const OpalMediaType &mediaType, const OpalMediaFormatList &srcFormats, const OpalMediaFormatList &dstFormats, const OpalMediaFormatList &allFormats, OpalMediaFormat &srcFormat, OpalMediaFormat &dstFormat) const
OpalRecordManager::Options
Definition: recording.h:80