Rerun C++ SDK
Loading...
Searching...
No Matches
video_sample.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/components/video_sample.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_descriptor.hpp"
8#include "../datatypes/blob.hpp"
9#include "../result.hpp"
10
11#include <cstdint>
12#include <memory>
13#include <utility>
14
15namespace rerun::components {
16 /// **Component**: Video sample data (also known as "video chunk").
17 ///
18 /// Each video sample must contain enough data for exactly one video frame
19 /// (this restriction may be relaxed in the future for some codecs).
20 ///
21 /// Keyframes may require additional data, for details see `components::VideoCodec`.
22 struct VideoSample {
24
25 public:
26 VideoSample() = default;
27
28 VideoSample(rerun::datatypes::Blob buffer_) : buffer(std::move(buffer_)) {}
29
30 VideoSample& operator=(rerun::datatypes::Blob buffer_) {
31 buffer = std::move(buffer_);
32 return *this;
33 }
34
35 VideoSample(rerun::Collection<uint8_t> data_) : buffer(std::move(data_)) {}
36
37 VideoSample& operator=(rerun::Collection<uint8_t> data_) {
38 buffer = std::move(data_);
39 return *this;
40 }
41
42 /// Cast to the underlying Blob datatype
43 operator rerun::datatypes::Blob() const {
44 return buffer;
45 }
46 };
47} // namespace rerun::components
48
49namespace rerun {
50 static_assert(sizeof(rerun::datatypes::Blob) == sizeof(components::VideoSample));
51
52 /// \private
53 template <>
54 struct Loggable<components::VideoSample> {
55 static constexpr ComponentDescriptor Descriptor = "rerun.components.VideoSample";
56
57 /// Returns the arrow data type this type corresponds to.
58 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
59 return Loggable<rerun::datatypes::Blob>::arrow_datatype();
60 }
61
62 /// Serializes an array of `rerun::components::VideoSample` into an arrow array.
63 static Result<std::shared_ptr<arrow::Array>> to_arrow(
64 const components::VideoSample* instances, size_t num_instances
65 ) {
66 if (num_instances == 0) {
67 return Loggable<rerun::datatypes::Blob>::to_arrow(nullptr, 0);
68 } else if (instances == nullptr) {
69 return rerun::Error(
70 ErrorCode::UnexpectedNullArgument,
71 "Passed array instances is null when num_elements> 0."
72 );
73 } else {
74 return Loggable<rerun::datatypes::Blob>::to_arrow(
75 &instances->buffer,
76 num_instances
77 );
78 }
79 }
80 };
81} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:99
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: Video sample data (also known as "video chunk").
Definition video_sample.hpp:22
Datatype: A binary blob of data.
Definition blob.hpp:22