Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class CallPeerMediaHandlerGTalkImpl

java.lang.Object
  extended by net.java.sip.communicator.util.event.PropertyChangeNotifier
      extended by net.java.sip.communicator.service.protocol.media.CallPeerMediaHandler<CallPeerGTalkImpl>
          extended by net.java.sip.communicator.impl.protocol.jabber.CallPeerMediaHandlerGTalkImpl

public class CallPeerMediaHandlerGTalkImpl
extends CallPeerMediaHandler<CallPeerGTalkImpl>

A Google Talk-specific extension of the generic media handler.

Author:
Sebastien Vincent

Field Summary
static String AUDIO_RTP
          Google Talk name for the audio part.
static String VIDEO_RTP
          Google Talk name for the video part.
 
Fields inherited from class net.java.sip.communicator.service.protocol.media.CallPeerMediaHandler
AUDIO_LOCAL_SSRC, AUDIO_REMOTE_SSRC, SSRC_UNKNOWN, VIDEO_LOCAL_SSRC, VIDEO_REMOTE_SSRC
 
Constructor Summary
CallPeerMediaHandlerGTalkImpl(CallPeerGTalkImpl peer)
          Creates a new handler that will be managing media streams for peer.
 
Method Summary
 RtpDescriptionPacketExtension createDescription()
          Creates a List containing the ContentPacketExtensions of the streams that this handler is prepared to initiate depending on available MediaDevices and local on-hold and video transmission preferences.
protected  void firePropertyChange(String property, Object oldValue, Object newValue)
          Overrides to give access to the transport manager to send events about ICE state changes.
 RtpDescriptionPacketExtension generateSessionAccept(boolean initStream)
          Wraps up any ongoing candidate harvests and returns our response to the last offer we've received, so that the peer could use it to send a accept.
protected  DynamicPayloadTypeRegistry getDynamicPayloadTypes()
          Returns the DynamicPayloadTypeRegistry instance we are currently using.
protected  TransportManagerGTalkImpl getTransportManager()
          Gets the TransportManager implementation handling our address management.
protected  void harvestCandidates(List<PayloadTypePacketExtension> local, CandidatesSender candidatesSender)
          Gathers local candidate addresses.
protected  MediaStream initStream(String streamName, StreamConnector connector, MediaDevice device, MediaFormat format, MediaStreamTarget target, MediaDirection direction, List<RTPExtension> rtpExtensions, boolean masterStream)
          Creates if necessary, and configures the stream that this MediaHandler is using for the MediaType matching the one of the MediaDevice.
 void processAnswer(RtpDescriptionPacketExtension answer)
          Handles the specified answer by creating and initializing the corresponding MediaStreams.
 void processCandidates(Iterable<GTalkCandidatePacketExtension> candidates)
          Processes the transport-related information provided by the remote peer in a specific set of CandidatePacketExtensions.
 void processOffer(RtpDescriptionPacketExtension offer)
          Parses and handles the specified offer and returns a content extension representing the current state of this media handler.
 void start()
          Waits for the associated TransportManagerJabberImpl to conclude any started connectivity establishment and then starts this CallPeerMediaHandler.
protected  void throwOperationFailedException(String message, int errorCode, Throwable cause)
          Lets the underlying implementation take note of this error and only then throws it to the using bundles.
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.CallPeerMediaHandler
addAdvertisedEncryptionMethod, addVideoListener, close, closeStream, createLocalVisualComponent, disposeLocalVisualComponent, findMediaFormat, fireVideoEvent, fireVideoEvent, getAdvertisedEncryptionMethods, getAudioRemoteSSRC, getDefaultDevice, getDirectionUserPreference, getEncryptionMethod, getExtensionsForType, getICECandidateExtendedType, getICEState, getMediaHandler, getPeer, getRtpExtensionsRegistry, getSrtpControls, getStream, getVisualComponent, getVisualComponents, initStream, intersectFormats, intersectRTPExtensions, isLocalAudioTransmissionEnabled, isLocallyOnHold, isLocalVideoTransmissionEnabled, isMute, isRemotelyOnHold, isSecure, processKeyFrameRequest, removeVideoListener, requestKeyFrame, sendHolePunchPacket, setCsrcAudioLevelListener, setLocalAudioTransmissionEnabled, setLocallyOnHold, setLocalUserAudioLevelListener, setLocalVideoTransmissionEnabled, setMediaHandler, setMute, setStreamAudioLevelListener, startSrtpMultistream
 
