UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mrcp_session.h
Go to the documentation of this file.
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_session.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_SESSION_H
20 #define MRCP_SESSION_H
21 
22 /**
23  * @file mrcp_session.h
24  * @brief Abstract MRCP Session
25  */
26 
27 #include "mrcp_sig_types.h"
28 #include "mpf_types.h"
29 #include "apt_string.h"
30 
32 
33 /** Macro to log session pointers */
34 #define MRCP_SESSION_PTR(session) (session)
35 /** Macro to log session string identifiers */
36 #define MRCP_SESSION_SID(session) \
37  (session)->id.buf ? (session)->id.buf : "new"
38 
39 /** Macro to log session pointers and string identifiers */
40 #define MRCP_SESSION_PTRSID(session) \
41  MRCP_SESSION_PTR(session), MRCP_SESSION_SID(session)
42 
43 /** MRCP session request vtable declaration */
45 /** MRCP session response vtable declaration */
47 /** MRCP session event vtable declaration */
49 
50 
51 /** MRCP session */
53  /** Memory pool to allocate memory from */
54  apr_pool_t *pool;
55  /** External object associated with session */
56  void *obj;
57  /** External logger object associated with session */
58  void *log_obj;
59  /** Informative name of the session used for debugging */
60  const char *name;
61 
62  /** Signaling (session managment) agent */
64  /** MRCPv2 connection agent, if any */
66  /** Media processing engine */
68  /** RTP termination factory */
70 
71  /** Session identifier */
73  /** Last request identifier sent for client, received for server */
75 
76  /** Virtual request methods */
78  /** Virtual response methods */
80  /** Virtual event methods */
82 };
83 
84 
85 /** MRCP session request vtable */
87  /** Offer session descriptor */
89  /** Terminate session */
91  /** Control session (MRCPv1 only) */
93  /** Discover resources */
95 };
96 
97 /** MRCP session response vtable */
99  /** Answer with remote session descriptor */
101  /** Session terminated */
103  /** Control session (MRCPv1 only) */
105  /** Response to resource discovery request */
107 };
108 
109 /** MRCP session event vtable */
111  /** Received session termination event without appropriate request */
113 };
114 
115 
116 /** Create new memory pool and allocate session object from the pool. */
117 MRCP_DECLARE(mrcp_session_t*) mrcp_session_create(apr_size_t padding);
118 
119 /** Destroy session and assosiated memory pool. */
121 
122 
123 /** Offer */
124 static APR_INLINE apt_bool_t mrcp_session_offer(mrcp_session_t *session, mrcp_session_descriptor_t *descriptor)
125 {
126  if(session->request_vtable->offer) {
127  return session->request_vtable->offer(session,descriptor);
128  }
129  return FALSE;
130 }
131 
132 /** Terminate */
133 static APR_INLINE apt_bool_t mrcp_session_terminate_request(mrcp_session_t *session)
134 {
135  if(session->request_vtable->terminate) {
136  return session->request_vtable->terminate(session);
137  }
138  return FALSE;
139 }
140 
141 /** Answer */
142 static APR_INLINE apt_bool_t mrcp_session_answer(mrcp_session_t *session, mrcp_session_descriptor_t *descriptor)
143 {
144  if(session->response_vtable->on_answer) {
145  return session->response_vtable->on_answer(session,descriptor);
146  }
147  return FALSE;
148 }
149 
150 /** On terminate response */
151 static APR_INLINE apt_bool_t mrcp_session_terminate_response(mrcp_session_t *session)
152 {
153  if(session->response_vtable->on_terminate) {
154  return session->response_vtable->on_terminate(session);
155  }
156  return FALSE;
157 }
158 
159 /** On terminate event */
160 static APR_INLINE apt_bool_t mrcp_session_terminate_event(mrcp_session_t *session)
161 {
162  if(session->event_vtable->on_terminate) {
163  return session->event_vtable->on_terminate(session);
164  }
165  return FALSE;
166 }
167 
168 /** Control request */
169 static APR_INLINE apt_bool_t mrcp_session_control_request(mrcp_session_t *session, mrcp_message_t *message)
170 {
171  if(session->request_vtable->control) {
172  return session->request_vtable->control(session,message);
173  }
174  return FALSE;
175 }
176 
177 /** On control response/event */
178 static APR_INLINE apt_bool_t mrcp_session_control_response(mrcp_session_t *session, mrcp_message_t *message)
179 {
180  if(session->response_vtable->on_control) {
181  return session->response_vtable->on_control(session,message);
182  }
183  return FALSE;
184 }
185 
186 /** Resource discovery request */
187 static APR_INLINE apt_bool_t mrcp_session_discover_request(mrcp_session_t *session, mrcp_session_descriptor_t *descriptor)
188 {
189  if(session->request_vtable->discover) {
190  return session->request_vtable->discover(session,descriptor);
191  }
192  return FALSE;
193 }
194 
195 /** On resource discovery response */
196 static APR_INLINE apt_bool_t mrcp_session_discover_response(mrcp_session_t *session, mrcp_session_descriptor_t *descriptor)
197 {
198  if(session->response_vtable->on_discover) {
199  return session->response_vtable->on_discover(session,descriptor);
200  }
201  return FALSE;
202 }
203 
205 
206 #endif /* MRCP_SESSION_H */