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 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 * @apiviz.exclude
26 */
27 public final class RtspMethods {
28
29 /**
30 * The OPTIONS method represents a request for information about the communication options
31 * available on the request/response chain identified by the Request-URI. This method allows
32 * the client to determine the options and/or requirements associated with a resource, or the
33 * capabilities of a server, without implying a resource action or initiating a resource
34 * retrieval.
35 */
36 public static final HttpMethod OPTIONS = HttpMethod.OPTIONS;
37
38 /**
39 * The DESCRIBE method retrieves the description of a presentation or
40 * media object identified by the request URL from a server.
41 */
42 public static final HttpMethod DESCRIBE = new HttpMethod("DESCRIBE");
43
44 /**
45 * The ANNOUNCE posts the description of a presentation or media object
46 * identified by the request URL to a server, or updates the client-side
47 * session description in real-time.
48 */
49 public static final HttpMethod ANNOUNCE = new HttpMethod("ANNOUNCE");
50
51 /**
52 * The SETUP request for a URI specifies the transport mechanism to be
53 * used for the streamed media.
54 */
55 public static final HttpMethod SETUP = new HttpMethod("SETUP");
56
57 /**
58 * The PLAY method tells the server to start sending data via the
59 * mechanism specified in SETUP.
60 */
61 public static final HttpMethod PLAY = new HttpMethod("PLAY");
62
63 /**
64 * The PAUSE request causes the stream delivery to be interrupted
65 * (halted) temporarily.
66 */
67 public static final HttpMethod PAUSE = new HttpMethod("PAUSE");
68
69 /**
70 * The TEARDOWN request stops the stream delivery for the given URI,
71 * freeing the resources associated with it.
72 */
73 public static final HttpMethod TEARDOWN = new HttpMethod("TEARDOWN");
74
75 /**
76 * The GET_PARAMETER request retrieves the value of a parameter of a
77 * presentation or stream specified in the URI.
78 */
79 public static final HttpMethod GET_PARAMETER = new HttpMethod("GET_PARAMETER");
80
81 /**
82 * The SET_PARAMETER requests to set the value of a parameter for a
83 * presentation or stream specified by the URI.
84 */
85 public static final HttpMethod SET_PARAMETER = new HttpMethod("SET_PARAMETER");
86
87 /**
88 * The REDIRECT request informs the client that it must connect to another
89 * server location.
90 */
91 public static final HttpMethod REDIRECT = new HttpMethod("REDIRECT");
92
93 /**
94 * The RECORD method initiates recording a range of media data according to
95 * the presentation description.
96 */
97 public static final HttpMethod RECORD = new HttpMethod("RECORD");
98
99 private static final Map<String, HttpMethod> methodMap = new HashMap<String, HttpMethod>();
100
101 static {
102 methodMap.put(DESCRIBE.toString(), DESCRIBE);
103 methodMap.put(ANNOUNCE.toString(), ANNOUNCE);
104 methodMap.put(GET_PARAMETER.toString(), GET_PARAMETER);
105 methodMap.put(OPTIONS.toString(), OPTIONS);
106 methodMap.put(PAUSE.toString(), PAUSE);
107 methodMap.put(PLAY.toString(), PLAY);
108 methodMap.put(RECORD.toString(), RECORD);
109 methodMap.put(REDIRECT.toString(), REDIRECT);
110 methodMap.put(SETUP.toString(), SETUP);
111 methodMap.put(SET_PARAMETER.toString(), SET_PARAMETER);
112 methodMap.put(TEARDOWN.toString(), TEARDOWN);
113 }
114
115 /**
116 * Returns the {@link HttpMethod} represented by the specified name.
117 * If the specified name is a standard RTSP method name, a cached instance
118 * will be returned. Otherwise, a new instance will be returned.
119 */
120 public static HttpMethod valueOf(String name) {
121 if (name == null) {
122 throw new NullPointerException("name");
123 }
124
125 name = name.trim().toUpperCase();
126 if (name.length() == 0) {
127 throw new IllegalArgumentException("empty name");
128 }
129
130 HttpMethod result = methodMap.get(name);
131 if (result != null) {
132 return result;
133 } else {
134 return new HttpMethod(name);
135 }
136 }
137
138 private RtspMethods() {
139 }
140 }