Rerun C++ SDK
Loading...
Searching...
No Matches
video_stream.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/video_stream.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/draw_order.hpp"
10#include "../components/video_codec.hpp"
11#include "../components/video_sample.hpp"
12#include "../result.hpp"
13
14#include <cstdint>
15#include <optional>
16#include <utility>
17#include <vector>
18
19namespace rerun::archetypes {
20 /// **Archetype**: Video stream consisting of raw video chunks.
21 ///
22 /// For logging video containers like mp4, refer to `archetypes::AssetVideo` and `archetypes::VideoFrameReference`.
23 /// To learn more about video support in Rerun, check the [video reference](https://rerun.io/docs/reference/video).
24 ///
25 /// All components except `sample` are typically logged statically once per entity.
26 /// `sample` is then logged repeatedly for each frame on the timeline.
27 ///
28 /// TODO(#10422): `archetypes::VideoFrameReference` does not yet work with `archetypes::VideoStream`.
29 ///
30 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
31 ///
32 struct VideoStream {
33 /// The codec used to encode the video chunks.
34 ///
35 /// This property is expected to be constant over time and is ideally logged statically once per stream.
36 std::optional<ComponentBatch> codec;
37
38 /// Video sample data (also known as "video chunk").
39 ///
40 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
41 /// There is currently no way to log differing decoding timestamps, meaning
42 /// that there is no support for B-frames.
43 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
44 ///
45 /// Unlike any other data in Rerun, video samples are not allowed to be logged out of order,
46 /// as this may break live video playback.
47 /// I.e. any appended sample should have a timestamp greater than all previously logged samples.
48 ///
49 /// The samples are expected to be encoded using the `codec` field.
50 /// Each video sample must contain enough data for exactly one video frame
51 /// (this restriction may be relaxed in the future for some codecs).
52 ///
53 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
54 /// never log this component as static data as this means that you loose all information of
55 /// previous samples which may be required to decode an image.
56 ///
57 /// See `components::VideoCodec` for codec specific requirements.
58 std::optional<ComponentBatch> sample;
59
60 /// An optional floating point value that specifies the 2D drawing order.
61 ///
62 /// Objects with higher values are drawn on top of those with lower values.
63 /// Defaults to `-15.0`.
64 std::optional<ComponentBatch> draw_order;
65
66 public:
67 /// The name of the archetype as used in `ComponentDescriptor`s.
68 static constexpr const char ArchetypeName[] = "rerun.archetypes.VideoStream";
69
70 /// `ComponentDescriptor` for the `codec` field.
71 static constexpr auto Descriptor_codec = ComponentDescriptor(
72 ArchetypeName, "VideoStream:codec",
74 );
75 /// `ComponentDescriptor` for the `sample` field.
76 static constexpr auto Descriptor_sample = ComponentDescriptor(
77 ArchetypeName, "VideoStream:sample",
79 );
80 /// `ComponentDescriptor` for the `draw_order` field.
82 ArchetypeName, "VideoStream:draw_order",
84 );
85
86 public:
87 VideoStream() = default;
88 VideoStream(VideoStream&& other) = default;
89 VideoStream(const VideoStream& other) = default;
90 VideoStream& operator=(const VideoStream& other) = default;
91 VideoStream& operator=(VideoStream&& other) = default;
92
94 : codec(ComponentBatch::from_loggable(std::move(_codec), Descriptor_codec)
95 .value_or_throw()) {}
96
97 /// Update only some specific fields of a `VideoStream`.
99 return VideoStream();
100 }
101
102 /// Clear all the fields of a `VideoStream`.
104
105 /// The codec used to encode the video chunks.
106 ///
107 /// This property is expected to be constant over time and is ideally logged statically once per stream.
109 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
110 return std::move(*this);
111 }
112
113 /// This method makes it possible to pack multiple `codec` in a single component batch.
114 ///
115 /// This only makes sense when used in conjunction with `columns`. `with_codec` should
116 /// be used when logging a single row's worth of data.
118 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
119 return std::move(*this);
120 }
121
122 /// Video sample data (also known as "video chunk").
123 ///
124 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
125 /// There is currently no way to log differing decoding timestamps, meaning
126 /// that there is no support for B-frames.
127 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
128 ///
129 /// Unlike any other data in Rerun, video samples are not allowed to be logged out of order,
130 /// as this may break live video playback.
131 /// I.e. any appended sample should have a timestamp greater than all previously logged samples.
132 ///
133 /// The samples are expected to be encoded using the `codec` field.
134 /// Each video sample must contain enough data for exactly one video frame
135 /// (this restriction may be relaxed in the future for some codecs).
136 ///
137 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
138 /// never log this component as static data as this means that you loose all information of
139 /// previous samples which may be required to decode an image.
140 ///
141 /// See `components::VideoCodec` for codec specific requirements.
143 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
144 return std::move(*this);
145 }
146
147 /// This method makes it possible to pack multiple `sample` in a single component batch.
148 ///
149 /// This only makes sense when used in conjunction with `columns`. `with_sample` should
150 /// be used when logging a single row's worth of data.
152 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
153 return std::move(*this);
154 }
155
156 /// An optional floating point value that specifies the 2D drawing order.
157 ///
158 /// Objects with higher values are drawn on top of those with lower values.
159 /// Defaults to `-15.0`.
161 draw_order =
162 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
163 return std::move(*this);
164 }
165
166 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
167 ///
168 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
169 /// be used when logging a single row's worth of data.
171 ) && {
172 draw_order =
173 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
174 return std::move(*this);
175 }
176
177 /// Partitions the component data into multiple sub-batches.
178 ///
179 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
180 /// instead, via `ComponentBatch::partitioned`.
181 ///
182 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
183 ///
184 /// The specified `lengths` must sum to the total length of the component batch.
186
187 /// Partitions the component data into unit-length sub-batches.
188 ///
189 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
190 /// where `n` is automatically guessed.
192 };
193
194} // namespace rerun::archetypes
195
196namespace rerun {
197 /// \private
198 template <typename T>
199 struct AsComponents;
200
201 /// \private
202 template <>
203 struct AsComponents<archetypes::VideoStream> {
204 /// Serialize all set component batches.
205 static Result<Collection<ComponentBatch>> as_batches(
206 const archetypes::VideoStream& archetype
207 );
208 };
209} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
VideoCodec
Component: The codec used to encode video stored in components::VideoSample.
Definition video_codec.hpp:30
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: Video stream consisting of raw video chunks.
Definition video_stream.hpp:32
static VideoStream update_fields()
Update only some specific fields of a VideoStream.
Definition video_stream.hpp:98
VideoStream with_sample(const rerun::components::VideoSample &_sample) &&
Video sample data (also known as "video chunk").
Definition video_stream.hpp:142
VideoStream with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
An optional floating point value that specifies the 2D drawing order.
Definition video_stream.hpp:160
std::optional< ComponentBatch > sample
Video sample data (also known as "video chunk").
Definition video_stream.hpp:58
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition video_stream.hpp:64
static constexpr auto Descriptor_sample
ComponentDescriptor for the sample field.
Definition video_stream.hpp:76
VideoStream with_many_sample(const Collection< rerun::components::VideoSample > &_sample) &&
This method makes it possible to pack multiple sample in a single component batch.
Definition video_stream.hpp:151
static VideoStream clear_fields()
Clear all the fields of a VideoStream.
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
VideoStream with_many_codec(const Collection< rerun::components::VideoCodec > &_codec) &&
This method makes it possible to pack multiple codec in a single component batch.
Definition video_stream.hpp:117
static constexpr auto Descriptor_codec
ComponentDescriptor for the codec field.
Definition video_stream.hpp:71
VideoStream with_many_draw_order(const Collection< rerun::components::DrawOrder > &_draw_order) &&
This method makes it possible to pack multiple draw_order in a single component batch.
Definition video_stream.hpp:170
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition video_stream.hpp:81
VideoStream with_codec(const rerun::components::VideoCodec &_codec) &&
The codec used to encode the video chunks.
Definition video_stream.hpp:108
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition video_stream.hpp:68
std::optional< ComponentBatch > codec
The codec used to encode the video chunks.
Definition video_stream.hpp:36
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Component: Draw order of 2D elements.
Definition draw_order.hpp:19
Component: Video sample data (also known as "video chunk").
Definition video_sample.hpp:21