Methods inherited from class net.java.sip.communicator.util.event.PropertyChangeNotifier
addPropertyChangeListener, getPropertyChangeSource, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUDIO_RTP

public static final String AUDIO_RTP
Google Talk name for the audio part.

See Also:
Constant Field Values

VIDEO_RTP

public static final String VIDEO_RTP
Google Talk name for the video part.

See Also:
Constant Field Values
Constructor Detail

CallPeerMediaHandlerGTalkImpl

public CallPeerMediaHandlerGTalkImpl(CallPeerGTalkImpl peer)
Creates a new handler that will be managing media streams for peer.

Parameters:
peer - that CallPeerGTalkImpl instance that we will be managing media for.
Method Detail

throwOperationFailedException

protected void throwOperationFailedException(String message,
                                             int errorCode,
                                             Throwable cause)
                                      throws OperationFailedException
Lets the underlying implementation take note of this error and only then throws it to the using bundles.

Specified by:
throwOperationFailedException in class CallPeerMediaHandler<CallPeerGTalkImpl>
Parameters:
message - the message to be logged and then wrapped in a new OperationFailedException
errorCode - the error code to be assigned to the new OperationFailedException
cause - the Throwable that has caused the necessity to log an error and have a new OperationFailedException thrown
Throws:
OperationFailedException - the exception that we wanted this method to throw.

processOffer

public void processOffer(RtpDescriptionPacketExtension offer)
                  throws OperationFailedException,
                         IllegalArgumentException
Parses and handles the specified offer and returns a content extension representing the current state of this media handler. This method MUST only be called when offer is the first session description that this MediaHandler is seeing.

Parameters:
offer - the offer that we'd like to parse, handle and get an answer for.
Throws:
OperationFailedException - if we have a problem satisfying the description received in offer (e.g. failed to open a device or initialize a stream ...).
IllegalArgumentException - if there's a problem with offer's format or semantics.

generateSessionAccept

public RtpDescriptionPacketExtension generateSessionAccept(boolean initStream)
                                                    throws OperationFailedException
Wraps up any ongoing candidate harvests and returns our response to the last offer we've received, so that the peer could use it to send a accept.

Parameters:
initStream - true to initialize stream, false to do nothing else
Returns:
the last generated list of RtpDescriptionPacketExtensions that the call peer could use to send a accept.
Throws:
OperationFailedException - if we fail to configure the media stream

processAnswer

public void processAnswer(RtpDescriptionPacketExtension answer)
                   throws OperationFailedException,
                          IllegalArgumentException
Handles the specified answer by creating and initializing the corresponding MediaStreams.

Parameters:
answer - the Google Talk answer
Throws:
OperationFailedException - if we fail to handle answer for reasons like failing to initialize media devices or streams.
IllegalArgumentException - if there's a problem with the syntax or the semantics of answer. Method is synchronized in order to avoid closing mediaHandler when we are currently in process of initializing, configuring and starting streams and anybody interested in this operation can synchronize to the mediaHandler instance to wait processing to stop (method setState in CallPeer).

getTransportManager

protected TransportManagerGTalkImpl getTransportManager()
Gets the TransportManager implementation handling our address management.

Specified by:
getTransportManager in class CallPeerMediaHandler<CallPeerGTalkImpl>
Returns:
the TransportManager implementation handling our address management
See Also:
CallPeerMediaHandler.getTransportManager()

processCandidates

