FileDocCategorySizeDatePackage
MediaDescription.javaAPI DocJMF 2.1.1e3264Mon May 12 12:20:52 BST 2003com.sun.media.sdp

MediaDescription

public class MediaDescription extends Parser

Fields Summary
public String
name
public String
port
public String
protocol
public int
payload_type
public String
payload
public String
mediaTitle
public String
connectionInfo
public String
bandwidthInfo
public String
encryptionKey
public Vector
mediaAttributes
Constructors Summary
public MediaDescription(ByteArrayInputStream bin, boolean connectionIncluded)

        // Media Name and Transport Address:
        String line = getLine(bin);

        int end = line.indexOf(' ");

        name = line.substring(0, end);


        int start = end + 1;

        end = line.indexOf(' ", start);

        port = line.substring(start, end);


        start = end + 1;

        end = line.indexOf(' ", start);

        protocol = line.substring(start, end);

        start = end + 1;

        payload = line.substring(start);

        try {
            payload_type = new Integer(payload).intValue();
        } catch (Exception e) {
            payload_type = -1;
        }


        // Session and Media Information:
        if (getToken(bin, "i=", false)) {
            mediaTitle = getLine(bin);

            System.out.println("media title: " + mediaTitle);
        }

        // Connection Information:
        boolean mandatory = true;

        if (connectionIncluded) {
            mandatory = false;
        }

        if (getToken(bin, "c=", mandatory)) {
            connectionInfo = getLine(bin);

            System.out.println("connection info: " + connectionInfo);
        }

        // Bandwidth Information:
        if (getToken(bin, "b=", false)) {
            bandwidthInfo = getLine(bin);

            System.out.println("bandwidth info: " + bandwidthInfo);
        }

        // Encryption Key:
        if (getToken(bin, "k=", false)) {
            encryptionKey = getLine(bin);

            System.out.println("encryption key: " + encryptionKey);
        }

        // Media Attributes:
        mediaAttributes = new Vector();

        boolean found = getToken(bin, "a=", false);

        while (found) {
            String mediaAttribute = getLine(bin);

            int index = mediaAttribute.indexOf(':");

            if (index > 0) {
                String name = mediaAttribute.substring(0, index);
                String value = mediaAttribute.substring(index + 1);

                MediaAttribute attribute = new MediaAttribute(name, value);

                mediaAttributes.addElement(attribute);
            }

            found = getToken(bin, "a=", false);
        }
    
Methods Summary
public com.sun.media.sdp.MediaAttributegetMediaAttribute(java.lang.String name)

        MediaAttribute attribute = null;

        if (mediaAttributes != null) {
            for (int i = 0; i < mediaAttributes.size(); i++) {
                MediaAttribute entry = (MediaAttribute) mediaAttributes.elementAt(i);

                if (entry.getName().equals(name)) {
                    attribute = entry;
                    break;
                }
            }
        }

        return attribute;