Ejemplo n.º 1
0
 /* HSC CHANGES START */
 public static SessionDescriptor sdpMediaProduct(
     SessionDescriptor sdp, Vector<MediaDescriptor> m_descs) {
   Vector<MediaDescriptor> new_media = new Vector<MediaDescriptor>();
   if (m_descs != null) {
     for (Enumeration<MediaDescriptor> e = m_descs.elements(); e.hasMoreElements(); ) {
       MediaDescriptor spec_md = e.nextElement();
       // System.out.print("DEBUG: SDP: sdp_select:
       // "+spec_md.toString());
       MediaDescriptor prev_md = sdp.getMediaDescriptor(spec_md.getMedia().getMedia());
       // System.out.print("DEBUG: SDP: sdp_origin:
       // "+prev_md.toString());
       if (prev_md != null) {
         Vector<AttributeField> spec_attributes = spec_md.getAttributes();
         Vector<AttributeField> prev_attributes = prev_md.getAttributes();
         if (spec_attributes.size() == 0 || prev_attributes.size() == 0) {
           new_media.addElement(prev_md);
         } else {
           Vector<AttributeField> new_attributes = new Vector<AttributeField>();
           for (Enumeration<AttributeField> i = spec_attributes.elements();
               i.hasMoreElements(); ) {
             AttributeField spec_attr = i.nextElement();
             String spec_name = spec_attr.getAttributeName();
             String spec_value = spec_attr.getAttributeValue();
             for (Enumeration<AttributeField> k = prev_attributes.elements();
                 k.hasMoreElements(); ) {
               AttributeField prev_attr = k.nextElement();
               String prev_name = prev_attr.getAttributeName();
               String prev_value = prev_attr.getAttributeValue();
               if (prev_name.equals(spec_name) && prev_value.equalsIgnoreCase(spec_value)) {
                 new_attributes.addElement(prev_attr);
                 break;
               }
             }
           }
           if (new_attributes.size() > 0)
             new_media.addElement(
                 new MediaDescriptor(prev_md.getMedia(), prev_md.getConnection(), new_attributes));
         }
       }
     }
   }
   SessionDescriptor new_sdp = new SessionDescriptor(sdp);
   new_sdp.removeMediaDescriptors();
   new_sdp.addMediaDescriptors(new_media);
   return new_sdp;
 }