src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java
/**
     * 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
     * <tt>session-accept</tt>.
     *
     * @return  the last generated list of {@link ContentPacketExtension}s that
     * the call peer could use to send a <tt>session-accept</tt>.
     *
     * @throws OperationFailedException if we fail to configure the media stream
     */
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
session-accept.

@return  the last generated list of  ContentPacketExtensions that
the call peer could use to send a session-accept.

@throws OperationFailedException if we fail to configure the media stream
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 session - accept . @return the last generated list of ContentPacketExtensions that the call peer could use to send a session - accept . @throws OperationFailedException if we fail to configure the media stream
public Iterable<ContentPacketExtension> generateSessionAccept()
        throws OperationFailedException
    {
        TransportManagerJabberImpl transportManager = getTransportManager();
        Iterable<ContentPacketExtension> sessAccept
            = transportManager.wrapupCandidateHarvest();
        CallPeerJabberImpl peer = getPeer();
        Map<ContentPacketExtension,RtpDescriptionPacketExtension> contents
            = new HashMap<ContentPacketExtension,RtpDescriptionPacketExtension>();
        for(ContentPacketExtension ourContent : sessAccept)
        {
            RtpDescriptionPacketExtension description
                = JingleUtils.getRtpDescription(ourContent);
            contents.put(ourContent, description);
        }
        boolean masterStreamSet = false;
        for(Map.Entry<ContentPacketExtension, RtpDescriptionPacketExtension> en
                : contents.entrySet())
        {
            ContentPacketExtension ourContent = en.getKey();
            RtpDescriptionPacketExtension description = en.getValue();
            MediaType type = MediaType.parseString(description.getMedia());
            StreamConnector connector
                = transportManager.getStreamConnector(type);
            MediaDevice dev = getDefaultDevice(type);
            if(!isDeviceActive(dev))
                continue;
            MediaStreamTarget target = transportManager.getStreamTarget(type);
            MediaDirection direction
                = JingleUtils.getDirection(ourContent, !peer.isInitiator());
            if (MediaType.VIDEO.equals(type)
                    && (isLocalVideoTransmissionEnabled()
                            || isRTPTranslationEnabled(type))
                    && dev.getDirection().allowsSending())
            {
               direction = MediaDirection.SENDRECV;
               ourContent.setSenders(ContentPacketExtension.SendersEnum.both);
            }
            String contentName = ourContent.getName();
            ContentPacketExtension theirContent
                = this.remoteContentMap.get(contentName);
            RtpDescriptionPacketExtension theirDescription
                = JingleUtils.getRtpDescription(theirContent);
            MediaFormat format = null;
            List<MediaFormat> localFormats = getLocallySupportedFormats(dev);
            for(PayloadTypePacketExtension payload
                    : theirDescription.getPayloadTypes())
            {
                MediaFormat remoteFormat = JingleUtils.payloadTypeToMediaFormat(
                            payload, getDynamicPayloadTypes());
                if(remoteFormat != null
                     && (format = findMediaFormat(localFormats, remoteFormat))
                            != null)
                    break;
            }
            if(format == null)
            {
                ProtocolProviderServiceJabberImpl.throwOperationFailedException(
                        "No matching codec.",
                        OperationFailedException.ILLEGAL_ARGUMENT,
                        null,
                        logger);
            }
            List<RTPExtension> rtpExtensions
                = JingleUtils.extractRTPExtensions(
                        description,
                        this.getRtpExtensionsRegistry());
            Map<String, String> adv = format.getAdvancedAttributes();
            if(adv != null)
            {
                for(Map.Entry<String, String> f : adv.entrySet())
                {
                    if(f.getKey().equals("imageattr"))
                        supportQualityControls = true;
                }
            }
            boolean masterStream = false;
            if(!masterStreamSet)
            {
                if(contents.size() > 1)
                {
                    if(type.equals(MediaType.AUDIO))
                    {
                        masterStream = true;
                        masterStreamSet = true;
                    }
                }
                else
                {
                    masterStream = true;
                    masterStreamSet = true;
                }
            }
            MediaStream stream = initStream(contentName,
                                            connector,
                                            dev,
                                            format,
                                            target,
                                            direction,
                                            rtpExtensions,
                                            masterStream);
            long ourSsrc = stream.getLocalSourceID();
            if (direction.allowsSending() && ourSsrc != -1)
            {
                description.setSsrc(Long.toString(ourSsrc));
                addSourceExtension(description, ourSsrc);
            }
        }
        return sessAccept;
    }
