webrtc/api/video/video_frame_metadata.h
Tove Petersson 1fccaa4485 Reland "operator== for VideoFrameMetadata + used in CloneSenderVideoFrame test"
This reverts commit 8bf3210629.

Reason for revert: Initialized an uninitialized member in GofInfoVP9 (+ removed some redundant initialization of members already initialized by SetGofInfoVP9())

Original change's description:
> Revert "operator== for VideoFrameMetadata + used in CloneSenderVideoFrame test"
>
> This reverts commit 437bf78ed9.
>
> Reason for revert: Breaks upstream project
>
> Original change's description:
> > operator== for VideoFrameMetadata + used in CloneSenderVideoFrame test
> >
> > Added equality and inequality operators for VideoFrameMetadata and used the equality operator to check that the cloned metadata property is equal to the original metadata in RtpSenderVideoFrameTransformerDelegateTest.CloneSenderVideoFrame.
> >
> > Also default-initialized VideoFrameMetadata::ssrc_ to 0.
> >
> > Bug: webrtc:14708
> > Change-Id: If1f5153069bc986061ff9f0a6abaa2a4a5a98dd1
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293560
> > Commit-Queue: Tove Petersson <tovep@google.com>
> > Reviewed-by: Tony Herre <herre@google.com>
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#39411}
>
> Bug: webrtc:14708
> Change-Id: Icbec1b65ed22b89766606cb9514dde6f4e9124be
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295500
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Auto-Submit: Andrey Logvin <landrey@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#39413}

Bug: webrtc:14708
Change-Id: I843d29f7dd0da2c7f16968a7fc08dc02cd359fc1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295520
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Tove Petersson <tovep@google.com>
Cr-Commit-Position: refs/heads/main@{#39418}
2023-02-28 15:44:21 +00:00

127 lines
4.3 KiB
C++

/*
* Copyright 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_VIDEO_VIDEO_FRAME_METADATA_H_
#define API_VIDEO_VIDEO_FRAME_METADATA_H_
#include <cstdint>
#include <vector>
#include "absl/container/inlined_vector.h"
#include "absl/types/optional.h"
#include "absl/types/variant.h"
#include "api/array_view.h"
#include "api/transport/rtp/dependency_descriptor.h"
#include "api/video/video_codec_type.h"
#include "api/video/video_content_type.h"
#include "api/video/video_frame_type.h"
#include "api/video/video_rotation.h"
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
using RTPVideoHeaderCodecSpecifics = absl::variant<absl::monostate,
RTPVideoHeaderVP8,
RTPVideoHeaderVP9,
RTPVideoHeaderH264>;
// A subset of metadata from the RTP video header, exposed in insertable streams
// API.
class RTC_EXPORT VideoFrameMetadata {
public:
VideoFrameMetadata();
VideoFrameMetadata(const VideoFrameMetadata&) = default;
VideoFrameMetadata& operator=(const VideoFrameMetadata&) = default;
VideoFrameType GetFrameType() const;
void SetFrameType(VideoFrameType frame_type);
uint16_t GetWidth() const;
void SetWidth(uint16_t width);
uint16_t GetHeight() const;
void SetHeight(uint16_t height);
VideoRotation GetRotation() const;
void SetRotation(VideoRotation rotation);
VideoContentType GetContentType() const;
void SetContentType(VideoContentType content_type);
absl::optional<int64_t> GetFrameId() const;
void SetFrameId(absl::optional<int64_t> frame_id);
int GetSpatialIndex() const;
void SetSpatialIndex(int spatial_index);
int GetTemporalIndex() const;
void SetTemporalIndex(int temporal_index);
rtc::ArrayView<const int64_t> GetFrameDependencies() const;
void SetFrameDependencies(rtc::ArrayView<const int64_t> frame_dependencies);
rtc::ArrayView<const DecodeTargetIndication> GetDecodeTargetIndications()
const;
void SetDecodeTargetIndications(
rtc::ArrayView<const DecodeTargetIndication> decode_target_indications);
bool GetIsLastFrameInPicture() const;
void SetIsLastFrameInPicture(bool is_last_frame_in_picture);
uint8_t GetSimulcastIdx() const;
void SetSimulcastIdx(uint8_t simulcast_idx);
VideoCodecType GetCodec() const;
void SetCodec(VideoCodecType codec);
// Which varient is used depends on the VideoCodecType from GetCodecs().
const RTPVideoHeaderCodecSpecifics& GetRTPVideoHeaderCodecSpecifics() const;
void SetRTPVideoHeaderCodecSpecifics(
RTPVideoHeaderCodecSpecifics codec_specifics);
uint32_t GetSsrc() const;
void SetSsrc(uint32_t ssrc);
std::vector<uint32_t> GetCsrcs() const;
void SetCsrcs(std::vector<uint32_t> csrcs);
friend bool operator==(const VideoFrameMetadata& lhs,
const VideoFrameMetadata& rhs);
friend bool operator!=(const VideoFrameMetadata& lhs,
const VideoFrameMetadata& rhs);
private:
VideoFrameType frame_type_ = VideoFrameType::kEmptyFrame;
int16_t width_ = 0;
int16_t height_ = 0;
VideoRotation rotation_ = VideoRotation::kVideoRotation_0;
VideoContentType content_type_ = VideoContentType::UNSPECIFIED;
// Corresponding to GenericDescriptorInfo.
absl::optional<int64_t> frame_id_;
int spatial_index_ = 0;
int temporal_index_ = 0;
absl::InlinedVector<int64_t, 5> frame_dependencies_;
absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications_;
bool is_last_frame_in_picture_ = true;
uint8_t simulcast_idx_ = 0;
VideoCodecType codec_ = VideoCodecType::kVideoCodecGeneric;
RTPVideoHeaderCodecSpecifics codec_specifics_;
// RTP info.
uint32_t ssrc_ = 0u;
std::vector<uint32_t> csrcs_;
};
} // namespace webrtc
#endif // API_VIDEO_VIDEO_FRAME_METADATA_H_