/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/StreamDescriptor.java
Java | 130 lines | 48 code | 20 blank | 62 comment | 6 complexity | bed928248f859d605945928950bdf566 MD5 | raw file
1package javax.megaco.message.descriptor; 2 3import java.io.Serializable; 4 5import javax.megaco.CommandEvent; 6import javax.megaco.ParameterNotSetException; 7import javax.megaco.message.CommandReq; 8import javax.megaco.message.CommandResp; 9import javax.megaco.message.Descriptor; 10import javax.megaco.message.DescriptorType; 11import javax.megaco.pkg.PkgItemParam; 12import javax.megaco.pkg.GenericPkg.GenSigComplEvent; 13import javax.megaco.pkg.ToneGenPkg.ToneGenParamInd; 14import javax.megaco.pkg.ToneGenPkg.ToneGenParamTl; 15import javax.megaco.pkg.ToneGenPkg.ToneGenPlayToneSignal; 16 17/** 18 * The class extends JAIN MEGACO Descriptor. This class describes the stream 19 * descriptor. The SDP information set within the local and remote descriptor 20 * for this class is outside the scope of JAIN MEGACO. It is defined in 21 * javax.sdp. 22 */ 23public class StreamDescriptor extends Descriptor implements Serializable { 24 25 private MediaStreamParam mediaStreamParam = null; 26 private Integer streamId = null; 27 28 /** 29 * Constructs a Stream Descriptor object. This extends the Descriptor class. 30 * It defines the Stream descriptor of the Megaco which contains the stream 31 * id and stream parameter. Multiple of these can be set in the media 32 * descriptor. 33 */ 34 public StreamDescriptor() { 35 super(); 36 super.descriptorId = DescriptorType.M_STREAM_DESC; 37 } 38 39 /** 40 * This method cannot be overridden by the derived class. This method 41 * returns that the descriptor identifier is of type descriptor Stream. This 42 * method overrides the corresponding method of the base class Descriptor. 43 * 44 * @return descriptorId - Returns an integer value that identifies this 45 * stream object as the type of stream descriptor. It returns that 46 * it is Stream Descriptor i.e., M_STREAM_DESC. 47 */ 48 public int getDescriptorId() { 49 return super.descriptorId; 50 } 51 52 /** 53 * This method gets the Stream parameter for the stream descriptor. This can 54 * be used to get the local descriptor, remote descriptor and the local 55 * control descriptor. 56 * 57 * @return Returns the object reference of type stream parameter. 58 */ 59 public final MediaStreamParam getMediaStreamParam() { 60 61 return this.mediaStreamParam; 62 } 63 64 /** 65 * This method sets the stream parameter. 66 * 67 * @param streamParam 68 * - Sets the stream parameter consisiting of atleast one of 69 * local descriptor, local control and remote descriptor. 70 * @throws IllegalArgumentException 71 * if the parameters set for the stream parameter are such that 72 * the Stream Descriptor cannot be encoded. 73 */ 74 public final void setMediaStreamParam(MediaStreamParam streamParam) throws IllegalArgumentException { 75 // FIXME: add error checks 76 77 if (streamParam == null) { 78 throw new IllegalArgumentException("MediaStreamParam must not be null"); 79 } 80 81 this.mediaStreamParam = streamParam; 82 } 83 84 /** 85 * The method can be used to get stream id in the stream descriptor. This 86 * method should be invoked after verifying that the port number is present 87 * using method isStreamIdPresent(). 88 * 89 * @return streamId - The integer value of the stream id shall be returned. 90 * @throws javax.megaco.ParameterNotSetException 91 * - Thrown if streamId has not been set. 92 */ 93 public int getStreamId() throws javax.megaco.ParameterNotSetException { 94 if (this.streamId == null) { 95 throw new ParameterNotSetException(); 96 } 97 98 return this.streamId.intValue(); 99 } 100 101 /** 102 * The method can be used to set stream id in the stream descriptor. 103 * 104 * @param streamId 105 * - The integer value of the stream id shall be set. 106 * @throws IllegalArgumentException 107 * - Thrown if streamId is set with an invalid value. 108 */ 109 public void setStreamId(int streamId) throws IllegalArgumentException { 110 if (streamId <= 0) { 111 throw new IllegalArgumentException("StreanId must not be less or equal to zero"); 112 } 113 114 this.streamId = new Integer(streamId); 115 } 116 117 /** 118 * This method is used for checking if the Stream Id is present for this 119 * descriptor or not. 120 * 121 * @return 122 */ 123 public boolean isStreamIdPresent() { 124 125 126 127 return this.streamId != null; 128 } 129 130}