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