00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mrcp_engine_types.h 1700 2010-05-21 18:56:06Z achaloyan $ 00017 */ 00018 00019 #ifndef MRCP_ENGINE_TYPES_H 00020 #define MRCP_ENGINE_TYPES_H 00021 00022 /** 00023 * @file mrcp_engine_types.h 00024 * @brief MRCP Engine Types 00025 */ 00026 00027 #include <apr_tables.h> 00028 #include "mrcp_state_machine.h" 00029 #include "mpf_types.h" 00030 #include "apt_string.h" 00031 00032 APT_BEGIN_EXTERN_C 00033 00034 /** MRCP engine declaration */ 00035 typedef struct mrcp_engine_t mrcp_engine_t; 00036 /** MRCP engine config declaration */ 00037 typedef struct mrcp_engine_config_t mrcp_engine_config_t; 00038 /** MRCP engine vtable declaration */ 00039 typedef struct mrcp_engine_method_vtable_t mrcp_engine_method_vtable_t; 00040 /** MRCP engine event vtable declaration */ 00041 typedef struct mrcp_engine_event_vtable_t mrcp_engine_event_vtable_t; 00042 /** MRCP engine channel declaration */ 00043 typedef struct mrcp_engine_channel_t mrcp_engine_channel_t; 00044 /** MRCP engine channel virtual method table declaration */ 00045 typedef struct mrcp_engine_channel_method_vtable_t mrcp_engine_channel_method_vtable_t; 00046 /** MRCP engine channel virtual event table declaration */ 00047 typedef struct mrcp_engine_channel_event_vtable_t mrcp_engine_channel_event_vtable_t; 00048 00049 /** Table of channel virtual methods */ 00050 struct mrcp_engine_channel_method_vtable_t { 00051 /** Virtual destroy */ 00052 apt_bool_t (*destroy)(mrcp_engine_channel_t *channel); 00053 /** Virtual open */ 00054 apt_bool_t (*open)(mrcp_engine_channel_t *channel); 00055 /** Virtual close */ 00056 apt_bool_t (*close)(mrcp_engine_channel_t *channel); 00057 /** Virtual process_request */ 00058 apt_bool_t (*process_request)(mrcp_engine_channel_t *channel, mrcp_message_t *request); 00059 }; 00060 00061 /** Table of channel virtual event handlers */ 00062 struct mrcp_engine_channel_event_vtable_t { 00063 /** Open event handler */ 00064 apt_bool_t (*on_open)(mrcp_engine_channel_t *channel, apt_bool_t status); 00065 /** Close event handler */ 00066 apt_bool_t (*on_close)(mrcp_engine_channel_t *channel); 00067 /** Message event handler */ 00068 apt_bool_t (*on_message)(mrcp_engine_channel_t *channel, mrcp_message_t *message); 00069 }; 00070 00071 /** MRCP engine channel declaration */ 00072 struct mrcp_engine_channel_t { 00073 /** Table of virtual methods */ 00074 const mrcp_engine_channel_method_vtable_t *method_vtable; 00075 /** External object used with virtual methods */ 00076 void *method_obj; 00077 /** Table of virtual event handlers */ 00078 const mrcp_engine_channel_event_vtable_t *event_vtable; 00079 /** External object used with event handlers */ 00080 void *event_obj; 00081 /** Media termination */ 00082 mpf_termination_t *termination; 00083 /** Back pointer to engine */ 00084 mrcp_engine_t *engine; 00085 /** Unique identifier to be used in traces */ 00086 apt_str_t id; 00087 /** MRCP version */ 00088 mrcp_version_e mrcp_version; 00089 /** Is channel successfully opened */ 00090 apt_bool_t is_open; 00091 /** Pool to allocate memory from */ 00092 apr_pool_t *pool; 00093 }; 00094 00095 /** Table of MRCP engine virtual methods */ 00096 struct mrcp_engine_method_vtable_t { 00097 /** Virtual destroy */ 00098 apt_bool_t (*destroy)(mrcp_engine_t *engine); 00099 /** Virtual open */ 00100 apt_bool_t (*open)(mrcp_engine_t *engine); 00101 /** Virtual close */ 00102 apt_bool_t (*close)(mrcp_engine_t *engine); 00103 /** Virtual channel create */ 00104 mrcp_engine_channel_t* (*create_channel)(mrcp_engine_t *engine, apr_pool_t *pool); 00105 }; 00106 00107 /** Table of MRCP engine virtual event handlers */ 00108 struct mrcp_engine_event_vtable_t { 00109 /** Open event handler */ 00110 apt_bool_t (*on_open)(mrcp_engine_t *channel, apt_bool_t status); 00111 /** Close event handler */ 00112 apt_bool_t (*on_close)(mrcp_engine_t *channel); 00113 }; 00114 00115 /** MRCP engine */ 00116 struct mrcp_engine_t { 00117 /** Identifier of the engine */ 00118 const char *id; 00119 /** Resource identifier */ 00120 mrcp_resource_id resource_id; 00121 /** External object associated with engine */ 00122 void *obj; 00123 /** Table of virtual methods */ 00124 const mrcp_engine_method_vtable_t *method_vtable; 00125 /** Table of virtual event handlers */ 00126 const mrcp_engine_event_vtable_t *event_vtable; 00127 /** External object used with event handlers */ 00128 void *event_obj; 00129 /** Codec manager */ 00130 const mpf_codec_manager_t *codec_manager; 00131 /** Dir layout structure */ 00132 const apt_dir_layout_t *dir_layout; 00133 /** Config of engine */ 00134 mrcp_engine_config_t *config; 00135 /** Number of simultaneous channels currently in use */ 00136 apr_size_t cur_channel_count; 00137 /** Is engine successfully opened */ 00138 apt_bool_t is_open; 00139 /** Pool to allocate memory from */ 00140 apr_pool_t *pool; 00141 00142 /** Create state machine */ 00143 mrcp_state_machine_t* (*create_state_machine)(void *obj, mrcp_version_e version, apr_pool_t *pool); 00144 }; 00145 00146 /** MRCP engine config */ 00147 struct mrcp_engine_config_t { 00148 /** Max number of simultaneous channels */ 00149 apr_size_t max_channel_count; 00150 /** Table of name/value string params */ 00151 apr_table_t *params; 00152 }; 00153 00154 APT_END_EXTERN_C 00155 00156 #endif /* MRCP_ENGINE_TYPES_H */