public Iterable < ContentPacketExtension > generateSessionAccept ( ) throws OperationFailedException { TransportManagerJabberImpl transportManager = getTransportManager ( ) ; Iterable < ContentPacketExtension > sessAccept = transportManager . wrapupCandidateHarvest ( ) ; CallPeerJabberImpl peer = getPeer ( ) ; Map < ContentPacketExtension , RtpDescriptionPacketExtension > contents = new HashMap < ContentPacketExtension , RtpDescriptionPacketExtension > ( ) ; for ( ContentPacketExtension ourContent : sessAccept ) { RtpDescriptionPacketExtension description = JingleUtils . getRtpDescription ( ourContent ) ; contents . put ( ourContent , description ) ; } boolean masterStreamSet = false ; for ( Map . Entry < ContentPacketExtension , RtpDescriptionPacketExtension > en : contents . entrySet ( ) ) { ContentPacketExtension ourContent = en . getKey ( ) ; RtpDescriptionPacketExtension description = en . getValue ( ) ; MediaType type = MediaType . parseString ( description . getMedia ( ) ) ; StreamConnector connector = transportManager . getStreamConnector ( type ) ; MediaDevice dev = getDefaultDevice ( type ) ; if ( ! isDeviceActive ( dev ) ) continue ; MediaStreamTarget target = transportManager . getStreamTarget ( type ) ; MediaDirection direction = JingleUtils . getDirection ( ourContent , ! peer . isInitiator ( ) ) ; if ( MediaType . VIDEO . equals ( type ) && ( isLocalVideoTransmissionEnabled ( ) || isRTPTranslationEnabled ( type ) ) && dev . getDirection ( ) . allowsSending ( ) ) { direction = MediaDirection . SENDRECV ; ourContent . setSenders ( ContentPacketExtension . SendersEnum . both ) ; } String contentName = ourContent . getName ( ) ; ContentPacketExtension theirContent = this . remoteContentMap . get ( contentName ) ; RtpDescriptionPacketExtension theirDescription = JingleUtils . getRtpDescription ( theirContent ) ; MediaFormat format = null ; List < MediaFormat > localFormats = getLocallySupportedFormats ( dev ) ; for ( PayloadTypePacketExtension payload : theirDescription . getPayloadTypes ( ) ) { MediaFormat remoteFormat = JingleUtils . payloadTypeToMediaFormat ( payload , getDynamicPayloadTypes ( ) ) ; if ( remoteFormat != null && ( format = findMediaFormat ( localFormats , remoteFormat ) ) != null ) break ; } if ( format == null ) { ProtocolProviderServiceJabberImpl . throwOperationFailedException ( "No matching codec." , OperationFailedException . ILLEGAL_ARGUMENT , null , logger ) ; } List < RTPExtension > rtpExtensions = JingleUtils . extractRTPExtensions ( description , this . getRtpExtensionsRegistry ( ) ) ; Map < String , String > adv = format . getAdvancedAttributes ( ) ; if ( adv != null ) { for ( Map . Entry < String , String > f : adv . entrySet ( ) ) { if ( f . getKey ( ) . equals ( "imageattr" ) ) supportQualityControls = true ; } } boolean masterStream = false ; if ( ! masterStreamSet ) { if ( contents . size ( ) > 1 ) { if ( type . equals ( MediaType . AUDIO ) ) { masterStream = true ; masterStreamSet = true ; } } else { masterStream = true ; masterStreamSet = true ; } } MediaStream stream = initStream ( contentName , connector , dev , format , target , direction , rtpExtensions , masterStream ) ; long ourSsrc = stream . getLocalSourceID ( ) ; if ( direction . allowsSending ( ) && ourSsrc != - 1 ) { description . setSsrc ( Long . toString ( ourSsrc ) ) ; addSourceExtension ( description , ourSsrc ) ; } } return sessAccept ; }
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
 <tt>session-accept</tt>.
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 <tt > session - accept< / tt > .
//user answered an incoming call so we go through whatever content //entries we are initializing and init their corresponding streams // First parse content so we know how many streams and what type of // content we have // stream connector //the device this stream would be reading from and writing to. // stream target //stream direction // if we answer with video, tell remote peer that video direction is // sendrecv, and whether video device can capture/send //let's now see what was the format we announced as first and //configure the stream with it. //extract the extensions that we are advertising: // check whether we will be exchanging any RTP extensions. // if we have more than one stream, lets the audio be the master // create the corresponding stream...