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: mpf_engine.h 1709 2010-05-24 17:12:11Z achaloyan $ 00017 */ 00018 00019 #ifndef MPF_ENGINE_H 00020 #define MPF_ENGINE_H 00021 00022 /** 00023 * @file mpf_engine.h 00024 * @brief Media Processing Framework Engine 00025 */ 00026 00027 #include "apt_task.h" 00028 #include "mpf_message.h" 00029 00030 APT_BEGIN_EXTERN_C 00031 00032 /** MPF task message definition */ 00033 typedef apt_task_msg_t mpf_task_msg_t; 00034 00035 /** 00036 * Create MPF engine. 00037 * @param id the identifier of the engine 00038 * @param pool the pool to allocate memory from 00039 */ 00040 MPF_DECLARE(mpf_engine_t*) mpf_engine_create(const char *id, apr_pool_t *pool); 00041 00042 /** 00043 * Create MPF codec manager. 00044 * @param pool the pool to allocate memory from 00045 */ 00046 MPF_DECLARE(mpf_codec_manager_t*) mpf_engine_codec_manager_create(apr_pool_t *pool); 00047 00048 /** 00049 * Register MPF codec manager. 00050 * @param engine the engine to register codec manager for 00051 * @param codec_manager the codec manager to register 00052 */ 00053 MPF_DECLARE(apt_bool_t) mpf_engine_codec_manager_register(mpf_engine_t *engine, const mpf_codec_manager_t *codec_manager); 00054 00055 /** 00056 * Create MPF context. 00057 * @param engine the engine to create context for 00058 * @param name the informative name of the context 00059 * @param obj the external object associated with context 00060 * @param max_termination_count the max number of terminations in context 00061 * @param pool the pool to allocate memory from 00062 */ 00063 MPF_DECLARE(mpf_context_t*) mpf_engine_context_create( 00064 mpf_engine_t *engine, 00065 const char *name, 00066 void *obj, 00067 apr_size_t max_termination_count, 00068 apr_pool_t *pool); 00069 00070 /** 00071 * Destroy MPF context. 00072 * @param context the context to destroy 00073 */ 00074 MPF_DECLARE(apt_bool_t) mpf_engine_context_destroy(mpf_context_t *context); 00075 00076 /** 00077 * Get external object associated with MPF context. 00078 * @param context the context to get object from 00079 */ 00080 MPF_DECLARE(void*) mpf_engine_context_object_get(const mpf_context_t *context); 00081 00082 /** 00083 * Get task. 00084 * @param engine the engine to get task from 00085 */ 00086 MPF_DECLARE(apt_task_t*) mpf_task_get(const mpf_engine_t *engine); 00087 00088 /** 00089 * Set task msg type to send responses and events with. 00090 * @param engine the engine to set task msg type for 00091 * @param type the type to set 00092 */ 00093 MPF_DECLARE(void) mpf_engine_task_msg_type_set(mpf_engine_t *engine, apt_task_msg_type_e type); 00094 00095 /** 00096 * Create task message(if not created) and add MPF termination message to it. 00097 * @param engine the engine task message belongs to 00098 * @param command_id the MPF command identifier 00099 * @param context the context to add termination to 00100 * @param termination the termination to add 00101 * @param descriptor the termination dependent descriptor 00102 * @param task_msg the task message to create and add constructed MPF message to 00103 */ 00104 MPF_DECLARE(apt_bool_t) mpf_engine_termination_message_add( 00105 mpf_engine_t *engine, 00106 mpf_command_type_e command_id, 00107 mpf_context_t *context, 00108 mpf_termination_t *termination, 00109 void *descriptor, 00110 mpf_task_msg_t **task_msg); 00111 00112 /** 00113 * Create task message(if not created) and add MPF association message to it. 00114 * @param engine the engine task message belongs to 00115 * @param command_id the MPF command identifier 00116 * @param context the context to add association of terminations for 00117 * @param termination the termination to associate 00118 * @param assoc_termination the termination to associate 00119 * @param task_msg the task message to create and add constructed MPF message to 00120 */ 00121 MPF_DECLARE(apt_bool_t) mpf_engine_assoc_message_add( 00122 mpf_engine_t *engine, 00123 mpf_command_type_e command_id, 00124 mpf_context_t *context, 00125 mpf_termination_t *termination, 00126 mpf_termination_t *assoc_termination, 00127 mpf_task_msg_t **task_msg); 00128 00129 /** 00130 * Create task message(if not created) and add MPF topology message to it. 00131 * @param engine the engine task message belongs to 00132 * @param command_id the MPF command identifier 00133 * @param context the context to modify topology for 00134 * @param task_msg the task message to create and add constructed MPF message to 00135 */ 00136 MPF_DECLARE(apt_bool_t) mpf_engine_topology_message_add( 00137 mpf_engine_t *engine, 00138 mpf_command_type_e command_id, 00139 mpf_context_t *context, 00140 mpf_task_msg_t **task_msg); 00141 00142 /** 00143 * Send MPF task message. 00144 * @param engine the engine to send task message to 00145 * @param task_msg the task message to send 00146 */ 00147 MPF_DECLARE(apt_bool_t) mpf_engine_message_send(mpf_engine_t *engine, mpf_task_msg_t **task_msg); 00148 00149 /** 00150 * Set scheduler rate. 00151 * @param engine the engine to set rate for 00152 * @param rate the rate (n times faster than real-time) 00153 */ 00154 MPF_DECLARE(apt_bool_t) mpf_engine_scheduler_rate_set(mpf_engine_t *engine, unsigned long rate); 00155 00156 /** 00157 * Get the identifier of the engine . 00158 * @param engine the engine to get name of 00159 */ 00160 MPF_DECLARE(const char*) mpf_engine_id_get(const mpf_engine_t *engine); 00161 00162 00163 APT_END_EXTERN_C 00164 00165 #endif /* MPF_ENGINE_H */