2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
3 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #define BT_LOG_TAG "MSG-ITER"
25 #include <babeltrace/lib-logging-internal.h>
27 #include <babeltrace/compiler-internal.h>
28 #include <babeltrace/trace-ir/field.h>
29 #include <babeltrace/trace-ir/event-const.h>
30 #include <babeltrace/trace-ir/event-internal.h>
31 #include <babeltrace/trace-ir/packet-const.h>
32 #include <babeltrace/trace-ir/packet-internal.h>
33 #include <babeltrace/trace-ir/stream-internal.h>
34 #include <babeltrace/graph/connection-const.h>
35 #include <babeltrace/graph/connection-internal.h>
36 #include <babeltrace/graph/component-const.h>
37 #include <babeltrace/graph/component-internal.h>
38 #include <babeltrace/graph/component-source-internal.h>
39 #include <babeltrace/graph/component-class-internal.h>
40 #include <babeltrace/graph/component-class-sink-colander-internal.h>
41 #include <babeltrace/graph/component-sink-const.h>
42 #include <babeltrace/graph/component-sink-internal.h>
43 #include <babeltrace/graph/message-const.h>
44 #include <babeltrace/graph/message-iterator-const.h>
45 #include <babeltrace/graph/message-iterator-internal.h>
46 #include <babeltrace/graph/self-component-port-input-message-iterator.h>
47 #include <babeltrace/graph/port-output-message-iterator.h>
48 #include <babeltrace/graph/message-internal.h>
49 #include <babeltrace/graph/message-event-const.h>
50 #include <babeltrace/graph/message-event-internal.h>
51 #include <babeltrace/graph/message-packet-const.h>
52 #include <babeltrace/graph/message-packet-internal.h>
53 #include <babeltrace/graph/message-stream-const.h>
54 #include <babeltrace/graph/message-stream-internal.h>
55 #include <babeltrace/graph/message-inactivity-internal.h>
56 #include <babeltrace/graph/port-const.h>
57 #include <babeltrace/graph/graph.h>
58 #include <babeltrace/graph/graph-const.h>
59 #include <babeltrace/graph/graph-internal.h>
60 #include <babeltrace/types.h>
61 #include <babeltrace/assert-internal.h>
62 #include <babeltrace/assert-pre-internal.h>
68 * TODO: Use graph's state (number of active iterators, etc.) and
69 * possibly system specifications to make a better guess than this.
71 #define MSG_BATCH_SIZE 15
73 #define BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(_iter) \
74 BT_ASSERT_PRE((_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE || \
75 (_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED || \
76 (_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN || \
77 (_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, \
78 "Message iterator is in the wrong state: %!+i", _iter)
81 void _set_self_comp_port_input_msg_iterator_state(
82 struct bt_self_component_port_input_message_iterator
*iterator
,
83 enum bt_self_component_port_input_message_iterator_state state
)
86 BT_LIB_LOGD("Updating message iterator's state: new-state=%s",
87 bt_self_component_port_input_message_iterator_state_string(state
));
88 iterator
->state
= state
;
92 # define set_self_comp_port_input_msg_iterator_state _set_self_comp_port_input_msg_iterator_state
94 # define set_self_comp_port_input_msg_iterator_state(_a, _b)
98 void destroy_base_message_iterator(struct bt_object
*obj
)
100 struct bt_message_iterator
*iterator
= (void *) obj
;
104 if (iterator
->msgs
) {
105 g_ptr_array_free(iterator
->msgs
, TRUE
);
106 iterator
->msgs
= NULL
;
113 void bt_self_component_port_input_message_iterator_destroy(struct bt_object
*obj
)
115 struct bt_self_component_port_input_message_iterator
*iterator
;
120 * The message iterator's reference count is 0 if we're
121 * here. Increment it to avoid a double-destroy (possibly
122 * infinitely recursive). This could happen for example if the
123 * message iterator's finalization function does
124 * bt_object_get_ref() (or anything that causes
125 * bt_object_get_ref() to be called) on itself (ref. count goes
126 * from 0 to 1), and then bt_object_put_ref(): the reference
127 * count would go from 1 to 0 again and this function would be
131 iterator
= (void *) obj
;
132 BT_LIB_LOGD("Destroying self component input port message iterator object: "
134 bt_self_component_port_input_message_iterator_try_finalize(iterator
);
136 if (iterator
->connection
) {
138 * Remove ourself from the originating connection so
139 * that it does not try to finalize a dangling pointer
142 bt_connection_remove_iterator(iterator
->connection
, iterator
);
143 iterator
->connection
= NULL
;
146 if (iterator
->auto_seek_msgs
) {
149 /* Put any remaining message in the auto-seek array */
150 for (i
= 0; i
< iterator
->auto_seek_msgs
->len
; i
++) {
151 if (iterator
->auto_seek_msgs
->pdata
[i
]) {
152 bt_object_put_no_null_check(
153 iterator
->auto_seek_msgs
->pdata
[i
]);
157 g_ptr_array_free(iterator
->auto_seek_msgs
, TRUE
);
158 iterator
->auto_seek_msgs
= NULL
;
161 destroy_base_message_iterator(obj
);
165 void bt_self_component_port_input_message_iterator_try_finalize(
166 struct bt_self_component_port_input_message_iterator
*iterator
)
168 typedef void (*method_t
)(void *);
170 struct bt_component_class
*comp_class
= NULL
;
171 method_t method
= NULL
;
175 switch (iterator
->state
) {
176 case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED
:
177 /* Skip user finalization if user initialization failed */
178 BT_LIB_LOGD("Not finalizing non-initialized message iterator: "
181 case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED
:
182 /* Already finalized */
183 BT_LIB_LOGD("Not finalizing message iterator: already finalized: "
186 case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING
:
187 /* Already finalized */
188 BT_LIB_LOGF("Message iterator is already being finalized: "
195 BT_LIB_LOGD("Finalizing message iterator: %!+i", iterator
);
196 set_self_comp_port_input_msg_iterator_state(iterator
,
197 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING
);
198 BT_ASSERT(iterator
->upstream_component
);
199 comp_class
= iterator
->upstream_component
->class;
201 /* Call user-defined destroy method */
202 switch (comp_class
->type
) {
203 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
205 struct bt_component_class_source
*src_comp_cls
=
208 method
= (method_t
) src_comp_cls
->methods
.msg_iter_finalize
;
211 case BT_COMPONENT_CLASS_TYPE_FILTER
:
213 struct bt_component_class_filter
*flt_comp_cls
=
216 method
= (method_t
) flt_comp_cls
->methods
.msg_iter_finalize
;
225 BT_LIB_LOGD("Calling user's finalization method: %!+i",
230 iterator
->upstream_component
= NULL
;
231 iterator
->upstream_port
= NULL
;
232 set_self_comp_port_input_msg_iterator_state(iterator
,
233 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED
);
234 BT_LIB_LOGD("Finalized message iterator: %!+i", iterator
);
241 void bt_self_component_port_input_message_iterator_set_connection(
242 struct bt_self_component_port_input_message_iterator
*iterator
,
243 struct bt_connection
*connection
)
246 iterator
->connection
= connection
;
247 BT_LIB_LOGV("Set message iterator's connection: "
248 "%![iter-]+i, %![conn-]+x", iterator
, connection
);
252 int init_message_iterator(struct bt_message_iterator
*iterator
,
253 enum bt_message_iterator_type type
,
254 bt_object_release_func destroy
)
258 bt_object_init_shared(&iterator
->base
, destroy
);
259 iterator
->type
= type
;
260 iterator
->msgs
= g_ptr_array_new();
261 if (!iterator
->msgs
) {
262 BT_LOGE_STR("Failed to allocate a GPtrArray.");
267 g_ptr_array_set_size(iterator
->msgs
, MSG_BATCH_SIZE
);
274 bt_bool
can_seek_ns_from_origin_true(
275 struct bt_self_component_port_input_message_iterator
*iterator
,
276 int64_t ns_from_origin
)
282 bt_bool
can_seek_beginning_true(
283 struct bt_self_component_port_input_message_iterator
*iterator
)
289 struct bt_self_component_port_input_message_iterator
*
290 bt_self_component_port_input_message_iterator_create_initial(
291 struct bt_component
*upstream_comp
,
292 struct bt_port
*upstream_port
)
295 struct bt_self_component_port_input_message_iterator
*iterator
= NULL
;
297 BT_ASSERT(upstream_comp
);
298 BT_ASSERT(upstream_port
);
299 BT_ASSERT(bt_port_is_connected(upstream_port
));
300 BT_LIB_LOGD("Creating initial message iterator on self component input port: "
301 "%![up-comp-]+c, %![up-port-]+p", upstream_comp
, upstream_port
);
302 BT_ASSERT(bt_component_get_class_type(upstream_comp
) ==
303 BT_COMPONENT_CLASS_TYPE_SOURCE
||
304 bt_component_get_class_type(upstream_comp
) ==
305 BT_COMPONENT_CLASS_TYPE_FILTER
);
307 struct bt_self_component_port_input_message_iterator
, 1);
309 BT_LOGE_STR("Failed to allocate one self component input port "
310 "message iterator.");
314 ret
= init_message_iterator((void *) iterator
,
315 BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT
,
316 bt_self_component_port_input_message_iterator_destroy
);
318 /* init_message_iterator() logs errors */
319 BT_OBJECT_PUT_REF_AND_RESET(iterator
);
323 iterator
->auto_seek_msgs
= g_ptr_array_new();
324 if (!iterator
->auto_seek_msgs
) {
325 BT_LOGE_STR("Failed to allocate a GPtrArray.");
330 g_ptr_array_set_size(iterator
->auto_seek_msgs
, MSG_BATCH_SIZE
);
331 iterator
->upstream_component
= upstream_comp
;
332 iterator
->upstream_port
= upstream_port
;
333 iterator
->connection
= iterator
->upstream_port
->connection
;
334 iterator
->graph
= bt_component_borrow_graph(upstream_comp
);
335 set_self_comp_port_input_msg_iterator_state(iterator
,
336 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED
);
338 switch (iterator
->upstream_component
->class->type
) {
339 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
341 struct bt_component_class_source
*src_comp_cls
=
342 (void *) iterator
->upstream_component
->class;
344 iterator
->methods
.next
=
345 (bt_self_component_port_input_message_iterator_next_method
)
346 src_comp_cls
->methods
.msg_iter_next
;
347 iterator
->methods
.seek_ns_from_origin
=
348 (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method
)
349 src_comp_cls
->methods
.msg_iter_seek_ns_from_origin
;
350 iterator
->methods
.seek_beginning
=
351 (bt_self_component_port_input_message_iterator_seek_beginning_method
)
352 src_comp_cls
->methods
.msg_iter_seek_beginning
;
353 iterator
->methods
.can_seek_ns_from_origin
=
354 (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method
)
355 src_comp_cls
->methods
.msg_iter_can_seek_ns_from_origin
;
356 iterator
->methods
.can_seek_beginning
=
357 (bt_self_component_port_input_message_iterator_can_seek_beginning_method
)
358 src_comp_cls
->methods
.msg_iter_can_seek_beginning
;
361 case BT_COMPONENT_CLASS_TYPE_FILTER
:
363 struct bt_component_class_filter
*flt_comp_cls
=
364 (void *) iterator
->upstream_component
->class;
366 iterator
->methods
.next
=
367 (bt_self_component_port_input_message_iterator_next_method
)
368 flt_comp_cls
->methods
.msg_iter_next
;
369 iterator
->methods
.seek_ns_from_origin
=
370 (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method
)
371 flt_comp_cls
->methods
.msg_iter_seek_ns_from_origin
;
372 iterator
->methods
.seek_beginning
=
373 (bt_self_component_port_input_message_iterator_seek_beginning_method
)
374 flt_comp_cls
->methods
.msg_iter_seek_beginning
;
375 iterator
->methods
.can_seek_ns_from_origin
=
376 (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method
)
377 flt_comp_cls
->methods
.msg_iter_can_seek_ns_from_origin
;
378 iterator
->methods
.can_seek_beginning
=
379 (bt_self_component_port_input_message_iterator_can_seek_beginning_method
)
380 flt_comp_cls
->methods
.msg_iter_can_seek_beginning
;
387 if (iterator
->methods
.seek_ns_from_origin
&&
388 !iterator
->methods
.can_seek_ns_from_origin
) {
389 iterator
->methods
.can_seek_ns_from_origin
=
390 (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method
)
391 can_seek_ns_from_origin_true
;
394 if (iterator
->methods
.seek_beginning
&&
395 !iterator
->methods
.can_seek_beginning
) {
396 iterator
->methods
.can_seek_beginning
=
397 (bt_self_component_port_input_message_iterator_seek_beginning_method
)
398 can_seek_beginning_true
;
401 BT_LIB_LOGD("Created initial message iterator on self component input port: "
402 "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i",
403 upstream_port
, upstream_comp
, iterator
);
409 struct bt_self_component_port_input_message_iterator
*
410 bt_self_component_port_input_message_iterator_create(
411 struct bt_self_component_port_input
*self_port
)
413 typedef enum bt_self_message_iterator_status (*init_method_t
)(
414 void *, void *, void *);
416 init_method_t init_method
= NULL
;
417 struct bt_self_component_port_input_message_iterator
*iterator
=
419 struct bt_port
*port
= (void *) self_port
;
420 struct bt_port
*upstream_port
;
421 struct bt_component
*comp
;
422 struct bt_component
*upstream_comp
;
423 struct bt_component_class
*upstream_comp_cls
;
425 BT_ASSERT_PRE_NON_NULL(port
, "Port");
426 comp
= bt_port_borrow_component_inline(port
);
427 BT_ASSERT_PRE(bt_port_is_connected(port
),
428 "Port is not connected: %![port-]+p", port
);
429 BT_ASSERT_PRE(comp
, "Port is not part of a component: %![port-]+p",
431 BT_ASSERT_PRE(!bt_component_graph_is_canceled(comp
),
432 "Port's component's graph is canceled: "
433 "%![port-]+p, %![comp-]+c", port
, comp
);
434 BT_ASSERT(port
->connection
);
435 upstream_port
= port
->connection
->upstream_port
;
436 BT_ASSERT(upstream_port
);
437 upstream_comp
= bt_port_borrow_component_inline(upstream_port
);
438 BT_ASSERT(upstream_comp
);
439 upstream_comp_cls
= upstream_comp
->class;
440 BT_ASSERT(upstream_comp
->class->type
==
441 BT_COMPONENT_CLASS_TYPE_SOURCE
||
442 upstream_comp
->class->type
==
443 BT_COMPONENT_CLASS_TYPE_FILTER
);
444 iterator
= bt_self_component_port_input_message_iterator_create_initial(
445 upstream_comp
, upstream_port
);
447 BT_LOGW_STR("Cannot create self component input port "
448 "message iterator.");
452 switch (upstream_comp_cls
->type
) {
453 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
455 struct bt_component_class_source
*src_comp_cls
=
456 (void *) upstream_comp_cls
;
459 (init_method_t
) src_comp_cls
->methods
.msg_iter_init
;
462 case BT_COMPONENT_CLASS_TYPE_FILTER
:
464 struct bt_component_class_filter
*flt_comp_cls
=
465 (void *) upstream_comp_cls
;
468 (init_method_t
) flt_comp_cls
->methods
.msg_iter_init
;
479 BT_LIB_LOGD("Calling user's initialization method: %!+i", iterator
);
480 iter_status
= init_method(iterator
, upstream_comp
,
482 BT_LOGD("User method returned: status=%s",
483 bt_message_iterator_status_string(iter_status
));
484 if (iter_status
!= BT_MESSAGE_ITERATOR_STATUS_OK
) {
485 BT_LOGW_STR("Initialization method failed.");
486 BT_OBJECT_PUT_REF_AND_RESET(iterator
);
491 set_self_comp_port_input_msg_iterator_state(iterator
,
492 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
);
493 g_ptr_array_add(port
->connection
->iterators
, iterator
);
494 BT_LIB_LOGD("Created message iterator on self component input port: "
495 "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i",
496 upstream_port
, upstream_comp
, iterator
);
502 void *bt_self_message_iterator_get_data(
503 const struct bt_self_message_iterator
*self_iterator
)
505 struct bt_self_component_port_input_message_iterator
*iterator
=
506 (void *) self_iterator
;
508 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
509 return iterator
->user_data
;
512 void bt_self_message_iterator_set_data(
513 struct bt_self_message_iterator
*self_iterator
, void *data
)
515 struct bt_self_component_port_input_message_iterator
*iterator
=
516 (void *) self_iterator
;
518 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
519 iterator
->user_data
= data
;
520 BT_LIB_LOGV("Set message iterator's user data: "
521 "%!+i, user-data-addr=%p", iterator
, data
);
526 void bt_message_borrow_packet_stream(const struct bt_message
*msg
,
527 const struct bt_stream
**stream
,
528 const struct bt_packet
**packet
)
533 case BT_MESSAGE_TYPE_EVENT
:
534 *packet
= bt_event_borrow_packet_const(
535 bt_message_event_borrow_event_const(msg
));
536 *stream
= bt_packet_borrow_stream_const(*packet
);
538 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
539 *stream
= bt_message_stream_beginning_borrow_stream_const(msg
);
541 case BT_MESSAGE_TYPE_STREAM_END
:
542 *stream
= bt_message_stream_end_borrow_stream_const(msg
);
544 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
545 *packet
= bt_message_packet_beginning_borrow_packet_const(msg
);
546 *stream
= bt_packet_borrow_stream_const(*packet
);
548 case BT_MESSAGE_TYPE_PACKET_END
:
549 *packet
= bt_message_packet_end_borrow_packet_const(msg
);
550 *stream
= bt_packet_borrow_stream_const(*packet
);
557 enum bt_message_iterator_status
558 bt_self_component_port_input_message_iterator_next(
559 struct bt_self_component_port_input_message_iterator
*iterator
,
560 bt_message_array_const
*msgs
, uint64_t *user_count
)
562 int status
= BT_MESSAGE_ITERATOR_STATUS_OK
;
564 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
565 BT_ASSERT_PRE_NON_NULL(msgs
, "Message array (output)");
566 BT_ASSERT_PRE_NON_NULL(user_count
, "Message count (output)");
567 BT_ASSERT_PRE(iterator
->state
==
568 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
,
569 "Message iterator's \"next\" called, but "
570 "message iterator is in the wrong state: %!+i", iterator
);
571 BT_ASSERT(iterator
->upstream_component
);
572 BT_ASSERT(iterator
->upstream_component
->class);
573 BT_ASSERT_PRE(bt_component_borrow_graph(iterator
->upstream_component
)->is_configured
,
574 "Graph is not configured: %!+g",
575 bt_component_borrow_graph(iterator
->upstream_component
));
576 BT_LIB_LOGD("Getting next self component input port "
577 "message iterator's messages: %!+i", iterator
);
580 * Call the user's "next" method to get the next messages
583 BT_ASSERT(iterator
->methods
.next
);
584 BT_LOGD_STR("Calling user's \"next\" method.");
585 status
= iterator
->methods
.next(iterator
,
586 (void *) iterator
->base
.msgs
->pdata
, MSG_BATCH_SIZE
,
588 BT_LOGD("User method returned: status=%s",
589 bt_message_iterator_status_string(status
));
591 BT_LOGW_STR("User method failed.");
597 * There is no way that this iterator could have been finalized
598 * during its "next" method, as the only way to do this is to
599 * put the last iterator's reference, and this can only be done
600 * by its downstream owner.
602 * For the same reason, there is no way that this iterator could
603 * have seeked (cannot seek a self message iterator).
605 BT_ASSERT(iterator
->state
==
606 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
);
610 case BT_MESSAGE_ITERATOR_STATUS_OK
:
611 BT_ASSERT_PRE(*user_count
<= MSG_BATCH_SIZE
,
612 "Invalid returned message count: greater than "
613 "batch size: count=%" PRIu64
", batch-size=%u",
614 *user_count
, MSG_BATCH_SIZE
);
615 *msgs
= (void *) iterator
->base
.msgs
->pdata
;
617 case BT_MESSAGE_ITERATOR_STATUS_AGAIN
:
619 case BT_MESSAGE_ITERATOR_STATUS_END
:
620 set_self_comp_port_input_msg_iterator_state(iterator
,
621 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED
);
624 /* Unknown non-error status */
632 enum bt_message_iterator_status
bt_port_output_message_iterator_next(
633 struct bt_port_output_message_iterator
*iterator
,
634 bt_message_array_const
*msgs_to_user
,
635 uint64_t *count_to_user
)
637 enum bt_message_iterator_status status
;
638 enum bt_graph_status graph_status
;
640 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
641 BT_ASSERT_PRE_NON_NULL(msgs_to_user
, "Message array (output)");
642 BT_ASSERT_PRE_NON_NULL(count_to_user
, "Message count (output)");
643 BT_LIB_LOGD("Getting next output port message iterator's messages: "
647 * As soon as the user calls this function, we mark the graph as
648 * being definitely configured.
650 bt_graph_set_is_configured(iterator
->graph
, true);
652 graph_status
= bt_graph_consume_sink_no_check(iterator
->graph
,
654 switch (graph_status
) {
655 case BT_GRAPH_STATUS_CANCELED
:
656 case BT_GRAPH_STATUS_AGAIN
:
657 case BT_GRAPH_STATUS_END
:
658 case BT_GRAPH_STATUS_NOMEM
:
659 status
= (int) graph_status
;
661 case BT_GRAPH_STATUS_OK
:
662 status
= BT_MESSAGE_ITERATOR_STATUS_OK
;
665 * On success, the colander sink moves the messages
666 * to this iterator's array and sets this iterator's
667 * message count: move them to the user.
669 *msgs_to_user
= (void *) iterator
->base
.msgs
->pdata
;
670 *count_to_user
= iterator
->count
;
674 status
= BT_MESSAGE_ITERATOR_STATUS_ERROR
;
680 struct bt_component
*
681 bt_self_component_port_input_message_iterator_borrow_component(
682 struct bt_self_component_port_input_message_iterator
*iterator
)
684 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
685 return iterator
->upstream_component
;
688 const struct bt_component
*
689 bt_self_component_port_input_message_iterator_borrow_component_const(
690 const struct bt_self_component_port_input_message_iterator
*iterator
)
692 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
693 return iterator
->upstream_component
;
696 struct bt_self_component
*bt_self_message_iterator_borrow_component(
697 struct bt_self_message_iterator
*self_iterator
)
699 struct bt_self_component_port_input_message_iterator
*iterator
=
700 (void *) self_iterator
;
702 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
703 return (void *) iterator
->upstream_component
;
706 struct bt_self_port_output
*bt_self_message_iterator_borrow_port(
707 struct bt_self_message_iterator
*self_iterator
)
709 struct bt_self_component_port_input_message_iterator
*iterator
=
710 (void *) self_iterator
;
712 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
713 return (void *) iterator
->upstream_port
;
717 void bt_port_output_message_iterator_destroy(struct bt_object
*obj
)
719 struct bt_port_output_message_iterator
*iterator
= (void *) obj
;
721 BT_LIB_LOGD("Destroying output port message iterator object: %!+i",
723 BT_LOGD_STR("Putting graph.");
724 BT_OBJECT_PUT_REF_AND_RESET(iterator
->graph
);
725 BT_LOGD_STR("Putting colander sink component.");
726 BT_OBJECT_PUT_REF_AND_RESET(iterator
->colander
);
727 destroy_base_message_iterator(obj
);
730 struct bt_port_output_message_iterator
*
731 bt_port_output_message_iterator_create(struct bt_graph
*graph
,
732 const struct bt_port_output
*output_port
)
734 struct bt_port_output_message_iterator
*iterator
= NULL
;
735 struct bt_component_class_sink
*colander_comp_cls
= NULL
;
736 struct bt_component
*output_port_comp
= NULL
;
737 struct bt_component_sink
*colander_comp
;
738 enum bt_graph_status graph_status
;
739 struct bt_port_input
*colander_in_port
= NULL
;
740 struct bt_component_class_sink_colander_data colander_data
;
743 BT_ASSERT_PRE_NON_NULL(graph
, "Graph");
744 BT_ASSERT_PRE_NON_NULL(output_port
, "Output port");
745 output_port_comp
= bt_port_borrow_component_inline(
746 (const void *) output_port
);
747 BT_ASSERT_PRE(output_port_comp
,
748 "Output port has no component: %!+p", output_port
);
749 BT_ASSERT_PRE(bt_component_borrow_graph(output_port_comp
) ==
751 "Output port is not part of graph: %![graph-]+g, %![port-]+p",
754 /* Create message iterator */
755 BT_LIB_LOGD("Creating message iterator on output port: "
756 "%![port-]+p, %![comp-]+c", output_port
, output_port_comp
);
757 iterator
= g_new0(struct bt_port_output_message_iterator
, 1);
759 BT_LOGE_STR("Failed to allocate one output port message iterator.");
763 ret
= init_message_iterator((void *) iterator
,
764 BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT
,
765 bt_port_output_message_iterator_destroy
);
767 /* init_message_iterator() logs errors */
768 BT_OBJECT_PUT_REF_AND_RESET(iterator
);
772 /* Create colander component */
773 colander_comp_cls
= bt_component_class_sink_colander_get();
774 if (!colander_comp_cls
) {
775 BT_LOGW("Cannot get colander sink component class.");
779 iterator
->graph
= graph
;
780 bt_object_get_no_null_check(iterator
->graph
);
781 colander_data
.msgs
= (void *) iterator
->base
.msgs
->pdata
;
782 colander_data
.count_addr
= &iterator
->count
;
784 /* Hope that nobody uses this very unique name */
786 bt_graph_add_sink_component_with_init_method_data(
787 (void *) graph
, colander_comp_cls
,
788 "colander-36ac3409-b1a8-4d60-ab1f-4fdf341a8fb1",
789 NULL
, &colander_data
, (void *) &iterator
->colander
);
790 if (graph_status
!= BT_GRAPH_STATUS_OK
) {
791 BT_LIB_LOGW("Cannot add colander sink component to graph: "
792 "%1[graph-]+g, status=%s", graph
,
793 bt_graph_status_string(graph_status
));
798 * Connect provided output port to the colander component's
802 (void *) bt_component_sink_borrow_input_port_by_index_const(
803 (void *) iterator
->colander
, 0);
804 BT_ASSERT(colander_in_port
);
805 graph_status
= bt_graph_connect_ports(graph
,
806 output_port
, colander_in_port
, NULL
);
807 if (graph_status
!= BT_GRAPH_STATUS_OK
) {
808 BT_LIB_LOGW("Cannot add colander sink component to graph: "
809 "%![graph-]+g, %![comp-]+c, status=%s", graph
,
811 bt_graph_status_string(graph_status
));
816 * At this point everything went fine. Make the graph
817 * nonconsumable forever so that only this message iterator
818 * can consume (thanks to bt_graph_consume_sink_no_check()).
819 * This avoids leaking the message created by the colander
820 * sink and moved to the message iterator's message
823 bt_graph_set_can_consume(iterator
->graph
, false);
827 if (iterator
&& iterator
->graph
&& iterator
->colander
) {
830 /* Remove created colander component from graph if any */
831 colander_comp
= iterator
->colander
;
832 BT_OBJECT_PUT_REF_AND_RESET(iterator
->colander
);
835 * At this point the colander component's reference
836 * count is 0 because iterator->colander was the only
837 * owner. We also know that it is not connected because
838 * this is the last operation before this function
841 * Since we honor the preconditions here,
842 * bt_graph_remove_unconnected_component() always
845 ret
= bt_graph_remove_unconnected_component(iterator
->graph
,
846 (void *) colander_comp
);
850 BT_OBJECT_PUT_REF_AND_RESET(iterator
);
853 bt_object_put_ref(colander_comp_cls
);
854 return (void *) iterator
;
857 bt_bool
bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
858 struct bt_self_component_port_input_message_iterator
*iterator
,
859 int64_t ns_from_origin
)
861 bt_bool can
= BT_FALSE
;
863 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
864 BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator
);
865 BT_ASSERT_PRE(bt_component_borrow_graph(iterator
->upstream_component
)->is_configured
,
866 "Graph is not configured: %!+g",
867 bt_component_borrow_graph(iterator
->upstream_component
));
869 if (iterator
->methods
.can_seek_ns_from_origin
) {
870 can
= iterator
->methods
.can_seek_ns_from_origin(iterator
,
876 * Automatic seeking fall back: if we can seek to the beginning,
877 * then we can automatically seek to any message.
879 if (iterator
->methods
.can_seek_beginning
) {
880 can
= iterator
->methods
.can_seek_beginning(iterator
);
887 bt_bool
bt_self_component_port_input_message_iterator_can_seek_beginning(
888 struct bt_self_component_port_input_message_iterator
*iterator
)
890 bt_bool can
= BT_FALSE
;
892 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
893 BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator
);
894 BT_ASSERT_PRE(bt_component_borrow_graph(iterator
->upstream_component
)->is_configured
,
895 "Graph is not configured: %!+g",
896 bt_component_borrow_graph(iterator
->upstream_component
));
898 if (iterator
->methods
.can_seek_beginning
) {
899 can
= iterator
->methods
.can_seek_beginning(iterator
);
906 void _set_iterator_state_after_seeking(
907 struct bt_self_component_port_input_message_iterator
*iterator
,
908 enum bt_message_iterator_status status
)
910 enum bt_self_component_port_input_message_iterator_state new_state
= 0;
912 /* Set iterator's state depending on seeking status */
914 case BT_MESSAGE_ITERATOR_STATUS_OK
:
915 new_state
= BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
;
917 case BT_MESSAGE_ITERATOR_STATUS_AGAIN
:
918 new_state
= BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN
;
920 case BT_MESSAGE_ITERATOR_STATUS_ERROR
:
921 case BT_MESSAGE_ITERATOR_STATUS_NOMEM
:
922 new_state
= BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR
;
924 case BT_MESSAGE_ITERATOR_STATUS_END
:
925 new_state
= BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED
;
931 set_self_comp_port_input_msg_iterator_state(iterator
, new_state
);
935 # define set_iterator_state_after_seeking _set_iterator_state_after_seeking
937 # define set_iterator_state_after_seeking(_iter, _status)
940 enum bt_message_iterator_status
941 bt_self_component_port_input_message_iterator_seek_beginning(
942 struct bt_self_component_port_input_message_iterator
*iterator
)
946 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
947 BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator
);
948 BT_ASSERT_PRE(bt_component_borrow_graph(iterator
->upstream_component
)->is_configured
,
949 "Graph is not configured: %!+g",
950 bt_component_borrow_graph(iterator
->upstream_component
));
952 bt_self_component_port_input_message_iterator_can_seek_beginning(
954 "Message iterator cannot seek beginning: %!+i", iterator
);
955 BT_LIB_LOGD("Calling user's \"seek beginning\" method: %!+i", iterator
);
956 set_self_comp_port_input_msg_iterator_state(iterator
,
957 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING
);
958 status
= iterator
->methods
.seek_beginning(iterator
);
959 BT_LOGD("User method returned: status=%s",
960 bt_message_iterator_status_string(status
));
961 BT_ASSERT_PRE(status
== BT_MESSAGE_ITERATOR_STATUS_OK
||
962 status
== BT_MESSAGE_ITERATOR_STATUS_ERROR
||
963 status
== BT_MESSAGE_ITERATOR_STATUS_NOMEM
||
964 status
== BT_MESSAGE_ITERATOR_STATUS_AGAIN
,
965 "Unexpected status: %![iter-]+i, status=%s",
966 iterator
, bt_self_message_iterator_status_string(status
));
967 set_iterator_state_after_seeking(iterator
, status
);
972 int get_message_ns_from_origin(const struct bt_message
*msg
,
973 int64_t *ns_from_origin
, bool *ignore
)
975 const struct bt_clock_snapshot
*clk_snapshot
= NULL
;
979 case BT_MESSAGE_TYPE_EVENT
:
981 const struct bt_message_event
*event_msg
=
984 clk_snapshot
= event_msg
->event
->default_cs
;
985 BT_ASSERT_PRE(clk_snapshot
,
986 "Event has no default clock snapshot: %!+e",
990 case BT_MESSAGE_TYPE_INACTIVITY
:
992 const struct bt_message_inactivity
*inactivity_msg
=
995 BT_ASSERT(inactivity_msg
->default_cs
);
996 clk_snapshot
= inactivity_msg
->default_cs
;
999 case BT_MESSAGE_TYPE_STREAM_BEGINNING
:
1000 case BT_MESSAGE_TYPE_STREAM_END
:
1003 case BT_MESSAGE_TYPE_PACKET_BEGINNING
:
1005 const struct bt_message_packet_beginning
*pkt_msg
=
1008 clk_snapshot
= pkt_msg
->packet
->default_beginning_cs
;
1011 case BT_MESSAGE_TYPE_PACKET_END
:
1013 const struct bt_message_packet_end
*pkt_msg
=
1016 clk_snapshot
= pkt_msg
->packet
->default_end_cs
;
1023 if (!clk_snapshot
) {
1028 ret
= bt_clock_snapshot_get_ns_from_origin(clk_snapshot
,
1036 enum bt_message_iterator_status
find_message_ge_ns_from_origin(
1037 struct bt_self_component_port_input_message_iterator
*iterator
,
1038 int64_t ns_from_origin
)
1041 enum bt_self_component_port_input_message_iterator_state init_state
=
1043 const struct bt_message
*messages
[MSG_BATCH_SIZE
];
1044 uint64_t user_count
= 0;
1047 BT_ASSERT(iterator
);
1048 memset(&messages
[0], 0, sizeof(messages
[0]) * MSG_BATCH_SIZE
);
1051 * Make this iterator temporarily active (not seeking) to call
1052 * the "next" method.
1054 set_self_comp_port_input_msg_iterator_state(iterator
,
1055 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
);
1057 BT_ASSERT(iterator
->methods
.next
);
1061 * Call the user's "next" method to get the next
1062 * messages and status.
1064 BT_LOGD_STR("Calling user's \"next\" method.");
1065 status
= iterator
->methods
.next(iterator
,
1066 &messages
[0], MSG_BATCH_SIZE
, &user_count
);
1067 BT_LOGD("User method returned: status=%s",
1068 bt_message_iterator_status_string(status
));
1072 * The user's "next" method must not do any action which
1073 * would change the iterator's state.
1075 BT_ASSERT(iterator
->state
==
1076 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE
);
1080 case BT_MESSAGE_ITERATOR_STATUS_OK
:
1081 BT_ASSERT_PRE(user_count
<= MSG_BATCH_SIZE
,
1082 "Invalid returned message count: greater than "
1083 "batch size: count=%" PRIu64
", batch-size=%u",
1084 user_count
, MSG_BATCH_SIZE
);
1086 case BT_MESSAGE_ITERATOR_STATUS_AGAIN
:
1087 case BT_MESSAGE_ITERATOR_STATUS_ERROR
:
1088 case BT_MESSAGE_ITERATOR_STATUS_NOMEM
:
1089 case BT_MESSAGE_ITERATOR_STATUS_END
:
1096 * Find first message which has a default clock snapshot
1097 * that is greater than or equal to the requested value.
1099 * For event and inactivity messages, compare with the
1100 * default clock snapshot.
1102 * For packet beginning messages, compare with the
1103 * default beginning clock snapshot, if any.
1105 * For packet end messages, compare with the default end
1106 * clock snapshot, if any.
1108 * For stream beginning, stream end, ignore.
1110 for (i
= 0; i
< user_count
; i
++) {
1111 const struct bt_message
*msg
= messages
[i
];
1112 int64_t msg_ns_from_origin
;
1113 bool ignore
= false;
1117 ret
= get_message_ns_from_origin(msg
, &msg_ns_from_origin
,
1120 status
= BT_MESSAGE_ITERATOR_STATUS_ERROR
;
1125 /* Skip message without a clock snapshot */
1129 if (msg_ns_from_origin
>= ns_from_origin
) {
1131 * We found it: move this message and
1132 * the following ones to the iterator's
1133 * auto-seek message array.
1137 for (j
= i
; j
< user_count
; j
++) {
1138 iterator
->auto_seek_msgs
->pdata
[j
- i
] =
1139 (void *) messages
[j
];
1143 iterator
->auto_seek_msg_count
= user_count
- i
;
1147 bt_object_put_no_null_check(msg
);
1153 for (i
= 0; i
< user_count
; i
++) {
1155 bt_object_put_no_null_check(messages
[i
]);
1159 set_self_comp_port_input_msg_iterator_state(iterator
, init_state
);
1164 enum bt_self_message_iterator_status
post_auto_seek_next(
1165 struct bt_self_component_port_input_message_iterator
*iterator
,
1166 bt_message_array_const msgs
, uint64_t capacity
,
1169 BT_ASSERT(iterator
->auto_seek_msg_count
<= capacity
);
1170 BT_ASSERT(iterator
->auto_seek_msg_count
> 0);
1173 * Move auto-seek messages to the output array (which is this
1174 * iterator's base message array.
1176 memcpy(&msgs
[0], &iterator
->auto_seek_msgs
->pdata
[0],
1177 sizeof(msgs
[0]) * iterator
->auto_seek_msg_count
);
1178 memset(&iterator
->auto_seek_msgs
->pdata
[0], 0,
1179 sizeof(iterator
->auto_seek_msgs
->pdata
[0]) *
1180 iterator
->auto_seek_msg_count
);
1181 *count
= iterator
->auto_seek_msg_count
;
1183 /* Restore real user's "next" method */
1184 switch (iterator
->upstream_component
->class->type
) {
1185 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
1187 struct bt_component_class_source
*src_comp_cls
=
1188 (void *) iterator
->upstream_component
->class;
1190 iterator
->methods
.next
=
1191 (bt_self_component_port_input_message_iterator_next_method
)
1192 src_comp_cls
->methods
.msg_iter_next
;
1195 case BT_COMPONENT_CLASS_TYPE_FILTER
:
1197 struct bt_component_class_filter
*flt_comp_cls
=
1198 (void *) iterator
->upstream_component
->class;
1200 iterator
->methods
.next
=
1201 (bt_self_component_port_input_message_iterator_next_method
)
1202 flt_comp_cls
->methods
.msg_iter_next
;
1209 return BT_SELF_MESSAGE_ITERATOR_STATUS_OK
;
1212 enum bt_message_iterator_status
1213 bt_self_component_port_input_message_iterator_seek_ns_from_origin(
1214 struct bt_self_component_port_input_message_iterator
*iterator
,
1215 int64_t ns_from_origin
)
1219 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
1220 BT_ASSERT_PRE_ITER_HAS_STATE_TO_SEEK(iterator
);
1221 BT_ASSERT_PRE(bt_component_borrow_graph(iterator
->upstream_component
)->is_configured
,
1222 "Graph is not configured: %!+g",
1223 bt_component_borrow_graph(iterator
->upstream_component
));
1225 bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
1226 iterator
, ns_from_origin
),
1227 "Message iterator cannot seek nanoseconds from origin: %!+i, "
1228 "ns-from-origin=%" PRId64
, iterator
, ns_from_origin
);
1229 set_self_comp_port_input_msg_iterator_state(iterator
,
1230 BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING
);
1232 if (iterator
->methods
.seek_ns_from_origin
) {
1233 BT_LIB_LOGD("Calling user's \"seek nanoseconds from origin\" method: "
1234 "%![iter-]+i, ns=%" PRId64
, iterator
, ns_from_origin
);
1235 status
= iterator
->methods
.seek_ns_from_origin(iterator
,
1237 BT_LOGD("User method returned: status=%s",
1238 bt_message_iterator_status_string(status
));
1239 BT_ASSERT_PRE(status
== BT_MESSAGE_ITERATOR_STATUS_OK
||
1240 status
== BT_MESSAGE_ITERATOR_STATUS_ERROR
||
1241 status
== BT_MESSAGE_ITERATOR_STATUS_NOMEM
||
1242 status
== BT_MESSAGE_ITERATOR_STATUS_AGAIN
,
1243 "Unexpected status: %![iter-]+i, status=%s",
1245 bt_self_message_iterator_status_string(status
));
1247 /* Start automatic seeking: seek beginning first */
1248 BT_ASSERT(iterator
->methods
.can_seek_beginning(iterator
));
1249 BT_ASSERT(iterator
->methods
.seek_beginning
);
1250 BT_LIB_LOGD("Calling user's \"seek beginning\" method: %!+i",
1252 status
= iterator
->methods
.seek_beginning(iterator
);
1253 BT_LOGD("User method returned: status=%s",
1254 bt_message_iterator_status_string(status
));
1255 BT_ASSERT_PRE(status
== BT_MESSAGE_ITERATOR_STATUS_OK
||
1256 status
== BT_MESSAGE_ITERATOR_STATUS_ERROR
||
1257 status
== BT_MESSAGE_ITERATOR_STATUS_NOMEM
||
1258 status
== BT_MESSAGE_ITERATOR_STATUS_AGAIN
,
1259 "Unexpected status: %![iter-]+i, status=%s",
1261 bt_self_message_iterator_status_string(status
));
1263 case BT_MESSAGE_ITERATOR_STATUS_OK
:
1265 case BT_MESSAGE_ITERATOR_STATUS_ERROR
:
1266 case BT_MESSAGE_ITERATOR_STATUS_NOMEM
:
1267 case BT_MESSAGE_ITERATOR_STATUS_AGAIN
:
1274 * Find the first message which has a default clock
1275 * snapshot greater than or equal to the requested
1276 * nanoseconds from origin, and move the received
1277 * messages from this point in the batch to this
1278 * iterator's auto-seek message array.
1280 status
= find_message_ge_ns_from_origin(iterator
,
1283 case BT_MESSAGE_ITERATOR_STATUS_OK
:
1285 * Replace the user's "next" method with a
1286 * custom, temporary "next" method which returns
1287 * the messages in the iterator's message array.
1289 iterator
->methods
.next
=
1290 (bt_self_component_port_input_message_iterator_next_method
)
1291 post_auto_seek_next
;
1293 case BT_MESSAGE_ITERATOR_STATUS_ERROR
:
1294 case BT_MESSAGE_ITERATOR_STATUS_NOMEM
:
1295 case BT_MESSAGE_ITERATOR_STATUS_AGAIN
:
1297 case BT_MESSAGE_ITERATOR_STATUS_END
:
1299 * The iterator reached the end: just return
1300 * `BT_MESSAGE_ITERATOR_STATUS_OK` here, as if
1301 * the seeking operation occured: the next
1302 * "next" method will return
1303 * `BT_MESSAGE_ITERATOR_STATUS_END` itself.
1312 set_iterator_state_after_seeking(iterator
, status
);
1314 if (status
== BT_MESSAGE_ITERATOR_STATUS_END
) {
1315 status
= BT_MESSAGE_ITERATOR_STATUS_OK
;
1322 bt_self_component_port_input_message_iterator
*
1323 borrow_output_port_message_iterator_upstream_iterator(
1324 struct bt_port_output_message_iterator
*iterator
)
1326 struct bt_component_class_sink_colander_priv_data
*colander_data
;
1328 BT_ASSERT(iterator
);
1329 colander_data
= (void *) iterator
->colander
->parent
.user_data
;
1330 BT_ASSERT(colander_data
);
1331 BT_ASSERT(colander_data
->msg_iter
);
1332 return colander_data
->msg_iter
;
1335 bt_bool
bt_port_output_message_iterator_can_seek_ns_from_origin(
1336 struct bt_port_output_message_iterator
*iterator
,
1337 int64_t ns_from_origin
)
1339 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
1340 return bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
1341 borrow_output_port_message_iterator_upstream_iterator(
1342 iterator
), ns_from_origin
);
1345 bt_bool
bt_port_output_message_iterator_can_seek_beginning(
1346 struct bt_port_output_message_iterator
*iterator
)
1348 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
1349 return bt_self_component_port_input_message_iterator_can_seek_beginning(
1350 borrow_output_port_message_iterator_upstream_iterator(
1354 enum bt_message_iterator_status
bt_port_output_message_iterator_seek_ns_from_origin(
1355 struct bt_port_output_message_iterator
*iterator
,
1356 int64_t ns_from_origin
)
1358 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
1359 return bt_self_component_port_input_message_iterator_seek_ns_from_origin(
1360 borrow_output_port_message_iterator_upstream_iterator(iterator
),
1364 enum bt_message_iterator_status
bt_port_output_message_iterator_seek_beginning(
1365 struct bt_port_output_message_iterator
*iterator
)
1367 BT_ASSERT_PRE_NON_NULL(iterator
, "Message iterator");
1368 return bt_self_component_port_input_message_iterator_seek_beginning(
1369 borrow_output_port_message_iterator_upstream_iterator(
1373 void bt_port_output_message_iterator_get_ref(
1374 const struct bt_port_output_message_iterator
*iterator
)
1376 bt_object_get_ref(iterator
);
1379 void bt_port_output_message_iterator_put_ref(
1380 const struct bt_port_output_message_iterator
*iterator
)
1382 bt_object_put_ref(iterator
);
1385 void bt_self_component_port_input_message_iterator_get_ref(
1386 const struct bt_self_component_port_input_message_iterator
*iterator
)
1388 bt_object_get_ref(iterator
);
1391 void bt_self_component_port_input_message_iterator_put_ref(
1392 const struct bt_self_component_port_input_message_iterator
*iterator
)
1394 bt_object_put_ref(iterator
);