|
35 | 35 | #include "include_internal/ten_runtime/path/result_return_policy.h" |
36 | 36 | #include "include_internal/ten_runtime/schema_store/store.h" |
37 | 37 | #include "include_internal/ten_runtime/ten_env/ten_env.h" |
38 | | -#include "include_internal/ten_utils/log/log.h" |
39 | 38 | #include "ten_runtime/addon/addon.h" |
40 | 39 | #include "ten_runtime/app/app.h" |
41 | 40 | #include "ten_runtime/common/error_code.h" |
@@ -211,128 +210,6 @@ void ten_extension_destroy(ten_extension_t *self) { |
211 | 210 | TEN_FREE(self); |
212 | 211 | } |
213 | 212 |
|
214 | | -static bool ten_extension_check_if_msg_dests_have_msg_names( |
215 | | - ten_extension_t *self, ten_list_t *msg_dests, ten_list_t *msg_names) { |
216 | | - TEN_ASSERT(msg_dests && msg_names, "Invalid argument."); |
217 | | - |
218 | | - ten_list_foreach (msg_dests, iter) { |
219 | | - ten_shared_ptr_t *shared_msg_dest = ten_smart_ptr_listnode_get(iter.node); |
220 | | - ten_msg_dest_info_t *msg_dest = ten_shared_ptr_get_data(shared_msg_dest); |
221 | | - TEN_ASSERT(msg_dest && ten_msg_dest_info_check_integrity(msg_dest), |
222 | | - "Invalid argument."); |
223 | | - |
224 | | - ten_listnode_t *node = ten_list_find_ptr_custom(msg_names, &msg_dest->name, |
225 | | - ten_string_is_equal); |
226 | | - if (node) { |
227 | | - TEN_ASSERT(0, "Extension (%s) has duplicated msg name (%s) in dest info.", |
228 | | - ten_extension_get_name(self, true), |
229 | | - ten_string_get_raw_str(&msg_dest->name)); |
230 | | - return true; |
231 | | - } |
232 | | - } |
233 | | - |
234 | | - return false; |
235 | | -} |
236 | | - |
237 | | -static bool ten_extension_merge_interface_dest_to_msg( |
238 | | - ten_extension_t *self, ten_extension_context_t *extension_context, |
239 | | - ten_list_iterator_t iter, TEN_MSG_TYPE msg_type, ten_list_t *msg_dests) { |
240 | | - TEN_ASSERT( |
241 | | - self && ten_extension_check_integrity(self, true) && extension_context, |
242 | | - "Should not happen."); |
243 | | - |
244 | | - ten_msg_dest_info_t *interface_dest = |
245 | | - ten_shared_ptr_get_data(ten_smart_ptr_listnode_get(iter.node)); |
246 | | - TEN_ASSERT(interface_dest, "Should not happen."); |
247 | | - |
248 | | - ten_string_t *interface_name = &interface_dest->name; |
249 | | - TEN_ASSERT(!ten_string_is_empty(interface_name), "Should not happen."); |
250 | | - |
251 | | - ten_list_t all_msg_names_in_interface_out = TEN_LIST_INIT_VAL; |
252 | | - bool interface_found = ten_schema_store_get_all_msg_names_in_interface_out( |
253 | | - &self->schema_store, msg_type, ten_string_get_raw_str(interface_name), |
254 | | - &all_msg_names_in_interface_out); |
255 | | - if (!interface_found) { |
256 | | - TEN_ASSERT(0, "Extension uses an undefined output interface (%s).", |
257 | | - ten_string_get_raw_str(interface_name)); |
258 | | - return false; |
259 | | - } |
260 | | - |
261 | | - if (ten_list_is_empty(&all_msg_names_in_interface_out)) { |
262 | | - // The interface does not define any message of this type, it's legal. |
263 | | - return true; |
264 | | - } |
265 | | - |
266 | | - if (ten_extension_check_if_msg_dests_have_msg_names( |
267 | | - self, msg_dests, &all_msg_names_in_interface_out)) { |
268 | | - TEN_ASSERT(0, "Should not happen."); |
269 | | - return false; |
270 | | - } |
271 | | - |
272 | | - ten_list_foreach (&all_msg_names_in_interface_out, iter) { |
273 | | - ten_string_t *msg_name = ten_ptr_listnode_get(iter.node); |
274 | | - TEN_ASSERT(msg_name, "Should not happen."); |
275 | | - |
276 | | - ten_msg_dest_info_t *msg_dest = |
277 | | - ten_msg_dest_info_create(ten_string_get_raw_str(msg_name)); |
278 | | - |
279 | | - ten_list_foreach (&interface_dest->dest, iter_dest) { |
280 | | - ten_weak_ptr_t *shared_dest_extension_info = |
281 | | - ten_smart_ptr_listnode_get(iter_dest.node); |
282 | | - ten_list_push_smart_ptr_back(&msg_dest->dest, shared_dest_extension_info); |
283 | | - } |
284 | | - |
285 | | - ten_shared_ptr_t *shared_msg_dest = |
286 | | - ten_shared_ptr_create(msg_dest, ten_msg_dest_info_destroy); |
287 | | - ten_list_push_smart_ptr_back(msg_dests, shared_msg_dest); |
288 | | - ten_shared_ptr_destroy(shared_msg_dest); |
289 | | - } |
290 | | - |
291 | | - ten_list_clear(&all_msg_names_in_interface_out); |
292 | | - |
293 | | - return true; |
294 | | -} |
295 | | - |
296 | | -bool ten_extension_determine_and_merge_all_interface_dest_extension( |
297 | | - ten_extension_t *self) { |
298 | | - TEN_ASSERT(self && ten_extension_check_integrity(self, true), |
299 | | - "Invalid argument."); |
300 | | - TEN_ASSERT(self->state == TEN_EXTENSION_STATE_ON_CONFIGURE_DONE, |
301 | | - "Extension should be on_configure_done."); |
302 | | - |
303 | | - if (!self->extension_info) { |
304 | | - return true; |
305 | | - } |
306 | | - |
307 | | - ten_list_foreach (&self->extension_info->msg_dest_info.interface, iter) { |
308 | | - if (!ten_extension_merge_interface_dest_to_msg( |
309 | | - self, self->extension_context, iter, TEN_MSG_TYPE_CMD, |
310 | | - &self->extension_info->msg_dest_info.cmd)) { |
311 | | - return false; |
312 | | - } |
313 | | - |
314 | | - if (!ten_extension_merge_interface_dest_to_msg( |
315 | | - self, self->extension_context, iter, TEN_MSG_TYPE_DATA, |
316 | | - &self->extension_info->msg_dest_info.data)) { |
317 | | - return false; |
318 | | - } |
319 | | - |
320 | | - if (!ten_extension_merge_interface_dest_to_msg( |
321 | | - self, self->extension_context, iter, TEN_MSG_TYPE_VIDEO_FRAME, |
322 | | - &self->extension_info->msg_dest_info.video_frame)) { |
323 | | - return false; |
324 | | - } |
325 | | - |
326 | | - if (!ten_extension_merge_interface_dest_to_msg( |
327 | | - self, self->extension_context, iter, TEN_MSG_TYPE_AUDIO_FRAME, |
328 | | - &self->extension_info->msg_dest_info.audio_frame)) { |
329 | | - return false; |
330 | | - } |
331 | | - } |
332 | | - |
333 | | - return true; |
334 | | -} |
335 | | - |
336 | 213 | static ten_msg_dest_info_t *ten_extension_get_msg_dests_from_graph_internal( |
337 | 214 | ten_list_t *dest_info_list, ten_shared_ptr_t *msg) { |
338 | 215 | TEN_ASSERT(dest_info_list && msg, "Should not happen."); |
|
0 commit comments