tor-browser

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

video_layers_allocation.h (2804B)


      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 #ifndef API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_
     12 #define API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_
     13 
     14 #include <cstdint>
     15 
     16 #include "absl/container/inlined_vector.h"
     17 #include "api/units/data_rate.h"
     18 
     19 namespace webrtc {
     20 
     21 // This struct contains additional stream-level information needed by a
     22 // Selective Forwarding Middlebox to make relay decisions of RTP streams.
     23 struct VideoLayersAllocation {
     24  static constexpr int kMaxSpatialIds = 4;
     25  static constexpr int kMaxTemporalIds = 4;
     26 
     27  friend bool operator==(const VideoLayersAllocation& lhs,
     28                         const VideoLayersAllocation& rhs) {
     29    return lhs.rtp_stream_index == rhs.rtp_stream_index &&
     30           lhs.resolution_and_frame_rate_is_valid ==
     31               rhs.resolution_and_frame_rate_is_valid &&
     32           lhs.active_spatial_layers == rhs.active_spatial_layers;
     33  }
     34 
     35  friend bool operator!=(const VideoLayersAllocation& lhs,
     36                         const VideoLayersAllocation& rhs) {
     37    return !(lhs == rhs);
     38  }
     39 
     40  struct SpatialLayer {
     41    friend bool operator==(const SpatialLayer& lhs, const SpatialLayer& rhs) {
     42      return lhs.rtp_stream_index == rhs.rtp_stream_index &&
     43             lhs.spatial_id == rhs.spatial_id &&
     44             lhs.target_bitrate_per_temporal_layer ==
     45                 rhs.target_bitrate_per_temporal_layer &&
     46             lhs.width == rhs.width && lhs.height == rhs.height &&
     47             lhs.frame_rate_fps == rhs.frame_rate_fps;
     48    }
     49 
     50    friend bool operator!=(const SpatialLayer& lhs, const SpatialLayer& rhs) {
     51      return !(lhs == rhs);
     52    }
     53    int rtp_stream_index = 0;
     54    // Index of the spatial layer per `rtp_stream_index`.
     55    int spatial_id = 0;
     56    // Target bitrate per decode target.
     57    absl::InlinedVector<DataRate, kMaxTemporalIds>
     58        target_bitrate_per_temporal_layer;
     59 
     60    // These fields are only valid if `resolution_and_frame_rate_is_valid` is
     61    // true
     62    uint16_t width = 0;
     63    uint16_t height = 0;
     64    // Max frame rate used in any temporal layer of this spatial layer.
     65    uint8_t frame_rate_fps = 0;
     66  };
     67 
     68  // Index of the rtp stream this allocation is sent on. Used for mapping
     69  // a SpatialLayer to a rtp stream.
     70  int rtp_stream_index = 0;
     71  bool resolution_and_frame_rate_is_valid = false;
     72  absl::InlinedVector<SpatialLayer, kMaxSpatialIds> active_spatial_layers;
     73 };
     74 
     75 }  // namespace webrtc
     76 
     77 #endif  // API_VIDEO_VIDEO_LAYERS_ALLOCATION_H_