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: mrcp_control_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_CONTROL_DESCRIPTOR_H
20 #define MRCP_CONTROL_DESCRIPTOR_H
21 
22 /**
23  * @file mrcp_control_descriptor.h
24  * @brief MRCPv2 Control Descriptor
25  */
26 
27 #include <apr_tables.h>
28 #include "apt_string.h"
29 #include "mrcp_connection_types.h"
30 
31 APT_BEGIN_EXTERN_C
32 
33 /** TCP discard port used in offer/answer */
34 #define TCP_DISCARD_PORT 9
35 
36 
37 /** MRCPv2 proto transport */
38 typedef enum {
39 	MRCP_PROTO_TCP,
40 	MRCP_PROTO_TLS,
41 
42 	MRCP_PROTO_COUNT,
43 	MRCP_PROTO_UNKNOWN = MRCP_PROTO_COUNT
44 }mrcp_proto_type_e;
45 
46 
47 /** MRCPv2 attributes */
48 typedef enum {
49 	MRCP_ATTRIB_SETUP,
50 	MRCP_ATTRIB_CONNECTION,
51 	MRCP_ATTRIB_RESOURCE,
52 	MRCP_ATTRIB_CHANNEL,
53 	MRCP_ATTRIB_CMID,
54 
55 	MRCP_ATTRIB_COUNT,
56 	MRCP_ATTRIB_UNKNOWN = MRCP_ATTRIB_COUNT
57 }mrcp_attrib_e;
58 
59 
60 /** MRCPv2 setup attributes */
61 typedef enum {
62 	MRCP_SETUP_TYPE_ACTIVE,
63 	MRCP_SETUP_TYPE_PASSIVE,
64 
65 	MRCP_SETUP_TYPE_COUNT,
66 	MRCP_SETUP_TYPE_UNKNOWN = MRCP_SETUP_TYPE_COUNT
67 } mrcp_setup_type_e;
68 
69 /** MRCPv2 connection attributes */
70 typedef enum {
71 	MRCP_CONNECTION_TYPE_NEW,
72 	MRCP_CONNECTION_TYPE_EXISTING,
73 
74 	MRCP_CONNECTION_TYPE_COUNT,
75 	MRCP_CONNECTION_TYPE_UNKNOWN = MRCP_CONNECTION_TYPE_COUNT
76 } mrcp_connection_type_e;
77 
78 
79 /** MRCPv2 control descriptor */
80 struct mrcp_control_descriptor_t {
81 	/** IP address */
82 	apt_str_t              ip;
83 	/** Port */
84 	apr_port_t             port;
85 	/** Protocol type */
86 	mrcp_proto_type_e      proto;
87 	/** Setup type */
88 	mrcp_setup_type_e      setup_type;
89 	/** Connection type */
90 	mrcp_connection_type_e connection_type;
91 	/** Resource name */
92 	apt_str_t              resource_name;
93 	/** Session identifier */
94 	apt_str_t              session_id;
95 	/** Array of cmid attributes */
96 	apr_array_header_t    *cmid_arr;
97 	/** Base identifier */
98 	apr_size_t             id;
99 };
100 
101 
102 /** Create MRCP control descriptor */
103 MRCP_DECLARE(mrcp_control_descriptor_t*) mrcp_control_descriptor_create(apr_pool_t *pool);
104 
105 /** Create MRCP control offer */
106 MRCP_DECLARE(mrcp_control_descriptor_t*) mrcp_control_offer_create(apr_pool_t *pool);
107 
108 /** Create MRCP control answer */
109 MRCP_DECLARE(mrcp_control_descriptor_t*) mrcp_control_answer_create(mrcp_control_descriptor_t *offer, apr_pool_t *pool);
110 
111 /** Add cmid to cmid_arr */
112 MRCP_DECLARE(void) mrcp_cmid_add(apr_array_header_t *cmid_arr, apr_size_t cmid);
113 
114 /** Find cmid in cmid_arr */
115 MRCP_DECLARE(apt_bool_t) mrcp_cmid_find(const apr_array_header_t *cmid_arr, apr_size_t cmid);
116 
117 /** Get MRCP protocol transport name by identifier */
118 MRCP_DECLARE(const apt_str_t*) mrcp_proto_get(mrcp_proto_type_e proto);
119 
120 /** Find MRCP protocol transport identifier by name */
121 MRCP_DECLARE(mrcp_proto_type_e) mrcp_proto_find(const apt_str_t *attrib);
122 
123 
124 /** Get MRCP attribute name by identifier */
125 MRCP_DECLARE(const apt_str_t*) mrcp_attrib_str_get(mrcp_attrib_e attrib_id);
126 
127 /** Find MRCP attribute identifier by name */
128 MRCP_DECLARE(mrcp_attrib_e) mrcp_attrib_id_find(const apt_str_t *attrib);
129 
130 
131 /** Get MRCP setup type name by identifier */
132 MRCP_DECLARE(const apt_str_t*) mrcp_setup_type_get(mrcp_setup_type_e setup_type);
133 
134 /** Find MRCP setup type identifier by name */
135 MRCP_DECLARE(mrcp_setup_type_e) mrcp_setup_type_find(const apt_str_t *attrib);
136 
137 
138 /** Get MRCP connection type name by identifier */
139 MRCP_DECLARE(const apt_str_t*) mrcp_connection_type_get(mrcp_connection_type_e connection_type);
140 
141 /** Find MRCP connection type identifier by name */
142 MRCP_DECLARE(mrcp_connection_type_e) mrcp_connection_type_find(const apt_str_t *attrib);
143 
144 
145 APT_END_EXTERN_C
146 
147 #endif /* MRCP_CONTROL_DESCRIPTOR_H */
148