OPAL  Version 3.18.8
OpalSockConnection Class Reference

#include <sockep.h>

Inheritance diagram for OpalSockConnection:
Collaboration diagram for OpalSockConnection:

Data Structures

struct  MediaBitrate
 
struct  MediaHeader
 

Public Member Functions

Construction
 OpalSockConnection (OpalCall &call, OpalSockEndPoint &endpoint, void *userData, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
 
 ~OpalSockConnection ()
 
Overrides from OpalConnection
virtual OpalMediaFormatList GetMediaFormats () const
 
virtual void OnReleased ()
 
virtual bool TransferConnection (const PString &remoteParty)
 
virtual bool OnMediaCommand (OpalMediaStream &stream, const OpalMediaCommand &command)
 
Overrides from OpalLocalConnection
virtual bool OnOutgoing ()
 
virtual bool OnIncoming ()
 
virtual bool OnReadMediaData (OpalMediaStream &mediaStream, void *data, PINDEX size, PINDEX &length)
 
virtual bool OnWriteMediaData (const OpalMediaStream &mediaStream, const void *data, PINDEX length, PINDEX &written)
 
- Public Member Functions inherited from OpalLocalConnection
 OpalLocalConnection (OpalCall &call, OpalLocalEndPoint &endpoint, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions, char tokenPrefix= 'L')
 
 ~OpalLocalConnection ()
 
virtual PBoolean OnIncomingConnection (unsigned int options, OpalConnection::StringOptions *stringOptions)
 
virtual PBoolean IsNetworkConnection () const
 
virtual void OnApplyStringOptions ()
 Call back for connection to act on changed string options. More...
 
virtual PBoolean SetUpConnection ()
 
virtual PBoolean SetAlerting (const PString &calleeName, PBoolean withMedia)
 
virtual PBoolean SetConnected ()
 
virtual bool HoldRemote (bool placeOnHold)
 
virtual OpalMediaStreamCreateMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
 
virtual void OnClosedMediaStream (const OpalMediaStream &stream)
 
virtual PBoolean SendUserInputString (const PString &value)
 
virtual bool OnOutgoingSetUp ()
 
virtual void AlertingIncoming (bool withMedia=false)
 
virtual void AcceptIncoming ()
 
virtual bool OnReadMediaFrame (const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
 
virtual bool OnWriteMediaFrame (const OpalMediaStream &mediaStream, RTP_DataFrame &frame)
 
virtual
OpalLocalEndPoint::Synchronicity 
GetSynchronicity (const OpalMediaFormat &mediaFormat, bool isSource) const
 
virtual bool CreateVideoInputDevice (const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, bool &autoDelete)
 
virtual bool CreateVideoOutputDevice (const OpalMediaFormat &mediaFormat, bool preview, PVideoOutputDevice *&device, bool &autoDelete)
 
virtual bool ChangeVideoInputDevice (const PVideoDevice::OpenArgs &device, unsigned sessionID=0)
 
virtual bool ChangeVideoOutputDevice (const PVideoDevice::OpenArgs &device, unsigned sessionID=0, bool preview=false)
 
bool FarEndCameraControl (PVideoControlInfo::Types what, int direction=0, const PTimeInterval &duration=0)
 
void SetFarEndCameraCapabilityChangedNotifier (const PNotifier &notifier)
 Set a callback for when the far end camera control capabilities change. More...
 
void SetFarEndCameraActionNotifier (const PNotifier &notifier)
 Set a callback for when a far end camera control action comes from remote. More...
 
void * GetUserData () const
 Get user data pointer. More...
 
void SetUserData (void *v)
 Set user data pointer. More...
 
- Public Member Functions inherited from OpalConnection
 P_DECLARE_TRACED_ENUM_EX (CallEndReasonCodes, NumCallEndReasons, EndedByLocalUser, 0, EndedByNoAccept, EndedByAnswerDenied, EndedByRemoteUser, EndedByRefusal, EndedByNoAnswer, EndedByCallerAbort, EndedByTransportFail, EndedByConnectFail, EndedByGatekeeper, EndedByNoUser, EndedByNoBandwidth, EndedByCapabilityExchange, EndedByCallForwarded, EndedBySecurityDenial, EndedByLocalBusy, EndedByLocalCongestion, EndedByRemoteBusy, EndedByRemoteCongestion, EndedByUnreachable, EndedByNoEndPoint, EndedByHostOffline, EndedByTemporaryFailure, EndedByQ931Cause, EndedByDurationLimit, EndedByInvalidConferenceID, EndedByNoDialTone, EndedByNoRingBackTone, EndedByOutOfService, EndedByAcceptingCallWaiting, EndedByGkAdmissionFailed, EndedByMediaFailed, EndedByCallCompletedElsewhere, EndedByCertificateAuthority, EndedByIllegalAddress, EndedByCustomCode)
 
 P_DECLARE_TRACED_ENUM (AnswerCallResponse, AnswerCallNow, AnswerCallDenied, AnswerCallPending, AnswerCallDeferred, AnswerCallAlertWithMedia, AnswerCallDeferredWithMedia, AnswerCallProgress, AnswerCallNowAndReleaseCurrent)
 
const StringOptionsGetStringOptions () const
 Get the string options associated with this connection. More...
 
void SetStringOptions (const StringOptions &options, bool overwrite)
 Set the string options associated with this connection. More...
 
virtual void EnableRecording ()
 
virtual void DisableRecording ()
 
 PDECLARE_NOTIFIER (RTP_DataFrame, OpalConnection, OnRecordAudio)
 
void InternalOnRecordAudio (PString key, PAutoPtr< RTP_DataFrame > frame)
 
 PDECLARE_NOTIFIER (RTP_DataFrame, OpalConnection, OnRecordVideo)
 
void InternalOnRecordVideo (PString key, PAutoPtr< RTP_DataFrame > frame)
 
virtual void OnStartRecording (OpalMediaPatch *patch)
 
virtual void OnStopRecording (OpalMediaPatch *patch)
 
bool InternalOnConnected ()
 
bool InternalOnEstablished ()
 
void InternalSetAsOriginating ()
 
bool InternalRelease (CallEndReason reason)
 
void InternalOnReleased ()
 
void InternalExecuteMediaCommand (OpalMediaCommand *command)
 
void InternalCreatedMediaTransport (const OpalMediaTransportPtr &transport)
 
 OpalConnection (OpalCall &call, OpalEndPoint &endpoint, const PString &token, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
 
 ~OpalConnection ()
 
void PrintOn (ostream &strm) const
 
virtual PBoolean OnSetUpConnection ()
 
virtual void OnProceeding ()
 
virtual void OnAlerting (bool withMedia)
 
virtual void OnAlerting ()
 
virtual AnswerCallResponse OnAnswerCall (const PString &callerName)
 
virtual void AnsweringCall (AnswerCallResponse response)
 
virtual void OnConnected ()
 
virtual void OnEstablished ()
 
virtual bool OnTransferNotify (const PStringToString &info, const OpalConnection *transferringConnection)
 
virtual void Release (CallEndReason reason=EndedByLocalUser, bool synchronous=false)
 
virtual PString GetDestinationAddress ()
 
virtual PBoolean ForwardCall (const PString &forwardParty)
 
PSafePtr< OpalConnectionGetOtherPartyConnection () const
 
template<class cls >
PSafePtr< cls > GetOtherPartyConnectionAs () const
 
virtual OpalMediaFormatList GetLocalMediaFormats ()
 
virtual void AdjustMediaFormats (bool local, const OpalConnection *otherConnection, OpalMediaFormatList &mediaFormats) const
 
virtual PStringArray GetMediaCryptoSuites () const
 
virtual unsigned GetNextSessionID (const OpalMediaType &mediaType, bool isSource)
 
virtual bool RequireSymmetricMediaStreams () const
 
virtual
OpalMediaType::AutoStartMode 
GetAutoStart (const OpalMediaType &mediaType) const
 
virtual void AutoStartMediaStreams (bool transfer=false)
 
virtual OpalMediaStreamPtr OpenMediaStream (const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource)
 
bool CloseMediaStream (unsigned sessionId, bool source)
 
bool CloseMediaStream (OpalMediaStreamPtr stream)
 
bool RemoveMediaStream (OpalMediaStream &strm)
 
virtual void StartMediaStreams ()
 
virtual void CloseMediaStreams ()
 
virtual void PauseMediaStreams (bool paused)
 
virtual void OnPauseMediaStream (OpalMediaStream &strm, bool paused)
 
OpalMediaStreamPtr GetMediaStream (const PString &streamID, bool source) const
 
OpalMediaStreamPtr GetMediaStream (unsigned sessionId, bool source) const
 
OpalMediaStreamPtr GetMediaStream (const OpalMediaType &mediaType, bool source, OpalMediaStreamPtr previous=NULL) const
 
bool GetStatistics (const OpalMediaType &mediaType, bool source, OpalMediaStatistics &statistics) const
 Get media statistics of the type, and of the specifed direction. More...
 
virtual PBoolean OnOpenMediaStream (OpalMediaStream &stream)
 
virtual void OnFailedMediaStream (bool fromRemote, const PString &reason)
 
virtual void OnPatchMediaStream (PBoolean isSource, OpalMediaPatch &patch)
 
virtual void OnStartMediaPatch (OpalMediaPatch &patch)
 
virtual void OnStopMediaPatch (OpalMediaPatch &patch)
 
virtual bool OnMediaFailed (unsigned sessionId)
 
bool AllMediaFailed () const
 
virtual bool ExecuteMediaCommand (const OpalMediaCommand &command, bool aync=false) const
 
virtual bool GetMediaTransportAddresses (OpalConnection &otherConnection, unsigned sessionId, const OpalMediaType &mediaType, OpalTransportAddressArray &transports) const
 
virtual PBoolean SetAudioVolume (PBoolean source, unsigned percentage)
 
virtual PBoolean GetAudioVolume (PBoolean source, unsigned &percentage)
 
virtual bool SetAudioMute (bool source, bool mute)
 
virtual bool GetAudioMute (bool source, bool &mute)
 
virtual unsigned GetAudioSignalLevel (PBoolean source)
 
OpalBandwidth GetBandwidthAvailable (OpalBandwidth::Direction dir) const
 
virtual bool SetBandwidthAvailable (OpalBandwidth::Direction dir, OpalBandwidth availableBandwidth)
 
virtual bool SetBandwidthAllocated (OpalBandwidth::Direction dir, OpalBandwidth newBandwidth)
 
virtual OpalBandwidth GetBandwidthUsed (OpalBandwidth::Direction dir) const
 
virtual bool SetBandwidthUsed (OpalBandwidth::Direction dir, OpalBandwidth releasedBandwidth, OpalBandwidth requiredBandwidth)
 
 P_DECLARE_TRACED_ENUM (SendUserInputModes, SendUserInputAsQ931, SendUserInputAsString, SendUserInputAsTone, SendUserInputAsRFC2833, SendUserInputAsInlineRFC2833=SendUserInputAsRFC2833, SendUserInputInBand, SendUserInputAsProtocolDefault)
 
virtual void SetSendUserInputMode (SendUserInputModes mode)
 
virtual SendUserInputModes GetSendUserInputMode () const
 
virtual SendUserInputModes GetRealSendUserInputMode () const
 
virtual PBoolean SendUserInputTone (char tone, unsigned duration=0)
 
virtual void OnUserInputString (const PString &value)
 
void OnUserInputStringCallback (PString value)
 
virtual void OnUserInputTone (char tone, unsigned duration)
 
void SendUserInputHookFlash (unsigned duration=500)
 
virtual PString GetUserInput (unsigned timeout=30)
 
virtual void SetUserInput (const PString &input)
 
virtual PString ReadUserInput (const char *terminators="YX#\r\n", unsigned lastDigitTimeout=4, unsigned firstDigitTimeout=30)
 
virtual PBoolean PromptUserInput (PBoolean play)
 
virtual bool GetConferenceState (OpalConferenceState *state) const
 
virtual bool RequestPresentationRole (bool release)
 
virtual bool OnChangedPresentationRole (const PString &newChairURI, bool request)
 
virtual bool HasPresentationRole () const
 
virtual bool GarbageCollection ()
 
OpalEndPointGetEndPoint () const
 
OpalCallGetCall () const
 
const PString & GetToken () const
 
virtual void SetToken (const PString &newToken)
 
PBoolean IsOriginating () const
 
const PTime & GetPhaseTime (Phases phase) const
 
const PTime & GetSetupUpTime () const
 
const PTime & GetAlertingTime () const
 
const PTime & GetConnectionStartTime () const
 
const PTime & GetConnectionEndTime () const
 
const OpalProductInfoGetProductInfo () const
 
void SetProductInfo (const OpalProductInfo &info)
 
virtual PString GetPrefixName () const
 
const PString & GetLocalPartyName () const
 
virtual void SetLocalPartyName (const PString &name)
 
virtual PString GetLocalPartyURL () const
 
const PString & GetDisplayName () const
 
void SetDisplayName (const PString &name)
 
virtual bool IsPresentationBlocked () const
 
const PString & GetRemotePartyName () const
 
void SetRemotePartyName (const PString &name)
 
const PString & GetRemotePartyNumber () const
 
virtual OpalTransportAddress GetRemoteAddress () const
 
virtual PString GetRemotePartyURL () const
 
virtual PString GetRemoteIdentity () const
 
P_DEPRECATED PString GetRemotePartyAddress () const
 
P_DEPRECATED const PString GetRemotePartyCallbackURL () const
 
PCaselessString GetRemoteApplication () const
 
const OpalProductInfoGetRemoteProductInfo () const
 
void SetRemoteProductInfo (const OpalProductInfo &info)
 
const PString & GetRedirectingParty () const
 
void SetRedirectingParty (const PString &party)
 
const PString & GetCalledPartyName () const
 
void SetCalledPartyName (const PString &name)
 
const PString & GetCalledPartyNumber () const
 
virtual PString GetCalledPartyURL ()
 
virtual PMultiPartList GetExtraCallInfo () const
 
void CopyPartyNames (const OpalConnection &other)
 
virtual PString GetAlertingType () const
 
virtual bool SetAlertingType (const PString &info)
 
virtual PString GetCallInfo () const
 
virtual PString GetSupportedFeatures () const
 
unsigned GetMinAudioJitterDelay () const
 
unsigned GetMaxAudioJitterDelay () const
 
void SetAudioJitterDelay (unsigned minDelay, unsigned maxDelay)
 
OpalSilenceDetectorGetSilenceDetector () const
 
virtual PString GetIdentifier () const
 
virtual PINDEX GetMaxRtpPayloadSize () const
 
 P_DECLARE_STREAMABLE_ENUM (Phases, UninitialisedPhase, SetUpPhase, ProceedingPhase, AlertingPhase, ConnectedPhase, EstablishedPhase, ForwardingPhase, ReleasingPhase, ReleasedPhase)
 
__inline Phases GetPhase () const
 
__inline bool IsEstablished () const
 Return true if connection is in the established phase. More...
 
__inline bool IsReleased () const
 Return true if connection is in the established phase. More...
 
void SetPhase (Phases phaseToSet)
 
CallEndReason GetCallEndReason () const
 
PString GetCallEndReasonText () const
 
virtual void SetCallEndReason (CallEndReason reason)
 
void ClearCall (CallEndReason reason=EndedByLocalUser, PSyncPoint *sync=NULL)
 
virtual void ClearCallSynchronous (PSyncPoint *sync, CallEndReason reason=EndedByLocalUser)
 
unsigned GetQ931Cause () const
 
void SetQ931Cause (unsigned v)
 
virtual bool IsOnHold (bool fromRemote) const
 
virtual void OnHold (bool fromRemote, bool onHold)
 

Protected Member Functions

bool OpenMediaSockets ()
 
bool OpenMediaSocket (PIPSocket *&socket, const PString &addrKey, const PString &portKey, const PCaselessString &protoKey)
 
 PDECLARE_MUTEX (m_writeMutex)
 
- Protected Member Functions inherited from OpalLocalConnection
void InternalAcceptIncoming ()
 
- Protected Member Functions inherited from OpalConnection
 PDECLARE_MUTEX (m_mediaSessionFailedMutex)
 

Protected Attributes

OpalSockEndPointm_endpoint
 
PIPSocket * m_audioSocket
 
PIPSocket * m_videoSocket
 
- Protected Attributes inherited from OpalLocalConnection
OpalLocalEndPointm_endpoint
 
void * m_userData
 
OpalH224Handlerm_h224Handler
 
OpalFarEndCameraControlm_farEndCameraControl
 
- Protected Attributes inherited from OpalConnection
OpalCallm_ownerCall
 
OpalEndPointm_endpoint
 
PString m_callToken
 
PBoolean m_originating
 
OpalProductInfo m_productInfo
 
PString m_localPartyName
 
PString m_displayName
 
PString m_remotePartyName
 
PString m_remotePartyURL
 
OpalProductInfo m_remoteProductInfo
 
PString m_remotePartyNumber
 
PString m_redirectingParty
 
CallEndReason m_callEndReason
 
PString m_calledPartyNumber
 
PString m_calledPartyName
 
SendUserInputModes m_sendUserInputMode
 
PString m_userInputString
 
PSyncPoint m_userInputAvailable
 
OpalSilenceDetectorm_silenceDetector
 
OpalMediaFormat m_filterMediaFormat
 
OpalMediaFormatList m_localMediaFormats
 
StreamDict m_mediaStreams
 
PSafeList< OpalMediaTransportm_mediaTransports
 
OpalJitterBuffer::Params m_jitterParams
 
OpalBandwidth m_rxBandwidthAvailable
 
OpalBandwidth m_txBandwidthAvailable
 
StringOptions m_stringOptions
 
PString m_recordingFilename
 
PNotifier m_recordAudioNotifier
 
PNotifier m_recordVideoNotifier
 
OpalMediaType::AutoStartMap m_autoStartInfo
 
ZeroTime m_phaseTime [NumPhases]
 
std::set< unsigned > m_mediaSessionFailed
 

Additional Inherited Members

- Public Types inherited from OpalConnection
enum  Options {
  FastStartOptionDisable = 0x0001, FastStartOptionEnable = 0x0002, FastStartOptionMask = 0x0003, H245TunnelingOptionDisable = 0x0004,
  H245TunnelingOptionEnable = 0x0008, H245TunnelingOptionMask = 0x000c, H245inSetupOptionDisable = 0x0010, H245inSetupOptionEnable = 0x0020,
  H245inSetupOptionMask = 0x0030, DetectInBandDTMFOptionDisable = 0x0040, DetectInBandDTMFOptionEnable = 0x0080, DetectInBandDTMFOptionMask = 0x00c0,
  RTPAggregationDisable = 0x0100, RTPAggregationEnable = 0x0200, RTPAggregationMask = 0x0300, SendDTMFAsDefault = 0x0000,
  SendDTMFAsString = 0x0400, SendDTMFAsTone = 0x0800, SendDTMFAsRFC2833 = 0x0c00, SendDTMFMask = 0x0c00,
  SynchronousSetUp = 0x1000
}
 
- Static Public Member Functions inherited from OpalConnection
static PString GetCallEndReasonText (CallEndReason reason)
 
static void SetCallEndReasonText (CallEndReasonCodes reasonCode, const PString &newText)
 
- Protected Types inherited from OpalConnection
typedef PSafeDictionary
< StreamKey, OpalMediaStream
StreamDict
 

Detailed Description

Socket media connection. This simply routes media to/from tcp/udp sockets

Constructor & Destructor Documentation

OpalSockConnection::OpalSockConnection ( OpalCall call,
OpalSockEndPoint endpoint,
void *  userData,
unsigned  options = 0,
OpalConnection::StringOptions stringOptions = NULL 
)

Create a new endpoint.

Parameters
callOwner calll for connection
endpointOwner endpoint for connection
userDataArbitrary data to pass to connection
optionsOption bit map to be passed to connection
stringOptionsOptions to be passed to connection
OpalSockConnection::~OpalSockConnection ( )

Destroy endpoint.

Member Function Documentation

virtual OpalMediaFormatList OpalSockConnection::GetMediaFormats ( ) const
virtual

Get the data formats this endpoint is capable of operating. This provides a list of media data format names that may be used by an OpalMediaStream may be created by a connection from this endpoint.

Note that a specific connection may not actually support all of the media formats returned here, but should return no more.

The default behaviour returns the most basic media formats, PCM audio and YUV420P video.

Reimplemented from OpalConnection.

virtual bool OpalSockConnection::OnIncoming ( )
virtual

Call back to indicate that there is an incoming call. Note this function should not block or it will impede the operation of the stack.

The default implementation call OpalLocalEndPoint::OnIncomingCall().

Returns
false if the call is to be aborted with status of EndedByLocalBusy.

Reimplemented from OpalLocalConnection.

virtual bool OpalSockConnection::OnMediaCommand ( OpalMediaStream stream,
const OpalMediaCommand command 
)
virtual

Callback for media commands. Executes OnMediaCommand ont he other connection in call.

Returns
true if command is handled.
Parameters
streamStream command executed on
commandMedia command being executed

Reimplemented from OpalConnection.

virtual bool OpalSockConnection::OnOutgoing ( )
virtual

Call back to indicate that remote is ringing.

The default implementation call OpalLocalEndPoint::OnOutgoingCall().

Returns
false if the call is to be aborted with EndedByNoAccept.

Reimplemented from OpalLocalConnection.

virtual bool OpalSockConnection::OnReadMediaData ( OpalMediaStream mediaStream,
void *  data,
PINDEX  size,
PINDEX &  length 
)
virtual

Call back to get media data for transmission. If false is returned the media stream will be closed.

Care with the handling of real time is required, see GetSynchronicity for more details.

The default implementation fills the buffer with zeros and returns true.

Parameters
mediaStreamMedia stream data is required for
dataData to send
sizeMaximum size of data buffer
lengthNumber of bytes placed in buffer

Reimplemented from OpalLocalConnection.

virtual void OpalSockConnection::OnReleased ( )
virtual

Clean up the termination of the connection. This function can do any internal cleaning up and waiting on background threads that may be using the connection object.

Note that there is not a one to one relationship with the OnEstablishedConnection() function. This function may be called without that function being called. For example if SetUpConnection() was used but the call never completed.

Classes that override this function should make sure they call the ancestor version for correct operation.

An application will not typically call this function as it is used by the OpalManager during a release of the connection.

The default behaviour calls the OpalEndPoint function of the same name.

Reimplemented from OpalConnection.

virtual bool OpalSockConnection::OnWriteMediaData ( const OpalMediaStream mediaStream,
const void *  data,
PINDEX  length,
PINDEX &  written 
)
virtual

Call back to handle received media data. If false is returned the media stream will be closed.

It is expected that this function be real time. That is if 320 bytes of PCM-16 are written, this function should take 20ms to execute. If not then the jitter buffer will not operate correctly and audio will not be of high quality. This timing can be simulated if required, see GetSynchronicity for more details.

Note: For encoded audio media, if data is NULL then that indicates there is no incoming audio available from the jitter buffer. The application should output silence for a time. The written value should still contain the bytes of silence emitted, even though it will be larger that length. This does not occcur for raw (PCM-16) audio.

The default implementation ignores the media data and returns true.

Parameters
mediaStreamMedia stream data is required for
dataData received
lengthAmount of data available to write
writtenAmount of data written

Reimplemented from OpalLocalConnection.

bool OpalSockConnection::OpenMediaSocket ( PIPSocket *&  socket,
const PString &  addrKey,
const PString &  portKey,
const PCaselessString &  protoKey 
)
protected
bool OpalSockConnection::OpenMediaSockets ( )
protected
OpalSockConnection::PDECLARE_MUTEX ( m_writeMutex  )
protected
virtual bool OpalSockConnection::TransferConnection ( const PString &  remoteParty)
virtual

Initiate the transfer of an existing call (connection) to a new remote party.

If remoteParty is a valid call token, then the remote party is transferred to that party (consultation transfer) and both calls are cleared.

Parameters
remotePartyRemote party to transfer the existing call to

Reimplemented from OpalConnection.

Field Documentation

PIPSocket* OpalSockConnection::m_audioSocket
protected
OpalSockEndPoint& OpalSockConnection::m_endpoint
protected
PIPSocket* OpalSockConnection::m_videoSocket
protected

The documentation for this class was generated from the following file: