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