diff --git a/api/video/hdr_metadata.cc b/api/video/hdr_metadata.cc index 25cd75253c..bfe54ce2e5 100644 --- a/api/video/hdr_metadata.cc +++ b/api/video/hdr_metadata.cc @@ -15,12 +15,21 @@ namespace webrtc { HdrMasteringMetadata::Chromaticity::Chromaticity() = default; HdrMasteringMetadata::Chromaticity::Chromaticity(const Chromaticity& rhs) = default; +HdrMasteringMetadata::Chromaticity::Chromaticity(Chromaticity&& rhs) = default; +HdrMasteringMetadata::Chromaticity& HdrMasteringMetadata::Chromaticity:: +operator=(const Chromaticity& rhs) = default; HdrMasteringMetadata::HdrMasteringMetadata() = default; HdrMasteringMetadata::HdrMasteringMetadata(const HdrMasteringMetadata& rhs) = default; +HdrMasteringMetadata::HdrMasteringMetadata(HdrMasteringMetadata&& rhs) = + default; +HdrMasteringMetadata& HdrMasteringMetadata::operator=( + const HdrMasteringMetadata& rhs) = default; HdrMetadata::HdrMetadata() = default; HdrMetadata::HdrMetadata(const HdrMetadata& rhs) = default; +HdrMetadata::HdrMetadata(HdrMetadata&& rhs) = default; +HdrMetadata& HdrMetadata::operator=(const HdrMetadata& rhs) = default; } // namespace webrtc diff --git a/api/video/hdr_metadata.h b/api/video/hdr_metadata.h index 8a2e6e8ef4..be0c17373b 100644 --- a/api/video/hdr_metadata.h +++ b/api/video/hdr_metadata.h @@ -31,6 +31,8 @@ struct HdrMasteringMetadata { Chromaticity(); Chromaticity(const Chromaticity& rhs); + Chromaticity(Chromaticity&& rhs); + Chromaticity& operator=(const Chromaticity& rhs); }; // The nominal primaries of the mastering display. @@ -53,6 +55,8 @@ struct HdrMasteringMetadata { HdrMasteringMetadata(); HdrMasteringMetadata(const HdrMasteringMetadata& rhs); + HdrMasteringMetadata(HdrMasteringMetadata&& rhs); + HdrMasteringMetadata& operator=(const HdrMasteringMetadata& rhs); bool operator==(const HdrMasteringMetadata& rhs) const { return ((primary_r == rhs.primary_r) && (primary_g == rhs.primary_g) && @@ -76,6 +80,8 @@ struct HdrMetadata { HdrMetadata(); HdrMetadata(const HdrMetadata& rhs); + HdrMetadata(HdrMetadata&& rhs); + HdrMetadata& operator=(const HdrMetadata& rhs); bool operator==(const HdrMetadata& rhs) const { return ( diff --git a/api/video/video_frame.cc b/api/video/video_frame.cc index 5521ad8a58..12da43f69f 100644 --- a/api/video/video_frame.cc +++ b/api/video/video_frame.cc @@ -21,7 +21,7 @@ VideoFrame::Builder::~Builder() = default; VideoFrame VideoFrame::Builder::build() { return VideoFrame(video_frame_buffer_, timestamp_us_, timestamp_rtp_, - ntp_time_ms_, rotation_, color_space_); + ntp_time_ms_, rotation_, color_space_, hdr_metadata_); } VideoFrame::Builder& VideoFrame::Builder::set_video_frame_buffer( @@ -64,6 +64,12 @@ VideoFrame::Builder& VideoFrame::Builder::set_color_space( return *this; } +VideoFrame::Builder& VideoFrame::Builder::set_hdr_metadata( + const HdrMetadata& hdr_metadata) { + hdr_metadata_ = hdr_metadata; + return *this; +} + VideoFrame::VideoFrame(const rtc::scoped_refptr& buffer, webrtc::VideoRotation rotation, int64_t timestamp_us) @@ -90,13 +96,15 @@ VideoFrame::VideoFrame(const rtc::scoped_refptr& buffer, uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, - const absl::optional& color_space) + const absl::optional& color_space, + const absl::optional& hdr_metadata) : video_frame_buffer_(buffer), timestamp_rtp_(timestamp_rtp), ntp_time_ms_(ntp_time_ms), timestamp_us_(timestamp_us), rotation_(rotation), - color_space_(color_space) {} + color_space_(color_space), + hdr_metadata_(hdr_metadata) {} VideoFrame::~VideoFrame() = default; diff --git a/api/video/video_frame.h b/api/video/video_frame.h index 83b45b2a31..58362b0bd8 100644 --- a/api/video/video_frame.h +++ b/api/video/video_frame.h @@ -15,6 +15,7 @@ #include "absl/types/optional.h" #include "api/video/color_space.h" +#include "api/video/hdr_metadata.h" #include "api/video/video_frame_buffer.h" #include "api/video/video_rotation.h" #include "rtc_base/scoped_ref_ptr.h" @@ -39,6 +40,7 @@ class RTC_EXPORT VideoFrame { Builder& set_ntp_time_ms(int64_t ntp_time_ms); Builder& set_rotation(VideoRotation rotation); Builder& set_color_space(const ColorSpace& color_space); + Builder& set_hdr_metadata(const HdrMetadata& hdr_metadata); private: rtc::scoped_refptr video_frame_buffer_; @@ -47,6 +49,7 @@ class RTC_EXPORT VideoFrame { int64_t ntp_time_ms_ = 0; VideoRotation rotation_ = kVideoRotation_0; absl::optional color_space_; + absl::optional hdr_metadata_; }; // To be deprecated. Migrate all use to Builder. @@ -112,9 +115,12 @@ class RTC_EXPORT VideoFrame { VideoRotation rotation() const { return rotation_; } void set_rotation(VideoRotation rotation) { rotation_ = rotation; } - // Set Color space when available. + // Get color space when available. absl::optional color_space() const { return color_space_; } + // Get HDR metadata when available. + absl::optional hdr_metadata() const { return hdr_metadata_; } + // Get render time in milliseconds. // TODO(nisse): Deprecated. Migrate all users to timestamp_us(). int64_t render_time_ms() const; @@ -135,7 +141,8 @@ class RTC_EXPORT VideoFrame { uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, - const absl::optional& color_space); + const absl::optional& color_space, + const absl::optional& hdr_metadata); // An opaque reference counted handle that stores the pixel data. rtc::scoped_refptr video_frame_buffer_; @@ -144,6 +151,7 @@ class RTC_EXPORT VideoFrame { int64_t timestamp_us_; VideoRotation rotation_; absl::optional color_space_; + absl::optional hdr_metadata_; }; } // namespace webrtc