Package org.zoolu.sdp

Examples of org.zoolu.sdp.MediaDescriptor


    public static Codec getNegotiatedAudioCodec(SessionDescriptor negotiatedSDP){
        int payloadId;
        String rtpmap;
        Codec sipCodec = null;
       
        MediaDescriptor md = negotiatedSDP.getMediaDescriptor(Codec.MEDIA_TYPE_AUDIO );
        rtpmap = md.getAttribute(Codec.ATTRIBUTE_RTPMAP).getAttributeValue();
       
        if (!rtpmap.isEmpty()) {           
            payloadId = Integer.parseInt(rtpmap.substring(0, rtpmap.indexOf(" ")));
           
            sipCodec = CodecFactory.getInstance().getSIPAudioCodec(payloadId);           
View Full Code Here


                    localSdp.getConnection(), localSdp.getTime());
           
            Vector remoteDescriptors = remoteSdp.getMediaDescriptors();
           
            for (Enumeration descriptorsEnum = remoteDescriptors.elements(); descriptorsEnum.hasMoreElements();) {               
                MediaDescriptor remoteDescriptor = (MediaDescriptor) descriptorsEnum.nextElement();
                MediaDescriptor localDescriptor = localSdp.getMediaDescriptor(remoteDescriptor.getMedia().getMedia() );
               
                if (localDescriptor != null) {                   
                    Vector remoteAttributes = remoteDescriptor.getAttributes(Codec.ATTRIBUTE_RTPMAP);
                    Vector<AttributeField> newSdpAttributes = new Vector<AttributeField>();
                   
                    for (Enumeration attributesEnum = remoteAttributes.elements(); attributesEnum.hasMoreElements();) {                       
                        AttributeField remoteAttribute = (AttributeField) attributesEnum.nextElement();
                       
                        String payloadId = getPayloadIdFromAttribute(remoteAttribute);
                       
                        if ("".equals(payloadId)) {                           
                            log.error("Payload id not found on attribute: Name = [" +
                                    remoteAttribute.getAttributeName() + "], Value = [" +
                                    remoteAttribute.getAttributeValue() + "]." );
                        } else if (findAttributeByPayloadId(remoteAttribute.getAttributeName(),
                            payloadId, localDescriptor) != null) {                           
                            newSdpAttributes.add(remoteAttribute);
                        }
                    }
                   
                    // Calculate the format list to be used on MediaDescriptor creation.
                    String formatList = getFormatList(newSdpAttributes);
                   
                    for (Enumeration attributesEnum = newSdpAttributes.elements(); attributesEnum.hasMoreElements();) {                       
                        AttributeField mediaAttribute = (AttributeField) attributesEnum.nextElement();
                       
                        if (newSdp.getMediaDescriptors().size() == 0) { 
                          MediaField mf = new MediaField(localDescriptor.getMedia().getMedia(),
                                                localDescriptor.getMedia().getPort(),
                                                0, localDescriptor.getMedia().getTransport(),
                                                formatList);
                            newSdp.addMediaDescriptor(new MediaDescriptor(mf, localDescriptor.getConnection()));
                        }
                       
                        newSdp.getMediaDescriptor(localDescriptor.getMedia().getMedia()).addAttribute( mediaAttribute );
                    }
                }
            }
        } catch (Exception exception) {           
            log.error("Failure creating initial SDP: " + exception.toString());
View Full Code Here

            }
           
            Vector remoteDescriptors = remoteSdp.getMediaDescriptors();
           
            for (Enumeration descriptorsEnum = remoteDescriptors.elements(); descriptorsEnum.hasMoreElements();) {               
                MediaDescriptor remoteDescriptor = (MediaDescriptor) descriptorsEnum.nextElement();
                MediaDescriptor localDescriptor = localSdp.getMediaDescriptor(remoteDescriptor.getMedia().getMedia());
               
                if (localDescriptor != null) {                   
                    // First we make the negotiation of remote attributes with
                    // local ones to generate the new SDP "newSdp".
                   
                    Vector remoteAttributes = remoteDescriptor.getAttributes();
                   
                    for (Enumeration atributesEnum = remoteAttributes.elements(); atributesEnum.hasMoreElements();) {                       
                        AttributeField remoteAttribute = (AttributeField) atributesEnum.nextElement();                       
                        makeAttributeNegotiation(newSdp, localDescriptor, remoteAttribute);
                    }
                   
                    // Now we add to "newSdp" all the local attributes that
                    // were not negotiated yet.
                   
                    Vector localAttributes = localDescriptor.getAttributes();
                   
                    for (Enumeration atributesEnum = localAttributes.elements(); atributesEnum.hasMoreElements();) {                       
                        AttributeField localAttribute = (AttributeField) atributesEnum.nextElement();
                        MediaDescriptor newLocalDescriptor = newSdp.getMediaDescriptor(localDescriptor.getMedia().getMedia());
                       
                        if (isPayloadRelatedAttribute(localAttribute)) {                           
                            String payloadId = getPayloadIdFromAttribute(localAttribute);
                           
                            if (findAttributeByPayloadId(localAttribute.getAttributeName(),
                                              payloadId, newLocalDescriptor) == null) {                               
                                newLocalDescriptor.addAttribute(localAttribute);
                            }
                        } else if (newLocalDescriptor.getAttribute(localAttribute.getAttributeName()) == null) {                           
                            newLocalDescriptor.addAttribute(localAttribute);
                        }
                    }
                }
            }
        } catch (Exception exception) {           
View Full Code Here

                        String attributeValueResult = sipCodec.codecNegotiateAttribute(remoteAttribute.getAttributeName(),
                                          localAttibuteValue, remoteAttribute.getAttributeValue());
                       
                        if ((attributeValueResult != null) && (!"".equals(attributeValueResult))) {
                          AttributeField af = new AttributeField(remoteAttribute.getAttributeName(), attributeValueResult);
                          MediaDescriptor md = newSdp.getMediaDescriptor(localMedia.getMedia().getMedia());
                            md.addAttribute(af);
                        }
                    } else {                       
                        log.warn("Codec not found!");
                    }
                }
