/* * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ package net.java.sip.communicator.service.neomedia; /** * The MediaDirections enumeration contains a list of media directions * that indicate read/write capabilities of different entities in this * MediaService such as for example devices. * * @author Emil Ivov */ public enum MediaDirection { /** * Represents a direction from the entity that this direction pertains to * to the outside. When applied to a MediaDevice the direction * indicates that the device is a read-only one. In the case of a stream * a SENDONLY direction indicates that the stream is only sending * data to the remote party without receiving. */ SENDONLY("sendonly"), /** * Represents a direction pointing to the entity that this object pertains * to and from the outside. When applied to a MediaDevice the * direction indicates that the device is a write-only one. In the case of a * MediaStream a RECVONLY direction indicates that the * stream is only receiving data from the remote party without sending * any. */ RECVONLY("recvonly"), /** * Indicates that the related entity supports both input and output (send * and receive) operations. */ SENDRECV("sendrecv"); /** * The name of this direction. */ private final String directionName; /** * Creates a MediaDirection instance with the specified name. * * @param directionName the name of the MediaDirections we'd like * to create. */ private MediaDirection(String directionName) { this.directionName = directionName; } /** * Returns the name of this MediaDirection (e.g. "sendonly" or * "sendrecv"). The name returned by this method is meant for use by * session description mechanisms such as SIP/SDP or XMPP/Jingle. * * @return the name of this MediaDirection (e.g. "sendonly", * "recvonly", "sendrecv"). */ public String toString() { return directionName; } /** * Returns a MediaDirection value corresponding to the specified * mediaDirectionName or in other words MediaType.SENDONLY * for "sendonly", MediaType.RECVONLY for "recvonly", and * MediaType.SENDRECV for "sendrecv". * * @param mediaDirectionName the name that we'd like to parse. * @return a MediaDirection value corresponding to the specified * mediaDirectionName. * * @throws IllegalArgumentException in case mediaDirectionName is * not a valid or currently supported media direction. */ public static MediaDirection parseString(String mediaDirectionName) throws IllegalArgumentException { if(SENDONLY.toString().equals(mediaDirectionName)) return SENDONLY; if(RECVONLY.toString().equals(mediaDirectionName)) return RECVONLY; if(SENDRECV.toString().equals(mediaDirectionName)) return SENDRECV; throw new IllegalArgumentException(mediaDirectionName + " is not a currently supported MediaDirection"); } }