Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class CallPeerMediaHandlerSipImpl

java.lang.Object
  extended by net.java.sip.communicator.util.PropertyChangeNotifier
      extended by net.java.sip.communicator.service.protocol.media.CallPeerMediaHandler<CallPeerSipImpl>
          extended by net.java.sip.communicator.impl.protocol.sip.CallPeerMediaHandlerSipImpl

public class CallPeerMediaHandlerSipImpl
extends CallPeerMediaHandler<CallPeerSipImpl>

The media handler class handles all media management for a single CallPeer. This includes initializing and configuring streams, generating SDP, handling ICE, etc. One instance of CallPeer always corresponds to exactly one instance of CallPeerMediaHandler and both classes are only separated for reasons of readability.

Author:
Emil Ivov, Lubomir Marinov

Field Summary
(package private)  boolean supportQualityControls
          Whether other party is able to change video quality settings.
 
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
CallPeerMediaHandlerSipImpl(CallPeerSipImpl peer)
          Creates a new handler that will be managing media streams for peer.
 
Method Summary
 String createOffer()
          Creates a session description String representing the MediaStreams that this MediaHandler is prepare to exchange.
 URL getCallInfoURL()
          Returns a URL pointing ta a location with call control information for this peer or null if no such URL is available for the CallPeer associated with this handler..
protected  ConfigurationService getConfigurationService()
          Returns a reference to the currently valid media service for use by this handler's generic ancestor.
protected  MediaService getMediaService()
          Returns a reference to the currently valid media service for use by this handler's generic ancestor.
protected  NetworkAddressManagerService getNetworkAddressManagerService()
          Returns a reference to the currently valid network address manager service for use by this handler's generic ancestor.
 QualityControl getQualityControl()
          Returns the quality control for video calls if any.
protected  TransportManagerSipImpl getTransportManager()
          Returns the transport manager that is handling our address management.
 void processAnswer(String answer)
          Handles the specified answer by creating and initializing the corresponding MediaStreams.
 String processOffer(String offerString)
          Parses offerString, creates the MediaStreams that it describes and constructs a response representing the state of this MediaHandler.
 void setSupportQualityControls(boolean value)
          Sometimes as initing a call with custom preset can set and we force that quality controls is supported.
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
addVideoListener, close, closeStream, configureStream, createLocalVisualComponent, disposeLocalVisualComponent, findMediaFormat, fireVideoEvent, fireVideoEvent, getAudioRemoteSSRC, getDefaultDevice, getDirectionUserPreference, getDynamicPayloadTypes, getExtensionsForType, getPeer, getRtpExtensionsRegistry, getSrtpControls, getStream, getVisualComponent, getVisualComponents, initStream, intersectFormats, intersectRTPExtensions, isLocalAudioTransmissionEnabled, isLocallyOnHold, isLocalVideoTransmissionEnabled, isMute, isRemotelyOnHold, isSecure, isStarted, processKeyFrameRequest, removeVideoListener, requestKeyFrame, sendHolePunchPacket, setAudioStream, setCsrcAudioLevelListener, setLocalAudioTransmissionEnabled, setLocallyOnHold, setLocalUserAudioLevelListener, setLocalVideoTransmissionEnabled, setMute, setStreamAudioLevelListener, start, startSrtpMultistream
 
Methods inherited from class net.java.sip.communicator.util.PropertyChangeNotifier
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportQualityControls

boolean supportQualityControls
Whether other party is able to change video quality settings. Normally its whether we have detected existence of imageattr in sdp.

Constructor Detail

CallPeerMediaHandlerSipImpl

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

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

createOffer

public String createOffer()
                   throws OperationFailedException
Creates a session description String representing the MediaStreams that this MediaHandler is prepare to exchange. The offer takes into account user preferences such as whether or not local user would be transmitting video, whether any or all streams are put on hold, etc. The method is also taking into account any previous offers that this handler may have previously issues hence making the newly generated String an session creation or a session update offer accordingly.

Returns:
an SDP description String representing the streams that this handler is prepared to initiate.
Throws:
OperationFailedException - if creating the SDP fails for some reason.

processOffer

public String processOffer(String offerString)
                    throws OperationFailedException,
                           IllegalArgumentException
Parses offerString, creates the MediaStreams that it describes and constructs a response representing the state of this MediaHandler. The method takes into account the presence or absence of previous negotiations and interprets the offerString as an initial offer or a session update accordingly.

Parameters:
offerString - The SDP offer that we'd like to parse, handle and get a response for.
Returns:
A String containing the SDP response representing the current state of this MediaHandler.
Throws:
OperationFailedException - if parsing or handling offerString fails or we have a problem while creating the response.
IllegalArgumentException - if there's a problem with the format or semantics of the offerString.

processAnswer

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

Parameters:
answer - the SDP answer that we'd like to handle.
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.

getCallInfoURL

public URL getCallInfoURL()
Returns a URL pointing ta a location with call control information for this peer or null if no such URL is available for the CallPeer associated with this handler..

Returns:
a URL link to a location with call information or a call control web interface related to our CallPeer or null if no such URL.

getNetworkAddressManagerService

protected NetworkAddressManagerService getNetworkAddressManagerService()
Returns a reference to the currently valid network address manager service for use by this handler's generic ancestor.

Returns:
a reference to the currently valid NetworkAddressManagerService

getConfigurationService

protected ConfigurationService getConfigurationService()
Returns a reference to the currently valid media service for use by this handler's generic ancestor.

Returns:
a reference to the currently valid MediaService

getMediaService

protected MediaService getMediaService()
Returns a reference to the currently valid media service for use by this handler's generic ancestor.

Returns:
a reference to the currently valid MediaService

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<CallPeerSipImpl>
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.

getTransportManager

protected TransportManagerSipImpl getTransportManager()
Returns the transport manager that is handling our address management.

Specified by:
getTransportManager in class CallPeerMediaHandler<CallPeerSipImpl>
Returns:
the transport manager that is handling our address management.

getQualityControl

public QualityControl getQualityControl()
Returns the quality control for video calls if any.

Returns:
the implemented quality control.

setSupportQualityControls

public void setSupportQualityControls(boolean value)
Sometimes as initing a call with custom preset can set and we force that quality controls is supported.

Parameters:
value - whether quality controls is supported..

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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