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_connection.h 1710 2010-05-24 17:36:19Z achaloyan $ 00017 */ 00018 00019 #ifndef MRCP_CONNECTION_H 00020 #define MRCP_CONNECTION_H 00021 00022 /** 00023 * @file mrcp_connection.h 00024 * @brief MRCP Connection 00025 */ 00026 00027 #include <apr_poll.h> 00028 #include <apr_hash.h> 00029 #include "apt_obj_list.h" 00030 #include "mrcp_connection_types.h" 00031 #include "mrcp_stream.h" 00032 00033 APT_BEGIN_EXTERN_C 00034 00035 /** Size of the buffer used for MRCP rx/tx stream */ 00036 #define MRCP_STREAM_BUFFER_SIZE 1024 00037 00038 /** MRCPv2 connection */ 00039 struct mrcp_connection_t { 00040 /** Memory pool */ 00041 apr_pool_t *pool; 00042 00043 /** Accepted/Connected socket */ 00044 apr_socket_t *sock; 00045 /** Socket poll descriptor */ 00046 apr_pollfd_t sock_pfd; 00047 /** Local sockaddr */ 00048 apr_sockaddr_t *l_sockaddr; 00049 /** Remote sockaddr */ 00050 apr_sockaddr_t *r_sockaddr; 00051 /** Remote IP */ 00052 apt_str_t remote_ip; 00053 /** String identifier used for traces */ 00054 const char *id; 00055 /** Transparently dump whatever received/sent on transport layer, 00056 if verbose is set to TRUE (default) */ 00057 apt_bool_t verbose; 00058 00059 /** Reference count */ 00060 apr_size_t access_count; 00061 /** Agent list element */ 00062 apt_list_elem_t *it; 00063 /** Opaque agent */ 00064 void *agent; 00065 00066 /** Table of control channels */ 00067 apr_hash_t *channel_table; 00068 00069 /** Rx buffer */ 00070 char *rx_buffer; 00071 /** Rx buffer size */ 00072 apr_size_t rx_buffer_size; 00073 /** Rx stream */ 00074 apt_text_stream_t rx_stream; 00075 /** MRCP parser to parser MRCP messages out of rx stream */ 00076 mrcp_parser_t *parser; 00077 00078 /** Tx buffer */ 00079 char *tx_buffer; 00080 /** Tx buffer size */ 00081 apr_size_t tx_buffer_size; 00082 /** MRCP generator to generate MRCP messages into tx stream */ 00083 mrcp_generator_t *generator; 00084 }; 00085 00086 /** Create MRCP connection. */ 00087 mrcp_connection_t* mrcp_connection_create(); 00088 00089 /** Destroy MRCP connection. */ 00090 void mrcp_connection_destroy(mrcp_connection_t *connection); 00091 00092 /** Add Control Channel to MRCP connection. */ 00093 apt_bool_t mrcp_connection_channel_add(mrcp_connection_t *connection, mrcp_control_channel_t *channel); 00094 00095 /** Find Control Channel by Channel Identifier. */ 00096 mrcp_control_channel_t* mrcp_connection_channel_find(const mrcp_connection_t *connection, const apt_str_t *identifier); 00097 00098 /** Remove Control Channel from MRCP connection. */ 00099 apt_bool_t mrcp_connection_channel_remove(mrcp_connection_t *connection, mrcp_control_channel_t *channel); 00100 00101 /** Raise disconnect event for each channel from the specified connection. */ 00102 apt_bool_t mrcp_connection_disconnect_raise(mrcp_connection_t *connection, const mrcp_connection_event_vtable_t *vtable); 00103 00104 APT_END_EXTERN_C 00105 00106 #endif /* MRCP_CONNECTION_H */