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_sdk_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/is_keyframe.hpp"
11#include "../components/opacity.hpp"
12#include "../components/video_codec.hpp"
13#include "../components/video_sample.hpp"
14#include "../result.hpp"
15
16#include <cstdint>
17#include <optional>
18#include <utility>
19#include <vector>
20
21namespace rerun::archetypes {
22 /// **Archetype**: Video stream consisting of raw video chunks.
23 ///
24 /// For logging video containers like mp4, refer to `archetypes::AssetVideo` and `archetypes::VideoFrameReference`.
25 /// To learn more about video support in Rerun, check the [video reference](https://rerun.io/docs/reference/video).
26 ///
27 /// All components except `sample` are typically logged statically once per entity.
28 /// `sample` is then logged repeatedly for each frame on the timeline.
29 ///
30 /// TODO(#10422): `archetypes::VideoFrameReference` does not yet work with `archetypes::VideoStream`.
31 ///
32 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
33 ///
34 struct VideoStream {
35 /// The codec used to encode the video chunks.
36 ///
37 /// This property is expected to be constant over time and is ideally logged statically once per stream.
38 std::optional<ComponentBatch> codec;
39
40 /// Video sample data (also known as "video chunk").
41 ///
42 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
43 /// There is currently no way to log differing decoding timestamps, meaning
44 /// that there is no support for B-frames.
45 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
46 ///
47 /// Rerun chunks containing frames (i.e. bundles of sample data) may arrive out of order,
48 /// but may cause the video playback in the Viewer to reset.
49 /// It is recommended to have all chunks for a video stream to be ordered temporally order.
50 ///
51 /// Logging separate videos on the same entity is allowed iff they share the exact same
52 /// codec parameters & resolution.
53 ///
54 /// The samples are expected to be encoded using the `codec` field.
55 /// Each video sample must contain enough data for exactly one video frame
56 /// (this restriction may be relaxed in the future for some codecs).
57 ///
58 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
59 /// never log this component as static data as this means that you loose all information of
60 /// previous samples which may be required to decode an image.
61 ///
62 /// See `components::VideoCodec` for codec specific requirements.
63 std::optional<ComponentBatch> sample;
64
65 /// Whether the corresponding `components::VideoSample` contains a keyframe.
66 ///
67 /// A keyframe (also known as a sync sample or IDR) is a frame from which a decoder can
68 /// start decoding the stream with no prior decoder state. See `components::IsKeyframe`
69 /// and `components::VideoCodec` for the codec-specific definition.
70 ///
71 /// This field is optional. It does not change how the stream itself is decoded: it is
72 /// metadata that travels with the sample and can be inspected when querying the data
73 /// back, for example to locate sync points or build a frame index.
74 std::optional<ComponentBatch> is_keyframe;
75
76 /// Opacity of the video stream, useful for layering several media.
77 ///
78 /// Defaults to 1.0 (fully opaque).
79 std::optional<ComponentBatch> opacity;
80
81 /// An optional floating point value that specifies the 2D drawing order.
82 ///
83 /// Objects with higher values are drawn on top of those with lower values.
84 /// Defaults to `-15.0`.
85 std::optional<ComponentBatch> draw_order;
86
87 public:
88 /// The name of the archetype as used in `ComponentDescriptor`s.
89 static constexpr const char ArchetypeName[] = "rerun.archetypes.VideoStream";
90
91 /// `ComponentDescriptor` for the `codec` field.
92 static constexpr auto Descriptor_codec = ComponentDescriptor(
93 ArchetypeName, "VideoStream:codec",
95 );
96 /// `ComponentDescriptor` for the `sample` field.
97 static constexpr auto Descriptor_sample = ComponentDescriptor(
98 ArchetypeName, "VideoStream:sample",
100 );
101 /// `ComponentDescriptor` for the `is_keyframe` field.
103 ArchetypeName, "VideoStream:is_keyframe",
105 );
106 /// `ComponentDescriptor` for the `opacity` field.
108 ArchetypeName, "VideoStream:opacity",
110 );
111 /// `ComponentDescriptor` for the `draw_order` field.
113 ArchetypeName, "VideoStream:draw_order",
115 );
116
117 public:
118 VideoStream() = default;
119 VideoStream(VideoStream&& other) = default;
120 VideoStream(const VideoStream& other) = default;
121 VideoStream& operator=(const VideoStream& other) = default;
122 VideoStream& operator=(VideoStream&& other) = default;
123
125 : codec(ComponentBatch::from_loggable(std::move(_codec), Descriptor_codec)
126 .value_or_throw()) {}
127
128 /// Update only some specific fields of a `VideoStream`.
130 return VideoStream();
131 }
132
133 /// Clear all the fields of a `VideoStream`.
135
136 /// The codec used to encode the video chunks.
137 ///
138 /// This property is expected to be constant over time and is ideally logged statically once per stream.
140 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
141 return std::move(*this);
142 }
143
144 /// This method makes it possible to pack multiple `codec` in a single component batch.
145 ///
146 /// This only makes sense when used in conjunction with `columns`. `with_codec` should
147 /// be used when logging a single row's worth of data.
149 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
150 return std::move(*this);
151 }
152
153 /// Video sample data (also known as "video chunk").
154 ///
155 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
156 /// There is currently no way to log differing decoding timestamps, meaning
157 /// that there is no support for B-frames.
158 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
159 ///
160 /// Rerun chunks containing frames (i.e. bundles of sample data) may arrive out of order,
161 /// but may cause the video playback in the Viewer to reset.
162 /// It is recommended to have all chunks for a video stream to be ordered temporally order.
163 ///
164 /// Logging separate videos on the same entity is allowed iff they share the exact same
165 /// codec parameters & resolution.
166 ///
167 /// The samples are expected to be encoded using the `codec` field.
168 /// Each video sample must contain enough data for exactly one video frame
169 /// (this restriction may be relaxed in the future for some codecs).
170 ///
171 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
172 /// never log this component as static data as this means that you loose all information of
173 /// previous samples which may be required to decode an image.
174 ///
175 /// See `components::VideoCodec` for codec specific requirements.
177 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
178 return std::move(*this);
179 }
180
181 /// This method makes it possible to pack multiple `sample` in a single component batch.
182 ///
183 /// This only makes sense when used in conjunction with `columns`. `with_sample` should
184 /// be used when logging a single row's worth of data.
186 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
187 return std::move(*this);
188 }
189
190 /// Whether the corresponding `components::VideoSample` contains a keyframe.
191 ///
192 /// A keyframe (also known as a sync sample or IDR) is a frame from which a decoder can
193 /// start decoding the stream with no prior decoder state. See `components::IsKeyframe`
194 /// and `components::VideoCodec` for the codec-specific definition.
195 ///
196 /// This field is optional. It does not change how the stream itself is decoded: it is
197 /// metadata that travels with the sample and can be inspected when querying the data
198 /// back, for example to locate sync points or build a frame index.
201 .value_or_throw();
202 return std::move(*this);
203 }
204
205 /// This method makes it possible to pack multiple `is_keyframe` in a single component batch.
206 ///
207 /// This only makes sense when used in conjunction with `columns`. `with_is_keyframe` should
208 /// be used when logging a single row's worth of data.
211 ) && {
213 .value_or_throw();
214 return std::move(*this);
215 }
216
217 /// Opacity of the video stream, useful for layering several media.
218 ///
219 /// Defaults to 1.0 (fully opaque).
221 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
222 return std::move(*this);
223 }
224
225 /// This method makes it possible to pack multiple `opacity` in a single component batch.
226 ///
227 /// This only makes sense when used in conjunction with `columns`. `with_opacity` should
228 /// be used when logging a single row's worth of data.
230 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
231 return std::move(*this);
232 }
233
234 /// An optional floating point value that specifies the 2D drawing order.
235 ///
236 /// Objects with higher values are drawn on top of those with lower values.
237 /// Defaults to `-15.0`.
239 draw_order =
240 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
241 return std::move(*this);
242 }
243
244 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
245 ///
246 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
247 /// be used when logging a single row's worth of data.
249 ) && {
250 draw_order =
251 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
252 return std::move(*this);
253 }
254
255 /// Partitions the component data into multiple sub-batches.
256 ///
257 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
258 /// instead, via `ComponentBatch::partitioned`.
259 ///
260 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
261 ///
262 /// The specified `lengths` must sum to the total length of the component batch.
264
265 /// Partitions the component data into unit-length sub-batches.
266 ///
267 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
268 /// where `n` is automatically guessed.
270 };
271
272} // namespace rerun::archetypes
273
274namespace rerun {
275 /// \private
276 template <typename T>
277 struct AsComponents;
278
279 /// \private
280 template <>
281 struct AsComponents<archetypes::VideoStream> {
282 /// Serialize all set component batches.
283 static Result<Collection<ComponentBatch>> as_batches(
284 const archetypes::VideoStream& archetype
285 );
286 };
287} // 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:87
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:34
static VideoStream update_fields()
Update only some specific fields of a VideoStream.
Definition video_stream.hpp:129
VideoStream with_many_is_keyframe(const Collection< rerun::components::IsKeyframe > &_is_keyframe) &&
This method makes it possible to pack multiple is_keyframe in a single component batch.
Definition video_stream.hpp:209
VideoStream with_many_opacity(const Collection< rerun::components::Opacity > &_opacity) &&
This method makes it possible to pack multiple opacity in a single component batch.
Definition video_stream.hpp:229
std::optional< ComponentBatch > opacity
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:79
static constexpr auto Descriptor_is_keyframe
ComponentDescriptor for the is_keyframe field.
Definition video_stream.hpp:102
VideoStream with_sample(const rerun::components::VideoSample &_sample) &&
Video sample data (also known as "video chunk").
Definition video_stream.hpp:176
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:238
std::optional< ComponentBatch > sample
Video sample data (also known as "video chunk").
Definition video_stream.hpp:63
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition video_stream.hpp:85
std::optional< ComponentBatch > is_keyframe
Whether the corresponding components::VideoSample contains a keyframe.
Definition video_stream.hpp:74
static constexpr auto Descriptor_sample
ComponentDescriptor for the sample field.
Definition video_stream.hpp:97
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:185
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:148
static constexpr auto Descriptor_codec
ComponentDescriptor for the codec field.
Definition video_stream.hpp:92
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition video_stream.hpp:107
VideoStream with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:220
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:248
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition video_stream.hpp:112
VideoStream with_is_keyframe(const rerun::components::IsKeyframe &_is_keyframe) &&
Whether the corresponding components::VideoSample contains a keyframe.
Definition video_stream.hpp:199
VideoStream with_codec(const rerun::components::VideoCodec &_codec) &&
The codec used to encode the video chunks.
Definition video_stream.hpp:139
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition video_stream.hpp:89
std::optional< ComponentBatch > codec
The codec used to encode the video chunks.
Definition video_stream.hpp:38
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: Whether a components::VideoSample contains a keyframe (also known as a sync sample or IDR)...
Definition is_keyframe.hpp:20
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:17
Component: Video sample data (also known as "video chunk").
Definition video_sample.hpp:21