public void processCandidates(Iterable<GTalkCandidatePacketExtension> candidates)
                       throws OperationFailedException
Processes the transport-related information provided by the remote peer in a specific set of CandidatePacketExtensions.

Parameters:
candidates - the CandidatePacketExtenions provided by the remote peer and containing the candidate-related information to be processed
Throws:
OperationFailedException - if anything goes wrong while processing the candidate-related information provided by the remote peer in the specified set of CandidatePacketExtensions

createDescription

public RtpDescriptionPacketExtension createDescription()
                                                throws OperationFailedException
Creates a List containing the ContentPacketExtensions of the streams that this handler is prepared to initiate depending on available MediaDevices and local on-hold and video transmission preferences.

Returns:
a RtpDescriptionPacketExtension that contains list of PayloadTypePacketExtension
Throws:
OperationFailedException - if we fail to create the descriptions for reasons like problems with device interaction, allocating ports, etc.

harvestCandidates

protected void harvestCandidates(List<PayloadTypePacketExtension> local,
                                 CandidatesSender candidatesSender)
                          throws OperationFailedException
Gathers local candidate addresses.

Parameters:
local - the media descriptions sent or to be sent from the local peer to the remote peer.
candidatesSender - the CandidatesSender to be used by this TransportManagerGTalkImpl to send candidates SessionIQs from the local peer to the remote peer if this TransportManagerGTalkImpl wishes to utilize candidates
Throws:
OperationFailedException - if anything goes wrong while starting or wrapping up the gathering of local candidate addresses

start

public void start()
           throws IllegalStateException
Waits for the associated TransportManagerJabberImpl to conclude any started connectivity establishment and then starts this CallPeerMediaHandler.

Overrides:
start in class CallPeerMediaHandler<CallPeerGTalkImpl>
Throws:
IllegalStateException - if no offer or answer has been provided or generated earlier

initStream

protected MediaStream initStream(String streamName,
                                 StreamConnector connector,
                                 MediaDevice device,
                                 MediaFormat format,
                                 MediaStreamTarget target,
                                 MediaDirection direction,
                                 List<RTPExtension> rtpExtensions,
                                 boolean masterStream)
                          throws OperationFailedException
Creates if necessary, and configures the stream that this MediaHandler is using for the MediaType matching the one of the MediaDevice. This method extends the one already available by adding a stream name, corresponding to a stream's content name.

Parameters:
streamName - the name of the stream as indicated in the XMPP content element.
connector - the MediaConnector that we'd like to bind the newly created stream to.
device - the MediaDevice that we'd like to attach the newly created MediaStream to.
format - the MediaFormat that we'd like the new MediaStream to be set to transmit in.
target - the MediaStreamTarget containing the RTP and RTCP address:port couples that the new stream would be sending packets to.
direction - the MediaDirection that we'd like the new stream to use (i.e. sendonly, sendrecv, recvonly, or inactive).
rtpExtensions - the list of RTPExtensions that should be enabled for this stream.
masterStream - whether the stream to be used as master if secured
Returns:
the newly created MediaStream.
Throws:
OperationFailedException - if creating the stream fails for any reason (like for example accessing the device or setting the format).

getDynamicPayloadTypes

protected DynamicPayloadTypeRegistry getDynamicPayloadTypes()
Returns the DynamicPayloadTypeRegistry instance we are currently using.

Overrides:
getDynamicPayloadTypes in class CallPeerMediaHandler<CallPeerGTalkImpl>
Returns:
the DynamicPayloadTypeRegistry instance we are currently using.

firePropertyChange

protected void firePropertyChange(String property,
                                  Object oldValue,
                                  Object newValue)
Overrides to give access to the transport manager to send events about ICE state changes.

Overrides:
firePropertyChange in class PropertyChangeNotifier
Parameters:
property - the name of the property of this PropertyChangeNotifier which had its value changed
oldValue - the value of the property with the specified name before the change
newValue - the value of the property with the specified name after

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.