use of java.util.Enumeration in project bigbluebutton by bigbluebutton.
the class SdpTools method sdpMediaProduct.
/** Costructs a new SessionDescriptor from a given SessionDescriptor
* with olny media types and attribute values specified by a MediaDescriptor Vector.
* <p> If no attribute is specified for a particular media, all present attributes are kept.
* <br>If no attribute is present for a selected media, the media is kept (regardless any sepcified attributes).
* @param sdp the given SessionDescriptor
* @param m_descs Vector of MediaDescriptor with the selecting media types and attributes
* @return this SessionDescriptor */
public static SessionDescriptor sdpMediaProduct(SessionDescriptor sdp, Vector m_descs) {
Vector new_media = new Vector();
if (m_descs != null) {
for (Enumeration e = m_descs.elements(); e.hasMoreElements(); ) {
MediaDescriptor spec_md = (MediaDescriptor) 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 spec_attributes = spec_md.getAttributes();
Vector prev_attributes = prev_md.getAttributes();
if (spec_attributes.size() == 0 || prev_attributes.size() == 0) {
new_media.addElement(prev_md);
} else {
Vector new_attributes = new Vector();
for (Enumeration i = spec_attributes.elements(); i.hasMoreElements(); ) {
AttributeField spec_attr = (AttributeField) i.nextElement();
String spec_name = spec_attr.getAttributeName();
String spec_value = spec_attr.getAttributeValue();
for (Enumeration k = prev_attributes.elements(); k.hasMoreElements(); ) {
AttributeField prev_attr = (AttributeField) 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;
}
use of java.util.Enumeration in project bigbluebutton by bigbluebutton.
the class SdpUtils method getFormatList.
private static String getFormatList(Vector mediaAttributes) {
AttributeField mediaAttribute = null;
String formatList = "";
for (Enumeration attributeEnum = mediaAttributes.elements(); attributeEnum.hasMoreElements(); ) {
mediaAttribute = (AttributeField) attributeEnum.nextElement();
if (mediaAttribute.getAttributeName().equalsIgnoreCase(Codec.ATTRIBUTE_RTPMAP)) {
if (!formatList.isEmpty()) {
formatList += " ";
}
formatList += getPayloadIdFromAttribute(mediaAttribute);
}
}
return formatList;
}
use of java.util.Enumeration in project bigbluebutton by bigbluebutton.
the class SdpUtils method makeMediaPayloadsNegotiation.
/**
* We must validate the existence of all remote "rtpmap" attributes
* on local SDP.
* If some exist, we add it to newSdp negotiated SDP result.
*
* @param localSdp
* @param remoteSdp
*
* @return Returns the new local descriptor as a result of media
* payloads negotiation.
*/
public static SessionDescriptor makeMediaPayloadsNegotiation(SessionDescriptor localSdp, SessionDescriptor remoteSdp) {
log.debug("makeMediaPayloadsNegotiation");
SessionDescriptor newSdp = null;
try {
newSdp = new SessionDescriptor(remoteSdp.getOrigin(), remoteSdp.getSessionName(), 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());
}
return newSdp;
}
use of java.util.Enumeration in project bigbluebutton by bigbluebutton.
the class SdpUtils method findAttributeByPayloadId.
private static AttributeField findAttributeByPayloadId(String attributeName, String payloadId, MediaDescriptor mediaDescriptor) {
AttributeField searchingMediaAttribute = null;
// log.debug("attributeName = [" + attributeName + "], payloadId = [" + payloadId + "].");
Vector mediaAttributes = mediaDescriptor.getAttributes(attributeName);
for (Enumeration attributesEnum = mediaAttributes.elements(); attributesEnum.hasMoreElements(); ) {
AttributeField mediaAttribute = (AttributeField) attributesEnum.nextElement();
if (getPayloadIdFromAttribute(mediaAttribute).equals(payloadId)) {
searchingMediaAttribute = mediaAttribute;
break;
}
}
if (searchingMediaAttribute != null) {
// log.debug("Attribute found with name = [" +
// searchingMediaAttribute.getAttributeName() + "] and value = [" +
// searchingMediaAttribute.getAttributeValue() + "]." );
} else {
// log.info("Attribute with name [" + attributeName + "] and payloadId [" + payloadId + "] was not found." );
}
return searchingMediaAttribute;
}
use of java.util.Enumeration in project bigbluebutton by bigbluebutton.
the class CodecAttributes method toString.
@Override
public String toString() {
String toStringRet = "";
if (codecEncodeAttributes.size() > 0) {
toStringRet += "Encode attributes:\n";
}
for (Enumeration keysEnum = codecEncodeAttributes.keys(); keysEnum.hasMoreElements(); ) {
String attributeName = (String) keysEnum.nextElement();
toStringRet += "\t" + attributeName + "=" + codecEncodeAttributes.get(attributeName);
}
if (codecDecodeAttributes.size() > 0) {
if (codecEncodeAttributes.size() > 0) {
toStringRet += "\n";
}
toStringRet += "Decode attributes:\n";
}
for (Enumeration keysEnum = codecDecodeAttributes.keys(); keysEnum.hasMoreElements(); ) {
String attributeName = (String) keysEnum.nextElement();
toStringRet += "\t" + attributeName + "=" + codecDecodeAttributes.get(attributeName);
}
return toStringRet;
}
Aggregations