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