tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_frame_metadata.cc (5123B)


      1 /*
      2 *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #include "api/video/video_frame_metadata.h"
     12 
     13 #include <cstdint>
     14 #include <optional>
     15 #include <utility>
     16 #include <vector>
     17 
     18 #include "api/array_view.h"
     19 #include "api/transport/rtp/dependency_descriptor.h"
     20 #include "api/video/video_codec_type.h"
     21 #include "api/video/video_content_type.h"
     22 #include "api/video/video_frame_type.h"
     23 #include "api/video/video_rotation.h"
     24 
     25 namespace webrtc {
     26 
     27 VideoFrameMetadata::VideoFrameMetadata() = default;
     28 
     29 VideoFrameType VideoFrameMetadata::GetFrameType() const {
     30  return frame_type_;
     31 }
     32 
     33 void VideoFrameMetadata::SetFrameType(VideoFrameType frame_type) {
     34  frame_type_ = frame_type;
     35 }
     36 
     37 uint16_t VideoFrameMetadata::GetWidth() const {
     38  return width_;
     39 }
     40 
     41 void VideoFrameMetadata::SetWidth(uint16_t width) {
     42  width_ = width;
     43 }
     44 
     45 uint16_t VideoFrameMetadata::GetHeight() const {
     46  return height_;
     47 }
     48 
     49 void VideoFrameMetadata::SetHeight(uint16_t height) {
     50  height_ = height;
     51 }
     52 
     53 VideoRotation VideoFrameMetadata::GetRotation() const {
     54  return rotation_;
     55 }
     56 
     57 void VideoFrameMetadata::SetRotation(VideoRotation rotation) {
     58  rotation_ = rotation;
     59 }
     60 
     61 VideoContentType VideoFrameMetadata::GetContentType() const {
     62  return content_type_;
     63 }
     64 
     65 void VideoFrameMetadata::SetContentType(VideoContentType content_type) {
     66  content_type_ = content_type;
     67 }
     68 
     69 std::optional<int64_t> VideoFrameMetadata::GetFrameId() const {
     70  return frame_id_;
     71 }
     72 
     73 void VideoFrameMetadata::SetFrameId(std::optional<int64_t> frame_id) {
     74  frame_id_ = frame_id;
     75 }
     76 
     77 int VideoFrameMetadata::GetSpatialIndex() const {
     78  return spatial_index_;
     79 }
     80 
     81 void VideoFrameMetadata::SetSpatialIndex(int spatial_index) {
     82  spatial_index_ = spatial_index;
     83 }
     84 
     85 int VideoFrameMetadata::GetTemporalIndex() const {
     86  return temporal_index_;
     87 }
     88 
     89 void VideoFrameMetadata::SetTemporalIndex(int temporal_index) {
     90  temporal_index_ = temporal_index;
     91 }
     92 
     93 ArrayView<const int64_t> VideoFrameMetadata::GetFrameDependencies() const {
     94  return frame_dependencies_;
     95 }
     96 
     97 void VideoFrameMetadata::SetFrameDependencies(
     98    ArrayView<const int64_t> frame_dependencies) {
     99  frame_dependencies_.assign(frame_dependencies.begin(),
    100                             frame_dependencies.end());
    101 }
    102 
    103 ArrayView<const DecodeTargetIndication>
    104 VideoFrameMetadata::GetDecodeTargetIndications() const {
    105  return decode_target_indications_;
    106 }
    107 
    108 void VideoFrameMetadata::SetDecodeTargetIndications(
    109    ArrayView<const DecodeTargetIndication> decode_target_indications) {
    110  decode_target_indications_.assign(decode_target_indications.begin(),
    111                                    decode_target_indications.end());
    112 }
    113 
    114 bool VideoFrameMetadata::GetIsLastFrameInPicture() const {
    115  return is_last_frame_in_picture_;
    116 }
    117 
    118 void VideoFrameMetadata::SetIsLastFrameInPicture(
    119    bool is_last_frame_in_picture) {
    120  is_last_frame_in_picture_ = is_last_frame_in_picture;
    121 }
    122 
    123 uint8_t VideoFrameMetadata::GetSimulcastIdx() const {
    124  return simulcast_idx_;
    125 }
    126 
    127 void VideoFrameMetadata::SetSimulcastIdx(uint8_t simulcast_idx) {
    128  simulcast_idx_ = simulcast_idx;
    129 }
    130 
    131 VideoCodecType VideoFrameMetadata::GetCodec() const {
    132  return codec_;
    133 }
    134 
    135 void VideoFrameMetadata::SetCodec(VideoCodecType codec) {
    136  codec_ = codec;
    137 }
    138 
    139 const RTPVideoHeaderCodecSpecifics&
    140 VideoFrameMetadata::GetRTPVideoHeaderCodecSpecifics() const {
    141  return codec_specifics_;
    142 }
    143 
    144 void VideoFrameMetadata::SetRTPVideoHeaderCodecSpecifics(
    145    RTPVideoHeaderCodecSpecifics codec_specifics) {
    146  codec_specifics_ = std::move(codec_specifics);
    147 }
    148 
    149 uint32_t VideoFrameMetadata::GetSsrc() const {
    150  return ssrc_;
    151 }
    152 
    153 void VideoFrameMetadata::SetSsrc(uint32_t ssrc) {
    154  ssrc_ = ssrc;
    155 }
    156 
    157 std::vector<uint32_t> VideoFrameMetadata::GetCsrcs() const {
    158  return csrcs_;
    159 }
    160 
    161 void VideoFrameMetadata::SetCsrcs(std::vector<uint32_t> csrcs) {
    162  csrcs_ = std::move(csrcs);
    163 }
    164 
    165 bool operator==(const VideoFrameMetadata& lhs, const VideoFrameMetadata& rhs) {
    166  return lhs.frame_type_ == rhs.frame_type_ && lhs.width_ == rhs.width_ &&
    167         lhs.height_ == rhs.height_ && lhs.rotation_ == rhs.rotation_ &&
    168         lhs.content_type_ == rhs.content_type_ &&
    169         lhs.frame_id_ == rhs.frame_id_ &&
    170         lhs.spatial_index_ == rhs.spatial_index_ &&
    171         lhs.temporal_index_ == rhs.temporal_index_ &&
    172         lhs.frame_dependencies_ == rhs.frame_dependencies_ &&
    173         lhs.decode_target_indications_ == rhs.decode_target_indications_ &&
    174         lhs.is_last_frame_in_picture_ == rhs.is_last_frame_in_picture_ &&
    175         lhs.simulcast_idx_ == rhs.simulcast_idx_ && lhs.codec_ == rhs.codec_ &&
    176         lhs.codec_specifics_ == rhs.codec_specifics_ &&
    177         lhs.ssrc_ == rhs.ssrc_ && lhs.csrcs_ == rhs.csrcs_;
    178 }
    179 
    180 bool operator!=(const VideoFrameMetadata& lhs, const VideoFrameMetadata& rhs) {
    181  return !(lhs == rhs);
    182 }
    183 
    184 }  // namespace webrtc