Skip to content

Commit f0c64b7

Browse files
authored
refactor: remove interface-related code and definitions across multiple files (#1048)
1 parent fd506dc commit f0c64b7

File tree

40 files changed

+12
-1869
lines changed

40 files changed

+12
-1869
lines changed

core/include_internal/ten_runtime/common/constant_str.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#define TEN_STR_CMD "cmd"
1313
#define TEN_STR_DATA "data"
1414
#define TEN_STR_VIDEO_FRAME "video_frame"
15-
#define TEN_STR_INTERFACE "interface"
1615
#define TEN_STR_AUDIO_FRAME "audio_frame"
1716

1817
// Message relevant fields.
@@ -45,8 +44,6 @@
4544
#define TEN_STR_DATA_OUT "data_out"
4645
#define TEN_STR_VIDEO_FRAME_IN "video_frame_in"
4746
#define TEN_STR_VIDEO_FRAME_OUT "video_frame_out"
48-
#define TEN_STR_INTERFACE_IN "interface_in"
49-
#define TEN_STR_INTERFACE_OUT "interface_out"
5047
#define TEN_STR_AUDIO_FRAME_IN "audio_frame_in"
5148
#define TEN_STR_AUDIO_FRAME_OUT "audio_frame_out"
5249

core/include_internal/ten_runtime/extension/extension.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ struct ten_extension_t {
228228
void *user_data;
229229
};
230230

231-
TEN_RUNTIME_PRIVATE_API bool
232-
ten_extension_determine_and_merge_all_interface_dest_extension(
233-
ten_extension_t *self);
234-
235231
TEN_RUNTIME_PRIVATE_API void ten_extension_on_init(ten_extension_t *self);
236232

237233
TEN_RUNTIME_PRIVATE_API void ten_extension_on_start(ten_extension_t *self);

core/include_internal/ten_runtime/extension/msg_dest_info/all_msg_type_dest_info.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ typedef struct ten_all_msg_type_dest_info_t {
1717
ten_list_t data; // ten_shared_ptr_t of ten_msg_dest_info_t
1818
ten_list_t video_frame; // ten_shared_ptr_t of ten_msg_dest_info_t
1919
ten_list_t audio_frame; // ten_shared_ptr_t of ten_msg_dest_info_t
20-
ten_list_t interface; // ten_shared_ptr_t of ten_msg_dest_info_t
2120
} ten_all_msg_type_dest_info_t;
2221

2322
TEN_RUNTIME_PRIVATE_API void ten_all_msg_type_dest_info_init(

core/include_internal/ten_runtime/schema_store/interface.h

Lines changed: 0 additions & 60 deletions
This file was deleted.

core/include_internal/ten_runtime/schema_store/store.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ typedef struct ten_schema_store_t {
5050
ten_hashtable_t video_frame_out;
5151
ten_hashtable_t audio_frame_in;
5252
ten_hashtable_t audio_frame_out;
53-
54-
// Key is the interface name, the type of value is `ten_interface_schema_t`.
55-
// Since this is a schema store, the interface_in/out here must be the
56-
// interface definitions after expanding the `$ref`.
57-
ten_hashtable_t interface_in;
58-
ten_hashtable_t interface_out;
5953
} ten_schema_store_t;
6054

6155
TEN_RUNTIME_PRIVATE_API bool ten_schema_store_check_integrity(
@@ -66,13 +60,6 @@ TEN_RUNTIME_API void ten_schema_store_init(ten_schema_store_t *self);
6660
TEN_RUNTIME_API bool ten_schema_store_set_schema_definition(
6761
ten_schema_store_t *self, ten_value_t *schema_def, ten_error_t *err);
6862

69-
/**
70-
* @param schema_def The definition defined in the `api` section.
71-
*/
72-
TEN_RUNTIME_API bool ten_schema_store_set_interface_schema_definition(
73-
ten_schema_store_t *self, ten_value_t *schema_def, const char *base_dir,
74-
ten_error_t *err);
75-
7663
TEN_RUNTIME_API void ten_schema_store_deinit(ten_schema_store_t *self);
7764

7865
/**
@@ -104,14 +91,3 @@ TEN_RUNTIME_API bool ten_schema_store_adjust_properties(
10491
TEN_RUNTIME_API ten_msg_schema_t *ten_schema_store_get_msg_schema(
10592
ten_schema_store_t *self, TEN_MSG_TYPE msg_type, const char *msg_name,
10693
bool is_msg_out);
107-
108-
/**
109-
* @brief Retrieve all msg names belonging to the interface.
110-
*
111-
* @return Whether the interface is found.
112-
*/
113-
TEN_RUNTIME_PRIVATE_API bool
114-
ten_schema_store_get_all_msg_names_in_interface_out(ten_schema_store_t *self,
115-
TEN_MSG_TYPE msg_type,
116-
const char *interface_name,
117-
ten_list_t *msg_names);

core/include_internal/ten_rust/ten_rust.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ TEN_RUST_PRIVATE_API bool ten_cipher_encrypt_inplace(Cipher *cipher_ptr,
2929
uint8_t *data,
3030
uintptr_t data_len);
3131

32-
TEN_RUST_PRIVATE_API bool ten_interface_schema_resolve_definition(
33-
const char *content, const char *base_dir, const char **out_content,
34-
const char **out_err_msg);
35-
3632
TEN_RUST_PRIVATE_API char *ten_remove_json_comments(
3733
const char *json_with_comments);
3834

core/src/ten_runtime/extension/extension.c

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "include_internal/ten_runtime/path/result_return_policy.h"
3636
#include "include_internal/ten_runtime/schema_store/store.h"
3737
#include "include_internal/ten_runtime/ten_env/ten_env.h"
38-
#include "include_internal/ten_utils/log/log.h"
3938
#include "ten_runtime/addon/addon.h"
4039
#include "ten_runtime/app/app.h"
4140
#include "ten_runtime/common/error_code.h"
@@ -211,128 +210,6 @@ void ten_extension_destroy(ten_extension_t *self) {
211210
TEN_FREE(self);
212211
}
213212

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-
336213
static ten_msg_dest_info_t *ten_extension_get_msg_dests_from_graph_internal(
337214
ten_list_t *dest_info_list, ten_shared_ptr_t *msg) {
338215
TEN_ASSERT(dest_info_list && msg, "Should not happen.");

core/src/ten_runtime/extension/extension_info/extension_info.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,6 @@ static ten_shared_ptr_t *ten_extension_info_clone_dest(
352352
return NULL;
353353
}
354354

355-
if (!copy_msg_dest(&exist_extension_info->msg_dest_info.interface,
356-
&self->msg_dest_info.interface, extensions_info, err)) {
357-
return NULL;
358-
}
359-
360355
return exist_dest;
361356
}
362357

core/src/ten_runtime/extension/extension_info/json.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ int ten_extension_info_connections_to_json(ten_extension_info_t *self,
9494
ten_list_is_empty(&self->msg_dest_info.data) &&
9595
ten_list_is_empty(&self->msg_dest_info.video_frame) &&
9696
ten_list_is_empty(&self->msg_dest_info.audio_frame) &&
97-
ten_list_is_empty(&self->msg_dest_info.interface) &&
9897
ten_list_is_empty(&self->msg_conversion_contexts)) {
9998
return 0;
10099
}
@@ -160,17 +159,5 @@ int ten_extension_info_connections_to_json(ten_extension_info_t *self,
160159
}
161160
}
162161

163-
if (!ten_list_is_empty(&self->msg_dest_info.interface)) {
164-
ten_json_t interface_dest_json = TEN_JSON_INIT_VAL(json->ctx, false);
165-
ten_json_object_peek_or_create_array(json, TEN_STR_INTERFACE,
166-
&interface_dest_json);
167-
168-
bool success = pack_msg_dest(self, &self->msg_dest_info.interface,
169-
&interface_dest_json, err);
170-
if (!success) {
171-
return -1;
172-
}
173-
}
174-
175162
return 1;
176163
}

core/src/ten_runtime/extension/extension_info/value.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,6 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value(
195195
}
196196
}
197197