View Full Code Here

   
  public static int getRemoteAudioPort(SessionDescriptor remoteSdp) {
      int remoteAudioPort = 0;

        for (Enumeration e = remoteSdp.getMediaDescriptors().elements(); e.hasMoreElements();) {
            MediaDescriptor descriptor = (MediaDescriptor) e.nextElement();
            MediaField media = descriptor.getMedia();

            if (media.getMedia().equals("audio")) {
                remoteAudioPort = media.getPort();
            }
        }
View Full Code Here

    public static Codec getNegotiatedAudioCodec(SessionDescriptor negotiatedSDP){
        int payloadId;
        String rtpmap;
        Codec sipCodec = null;
       
        MediaDescriptor md = negotiatedSDP.getMediaDescriptor(Codec.MEDIA_TYPE_AUDIO );
        rtpmap = md.getAttribute(Codec.ATTRIBUTE_RTPMAP).getAttributeValue();
       
        if (!rtpmap.isEmpty()) {           
            payloadId = Integer.parseInt(rtpmap.substring(0, rtpmap.indexOf(" ")));
           
            sipCodec = CodecFactory.getInstance().getSIPAudioCodec(payloadId);           
View Full Code Here

                    localSdp.getConnection(), localSdp.getTime());
           
            Vector remoteDescriptors = remoteSdp.getMediaDescriptors();
           
            for (Enumeration descriptorsEnum = remoteDescriptors.elements(); descriptorsEnum.hasMoreElements();) {               
                MediaDescriptor remoteDescriptor = (MediaDescriptor) descriptorsEnum.nextElement();
                MediaDescriptor localDescriptor = localSdp.getMediaDescriptor(remoteDescriptor.getMedia().getMedia() );
               
                if (localDescriptor != null) {                   
                    Vector remoteAttributes = remoteDescriptor.getAttributes(Codec.ATTRIBUTE_RTPMAP);
                    Vector newSdpAttributes = new Vector();
                   
                    for (Enumeration attributesEnum = remoteAttributes.elements(); attributesEnum.hasMoreElements();) {                       
                        AttributeField remoteAttribute = (AttributeField) attributesEnum.nextElement();
                       
                        String payloadId = getPayloadIdFromAttribute(remoteAttribute);
                       
                        if ("".equals(payloadId)) {                           
                            log.error("Payload id not found on attribute: Name = [" +
                                    remoteAttribute.getAttributeName() + "], Value = [" +
                                    remoteAttribute.getAttributeValue() + "]." );
                        } else if (findAttributeByPayloadId(remoteAttribute.getAttributeName(),
                            payloadId, localDescriptor) != null) {                           
                            newSdpAttributes.add(remoteAttribute);
                        }
                    }
                   
                    // Calculate the format list to be used on MediaDescriptor creation.
                    String formatList = getFormatList(newSdpAttributes);
                   
                    for (Enumeration attributesEnum = newSdpAttributes.elements(); attributesEnum.hasMoreElements();) {                       
                        AttributeField mediaAttribute = (AttributeField) attributesEnum.nextElement();
                       
                        if (newSdp.getMediaDescriptors().size() == 0) { 
                          MediaField mf = new MediaField(localDescriptor.getMedia().getMedia(),
                                                localDescriptor.getMedia().getPort(),
                                                0, localDescriptor.getMedia().getTransport(),
                                                formatList);
                            newSdp.addMediaDescriptor(new MediaDescriptor(mf, localDescriptor.getConnection()));
                        }
                       
                        newSdp.getMediaDescriptor(localDescriptor.getMedia().getMedia()).addAttribute( mediaAttribute );
                    }
                }
            }
        } catch (Exception exception) {           
            log.error("Failure creating initial SDP: " + exception.toString());
View Full Code Here

            }
           
            Vector remoteDescriptors = remoteSdp.getMediaDescriptors();
           
            for (Enumeration descriptorsEnum = remoteDescriptors.elements(); descriptorsEnum.hasMoreElements();) {               
                MediaDescriptor remoteDescriptor = (MediaDescriptor) descriptorsEnum.nextElement();
                MediaDescriptor localDescriptor = localSdp.getMediaDescriptor(remoteDescriptor.getMedia().getMedia());
               
                if (localDescriptor != null) {                   
                    // First we make the negotiation of remote attributes with
                    // local ones to generate the new SDP "newSdp".
                   
                    Vector remoteAttributes = remoteDescriptor.getAttributes();
                   
                    for (Enumeration atributesEnum = remoteAttributes.elements(); atributesEnum.hasMoreElements();) {                       
                        AttributeField remoteAttribute = (AttributeField) atributesEnum.nextElement();                       
                        makeAttributeNegotiation(newSdp, localDescriptor, remoteAttribute);
                    }
                   
                    // Now we add to "newSdp" all the local attributes that
                    // were not negotiated yet.
                   
                    Vector localAttributes = localDescriptor.getAttributes();
                   
                    for (Enumeration atributesEnum = localAttributes.elements(); atributesEnum.hasMoreElements();) {                       
                        AttributeField localAttribute = (AttributeField) atributesEnum.nextElement();
                        MediaDescriptor newLocalDescriptor = newSdp.getMediaDescriptor(localDescriptor.getMedia().getMedia());
                       
                        if (isPayloadRelatedAttribute(localAttribute)) {                           
                            String payloadId = getPayloadIdFromAttribute(localAttribute);
                           
                            if (findAttributeByPayloadId(localAttribute.getAttributeName(),
                                              payloadId, newLocalDescriptor) == null) {                               
                                newLocalDescriptor.addAttribute(localAttribute);
                            }
                        } else if (newLocalDescriptor.getAttribute(localAttribute.getAttributeName()) == null) {                           
                            newLocalDescriptor.addAttribute(localAttribute);
                        }
                    }
                }
            }
        } catch (Exception exception) {           
View Full Code Here

                        String attributeValueResult = sipCodec.codecNegotiateAttribute(remoteAttribute.getAttributeName(),
                                          localAttibuteValue, remoteAttribute.getAttributeValue());
                       
                        if ((attributeValueResult != null) && (!"".equals(attributeValueResult))) {
                          AttributeField af = new AttributeField(remoteAttribute.getAttributeName(), attributeValueResult);
                          MediaDescriptor md = newSdp.getMediaDescriptor(localMedia.getMedia().getMedia());
                            md.addAttribute(af);
                        }
                    } else {                       
                        log.warn("Codec not found!");
                    }
                }
View Full Code Here

TOP

Related Classes of org.zoolu.sdp.MediaDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.