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/opacity.hpp"
11#include "../components/video_codec.hpp"
12#include "../components/video_sample.hpp"
13#include "../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::archetypes {
21 /// **Archetype**: Video stream consisting of raw video chunks.
22 ///
23 /// For logging video containers like mp4, refer to `archetypes::AssetVideo` and `archetypes::VideoFrameReference`.
24 /// To learn more about video support in Rerun, check the [video reference](https://rerun.io/docs/reference/video).
25 ///
26 /// All components except `sample` are typically logged statically once per entity.
27 /// `sample` is then logged repeatedly for each frame on the timeline.
28 ///
29 /// TODO(#10422): `archetypes::VideoFrameReference` does not yet work with `archetypes::VideoStream`.
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 /// Unlike any other data in Rerun, video samples are not allowed to be logged out of order,
47 /// as this may break live video playback.
48 /// I.e. any appended sample should have a timestamp greater than all previously logged samples.
49 ///
50 /// The samples are expected to be encoded using the `codec` field.
51 /// Each video sample must contain enough data for exactly one video frame
52 /// (this restriction may be relaxed in the future for some codecs).
53 ///
54 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
55 /// never log this component as static data as this means that you loose all information of
56 /// previous samples which may be required to decode an image.
57 ///
58 /// See `components::VideoCodec` for codec specific requirements.
59 std::optional<ComponentBatch> sample;
60
61 /// Opacity of the video stream, useful for layering several media.
62 ///
63 /// Defaults to 1.0 (fully opaque).
64 std::optional<ComponentBatch> opacity;
65
66 /// An optional floating point value that specifies the 2D drawing order.
67 ///
68 /// Objects with higher values are drawn on top of those with lower values.
69 /// Defaults to `-15.0`.
70 std::optional<ComponentBatch> draw_order;
71
72 public:
73 /// The name of the archetype as used in `ComponentDescriptor`s.
74 static constexpr const char ArchetypeName[] = "rerun.archetypes.VideoStream";
75
76 /// `ComponentDescriptor` for the `codec` field.
77 static constexpr auto Descriptor_codec = ComponentDescriptor(
78 ArchetypeName, "VideoStream:codec",
80 );
81 /// `ComponentDescriptor` for the `sample` field.
82 static constexpr auto Descriptor_sample = ComponentDescriptor(
83 ArchetypeName, "VideoStream:sample",
85 );
86 /// `ComponentDescriptor` for the `opacity` field.
87 static constexpr auto Descriptor_opacity = ComponentDescriptor(
88 ArchetypeName, "VideoStream:opacity",
90 );
91 /// `ComponentDescriptor` for the `draw_order` field.
93 ArchetypeName, "VideoStream:draw_order",
95 );
96
97 public:
98 VideoStream() = default;
99 VideoStream(VideoStream&& other) = default;
100 VideoStream(const VideoStream& other) = default;
101 VideoStream& operator=(const VideoStream& other) = default;
102 VideoStream& operator=(VideoStream&& other) = default;
103
105 : codec(ComponentBatch::from_loggable(std::move(_codec), Descriptor_codec)
106 .value_or_throw()) {}
107
108 /// Update only some specific fields of a `VideoStream`.
110 return VideoStream();
111 }
112
113 /// Clear all the fields of a `VideoStream`.
115
116 /// The codec used to encode the video chunks.
117 ///
118 /// This property is expected to be constant over time and is ideally logged statically once per stream.
120 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
121 return std::move(*this);
122 }
123
124 /// This method makes it possible to pack multiple `codec` in a single component batch.
125 ///
126 /// This only makes sense when used in conjunction with `columns`. `with_codec` should
127 /// be used when logging a single row's worth of data.
129 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
130 return std::move(*this);
131 }
132
133 /// Video sample data (also known as "video chunk").
134 ///
135 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
136 /// There is currently no way to log differing decoding timestamps, meaning
137 /// that there is no support for B-frames.
138 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
139 ///
140 /// Unlike any other data in Rerun, video samples are not allowed to be logged out of order,
141 /// as this may break live video playback.
142 /// I.e. any appended sample should have a timestamp greater than all previously logged samples.
143 ///
144 /// The samples are expected to be encoded using the `codec` field.
145 /// Each video sample must contain enough data for exactly one video frame
146 /// (this restriction may be relaxed in the future for some codecs).
147 ///
148 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
149 /// never log this component as static data as this means that you loose all information of
150 /// previous samples which may be required to decode an image.
151 ///
152 /// See `components::VideoCodec` for codec specific requirements.
154 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
155 return std::move(*this);
156 }
157
158 /// This method makes it possible to pack multiple `sample` in a single component batch.
159 ///
160 /// This only makes sense when used in conjunction with `columns`. `with_sample` should
161 /// be used when logging a single row's worth of data.
163 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
164 return std::move(*this);
165 }
166
167 /// Opacity of the video stream, useful for layering several media.
168 ///
169 /// Defaults to 1.0 (fully opaque).
171 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
172 return std::move(*this);
173 }
174
175 /// This method makes it possible to pack multiple `opacity` in a single component batch.
176 ///
177 /// This only makes sense when used in conjunction with `columns`. `with_opacity` should
178 /// be used when logging a single row's worth of data.
180 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
181 return std::move(*this);
182 }
183
184 /// An optional floating point value that specifies the 2D drawing order.
185 ///
186 /// Objects with higher values are drawn on top of those with lower values.
187 /// Defaults to `-15.0`.
189 draw_order =
190 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
191 return std::move(*this);
192 }
193
194 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
195 ///
196 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
197 /// be used when logging a single row's worth of data.
199 ) && {
200 draw_order =
201 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
202 return std::move(*this);
203 }
204
205 /// Partitions the component data into multiple sub-batches.
206 ///
207 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
208 /// instead, via `ComponentBatch::partitioned`.
209 ///
210 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
211 ///
212 /// The specified `lengths` must sum to the total length of the component batch.
214
215 /// Partitions the component data into unit-length sub-batches.
216 ///
217 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
218 /// where `n` is automatically guessed.
220 };
221
222} // namespace rerun::archetypes
223
224namespace rerun {
225 /// \private
226 template <typename T>
227 struct AsComponents;
228
229 /// \private
230 template <>
231 struct AsComponents<archetypes::VideoStream> {
232 /// Serialize all set component batches.
233 static Result<Collection<ComponentBatch>> as_batches(
234 const archetypes::VideoStream& archetype
235 );
236 };
237} // 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:33
static VideoStream update_fields()
Update only some specific fields of a VideoStream.
Definition video_stream.hpp:109
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:179
std::optional< ComponentBatch > opacity
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:64
VideoStream with_sample(const rerun::components::VideoSample &_sample) &&
Video sample data (also known as "video chunk").
Definition video_stream.hpp:153
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:188
std::optional< ComponentBatch > sample
Video sample data (also known as "video chunk").
Definition video_stream.hpp:59
std::optional< ComponentBatch > draw_order
An optional floating point value that specifies the 2D drawing order.
Definition video_stream.hpp:70
static constexpr auto Descriptor_sample
ComponentDescriptor for the sample field.
Definition video_stream.hpp:82
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:162
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:128
static constexpr auto Descriptor_codec
ComponentDescriptor for the codec field.
Definition video_stream.hpp:77
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition video_stream.hpp:87
VideoStream with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:170
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:198
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition video_stream.hpp:92
VideoStream with_codec(const rerun::components::VideoCodec &_codec) &&
The codec used to encode the video chunks.
Definition video_stream.hpp:119
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition video_stream.hpp:74
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: 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