198-
// Parse 'interface'.
199-
ten_value_t *interface_value =
200-
ten_value_object_peek(value, TEN_STR_INTERFACE);
201-
if (interface_value) {
202-
if (!parse_msg_dest_value(interface_value, extensions_info,
203-
&extension_info->msg_dest_info.interface,
204-
extension_info, err)) {
205-
return NULL;
206-
}
207-
}
208-
209198
return self;
210199
}
211200

@@ -388,7 +377,6 @@ ten_value_t *ten_extension_info_connection_to_value(ten_extension_info_t *self,
388377
ten_list_is_empty(&self->msg_dest_info.data) &&
389378
ten_list_is_empty(&self->msg_dest_info.video_frame) &&
390379
ten_list_is_empty(&self->msg_dest_info.audio_frame) &&
391-
ten_list_is_empty(&self->msg_dest_info.interface) &&
392380
ten_list_is_empty(&self->msg_conversion_contexts)) {
393381
return NULL;
394382
}
@@ -413,9 +401,6 @@ ten_value_t *ten_extension_info_connection_to_value(ten_extension_info_t *self,
413401
// ],
414402
// "audio_frame": [
415403
// ...
416-
// ],
417-
// "interface": [
418-
// ...
419404
// ]
420405
// }
421406
ten_list_t kv_list = TEN_LIST_INIT_VAL;
@@ -503,19 +488,6 @@ ten_value_t *ten_extension_info_connection_to_value(ten_extension_info_t *self,
503488
(ten_ptr_listnode_destroy_func_t)ten_value_kv_destroy);
504489
}
505490

506-
// Parse 'interface'
507-
if (!ten_list_is_empty(&self->msg_dest_info.interface)) {
508-
ten_value_t *interface_dest_value =
509-
pack_msg_dest(self, &self->msg_dest_info.interface, err);
510-
if (!interface_dest_value) {
511-
return NULL;
512-
}
513-
514-
ten_list_push_ptr_back(
515-
&kv_list, ten_value_kv_create(TEN_STR_INTERFACE, interface_dest_value),
516-
(ten_ptr_listnode_destroy_func_t)ten_value_kv_destroy);
517-
}
518-
519491
ten_value_t *result = ten_value_create_object_with_move(&kv_list);
520492
TEN_ASSERT(result, "Should not happen.");
521493

0 commit comments

Comments
 (0)