src/net/java/sip/communicator/service/protocol/media/MediaHandler.java
/**
     * Configures <tt>stream</tt> to use the specified <tt>device</tt>,
     * <tt>format</tt>, <tt>target</tt>, <tt>direction</tt>, etc.
     *
     * @param device the <tt>MediaDevice</tt> to be used by <tt>stream</tt>
     * for capture and playback
     * @param format the <tt>MediaFormat</tt> that we'd like the new stream
     * to transmit in.
     * @param target the <tt>MediaStreamTarget</tt> containing the RTP and
     * RTCP address:port couples that the new stream would be sending
     * packets to.
     * @param direction the <tt>MediaDirection</tt> that we'd like the new
     * stream to use (i.e. sendonly, sendrecv, recvonly, or inactive).
     * @param rtpExtensions the list of <tt>RTPExtension</tt>s that should be
     * enabled for this stream.
     * @param stream the <tt>MediaStream</tt> that we'd like to configure.
     * @param masterStream whether the stream to be used as master if secured
     *
     * @return the <tt>MediaStream</tt> that we received as a parameter (for
     * convenience reasons).
     *
     * @throws OperationFailedException if setting the <tt>MediaFormat</tt>
     * or connecting to the specified <tt>MediaDevice</tt> fails for some
     * reason.
     */
Configures stream to use the specified device,
format, target, direction, etc.

@param device the MediaDevice to be used by stream
for capture and playback
@param format the MediaFormat that we'd like the new stream
to transmit in.
@param target the MediaStreamTarget containing the RTP and
RTCP address:port couples that the new stream would be sending
packets to.
@param direction the MediaDirection that we'd like the new
stream to use .
@param rtpExtensions the list of RTPExtensions that should be
enabled for this stream.
@param stream the MediaStream that we'd like to configure.
@param masterStream whether the stream to be used as master if secured

@return the MediaStream that we received as a parameter (for
convenience reasons).

@throws OperationFailedException if setting the MediaFormat
or connecting to the specified MediaDevice fails for some
reason.
Configures stream to use the specified device format target direction etc . @param device the MediaDevice to be used by stream for capture and playback @param format the MediaFormat that we ' d like the new stream to transmit in . @param target the MediaStreamTarget containing the RTP and RTCP address : port couples that the new stream would be sending packets to . @param direction the MediaDirection that we ' d like the new stream to use . @param rtpExtensions the list of RTPExtensions that should be enabled for this stream . @param stream the MediaStream that we ' d like to configure . @param masterStream whether the stream to be used as master if secured @return the MediaStream that we received as a parameter ( for convenience reasons ) . @throws OperationFailedException if setting the MediaFormat or connecting to the specified MediaDevice fails for some reason .
protected MediaStream configureStream(
            CallPeerMediaHandler<?> callPeerMediaHandler,
            MediaDevice device,
            MediaFormat format,
            MediaStreamTarget target,
            MediaDirection direction,
            List<RTPExtension> rtpExtensions,
            MediaStream stream,
            boolean masterStream)
        throws OperationFailedException
    {
        registerDynamicPTsWithStream(callPeerMediaHandler, stream);
        registerRTPExtensionsWithStream(
                callPeerMediaHandler,
                rtpExtensions, stream);
        stream.setDevice(device);
        stream.setTarget(target);
        stream.setDirection(direction);
        stream.setFormat(format);
        MediaAwareCall<?,?,?> call = callPeerMediaHandler.getPeer().getCall();
        MediaType mediaType
            = (stream instanceof AudioMediaStream)
                ? MediaType.AUDIO
                : MediaType.VIDEO;
        stream.setRTPTranslator(call.getRTPTranslator(mediaType));
        switch (mediaType)
        {
        case AUDIO:
            AudioMediaStream audioStream = (AudioMediaStream) stream;
            /*
             * The volume (level) of the audio played back in calls should be
             * call-specific i.e. it should be able to change the volume (level)
             * of a call without affecting any other simultaneous calls.
             */
            setOutputVolumeControl(audioStream, call);
            setAudioStream(audioStream);
            break;
        case VIDEO:
            setVideoStream((VideoMediaStream) stream);
            break;
        }
        if (call.isDefaultEncrypted())
        {
            /*
             * We'll use the audio stream as the master stream when using SRTP
             * multistreams.
             */
            SrtpControl srtpControl = stream.getSrtpControl();
            srtpControl.setMasterSession(masterStream);
            srtpControl.setSrtpListener(srtpListener);
            srtpControl.start(mediaType);
        }
        /*
         * If the specified callPeerMediaHandler is going to see the stream as
         * a new instance, count a new reference to it so that this MediaHandler
         * knows when it really needs to close the stream later on upon calls to
         * #closeStream(CallPeerMediaHandler<?>, MediaType).
         */
        if (stream != callPeerMediaHandler.getStream(mediaType))
            streamReferenceCounts[mediaType.ordinal()]++;
        return stream;
    }
protected MediaStream configureStream ( CallPeerMediaHandler < ? > callPeerMediaHandler , MediaDevice device , MediaFormat format , MediaStreamTarget target , MediaDirection direction , List < RTPExtension > rtpExtensions , MediaStream stream , boolean masterStream ) throws OperationFailedException { registerDynamicPTsWithStream ( callPeerMediaHandler , stream ) ; registerRTPExtensionsWithStream ( callPeerMediaHandler , rtpExtensions , stream ) ; stream . setDevice ( device ) ; stream . setTarget ( target ) ; stream . setDirection ( direction ) ; stream . setFormat ( format ) ; MediaAwareCall < ? , ? , ? > call = callPeerMediaHandler . getPeer ( ) . getCall ( ) ; MediaType mediaType = ( stream instanceof AudioMediaStream ) ? MediaType . AUDIO : MediaType . VIDEO ; stream . setRTPTranslator ( call . getRTPTranslator ( mediaType ) ) ; switch ( mediaType ) { case AUDIO : AudioMediaStream audioStream = ( AudioMediaStream ) stream ; /*
             * The volume (level) of the audio played back in calls should be
             * call-specific i.e. it should be able to change the volume (level)
             * of a call without affecting any other simultaneous calls.
             */ setOutputVolumeControl ( audioStream , call ) ; setAudioStream ( audioStream ) ; break ; case VIDEO : setVideoStream ( ( VideoMediaStream ) stream ) ; break ; } if ( call . isDefaultEncrypted ( ) ) { /*
             * We'll use the audio stream as the master stream when using SRTP
             * multistreams.
             */ SrtpControl srtpControl = stream . getSrtpControl ( ) ; srtpControl . setMasterSession ( masterStream ) ; srtpControl . setSrtpListener ( srtpListener ) ; srtpControl . start ( mediaType ) ; } /*
         * If the specified callPeerMediaHandler is going to see the stream as
         * a new instance, count a new reference to it so that this MediaHandler
         * knows when it really needs to close the stream later on upon calls to
         * #closeStream(CallPeerMediaHandler<?>, MediaType).
         */ if ( stream != callPeerMediaHandler . getStream ( mediaType ) ) streamReferenceCounts [ mediaType . ordinal ( ) ] ++ ; return stream ; }
Configures <tt>stream</tt> to use the specified <tt>device</tt>,
 <tt>format</tt>, <tt>target</tt>, <tt>direction</tt>, etc.
Configures <tt > stream< / tt > to use the specified <tt > device< / tt > <tt > format< / tt > <tt > target< / tt > <tt > direction< / tt > etc .