UniMRCP  1.7.0
mrcp_application.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
17 #ifndef MRCP_APPLICATION_H
18 #define MRCP_APPLICATION_H
19 
20 /**
21  * @file mrcp_application.h
22  * @brief MRCP User Level Application Interface
23  */
24 
25 #include "mrcp_client_types.h"
26 #include "mpf_rtp_descriptor.h"
27 #include "mpf_stream.h"
28 
30 
31 /** MRCP application message declaration */
33 
34 /** MRCP signaling message declaration */
36 
37 /** MRCP application message dispatcher declaration */
39 
40 /** MRCP application message handler */
42 
43 /** Enumeration of MRCP signaling message types */
44 typedef enum {
45  MRCP_SIG_MESSAGE_TYPE_REQUEST, /**< request message */
46  MRCP_SIG_MESSAGE_TYPE_RESPONSE, /**< response message */
47  MRCP_SIG_MESSAGE_TYPE_EVENT /**< event message */
49 
50 /** Enumeration of MRCP signaling status codes */
51 typedef enum {
52  MRCP_SIG_STATUS_CODE_SUCCESS, /**< indicates success */
53  MRCP_SIG_STATUS_CODE_FAILURE, /**< request failed */
54  MRCP_SIG_STATUS_CODE_TERMINATE, /**< request failed, session/channel/connection unexpectedly terminated */
55  MRCP_SIG_STATUS_CODE_CANCEL /**< request cancelled */
57 
58 
59 /** Enumeration of MRCP signaling commands (requests/responses) */
60 typedef enum {
61  MRCP_SIG_COMMAND_SESSION_UPDATE,
62  MRCP_SIG_COMMAND_SESSION_TERMINATE,
63  MRCP_SIG_COMMAND_CHANNEL_ADD,
64  MRCP_SIG_COMMAND_CHANNEL_REMOVE,
65  MRCP_SIG_COMMAND_RESOURCE_DISCOVER
67 
68 /** Enumeration of MRCP signaling events */
69 typedef enum {
70  MRCP_SIG_EVENT_TERMINATE
72 
73 
74 /** Enumeration of MRCP application message types */
75 typedef enum {
76  MRCP_APP_MESSAGE_TYPE_SIGNALING, /**< signaling message type */
77  MRCP_APP_MESSAGE_TYPE_CONTROL /**< control message type */
79 
80 /** MRCP signaling message definition */
82  /** Message type (request/response/event) */
84  /** Command (request/response) identifier */
86  /** Event identifier */
88  /** Status code used in response */
90 };
91 
92 
93 /** MRCP application message definition */
95  /** Message type (signaling/control) */
97 
98  /** Application */
100  /** Session */
102  /** Channel */
104  /** Session/resource descriptor */
106 
107  /** MRCP signaling message (used if message_type == MRCP_APP_MESSAGE_SIGNALING) */
109  /** MRCP control message (used if message_type == MRCP_APP_MESSAGE_CONTROL) */
111 };
112 
113 /** MRCP application message dispatcher interface */
115  /** Response to mrcp_application_session_update()request */
116  apt_bool_t (*on_session_update)(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status);
117  /** Response to mrcp_application_session_terminate()request */
118  apt_bool_t (*on_session_terminate)(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status);
119 
120  /** Response to mrcp_application_channel_add() request */
121  apt_bool_t (*on_channel_add)(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status);
122  /** Response to mrcp_application_channel_remove() request */
123  apt_bool_t (*on_channel_remove)(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status);
124 
125  /** Response (event) to mrcp_application_message_send() request */
126  apt_bool_t (*on_message_receive)(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message);
127 
128  /** Event indicating unexpected session/channel termination */
129  apt_bool_t (*on_terminate_event)(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel);
130 
131  /** Response to mrcp_application_resource_discover() request */
132  apt_bool_t (*on_resource_discover)(mrcp_application_t *application, mrcp_session_t *session, mrcp_session_descriptor_t *descriptor, mrcp_sig_status_code_e status);
133 };
134 
135 
136 
137 /**
138  * Create application instance.
139  * @param handler the event handler
140  * @param obj the external object
141  * @param pool the pool to allocate memory from
142  */
143 MRCP_DECLARE(mrcp_application_t*) mrcp_application_create(const mrcp_app_message_handler_f handler, void *obj, apr_pool_t *pool);
144 
145 /**
146  * Destroy application instance.
147  * @param application the application to destroy
148  */
150 
151 /**
152  * Get external object associated with the application.
153  * @param application the application to get object from
154  */
156 
157 /**
158  * Get dir layout structure.
159  * @param application the application to get dir layout from
160  */
162 
163 /**
164  * Create session.
165  * @param application the application to use
166  * @param profile the name of the profile to use
167  * @param obj the external object
168  * @return the created session instance
169  */
170 MRCP_DECLARE(mrcp_session_t*) mrcp_application_session_create(mrcp_application_t *application, const char *profile, void *obj);
171 
172 /**
173  * Create session using the provided memory pool.
174  * @param application the application to use
175  * @param profile the name of the profile to use
176  * @param obj the external object
177  * @param take_ownership whether the session takes ownership over the memory pool or not
178  * @param pool memory pool to use
179  * @return the created session instance
180  */
182  mrcp_application_t *application,
183  const char *profile,
184  void *obj,
185  apt_bool_t take_ownership,
186  apr_pool_t *pool);
187 
188 /**
189  * Get memory pool the session object is created out of.
190  * @param session the session to get pool from
191  */
193 
194 /**
195  * Get session identifier.
196  * @param session the session to get identifier of
197  */
199 
200 /**
201  * Get SIP or RTSP response code.
202  * @param session the session to use
203  */
205 
206 /**
207  * Get external object associated with the session.
208  * @param session the session to get object from
209  */
211 
212 /**
213  * Set (associate) external object to the session.
214  * @param session the session to set object for
215  * @param obj the object to set
216  */
218 
219 /**
220  * Set name of the session (informative only used for debugging).
221  * @param session the session to set name for
222  * @param name the name to set
223  */
224 MRCP_DECLARE(void) mrcp_application_session_name_set(mrcp_session_t *session, const char *name);
225 
226 /**
227  * Set session attributes.
228  * @param session the session to set attributes for
229  * @param attribs the attributes to set
230  */
232 
233 /**
234  * Send session update request.
235  * @param session the session to update
236  */
238 
239 /**
240  * Send session termination request.
241  * @param session the session to terminate
242  */
244 
245 /**
246  * Destroy client session (session must be terminated prior to destroy).
247  * @param session the session to destroy
248  */
250 
251 
252 /**
253  * Create control channel.
254  * @param session the session to create channel for
255  * @param resource_id the resource identifier of the channel
256  * @param termination the media termination
257  * @param rtp_descriptor the RTP termination descriptor (NULL by default)
258  * @param obj the external object
259  */
261  mrcp_session_t *session,
262  mrcp_resource_id resource_id,
263  mpf_termination_t *termination,
264  mpf_rtp_termination_descriptor_t *rtp_descriptor,
265  void *obj);
266 
267 /**
268  * Get external object associated with the channel.
269  * @param channel the channel to get object from
270  */
272 
273 /**
274  * Get RTP termination descriptor.
275  * @param channel the channel to get descriptor from
276  */
278 
279 /**
280  * Get codec descriptor of source stream.
281  * @param channel the channel to get descriptor from
282  */
284 
285 /**
286  * Get codec descriptor of sink stream.
287  * @param channel the channel to get descriptor from
288  */
290 
291 /**
292  * Get associated audio stream.
293  * @param channel the channel to get associated stream from
294  */
296 
297 /**
298  * Send channel add request.
299  * @param session the session to create channel for
300  * @param channel the control channel
301  */
303 
304 /**
305  * Create MRCP message.
306  * @param session the session
307  * @param channel the control channel
308  * @param method_id the method identifier of MRCP message
309  */
311 
312 /**
313  * Send MRCP message.
314  * @param session the session
315  * @param channel the control channel
316  * @param message the MRCP message to send
317  */
319 
320 /**
321  * Remove channel.
322  * @param session the session to remove channel from
323  * @param channel the control channel to remove
324  */
326 
327 /**
328  * Discover resources.
329  * @param session the session to use as communication object
330  */
332 
333 /**
334  * Dispatch application message.
335  * @param dispatcher the dispatcher inteface
336  * @param app_message the message to dispatch
337  */
339 
340 /**
341  * Create audio termination
342  * @param session the session to create termination for
343  * @param stream_vtable the virtual table of audio stream
344  * @param capabilities the capabilities of the stream
345  * @param obj the external object
346  */
348  mrcp_session_t *session,
349  const mpf_audio_stream_vtable_t *stream_vtable,
350  mpf_stream_capabilities_t *capabilities,
351  void *obj);
352 /**
353  * Create source media termination
354  * @param session the session to create termination for
355  * @param stream_vtable the virtual table of audio stream
356  * @param codec_descriptor the descriptor of audio stream (NULL by default)
357  * @param obj the external object
358  * @deprecated @see mrcp_application_audio_termination_create()
359  */
361  mrcp_session_t *session,
362  const mpf_audio_stream_vtable_t *stream_vtable,
363  mpf_codec_descriptor_t *codec_descriptor,
364  void *obj);
365 /**
366  * Create sink media termination
367  * @param session the session to create termination for
368  * @param stream_vtable the virtual table of audio stream
369  * @param codec_descriptor the descriptor of audio stream (NULL by default)
370  * @param obj the external object
371  * @deprecated @see mrcp_application_audio_termination_create()
372  */
374  mrcp_session_t *session,
375  const mpf_audio_stream_vtable_t *stream_vtable,
376  mpf_codec_descriptor_t *codec_descriptor,
377  void *obj);
378 
380 
381 #endif /* MRCP_APPLICATION_H */
Definition: mpf_stream.h:37
#define MRCP_DECLARE(type)
Definition: mrcp.h:40
apt_bool_t mrcp_application_session_destroy(mrcp_session_t *session)
Definition: mrcp_application.h:47
Definition: mrcp_session.h:49
Definition: mrcp_application.h:52
mrcp_app_message_type_e message_type
Definition: mrcp_application.h:96
void * mrcp_application_session_object_get(const mrcp_session_t *session)
void mrcp_application_session_name_set(mrcp_session_t *session, const char *name)
mrcp_message_t * mrcp_application_message_create(mrcp_session_t *session, mrcp_channel_t *channel, mrcp_method_id method_id)
void * mrcp_application_object_get(const mrcp_application_t *application)
apt_bool_t mrcp_application_session_terminate(mrcp_session_t *session)
struct apt_dir_layout_t apt_dir_layout_t
Definition: apt_dir_layout.h:38
Definition: mpf_termination.h:51
apr_size_t mrcp_method_id
Definition: mrcp_types.h:66
MPF Bidirectional Stream.
Definition: mpf_stream.h:69
mrcp_application_t * mrcp_application_create(const mrcp_app_message_handler_f handler, void *obj, apr_pool_t *pool)
Definition: mrcp_client_session.h:100
apt_bool_t mrcp_application_resource_discover(mrcp_session_t *session)
apt_bool_t mrcp_application_channel_add(mrcp_session_t *session, mrcp_channel_t *channel)
Definition: mrcp_application.h:46
mrcp_sig_message_type_e
Definition: mrcp_application.h:44
apt_bool_t mrcp_application_message_dispatch(const mrcp_app_message_dispatcher_t *dispatcher, const mrcp_app_message_t *app_message)
#define APT_END_EXTERN_C
Definition: apt.h:38
const apt_str_t * mrcp_application_session_id_get(const mrcp_session_t *session)
const apt_dir_layout_t * mrcp_application_dir_layout_get(const mrcp_application_t *application)
int apt_bool_t
Definition: apt.h:57
mrcp_session_t * mrcp_application_session_create_ex(mrcp_application_t *application, const char *profile, void *obj, apt_bool_t take_ownership, apr_pool_t *pool)
const mpf_codec_descriptor_t * mrcp_application_sink_descriptor_get(const mrcp_channel_t *channel)
Definition: mrcp_application.h:45
mrcp_sig_status_code_e status
Definition: mrcp_application.h:89
mpf_termination_t * mrcp_application_audio_termination_create(mrcp_session_t *session, const mpf_audio_stream_vtable_t *stream_vtable, mpf_stream_capabilities_t *capabilities, void *obj)
apt_bool_t mrcp_application_session_update(mrcp_session_t *session)
int mrcp_application_session_response_code_get(const mrcp_session_t *session)
Definition: mrcp_application.h:94
void mrcp_application_session_object_set(mrcp_session_t *session, void *obj)
Definition: mrcp_session_descriptor.h:42
mrcp_session_t * mrcp_application_session_create(mrcp_application_t *application, const char *profile, void *obj)
mrcp_channel_t * channel
Definition: mrcp_application.h:103
apr_pool_t * mrcp_application_session_pool_get(const mrcp_session_t *session)
Definition: mpf_rtp_descriptor.h:85
mrcp_message_t * control_message
Definition: mrcp_application.h:110
void * mrcp_application_channel_object_get(const mrcp_channel_t *channel)
Definition: mpf_stream_descriptor.h:43
mrcp_sig_event_e event_id
Definition: mrcp_application.h:87
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
apt_bool_t mrcp_application_channel_remove(mrcp_session_t *session, mrcp_channel_t *channel)
const mpf_audio_stream_t * mrcp_application_audio_stream_get(const mrcp_channel_t *channel)
apt_bool_t mrcp_application_destroy(mrcp_application_t *application)
Definition: mrcp_application.h:55
mrcp_sig_command_e command_id
Definition: mrcp_application.h:85
mrcp_sig_command_e
Definition: mrcp_application.h:60
apr_size_t mrcp_resource_id
Definition: mrcp_types.h:68
mrcp_session_descriptor_t * descriptor
Definition: mrcp_application.h:105
mrcp_app_message_type_e
Definition: mrcp_application.h:75
mrcp_sig_status_code_e
Definition: mrcp_application.h:51
mpf_rtp_termination_descriptor_t * mrcp_application_rtp_descriptor_get(const mrcp_channel_t *channel)
Definition: mrcp_application.h:54
mpf_termination_t * mrcp_application_source_termination_create(mrcp_session_t *session, const mpf_audio_stream_vtable_t *stream_vtable, mpf_codec_descriptor_t *codec_descriptor, void *obj)
mrcp_channel_t * mrcp_application_channel_create(mrcp_session_t *session, mrcp_resource_id resource_id, mpf_termination_t *termination, mpf_rtp_termination_descriptor_t *rtp_descriptor, void *obj)
Definition: mrcp_application.h:53
Definition: mrcp_application.h:76
Definition: apt_string.h:36
Definition: mrcp_client_session.h:161
Definition: mrcp_session_descriptor.h:50
mpf_termination_t * mrcp_application_sink_termination_create(mrcp_session_t *session, const mpf_audio_stream_vtable_t *stream_vtable, mpf_codec_descriptor_t *codec_descriptor, void *obj)
mrcp_sig_message_type_e message_type
Definition: mrcp_application.h:83
const mpf_codec_descriptor_t * mrcp_application_source_descriptor_get(const mrcp_channel_t *channel)
apt_bool_t(* mrcp_app_message_handler_f)(const mrcp_app_message_t *app_message)
Definition: mrcp_application.h:41
void mrcp_application_session_attribs_set(mrcp_session_t *session, mrcp_session_attribs_t *attribs)
Definition: mrcp_application.h:77
MRCP Client Types.
mrcp_session_t * session
Definition: mrcp_application.h:101
MPF RTP Stream Descriptor.
mrcp_sig_message_t sig_message
Definition: mrcp_application.h:108
mrcp_sig_event_e
Definition: mrcp_application.h:69
Definition: mrcp_application.h:114
apt_bool_t mrcp_application_message_send(mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message)
mrcp_application_t * application
Definition: mrcp_application.h:99
Definition: mrcp_application.h:81
Definition: mrcp_message.h:37
Definition: mpf_codec_descriptor.h:63