+#include <babeltrace/babeltrace.h>
+#include "viewer-connection.h"
+
+//TODO: this should not be used by plugins. Should copy code into plugin
+//instead.
+#include "babeltrace/object-internal.h"
+#include "babeltrace/list-internal.h"
+#include "../common/metadata/decoder.h"
+
+#define STREAM_NAME_PREFIX "stream-"
+/* Account for u64 max string length. */
+#define U64_STR_MAX_LEN 20
+#define STREAM_NAME_MAX_LEN (sizeof(STREAM_NAME_PREFIX) + U64_STR_MAX_LEN)
+
+struct lttng_live_component;
+struct lttng_live_session;
+
+enum lttng_live_stream_state {
+ LTTNG_LIVE_STREAM_ACTIVE_NO_DATA,
+ LTTNG_LIVE_STREAM_QUIESCENT_NO_DATA,
+ LTTNG_LIVE_STREAM_QUIESCENT,
+ LTTNG_LIVE_STREAM_ACTIVE_DATA,
+ LTTNG_LIVE_STREAM_EOF,
+};
+
+enum live_stream_type {
+ LIVE_STREAM_TYPE_NO_STREAM,
+ LIVE_STREAM_TYPE_STREAM,
+};
+
+struct lttng_live_stream_iterator_generic {
+ enum live_stream_type type;
+};
+
+/* Iterator over a live stream. */
+struct lttng_live_stream_iterator {
+ struct lttng_live_stream_iterator_generic p;
+
+ const struct bt_stream *stream;
+ struct lttng_live_trace *trace;
+ struct bt_private_port *port; /* weak ref. */
+
+ /* Node of stream list within the trace. */
+ struct bt_list_head node;
+
+ /*
+ * Since only a single iterator per viewer connection, we have
+ * only a single notification iterator per stream.
+ */
+ struct bt_notif_iter *notif_iter;
+
+ uint64_t viewer_stream_id;
+
+ uint64_t ctf_stream_class_id;
+ uint64_t base_offset; /* base offset in current index. */
+ uint64_t len; /* len to read in current index. */
+ uint64_t offset; /* offset in current index. */
+
+ int64_t last_returned_inactivity_timestamp;
+ int64_t current_inactivity_timestamp;
+
+ enum lttng_live_stream_state state;
+
+ uint64_t current_packet_end_timestamp;
+ struct bt_notification *packet_end_notif_queue;
+
+ uint8_t *buf;
+ size_t buflen;
+
+ char name[STREAM_NAME_MAX_LEN];
+};
+
+struct lttng_live_no_stream_iterator {
+ struct lttng_live_stream_iterator_generic p;
+
+ struct lttng_live_component *lttng_live;
+ struct bt_private_port *port; /* weak ref. */
+};
+
+struct lttng_live_component_options {
+ bool opt_dummy : 1;
+};
+
+struct lttng_live_metadata {
+ struct lttng_live_trace *trace;
+ uint64_t stream_id;
+ uint8_t uuid[16];
+ bool is_uuid_set;
+ int bo;
+ char *text;
+
+ struct ctf_metadata_decoder *decoder;
+
+ bool closed;
+};
+
+struct lttng_live_trace {
+ struct bt_object obj;
+
+ /* Node of trace list within the session. */
+ struct bt_list_head node;
+
+ /* Back reference to session. */
+ struct lttng_live_session *session;
+
+ uint64_t id; /* ctf trace ID within the session. */