1 /* 2 * Copyright 2012 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package io.netty.handler.codec.rtsp; 17 18 import io.netty.handler.codec.http.HttpMethod; 19 20 import java.util.HashMap; 21 import java.util.Map; 22 23 /** 24 * The request getMethod of RTSP. 25 */ 26 public final class RtspMethods { 27 28 /** 29 * The OPTIONS getMethod represents a request for information about the communication options 30 * available on the request/response chain identified by the Request-URI. This getMethod allows 31 * the client to determine the options and/or requirements associated with a resource, or the 32 * capabilities of a server, without implying a resource action or initiating a resource 33 * retrieval. 34 */ 35 public static final HttpMethod OPTIONS = HttpMethod.OPTIONS; 36 37 /** 38 * The DESCRIBE getMethod retrieves the description of a presentation or 39 * media object identified by the request URL from a server. 40 */ 41 public static final HttpMethod DESCRIBE = new HttpMethod("DESCRIBE"); 42 43 /** 44 * The ANNOUNCE posts the description of a presentation or media object 45 * identified by the request URL to a server, or updates the client-side 46 * session description in real-time. 47 */ 48 public static final HttpMethod ANNOUNCE = new HttpMethod("ANNOUNCE"); 49 50 /** 51 * The SETUP request for a URI specifies the transport mechanism to be 52 * used for the streamed media. 53 */ 54 public static final HttpMethod SETUP = new HttpMethod("SETUP"); 55 56 /** 57 * The PLAY getMethod tells the server to start sending data via the 58 * mechanism specified in SETUP. 59 */ 60 public static final HttpMethod PLAY = new HttpMethod("PLAY"); 61 62 /** 63 * The PAUSE request causes the stream delivery to be interrupted 64 * (halted) temporarily. 65 */ 66 public static final HttpMethod PAUSE = new HttpMethod("PAUSE"); 67 68 /** 69 * The TEARDOWN request stops the stream delivery for the given URI, 70 * freeing the resources associated with it. 71 */ 72 public static final HttpMethod TEARDOWN = new HttpMethod("TEARDOWN"); 73 74 /** 75 * The GET_PARAMETER request retrieves the value of a parameter of a 76 * presentation or stream specified in the URI. 77 */ 78 public static final HttpMethod GET_PARAMETER = new HttpMethod("GET_PARAMETER"); 79 80 /** 81 * The SET_PARAMETER requests to set the value of a parameter for a 82 * presentation or stream specified by the URI. 83 */ 84 public static final HttpMethod SET_PARAMETER = new HttpMethod("SET_PARAMETER"); 85 86 /** 87 * The REDIRECT request informs the client that it must connect to another 88 * server location. 89 */ 90 public static final HttpMethod REDIRECT = new HttpMethod("REDIRECT"); 91 92 /** 93 * The RECORD getMethod initiates recording a range of media data according to 94 * the presentation description. 95 */ 96 public static final HttpMethod RECORD = new HttpMethod("RECORD"); 97 98 private static final Map<String, HttpMethod> methodMap = new HashMap<String, HttpMethod>(); 99 100 static { 101 methodMap.put(DESCRIBE.toString(), DESCRIBE); 102 methodMap.put(ANNOUNCE.toString(), ANNOUNCE); 103 methodMap.put(GET_PARAMETER.toString(), GET_PARAMETER); 104 methodMap.put(OPTIONS.toString(), OPTIONS); 105 methodMap.put(PAUSE.toString(), PAUSE); 106 methodMap.put(PLAY.toString(), PLAY); 107 methodMap.put(RECORD.toString(), RECORD); 108 methodMap.put(REDIRECT.toString(), REDIRECT); 109 methodMap.put(SETUP.toString(), SETUP); 110 methodMap.put(SET_PARAMETER.toString(), SET_PARAMETER); 111 methodMap.put(TEARDOWN.toString(), TEARDOWN); 112 } 113 114 /** 115 * Returns the {@link HttpMethod} represented by the specified name. 116 * If the specified name is a standard RTSP getMethod name, a cached instance 117 * will be returned. Otherwise, a new instance will be returned. 118 */ 119 public static HttpMethod valueOf(String name) { 120 if (name == null) { 121 throw new NullPointerException("name"); 122 } 123 124 name = name.trim().toUpperCase(); 125 if (name.isEmpty()) { 126 throw new IllegalArgumentException("empty name"); 127 } 128 129 HttpMethod result = methodMap.get(name); 130 if (result != null) { 131 return result; 132 } else { 133 return new HttpMethod(name); 134 } 135 } 136 137 private RtspMethods() { 138 } 139 }