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_engine_iface.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_ENGINE_IFACE_H
20 #define MRCP_ENGINE_IFACE_H
21 
22 /**
23  * @file mrcp_engine_iface.h
24  * @brief MRCP Engine User Interface (typically user is an MRCP server)
25  */
26 
27 #include "mrcp_engine_types.h"
28 
29 APT_BEGIN_EXTERN_C
30 
31 /** Destroy engine */
32 apt_bool_t mrcp_engine_virtual_destroy(mrcp_engine_t *engine);
33 
34 /** Open engine */
35 apt_bool_t mrcp_engine_virtual_open(mrcp_engine_t *engine);
36 
37 /** Response to open engine request */
38 void mrcp_engine_on_open(mrcp_engine_t *engine, apt_bool_t status);
39 
40 /** Close engine */
41 apt_bool_t mrcp_engine_virtual_close(mrcp_engine_t *engine);
42 
43 /** Response to close engine request */
44 void mrcp_engine_on_close(mrcp_engine_t *engine);
45 
46 
47 /** Create engine channel */
48 mrcp_engine_channel_t* mrcp_engine_channel_virtual_create(mrcp_engine_t *engine, mrcp_version_e mrcp_version, apr_pool_t *pool);
49 
50 /** Destroy engine channel */
51 apt_bool_t mrcp_engine_channel_virtual_destroy(mrcp_engine_channel_t *channel);
52 
53 /** Open engine channel */
mrcp_engine_channel_virtual_open(mrcp_engine_channel_t * channel)54 static APR_INLINE apt_bool_t mrcp_engine_channel_virtual_open(mrcp_engine_channel_t *channel)
55 {
56 	if(channel->is_open == FALSE) {
57 		channel->is_open = channel->method_vtable->open(channel);
58 		return channel->is_open;
59 	}
60 	return FALSE;
61 }
62 
63 /** Close engine channel */
mrcp_engine_channel_virtual_close(mrcp_engine_channel_t * channel)64 static APR_INLINE apt_bool_t mrcp_engine_channel_virtual_close(mrcp_engine_channel_t *channel)
65 {
66 	if(channel->is_open == TRUE) {
67 		channel->is_open = FALSE;
68 		return channel->method_vtable->close(channel);
69 	}
70 	return FALSE;
71 }
72 
73 /** Process request */
mrcp_engine_channel_request_process(mrcp_engine_channel_t * channel,mrcp_message_t * message)74 static APR_INLINE apt_bool_t mrcp_engine_channel_request_process(mrcp_engine_channel_t *channel, mrcp_message_t *message)
75 {
76 	return channel->method_vtable->process_request(channel,message);
77 }
78 
79 /** Allocate engine config */
80 mrcp_engine_config_t* mrcp_engine_config_alloc(apr_pool_t *pool);
81 
82 
83 APT_END_EXTERN_C
84 
85 #endif /* MRCP_ENGINE_IFACE_H */
86