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: mpf_engine.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $ 17 */ 18 19 #ifndef MPF_ENGINE_H 20 #define MPF_ENGINE_H 21 22 /** 23 * @file mpf_engine.h 24 * @brief Media Processing Framework Engine 25 */ 26 27 #include "apt_task.h" 28 #include "mpf_message.h" 29 30 APT_BEGIN_EXTERN_C 31 32 /** MPF task message definition */ 33 typedef apt_task_msg_t mpf_task_msg_t; 34 35 /** 36 * Create MPF engine. 37 * @param id the identifier of the engine 38 * @param pool the pool to allocate memory from 39 */ 40 MPF_DECLARE(mpf_engine_t*) mpf_engine_create(const char *id, apr_pool_t *pool); 41 42 /** 43 * Create MPF codec manager. 44 * @param pool the pool to allocate memory from 45 */ 46 MPF_DECLARE(mpf_codec_manager_t*) mpf_engine_codec_manager_create(apr_pool_t *pool); 47 48 /** 49 * Register MPF codec manager. 50 * @param engine the engine to register codec manager for 51 * @param codec_manager the codec manager to register 52 */ 53 MPF_DECLARE(apt_bool_t) mpf_engine_codec_manager_register(mpf_engine_t *engine, const mpf_codec_manager_t *codec_manager); 54 55 /** 56 * Create MPF context. 57 * @param engine the engine to create context for 58 * @param name the informative name of the context 59 * @param obj the external object associated with context 60 * @param max_termination_count the max number of terminations in context 61 * @param pool the pool to allocate memory from 62 */ 63 MPF_DECLARE(mpf_context_t*) mpf_engine_context_create( 64 mpf_engine_t *engine, 65 const char *name, 66 void *obj, 67 apr_size_t max_termination_count, 68 apr_pool_t *pool); 69 70 /** 71 * Destroy MPF context. 72 * @param context the context to destroy 73 */ 74 MPF_DECLARE(apt_bool_t) mpf_engine_context_destroy(mpf_context_t *context); 75 76 /** 77 * Get external object associated with MPF context. 78 * @param context the context to get object from 79 */ 80 MPF_DECLARE(void*) mpf_engine_context_object_get(const mpf_context_t *context); 81 82 /** 83 * Get task. 84 * @param engine the engine to get task from 85 */ 86 MPF_DECLARE(apt_task_t*) mpf_task_get(const mpf_engine_t *engine); 87 88 /** 89 * Set task msg type to send responses and events with. 90 * @param engine the engine to set task msg type for 91 * @param type the type to set 92 */ 93 MPF_DECLARE(void) mpf_engine_task_msg_type_set(mpf_engine_t *engine, apt_task_msg_type_e type); 94 95 /** 96 * Create task message(if not created) and add MPF termination message to it. 97 * @param engine the engine task message belongs to 98 * @param command_id the MPF command identifier 99 * @param context the context to add termination to 100 * @param termination the termination to add 101 * @param descriptor the termination dependent descriptor 102 * @param task_msg the task message to create and add constructed MPF message to 103 */ 104 MPF_DECLARE(apt_bool_t) mpf_engine_termination_message_add( 105 mpf_engine_t *engine, 106 mpf_command_type_e command_id, 107 mpf_context_t *context, 108 mpf_termination_t *termination, 109 void *descriptor, 110 mpf_task_msg_t **task_msg); 111 112 /** 113 * Create task message(if not created) and add MPF association message to it. 114 * @param engine the engine task message belongs to 115 * @param command_id the MPF command identifier 116 * @param context the context to add association of terminations for 117 * @param termination the termination to associate 118 * @param assoc_termination the termination to associate 119 * @param task_msg the task message to create and add constructed MPF message to 120 */ 121 MPF_DECLARE(apt_bool_t) mpf_engine_assoc_message_add( 122 mpf_engine_t *engine, 123 mpf_command_type_e command_id, 124 mpf_context_t *context, 125 mpf_termination_t *termination, 126 mpf_termination_t *assoc_termination, 127 mpf_task_msg_t **task_msg); 128 129 /** 130 * Create task message(if not created) and add MPF topology message to it. 131 * @param engine the engine task message belongs to 132 * @param command_id the MPF command identifier 133 * @param context the context to modify topology for 134 * @param task_msg the task message to create and add constructed MPF message to 135 */ 136 MPF_DECLARE(apt_bool_t) mpf_engine_topology_message_add( 137 mpf_engine_t *engine, 138 mpf_command_type_e command_id, 139 mpf_context_t *context, 140 mpf_task_msg_t **task_msg); 141 142 /** 143 * Send MPF task message. 144 * @param engine the engine to send task message to 145 * @param task_msg the task message to send 146 */ 147 MPF_DECLARE(apt_bool_t) mpf_engine_message_send(mpf_engine_t *engine, mpf_task_msg_t **task_msg); 148 149 /** 150 * Set scheduler rate. 151 * @param engine the engine to set rate for 152 * @param rate the rate (n times faster than real-time) 153 */ 154 MPF_DECLARE(apt_bool_t) mpf_engine_scheduler_rate_set(mpf_engine_t *engine, unsigned long rate); 155 156 /** 157 * Get the identifier of the engine . 158 * @param engine the engine to get name of 159 */ 160 MPF_DECLARE(const char*) mpf_engine_id_get(const mpf_engine_t *engine); 161 162 163 APT_END_EXTERN_C 164 165 #endif /* MPF_ENGINE_H */ 166