UniMRCP  1.7.0
rtsp_header.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
17 #ifndef RTSP_HEADER_H
18 #define RTSP_HEADER_H
19 
20 /**
21  * @file rtsp_header.h
22  * @brief RTSP Header
23  */
24 
25 #include "rtsp.h"
26 #include "apt_header_field.h"
27 
29 
30 /** RTSP transport protocol */
31 typedef enum{
32  RTSP_TRANSPORT_RTP,
33 
34  RTSP_TRANSPORT_COUNT,
35  RTSP_TRANSPORT_NONE = RTSP_TRANSPORT_COUNT
37 
38 /** RTSP transport profile */
39 typedef enum{
40  RTSP_PROFILE_AVP,
41  RTSP_PROFILE_SAVP,
42 
43  RTSP_PROFILE_COUNT,
44  RTSP_PROFILE_NONE = RTSP_PROFILE_COUNT
46 
47 /** RTSP lower-transport */
48 typedef enum{
49  RTSP_LOWER_TRANSPORT_UDP,
50  RTSP_LOWER_TRANSPORT_TCP,
51 
52  RTSP_LOWER_TRANSPORT_COUNT,
53  RTSP_LOWER_TRANSPORT_NONE = RTSP_LOWER_TRANSPORT_COUNT
55 
56 /** RTSP transport attributes */
57 typedef enum{
58  RTSP_TRANSPORT_ATTRIB_CLIENT_PORT,
59  RTSP_TRANSPORT_ATTRIB_SERVER_PORT,
60  RTSP_TRANSPORT_ATTRIB_SOURCE,
61  RTSP_TRANSPORT_ATTRIB_DESTINATION,
62  RTSP_TRANSPORT_ATTRIB_UNICAST,
63  RTSP_TRANSPORT_ATTRIB_MULTICAST,
64  RTSP_TRANSPORT_ATTRIB_MODE,
65 
66  RTSP_TRANSPORT_ATTRIB_COUNT,
67  RTSP_TRANSPORT_ATTRIB_NONE = RTSP_TRANSPORT_ATTRIB_COUNT
69 
70 /** RTSP delivery */
71 typedef enum{
72  RTSP_DELIVERY_UNICAST,
73  RTSP_DELIVERY_MULTICAST,
74 
75  RTSP_DELIVERY_COUNT,
76  RTSP_DELIVERY_NONE = RTSP_DELIVERY_COUNT
78 
79 /** RTSP header fields */
80 typedef enum{
81  RTSP_HEADER_FIELD_CSEQ,
82  RTSP_HEADER_FIELD_TRANSPORT,
83  RTSP_HEADER_FIELD_SESSION_ID,
84  RTSP_HEADER_FIELD_RTP_INFO,
85  RTSP_HEADER_FIELD_CONTENT_TYPE,
86  RTSP_HEADER_FIELD_CONTENT_LENGTH,
87 
88  RTSP_HEADER_FIELD_COUNT,
89  RTSP_HEADER_FIELD_UNKNOWN = RTSP_HEADER_FIELD_COUNT
91 
92 /** RTSP content types */
93 typedef enum {
94  RTSP_CONTENT_TYPE_SDP,
95  RTSP_CONTENT_TYPE_MRCP,
96 
97  RTSP_CONTENT_TYPE_COUNT,
98  RTSP_CONTENT_TYPE_NONE = RTSP_CONTENT_TYPE_COUNT
100 
101 
102 
103 /** RTSP/RTP port range declaration */
105 /** RTSP transport declaration */
107 /** RTSP header declaration */
109 
110 /** RTSP/RTP port range */
112  /** Min (low) port */
113  apr_port_t min;
114  /** Max (high) port */
115  apr_port_t max;
116 };
117 
118 /** RTSP transport */
120  /** Transport profile */
122  /** Transport profile */
124  /** Lower transport */
126  /** Delivery method */
128  /** Client port range */
130  /** Server port range */
132  /** Source IP address */
134  /** Destination IP address */
136  /** Mode indicates the method to support (either PLAY or RECORD) */
138 };
139 
140 /** RTSP header */
142  /** Sequence number */
143  apr_size_t cseq;
144  /** Transport */
146  /** Session identifier */
148  /** RTP-info */
150 
151  /** Content type */
153  /** Content length */
154  apr_size_t content_length;
155 
156  /** Header section (collection of header fields)*/
158 };
159 
160 
161 /** Initialize port range */
162 static APR_INLINE void rtsp_port_range_init(rtsp_port_range_t *port_range)
163 {
164  port_range->min = 0;
165  port_range->max = 0;
166 }
167 
168 /** Initialize port range */
169 static APR_INLINE apt_bool_t rtsp_port_range_is_valid(const rtsp_port_range_t *port_range)
170 {
171  return (port_range->min == 0 && port_range->max == 0) == FALSE;
172 }
173 
174 /** Initialize transport */
175 static APR_INLINE void rtsp_transport_init(rtsp_transport_t *transport)
176 {
177  transport->protocol = RTSP_TRANSPORT_RTP;
178  transport->profile = RTSP_PROFILE_NONE;
179  transport->lower_protocol = RTSP_LOWER_TRANSPORT_NONE;
180  rtsp_port_range_init(&transport->client_port_range);
181  rtsp_port_range_init(&transport->server_port_range);
182  apt_string_reset(&transport->source);
183  apt_string_reset(&transport->destination);
184  apt_string_reset(&transport->mode);
185 }
186 
187 /** Initialize header */
188 static APR_INLINE void rtsp_header_init(rtsp_header_t *header, apr_pool_t *pool)
189 {
190  header->cseq = 0;
191  rtsp_transport_init(&header->transport);
192  apt_string_reset(&header->session_id);
193  apt_string_reset(&header->rtp_info);
194  header->content_type = RTSP_CONTENT_TYPE_NONE;
195  header->content_length = 0;
196 
198  apt_header_section_array_alloc(&header->header_section,RTSP_HEADER_FIELD_COUNT,pool);
199 }
200 
201 
202 /** Add RTSP header field */
203 RTSP_DECLARE(apt_bool_t) rtsp_header_field_add(rtsp_header_t *header, apt_header_field_t *header_field, apr_pool_t *pool);
204 
205 /** Parse RTSP header fields */
207 
208 /** Add RTSP header field property */
210 
211 /** Remove RTSP header field property */
212 static APR_INLINE apt_bool_t rtsp_header_property_remove(rtsp_header_t *header, rtsp_header_field_id id)
213 {
214  apt_header_field_t *header_field = apt_header_section_field_get(&header->header_section,id);
215  if(header_field) {
216  return apt_header_section_field_remove(&header->header_section,header_field);
217  }
218  return FALSE;
219 }
220 
221 /** Check RTSP header field property */
222 static APR_INLINE apt_bool_t rtsp_header_property_check(const rtsp_header_t *header, rtsp_header_field_id id)
223 {
224  return apt_header_section_field_check(&header->header_section,id);
225 }
226 
227 
229 
230 #endif /* RTSP_HEADER_H */
apr_port_t min
Definition: rtsp_header.h:113
apt_bool_t apt_header_section_field_remove(apt_header_section_t *header, apt_header_field_t *header_field)
apt_str_t mode
Definition: rtsp_header.h:137
rtsp_port_range_t server_port_range
Definition: rtsp_header.h:131
apt_bool_t apt_header_section_array_alloc(apt_header_section_t *header, apr_size_t max_field_count, apr_pool_t *pool)
Definition: rtsp_header.h:141
#define APT_END_EXTERN_C
Definition: apt.h:38
int apt_bool_t
Definition: apt.h:57
apt_header_section_t header_section
Definition: rtsp_header.h:157
Definition: rtsp_header.h:111
apt_str_t rtp_info
Definition: rtsp_header.h:149
apt_bool_t rtsp_header_field_add(rtsp_header_t *header, apt_header_field_t *header_field, apr_pool_t *pool)
rtsp_port_range_t client_port_range
Definition: rtsp_header.h:129
rtsp_delivery_e delivery
Definition: rtsp_header.h:127
apr_port_t max
Definition: rtsp_header.h:115
apt_str_t destination
Definition: rtsp_header.h:135
Definition: apt_header_field.h:39
apt_bool_t rtsp_header_property_add(rtsp_header_t *header, rtsp_header_field_id id, apr_pool_t *pool)
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
Definition: rtsp_header.h:119
rtsp_content_type_e
Definition: rtsp_header.h:93
rtsp_profile_e profile
Definition: rtsp_header.h:123
rtsp_lower_transport_e lower_protocol
Definition: rtsp_header.h:125
void apt_header_section_init(apt_header_section_t *header)
#define RTSP_DECLARE(type)
Definition: rtsp.h:41
rtsp_transport_e protocol
Definition: rtsp_header.h:121
rtsp_transport_attrib_e
Definition: rtsp_header.h:57
rtsp_lower_transport_e
Definition: rtsp_header.h:48
Definition: apt_header_field.h:58
apr_size_t content_length
Definition: rtsp_header.h:154
Definition: apt_string.h:36
apt_str_t session_id
Definition: rtsp_header.h:147
rtsp_delivery_e
Definition: rtsp_header.h:71
rtsp_profile_e
Definition: rtsp_header.h:39
rtsp_header_field_id
Definition: rtsp_header.h:80
apt_bool_t rtsp_header_fields_parse(rtsp_header_t *header, apr_pool_t *pool)
apr_size_t cseq
Definition: rtsp_header.h:143
Header Field Declaration (RFC5322)
rtsp_transport_t transport
Definition: rtsp_header.h:145
RTSP Core Definitions.
rtsp_transport_e
Definition: rtsp_header.h:31
rtsp_content_type_e content_type
Definition: rtsp_header.h:152
apt_str_t source
Definition: rtsp_header.h:133