UniMRCP  1.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rtsp_start_line.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Id: rtsp_start_line.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef RTSP_START_LINE_H
20 #define RTSP_START_LINE_H
21 
22 /**
23  * @file rtsp_start_line.h
24  * @brief RTSP Start Line (request-line/status-line)
25  */
26 
27 #include "rtsp.h"
28 #include "apt_text_stream.h"
29 
31 
32 /** Protocol version */
33 typedef enum {
34  /** Unknown version */
36  /** RTSP 1.0 */
39 
40 /** RTSP message types */
41 typedef enum {
42  RTSP_MESSAGE_TYPE_UNKNOWN,
43  RTSP_MESSAGE_TYPE_REQUEST,
44  RTSP_MESSAGE_TYPE_RESPONSE
46 
47 /** RTSP methods */
48 typedef enum{
49  RTSP_METHOD_SETUP,
50  RTSP_METHOD_ANNOUNCE,
51  RTSP_METHOD_TEARDOWN,
52  RTSP_METHOD_DESCRIBE,
53 
54  RTSP_METHOD_COUNT,
55  RTSP_METHOD_UNKNOWN = RTSP_METHOD_COUNT
57 
58 /** Status codes */
59 typedef enum {
60  RTSP_STATUS_CODE_UNKNOWN = 0,
61  /** Success codes (2xx) */
63  RTSP_STATUS_CODE_CREATED = 201,
64  /** Failure codec (4xx) */
66  RTSP_STATUS_CODE_UNAUTHORIZED = 401,
67  RTSP_STATUS_CODE_NOT_FOUND = 404,
68  RTSP_STATUS_CODE_METHOD_NOT_ALLOWED = 405,
69  RTSP_STATUS_CODE_NOT_ACCEPTABLE = 406,
70  RTSP_STATUS_CODE_PROXY_AUTH_REQUIRED = 407,
71  RTSP_STATUS_CODE_REQUEST_TIMEOUT = 408,
72  RTSP_STATUS_CODE_SESSION_NOT_FOUND = 454,
73 
74  RTSP_STATUS_CODE_INTERNAL_SERVER_ERROR = 500,
75  RTSP_STATUS_CODE_NOT_IMPLEMENTED = 501,
77 
78 /** Reason phrases */
79 typedef enum {
80  RTSP_REASON_PHRASE_OK,
81  RTSP_REASON_PHRASE_CREATED,
82  RTSP_REASON_PHRASE_BAD_REQUEST,
83  RTSP_REASON_PHRASE_UNAUTHORIZED,
84  RTSP_REASON_PHRASE_NOT_FOUND,
85  RTSP_REASON_PHRASE_METHOD_NOT_ALLOWED,
86  RTSP_REASON_PHRASE_NOT_ACCEPTABLE,
87  RTSP_REASON_PHRASE_PROXY_AUTH_REQUIRED,
88  RTSP_REASON_PHRASE_REQUEST_TIMEOUT,
89  RTSP_REASON_PHRASE_SESSION_NOT_FOUND,
90  RTSP_REASON_PHRASE_INTERNAL_SERVER_ERROR,
91  RTSP_REASON_PHRASE_NOT_IMPLEMENTED,
92  RTSP_REASON_PHRASE_COUNT,
93 
94  /** Unknown reason phrase */
95  RTSP_REASON_PHRASE_UNKNOWN = RTSP_REASON_PHRASE_COUNT
97 
98 
99 /** RTSP request-line declaration */
101 /** RTSP status-line declaration */
103 /** RTSP start-line declaration */
105 
106 /** RTSP request-line */
108  /** Method name */
110  /** Method id */
112  /** RTSP URL */
114  /** Resource name parsed from RTSP URL */
115  const char *resource_name;
116  /** Version of protocol in use */
118 };
119 
120 /** RTSP status-line */
122  /** Version of protocol in use */
124  /** success or failure or other status of the request */
126  /** Reason phrase */
128 };
129 
130 /** RTSP start-line */
132  /** RTSP message type */
134  /** RTSP start-line */
135  union {
136  rtsp_request_line_t request_line;
137  rtsp_status_line_t status_line;
138  } common;
139 };
140 
141 
142 static APR_INLINE void rtsp_request_line_init(rtsp_request_line_t *request_line)
143 {
144  apt_string_reset(&request_line->method_name);
145  request_line->method_id = RTSP_METHOD_UNKNOWN;
146  apt_string_reset(&request_line->url);
147  request_line->resource_name = NULL;
148  request_line->version = RTSP_VERSION_1;
149 }
150 
151 static APR_INLINE void rtsp_status_line_init(rtsp_status_line_t *status_line)
152 {
153  status_line->version = RTSP_VERSION_1;
154  status_line->status_code = RTSP_STATUS_CODE_OK;
155  apt_string_reset(&status_line->reason);
156 }
157 
158 /** Initialize RTSP start-line */
159 static APR_INLINE void rtsp_start_line_init(rtsp_start_line_t *start_line, rtsp_message_type_e message_type)
160 {
161  start_line->message_type = message_type;
162  if(message_type == RTSP_MESSAGE_TYPE_REQUEST) {
163  rtsp_request_line_init(&start_line->common.request_line);
164  }
165  else if(message_type == RTSP_MESSAGE_TYPE_RESPONSE) {
166  rtsp_status_line_init(&start_line->common.status_line);
167  }
168 }
169 
170 /** Parse RTSP start-line */
171 RTSP_DECLARE(apt_bool_t) rtsp_start_line_parse(rtsp_start_line_t *start_line, apt_str_t *str, apr_pool_t *pool);
172 
173 /** Generate RTSP start-line */
175 
176 /** Get reason phrase by status code */
178 
180 
181 #endif /* RTSP_START_LINE_H */