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 /// 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 /// Opacity of the video stream, useful for layering several media.
65 ///
66 /// Defaults to 1.0 (fully opaque).
67 std::optional<ComponentBatch> opacity;
68
69 /// An optional floating point value that specifies the 2D drawing order.
70 ///
71 /// Objects with higher values are drawn on top of those with lower values.
72 /// Defaults to `-15.0`.
73 std::optional<ComponentBatch> draw_order;
74
75 public:
76 /// The name of the archetype as used in `ComponentDescriptor`s.
77 static constexpr const char ArchetypeName[] = "rerun.archetypes.VideoStream";
78
79 /// `ComponentDescriptor` for the `codec` field.
80 static constexpr auto Descriptor_codec = ComponentDescriptor(
81 ArchetypeName, "VideoStream:codec",
83 );
84 /// `ComponentDescriptor` for the `sample` field.
85 static constexpr auto Descriptor_sample = ComponentDescriptor(
86 ArchetypeName, "VideoStream:sample",
88 );
89 /// `ComponentDescriptor` for the `opacity` field.
90 static constexpr auto Descriptor_opacity = ComponentDescriptor(
91 ArchetypeName, "VideoStream:opacity",
93 );
94 /// `ComponentDescriptor` for the `draw_order` field.
96 ArchetypeName, "VideoStream:draw_order",
98 );
99
100 public:
101 VideoStream() = default;
102 VideoStream(VideoStream&& other) = default;
103 VideoStream(const VideoStream& other) = default;
104 VideoStream& operator=(const VideoStream& other) = default;
105 VideoStream& operator=(VideoStream&& other) = default;
106
108 : codec(ComponentBatch::from_loggable(std::move(_codec), Descriptor_codec)
109 .value_or_throw()) {}
110
111 /// Update only some specific fields of a `VideoStream`.
113 return VideoStream();
114 }
115
116 /// Clear all the fields of a `VideoStream`.
118
119 /// The codec used to encode the video chunks.
120 ///
121 /// This property is expected to be constant over time and is ideally logged statically once per stream.
123 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
124 return std::move(*this);
125 }
126
127 /// This method makes it possible to pack multiple `codec` in a single component batch.
128 ///
129 /// This only makes sense when used in conjunction with `columns`. `with_codec` should
130 /// be used when logging a single row's worth of data.
132 codec = ComponentBatch::from_loggable(_codec, Descriptor_codec).value_or_throw();
133 return std::move(*this);
134 }
135
136 /// Video sample data (also known as "video chunk").
137 ///
138 /// The current timestamp is used as presentation timestamp (PTS) for all data in this sample.
139 /// There is currently no way to log differing decoding timestamps, meaning
140 /// that there is no support for B-frames.
141 /// See <https://github.com/rerun-io/rerun/issues/10090> for more details.
142 ///
143 /// Rerun chunks containing frames (i.e. bundles of sample data) may arrive out of order,
144 /// but may cause the video playback in the Viewer to reset.
145 /// It is recommended to have all chunks for a video stream to be ordered temporally order.
146 ///
147 /// Logging separate videos on the same entity is allowed iff they share the exact same
148 /// codec parameters & resolution.
149 ///
150 /// The samples are expected to be encoded using the `codec` field.
151 /// Each video sample must contain enough data for exactly one video frame
152 /// (this restriction may be relaxed in the future for some codecs).
153 ///
154 /// Unless your stream consists entirely of key-frames (in which case you should consider `archetypes::EncodedImage`)
155 /// never log this component as static data as this means that you loose all information of
156 /// previous samples which may be required to decode an image.
157 ///
158 /// See `components::VideoCodec` for codec specific requirements.
160 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
161 return std::move(*this);
162 }
163
164 /// This method makes it possible to pack multiple `sample` in a single component batch.
165 ///
166 /// This only makes sense when used in conjunction with `columns`. `with_sample` should
167 /// be used when logging a single row's worth of data.
169 sample = ComponentBatch::from_loggable(_sample, Descriptor_sample).value_or_throw();
170 return std::move(*this);
171 }
172
173 /// Opacity of the video stream, useful for layering several media.
174 ///
175 /// Defaults to 1.0 (fully opaque).
177 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
178 return std::move(*this);
179 }
180
181 /// This method makes it possible to pack multiple `opacity` in a single component batch.
182 ///
183 /// This only makes sense when used in conjunction with `columns`. `with_opacity` should
184 /// be used when logging a single row's worth of data.
186 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
187 return std::move(*this);
188 }
189
190 /// An optional floating point value that specifies the 2D drawing order.
191 ///
192 /// Objects with higher values are drawn on top of those with lower values.
193 /// Defaults to `-15.0`.
195 draw_order =
196 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
197 return std::move(*this);
198 }
199
200 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
201 ///
202 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
203 /// be used when logging a single row's worth of data.
205 ) && {
206 draw_order =
207 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
208 return std::move(*this);
209 }
210
211 /// Partitions the component data into multiple sub-batches.
212 ///
213 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
214 /// instead, via `ComponentBatch::partitioned`.
215 ///
216 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
217 ///
218 /// The specified `lengths` must sum to the total length of the component batch.
220
221 /// Partitions the component data into unit-length sub-batches.
222 ///
223 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
224 /// where `n` is automatically guessed.
226 };
227
228} // namespace rerun::archetypes
229
230namespace rerun {
231 /// \private
232 template <typename T>
233 struct AsComponents;
234
235 /// \private
236 template <>
237 struct AsComponents<archetypes::VideoStream> {
238 /// Serialize all set component batches.
239 static Result<Collection<ComponentBatch>> as_batches(
240 const archetypes::VideoStream& archetype
241 );
242 };
243} // 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:112
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:185
std::optional< ComponentBatch > opacity
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:67
VideoStream with_sample(const rerun::components::VideoSample &_sample) &&
Video sample data (also known as "video chunk").
Definition video_stream.hpp:159
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:194
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:73
static constexpr auto Descriptor_sample
ComponentDescriptor for the sample field.
Definition video_stream.hpp:85
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:168
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:131
static constexpr auto Descriptor_codec
ComponentDescriptor for the codec field.
Definition video_stream.hpp:80
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition video_stream.hpp:90
VideoStream with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the video stream, useful for layering several media.
Definition video_stream.hpp:176
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:204
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition video_stream.hpp:95
VideoStream with_codec(const rerun::components::VideoCodec &_codec) &&
The codec used to encode the video chunks.
Definition video_stream.hpp:122
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition video_stream.hpp:77
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