1 /*
2 * Copyright 2010 Red Hat, Inc.
3 *
4 * Red Hat licenses this file to you under the Apache License, version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * 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 org.jboss.netty.handler.codec.rtsp;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.jboss.netty.handler.codec.http.HttpMethod;
22
23 /**
24 * The request method of RTSP.
25 *
26 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
27 * @author <a href="http://amitbhayani.blogspot.com/">Amit Bhayani</a>
28 * @author <a href="http://gleamynode.net/">Trustin Lee</a>
29 * @version $Rev: 2243 $, $Date: 2010-04-16 14:01:55 +0900 (Fri, 16 Apr 2010) $
30 *
31 * @apiviz.exclude
32 */
33 public final class RtspMethods {
34
35 /**
36 * The OPTIONS method represents a request for information about the communication options available on the request/response
37 * chain identified by the Request-URI. This method allows the client to determine the options and/or requirements
38 * associated with a resource, or the capabilities of a server, without implying a resource action or initiating a
39 * resource retrieval.
40 */
41 public static final HttpMethod OPTIONS = HttpMethod.OPTIONS;
42
43 /**
44 * The DESCRIBE method retrieves the description of a presentation or
45 * media object identified by the request URL from a server.
46 */
47 public static final HttpMethod DESCRIBE = new HttpMethod("DESCRIBE");
48
49 /**
50 * The ANNOUNCE posts the description of a presentation or media object
51 * identified by the request URL to a server, or updates the client-side
52 * session description in real-time.
53 */
54 public static final HttpMethod ANNOUNCE = new HttpMethod("ANNOUNCE");
55
56 /**
57 * The SETUP request for a URI specifies the transport mechanism to be
58 * used for the streamed media.
59 */
60 public static final HttpMethod SETUP = new HttpMethod("SETUP");
61
62 /**
63 * The PLAY method tells the server to start sending data via the
64 * mechanism specified in SETUP.
65 */
66 public static final HttpMethod PLAY = new HttpMethod("PLAY");
67
68 /**
69 * The PAUSE request causes the stream delivery to be interrupted
70 * (halted) temporarily.
71 */
72 public static final HttpMethod PAUSE = new HttpMethod("PAUSE");
73
74 /**
75 * The TEARDOWN request stops the stream delivery for the given URI,
76 * freeing the resources associated with it.
77 */
78 public static final HttpMethod TEARDOWN = new HttpMethod("TEARDOWN");
79
80 /**
81 * The GET_PARAMETER request retrieves the value of a parameter of a
82 * presentation or stream specified in the URI.
83 */
84 public static final HttpMethod GET_PARAMETER = new HttpMethod("GET_PARAMETER");
85
86 /**
87 * The SET_PARAMETER requests to set the value of a parameter for a
88 * presentation or stream specified by the URI.
89 */
90 public static final HttpMethod SET_PARAMETER = new HttpMethod("SET_PARAMETER");
91
92 /**
93 * The REDIRECT request informs the client that it must connect to another
94 * server location.
95 */
96 public static final HttpMethod REDIRECT = new HttpMethod("REDIRECT");
97
98 /**
99 * The RECORD method initiates recording a range of media data according to
100 * the presentation description.
101 */
102 public static final HttpMethod RECORD = new HttpMethod("RECORD");
103
104 private static final Map<String, HttpMethod> methodMap = new HashMap<String, HttpMethod>();
105
106 static {
107 methodMap.put(DESCRIBE.toString(), DESCRIBE);
108 methodMap.put(ANNOUNCE.toString(), ANNOUNCE);
109 methodMap.put(GET_PARAMETER.toString(), GET_PARAMETER);
110 methodMap.put(OPTIONS.toString(), OPTIONS);
111 methodMap.put(PAUSE.toString(), PAUSE);
112 methodMap.put(PLAY.toString(), PLAY);
113 methodMap.put(RECORD.toString(), RECORD);
114 methodMap.put(REDIRECT.toString(), REDIRECT);
115 methodMap.put(SETUP.toString(), SETUP);
116 methodMap.put(SET_PARAMETER.toString(), SET_PARAMETER);
117 methodMap.put(TEARDOWN.toString(), TEARDOWN);
118 }
119
120 /**
121 * Returns the {@link HttpMethod} represented by the specified name.
122 * If the specified name is a standard RTSP method name, a cached instance
123 * will be returned. Otherwise, a new instance will be returned.
124 */
125 public static HttpMethod valueOf(String name) {
126 if (name == null) {
127 throw new NullPointerException("name");
128 }
129
130 name = name.trim().toUpperCase();
131 if (name.length() == 0) {
132 throw new IllegalArgumentException("empty name");
133 }
134
135 HttpMethod result = methodMap.get(name);
136 if (result != null) {
137 return result;
138 } else {
139 return new HttpMethod(name);
140 }
141 }
142
143 private RtspMethods() {
144 super();
145 }
146 }