UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rtsp_header.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_header.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef RTSP_HEADER_H
20 #define RTSP_HEADER_H
21 
22 /**
23  * @file rtsp_header.h
24  * @brief RTSP Header
25  */
26 
27 #include "rtsp.h"
28 #include "apt_header_field.h"
29 
31 
32 /** RTSP transport protocol */
33 typedef enum{
34  RTSP_TRANSPORT_RTP,
35 
36  RTSP_TRANSPORT_COUNT,
37  RTSP_TRANSPORT_NONE = RTSP_TRANSPORT_COUNT
39 
40 /** RTSP transport profile */
41 typedef enum{
42  RTSP_PROFILE_AVP,
43  RTSP_PROFILE_SAVP,
44 
45  RTSP_PROFILE_COUNT,
46  RTSP_PROFILE_NONE = RTSP_PROFILE_COUNT
48 
49 /** RTSP lower-transport */
50 typedef enum{
51  RTSP_LOWER_TRANSPORT_UDP,
52  RTSP_LOWER_TRANSPORT_TCP,
53 
54  RTSP_LOWER_TRANSPORT_COUNT,
55  RTSP_LOWER_TRANSPORT_NONE = RTSP_LOWER_TRANSPORT_COUNT
57 
58 /** RTSP transport attributes */
59 typedef enum{
60  RTSP_TRANSPORT_ATTRIB_CLIENT_PORT,
61  RTSP_TRANSPORT_ATTRIB_SERVER_PORT,
62  RTSP_TRANSPORT_ATTRIB_SOURCE,
63  RTSP_TRANSPORT_ATTRIB_DESTINATION,
64  RTSP_TRANSPORT_ATTRIB_UNICAST,
65  RTSP_TRANSPORT_ATTRIB_MULTICAST,
66  RTSP_TRANSPORT_ATTRIB_MODE,
67 
68  RTSP_TRANSPORT_ATTRIB_COUNT,
69  RTSP_TRANSPORT_ATTRIB_NONE = RTSP_TRANSPORT_ATTRIB_COUNT
71 
72 /** RTSP delivery */
73 typedef enum{
74  RTSP_DELIVERY_UNICAST,
75  RTSP_DELIVERY_MULTICAST,
76 
77  RTSP_DELIVERY_COUNT,
78  RTSP_DELIVERY_NONE = RTSP_DELIVERY_COUNT
80 
81 /** RTSP header fields */
82 typedef enum{
83  RTSP_HEADER_FIELD_CSEQ,
84  RTSP_HEADER_FIELD_TRANSPORT,
85  RTSP_HEADER_FIELD_SESSION_ID,
86  RTSP_HEADER_FIELD_RTP_INFO,
87  RTSP_HEADER_FIELD_CONTENT_TYPE,
88  RTSP_HEADER_FIELD_CONTENT_LENGTH,
89 
90  RTSP_HEADER_FIELD_COUNT,
91  RTSP_HEADER_FIELD_UNKNOWN = RTSP_HEADER_FIELD_COUNT
93 
94 /** RTSP content types */
95 typedef enum {
96  RTSP_CONTENT_TYPE_SDP,
97  RTSP_CONTENT_TYPE_MRCP,
98 
99  RTSP_CONTENT_TYPE_COUNT,
100  RTSP_CONTENT_TYPE_NONE = RTSP_CONTENT_TYPE_COUNT
102 
103 
104 
105 /** RTSP/RTP port range declaration */
107 /** RTSP transport declaration */
109 /** RTSP header declaration */
111 
112 /** RTSP/RTP port range */
114  /** Min (low) port */
115  apr_port_t min;
116  /** Max (high) port */
117  apr_port_t max;
118 };
119 
120 /** RTSP transport */
122  /** Transport profile */
124  /** Transport profile */
126  /** Lower transport */
128  /** Delivery method */
130  /** Client port range */
132  /** Server port range */
134  /** Source IP address */
136  /** Destination IP address */
138  /** Mode indicates the method to support (either PLAY or RECORD) */
140 };
141 
142 /** RTSP header */
144  /** Sequence number */
145  apr_size_t cseq;
146  /** Transport */
148  /** Session identifier */
150  /** RTP-info */
152 
153  /** Content type */
155  /** Content length */
156  apr_size_t content_length;
157 
158  /** Header section (collection of header fields)*/
160 };
161 
162 
163 /** Initialize port range */
164 static APR_INLINE void rtsp_port_range_init(rtsp_port_range_t *port_range)
165 {
166  port_range->min = 0;
167  port_range->max = 0;
168 }
169 
170 /** Initialize port range */
171 static APR_INLINE apt_bool_t rtsp_port_range_is_valid(const rtsp_port_range_t *port_range)
172 {
173  return (port_range->min == 0 && port_range->max == 0) == FALSE;
174 }
175 
176 /** Initialize transport */
177 static APR_INLINE void rtsp_transport_init(rtsp_transport_t *transport)
178 {
179  transport->protocol = RTSP_TRANSPORT_RTP;
180  transport->profile = RTSP_PROFILE_NONE;
181  transport->lower_protocol = RTSP_LOWER_TRANSPORT_NONE;
182  rtsp_port_range_init(&transport->client_port_range);
183  rtsp_port_range_init(&transport->server_port_range);
184  apt_string_reset(&transport->source);
185  apt_string_reset(&transport->destination);
186  apt_string_reset(&transport->mode);
187 }
188 
189 /** Initialize header */
190 static APR_INLINE void rtsp_header_init(rtsp_header_t *header, apr_pool_t *pool)
191 {
192  header->cseq = 0;
193  rtsp_transport_init(&header->transport);
194  apt_string_reset(&header->session_id);
195  apt_string_reset(&header->rtp_info);
196  header->content_type = RTSP_CONTENT_TYPE_NONE;
197  header->content_length = 0;
198 
200  apt_header_section_array_alloc(&header->header_section,RTSP_HEADER_FIELD_COUNT,pool);
201 }
202 
203 
204 /** Add RTSP header field */
205 RTSP_DECLARE(apt_bool_t) rtsp_header_field_add(rtsp_header_t *header, apt_header_field_t *header_field, apr_pool_t *pool);
206 
207 /** Parse RTSP header fields */
209 
210 /** Add RTSP header field property */
212 
213 /** Remove RTSP header field property */
214 static APR_INLINE apt_bool_t rtsp_header_property_remove(rtsp_header_t *header, rtsp_header_field_id id)
215 {
216  apt_header_field_t *header_field = apt_header_section_field_get(&header->header_section,id);
217  if(header_field) {
218  return apt_header_section_field_remove(&header->header_section,header_field);
219  }
220  return FALSE;
221 }
222 
223 /** Check RTSP header field property */
224 static APR_INLINE apt_bool_t rtsp_header_property_check(const rtsp_header_t *header, rtsp_header_field_id id)
225 {
226  return apt_header_section_field_check(&header->header_section,id);
227 }
228 
229 
231 
232 #endif /* RTSP_HEADER_H */