rtpconn.h
Go to the documentation of this file.
/*
* rtpconn.h
*
* Connection abstraction
*
* Open Phone Abstraction Library (OPAL)
*
* Copyright (C) 2007 Post Increment
*
* 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 Post Increment
*
* Contributor(s): ______________________________________.
*
* $Revision: 26728 $
* $Author: rjongbloed $
* $Date: 2011-12-01 22:59:14 -0600 (Thu, 01 Dec 2011) $
*/
#ifndef OPAL_OPAL_RTPCONN_H
#define OPAL_OPAL_RTPCONN_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#include <opal/connection.h>
#include <opal/mediatype.h>
#ifdef OPAL_ZRTP
class OpalZRTPStreamInfo {
public:
virtual bool Open() = 0;
virtual RTP_UDP * CreateRTPSession(OpalConnection & conn, unsigned sessionId, bool remoteIsNat) = 0;
};
class OpalZRTPConnectionInfo {
public:
virtual bool Open() = 0;
virtual RTP_UDP * CreateRTPSession(OpalConnection & conn, unsigned sessionId, bool remoteIsNat) = 0;
PMutex mutex;
};
#endif // OPAL_ZRTP
class OpalRTPEndPoint;
//#ifdef HAS_LIBZRTP
//#ifndef __ZRTP_TYPES_H__
//struct zrtp_conn_ctx_t;
//#endif
//#endif
class OpalMediaSession : public PObject
{
PCLASSINFO(OpalMediaSession, PObject);
public:
OpalMediaSession(OpalConnection & conn, const OpalMediaType & _mediaType, unsigned sessionId);
OpalMediaSession(const OpalMediaSession & _obj);
virtual void Close() = 0;
virtual PObject * Clone() const = 0;
virtual bool IsActive() const = 0;
virtual bool IsRTP() const = 0;
virtual bool HasFailed() const = 0;
virtual OpalTransportAddress GetLocalMediaAddress() const = 0;
virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList & ) { }
#if OPAL_SIP
virtual SDPMediaDescription * CreateSDPMediaDescription(
const OpalTransportAddress & localAddress
) = 0;
#endif
virtual OpalMediaStream * CreateMediaStream(
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
) = 0;
OpalConnection & connection;
OpalMediaType mediaType; // media type for session
unsigned sessionId; // unique session ID
};
class OpalRTPMediaSession : public OpalMediaSession
{
PCLASSINFO(OpalRTPMediaSession, OpalMediaSession);
public:
OpalRTPMediaSession(
OpalConnection & conn,
const OpalMediaType & mediaType,
unsigned sessionId
);
OpalRTPMediaSession(const OpalRTPMediaSession & obj);
~OpalRTPMediaSession();
PObject * Clone() const { return new OpalRTPMediaSession(*this); }
void Attach(RTP_Session * rtpSession);
virtual void Close();
virtual bool IsActive() const { return rtpSession != NULL; }
virtual bool IsRTP() const { return true; }
virtual bool HasFailed() const { return (rtpSession != NULL) && (rtpSession->HasFailed() || (rtpSession->GetPacketsReceived() == 0)); }
virtual OpalTransportAddress GetLocalMediaAddress() const;
#if OPAL_SIP
virtual SDPMediaDescription * CreateSDPMediaDescription(
const OpalTransportAddress & localAddress
);
#endif
virtual OpalMediaStream * CreateMediaStream(
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
);
RTP_Session * GetSession() const { return rtpSession; }
protected:
RTP_Session * rtpSession; // RTP session
};
class OpalRTPSessionManager : public PObject
{
PCLASSINFO(OpalRTPSessionManager , PObject);
public:
OpalRTPSessionManager(
OpalRTPConnection & connection
);
~OpalRTPSessionManager();
OpalRTPSessionManager(const OpalRTPSessionManager & other);
void operator=(const OpalRTPSessionManager & other) { sessions = other.sessions; }
unsigned GetNextSessionID();
void AddSession(
RTP_Session * session,
const OpalMediaType & mediaType
);
void AddMediaSession(
OpalMediaSession * session,
const OpalMediaType & mediaType
);
virtual void CloseSession(
unsigned sessionID
);
RTP_Session * GetSession(
unsigned sessionID
) const;
OpalMediaSession * GetMediaSession(
unsigned sessionID
) const;
bool ChangeSessionID(
unsigned fromSessionID,
unsigned toSessionID
);
PMutex & GetMutex() { return m_mutex; }
virtual bool AllSessionsFailing();
protected:
OpalRTPConnection & m_connection;
PMutex m_mutex;
PDICTIONARY(SessionDict, POrdinalKey, OpalMediaSession);
SessionDict sessions;
};
typedef OpalRTPSessionManager RTP_SessionManager;
class OpalRTPConnection : public OpalConnection
{
PCLASSINFO(OpalRTPConnection, OpalConnection);
public:
OpalRTPConnection(
OpalCall & call,
OpalRTPEndPoint & endpoint,
const PString & token,
unsigned options = 0,
OpalConnection::StringOptions * stringOptions = NULL
);
~OpalRTPConnection();
virtual void OnReleased();
virtual unsigned GetNextSessionID(
const OpalMediaType & mediaType,
bool isSource
);
virtual RTP_Session * GetSession(
unsigned sessionID
) const;
virtual OpalMediaSession * GetMediaSession(
unsigned sessionID
) const;
virtual RTP_Session * UseSession(
const OpalTransport & transport,
unsigned sessionID,
const OpalMediaType & mediatype,
RTP_QOS * rtpqos = NULL
);
virtual void CloseSession(
unsigned sessionID
);
virtual RTP_Session * CreateSession(
const OpalTransport & transport,
unsigned sessionID,
const OpalMediaType & mediaType,
RTP_QOS * rtpqos
);
virtual RTP_UDP * CreateRTPSession(
unsigned sessionId,
const OpalMediaType & mediaType,
bool remoteIsNat
);
virtual bool ChangeSessionID(
unsigned fromSessionID,
unsigned toSessionID
);
virtual PBoolean RemoteIsNAT() const
{ return remoteIsNAT; }
virtual PBoolean IsRTPNATEnabled(
const PIPSocket::Address & localAddr,
const PIPSocket::Address & peerAddr,
const PIPSocket::Address & signalAddr,
PBoolean incoming
);
virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch & patch);
virtual PBoolean SendUserInputTone(
char tone,
unsigned duration = 0
);
struct MediaInformation {
MediaInformation() {
rfc2833 = RTP_DataFrame::IllegalPayloadType;
ciscoNSE = RTP_DataFrame::IllegalPayloadType;
}
OpalTransportAddress data;
OpalTransportAddress control;
RTP_DataFrame::PayloadTypes rfc2833;
RTP_DataFrame::PayloadTypes ciscoNSE;
};
virtual PBoolean GetMediaInformation(
unsigned sessionID,
MediaInformation & info
) const;
virtual PBoolean IsMediaBypassPossible(
unsigned sessionID
) const;
virtual OpalMediaStream * CreateMediaStream(
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
);
virtual void AdjustMediaFormats(
bool local,
const OpalConnection * otherConnection,
OpalMediaFormatList & mediaFormats
) const;
virtual void OnPatchMediaStream(
PBoolean isSource,
OpalMediaPatch & patch
);
virtual bool OnMediaCommand(
OpalMediaStream & stream,
const OpalMediaCommand & command
);
virtual void SessionFailing(RTP_Session & session);
protected:
PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineRFC2833);
PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineCiscoNSE);
OpalRTPSessionManager m_rtpSessions;
OpalRFC2833Proto * rfc2833Handler;
#if OPAL_T38_CAPABILITY
OpalRFC2833Proto * ciscoNSEHandler;
#endif
PBoolean remoteIsNAT;
PBoolean useRTPAggregation;
#ifdef OPAL_ZRTP
bool zrtpEnabled;
PMutex zrtpConnInfoMutex;
OpalZRTPConnectionInfo * zrtpConnInfo;
#endif
};
class RTP_UDP;
class OpalSecurityMode : public PObject
{
PCLASSINFO(OpalSecurityMode, PObject);
public:
virtual RTP_UDP * CreateRTPSession(
OpalRTPConnection & connection,
const RTP_Session::Params & options
) = 0;
virtual PBoolean Open() = 0;
};
#endif // OPAL_OPAL_RTPCONN_H
OpalRTPConnection::RemoteIsNAT
virtual PBoolean RemoteIsNAT() const
Definition: rtpconn.h:362
OpalRTPConnection::GetNextSessionID
virtual unsigned GetNextSessionID(const OpalMediaType &mediaType, bool isSource)
OpalRTPSessionManager::~OpalRTPSessionManager
~OpalRTPSessionManager()
Destroy sessions, unlinking from connection.
OpalSecurityMode::CreateRTPSession
virtual RTP_UDP * CreateRTPSession(OpalRTPConnection &connection, const RTP_Session::Params &options)=0
RTP_DataFrame::IllegalPayloadType
Definition: rtp.h:122
OpalRTPMediaSession::CreateMediaStream
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
OpalSecurityMode
Definition: rtpconn.h:525
OpalRTPConnection
Definition: rtpconn.h:247
OpalRTPConnection::AdjustMediaFormats
virtual void AdjustMediaFormats(bool local, const OpalConnection *otherConnection, OpalMediaFormatList &mediaFormats) const
OpalRTPSessionManager::GetNextSessionID
unsigned GetNextSessionID()
OpalRTPConnection::~OpalRTPConnection
~OpalRTPConnection()
RTP_Session
Definition: rtp.h:502
OpalRTPConnection::MediaInformation::rfc2833
RTP_DataFrame::PayloadTypes rfc2833
Payload type for RFC2833.
Definition: rtpconn.h:411
OpalRTPConnection::CreateSession
virtual RTP_Session * CreateSession(const OpalTransport &transport, unsigned sessionID, const OpalMediaType &mediaType, RTP_QOS *rtpqos)
OpalConnection::endpoint
OpalEndPoint & endpoint
Definition: connection.h:1788
OpalMediaSession::HasFailed
virtual bool HasFailed() const =0
OpalRTPSessionManager::operator=
void operator=(const OpalRTPSessionManager &other)
Assignment of RTP session managers.
Definition: rtpconn.h:178
OpalRTPConnection::rfc2833Handler
OpalRFC2833Proto * rfc2833Handler
Definition: rtpconn.h:507
OpalRTPSessionManager::GetSession
RTP_Session * GetSession(unsigned sessionID) const
OpalRTPConnection::m_rtpSessions
OpalRTPSessionManager m_rtpSessions
Definition: rtpconn.h:506
OpalRTPSessionManager::AddSession
void AddSession(RTP_Session *session, const OpalMediaType &mediaType)
OpalMediaCommand
Definition: mediacmd.h:43
connection.h
OpalRTPMediaSession::IsActive
virtual bool IsActive() const
Definition: rtpconn.h:131
buildopts.h
OpalMediaSession::OpalMediaSession
OpalMediaSession(OpalConnection &conn, const OpalMediaType &_mediaType, unsigned sessionId)
OpalRTPMediaSession::GetSession
RTP_Session * GetSession() const
Definition: rtpconn.h:151
OpalSecurityMode::Open
virtual PBoolean Open()=0
OpalRTPConnection::MediaInformation::control
OpalTransportAddress control
Control channel address.
Definition: rtpconn.h:410
OpalMediaSession
Definition: rtpconn.h:72
OpalTransport
Definition: transports.h:703
OpalRTPMediaSession::CreateSDPMediaDescription
virtual SDPMediaDescription * CreateSDPMediaDescription(const OpalTransportAddress &localAddress)
OpalRTPSessionManager
Definition: rtpconn.h:159
OpalRTPConnection::IsRTPNATEnabled
virtual PBoolean IsRTPNATEnabled(const PIPSocket::Address &localAddr, const PIPSocket::Address &peerAddr, const PIPSocket::Address &signalAddr, PBoolean incoming)
OpalRTPConnection::MediaInformation::data
OpalTransportAddress data
Data channel address.
Definition: rtpconn.h:409
OpalRTPSessionManager::GetMediaSession
OpalMediaSession * GetMediaSession(unsigned sessionID) const
OpalRTPConnection::OpalRTPConnection
OpalRTPConnection(OpalCall &call, OpalRTPEndPoint &endpoint, const PString &token, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
OpalMediaType
Definition: mediatype.h:57
OpalRTPConnection::OnReleased
virtual void OnReleased()
OpalRTPConnection::SendUserInputTone
virtual PBoolean SendUserInputTone(char tone, unsigned duration=0)
RTP_QOS
Definition: rtp.h:58
RTP_Session::HasFailed
bool HasFailed() const
Definition: rtp.h:976
OpalMediaSession::IsRTP
virtual bool IsRTP() const =0
OpalRTPMediaSession::GetLocalMediaAddress
virtual OpalTransportAddress GetLocalMediaAddress() const
OpalRTPSessionManager::ChangeSessionID
bool ChangeSessionID(unsigned fromSessionID, unsigned toSessionID)
OpalRTPConnection::ChangeSessionID
virtual bool ChangeSessionID(unsigned fromSessionID, unsigned toSessionID)
OpalMediaSession::CreateSDPMediaDescription
virtual SDPMediaDescription * CreateSDPMediaDescription(const OpalTransportAddress &localAddress)=0
OpalMediaSession::mediaType
OpalMediaType mediaType
Definition: rtpconn.h:106
OpalMediaSession::Close
virtual void Close()=0
OpalRTPMediaSession::Close
virtual void Close()
OpalRTPSessionManager::CloseSession
virtual void CloseSession(unsigned sessionID)
RTP_DataFrame::PayloadTypes
PayloadTypes
Definition: rtp.h:86
OpalRTPConnection::remoteIsNAT
PBoolean remoteIsNAT
Definition: rtpconn.h:512
RTP_Session::GetPacketsReceived
DWORD GetPacketsReceived() const
Definition: rtp.h:843
OpalRFC2833Info
Definition: rfc2833.h:65
OpalRTPConnection::useRTPAggregation
PBoolean useRTPAggregation
Definition: rtpconn.h:513
OpalRTPMediaSession::OpalRTPMediaSession
OpalRTPMediaSession(OpalConnection &conn, const OpalMediaType &mediaType, unsigned sessionId)
OpalMediaFormatList
Definition: mediafmt.h:72
OpalRTPConnection::OnMediaCommand
virtual bool OnMediaCommand(OpalMediaStream &stream, const OpalMediaCommand &command)
OpalRTPMediaSession::Attach
void Attach(RTP_Session *rtpSession)
OpalMediaSession::connection
OpalConnection & connection
Definition: rtpconn.h:105
OpalConnection::StringOptions
Definition: connection.h:462
OpalRTPSessionManager::m_mutex
PMutex m_mutex
Definition: rtpconn.h:234
OpalRTPConnection::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(OpalRFC2833Info, OpalRTPConnection, OnUserInputInlineRFC2833)
OpalMediaPatch
Definition: patch.h:60
OpalRTPConnection::MediaInformation::MediaInformation
MediaInformation()
Definition: rtpconn.h:404
OpalMediaSession::IsActive
virtual bool IsActive() const =0
OpalRTPMediaSession::Clone
PObject * Clone() const
Definition: rtpconn.h:125
OpalMediaFormat
Definition: mediafmt.h:724
OpalRTPConnection::CloseSession
virtual void CloseSession(unsigned sessionID)
OpalRTPMediaSession::rtpSession
RTP_Session * rtpSession
Definition: rtpconn.h:154
SDPMediaDescription
Definition: sdp.h:119
mediatype.h
OpalCall
Definition: call.h:65
RTP_Session::Params
Definition: rtp.h:509
OpalRTPSessionManager::AllSessionsFailing
virtual bool AllSessionsFailing()
OpalRTPSessionManager::PDICTIONARY
PDICTIONARY(SessionDict, POrdinalKey, OpalMediaSession)
OpalRTPConnection::MediaInformation
Definition: rtpconn.h:403
OpalRTPConnection::GetMediaInformation
virtual PBoolean GetMediaInformation(unsigned sessionID, MediaInformation &info) const
OpalRTPConnection::UseSession
virtual RTP_Session * UseSession(const OpalTransport &transport, unsigned sessionID, const OpalMediaType &mediatype, RTP_QOS *rtpqos=NULL)
OpalRFC2833Proto
Definition: rfc2833.h:112
OpalRTPSessionManager::GetMutex
PMutex & GetMutex()
Definition: rtpconn.h:228
OpalRTPConnection::AttachRFC2833HandlerToPatch
virtual void AttachRFC2833HandlerToPatch(PBoolean isSource, OpalMediaPatch &patch)
OpalMediaSession::CreateMediaStream
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)=0
OpalMediaSession::sessionId
unsigned sessionId
Definition: rtpconn.h:107
OpalRTPConnection::CreateMediaStream
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
OpalRTPMediaSession::HasFailed
virtual bool HasFailed() const
Definition: rtpconn.h:135
OpalMediaSession::SetRemoteMediaAddress
virtual void SetRemoteMediaAddress(const OpalTransportAddress &, const OpalMediaFormatList &)
Definition: rtpconn.h:91
OpalRTPSessionManager::m_connection
OpalRTPConnection & m_connection
Definition: rtpconn.h:233
OpalMediaStream
Definition: mediastrm.h:111
OpalConnection
Definition: connection.h:353
OpalRTPConnection::GetMediaSession
virtual OpalMediaSession * GetMediaSession(unsigned sessionID) const
OpalRTPMediaSession
Definition: rtpconn.h:113
OpalRTPConnection::OnPatchMediaStream
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch &patch)
OpalRTPMediaSession::IsRTP
virtual bool IsRTP() const
Definition: rtpconn.h:133
OpalRTPSessionManager::OpalRTPSessionManager
OpalRTPSessionManager(OpalRTPConnection &connection)
OpalRTPConnection::GetSession
virtual RTP_Session * GetSession(unsigned sessionID) const
OpalTransportAddress
Definition: transports.h:149
OpalRTPSessionManager::AddMediaSession
void AddMediaSession(OpalMediaSession *session, const OpalMediaType &mediaType)
OpalRTPConnection::MediaInformation::ciscoNSE
RTP_DataFrame::PayloadTypes ciscoNSE
Payload type for RFC2833.
Definition: rtpconn.h:412
OpalMediaSession::GetLocalMediaAddress
virtual OpalTransportAddress GetLocalMediaAddress() const =0
OpalRTPConnection::SessionFailing
virtual void SessionFailing(RTP_Session &session)
OpalRTPMediaSession::~OpalRTPMediaSession
~OpalRTPMediaSession()
OpalRTPConnection::IsMediaBypassPossible
virtual PBoolean IsMediaBypassPossible(unsigned sessionID) const
RTP_SessionManager
OpalRTPSessionManager RTP_SessionManager
Definition: rtpconn.h:241
OpalRTPEndPoint
Definition: rtpep.h:44
OpalRTPSessionManager::sessions
SessionDict sessions
Definition: rtpconn.h:237
OpalMediaSession::Clone
virtual PObject * Clone() const =0
RTP_UDP
Definition: rtp.h:1098
OpalRTPConnection::CreateRTPSession
virtual RTP_UDP * CreateRTPSession(unsigned sessionId, const OpalMediaType &mediaType, bool remoteIsNat)