tor-browser

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

sdp_video_format.h (3762B)


      1 /*
      2 *  Copyright (c) 2017 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_CODECS_SDP_VIDEO_FORMAT_H_
     12 #define API_VIDEO_CODECS_SDP_VIDEO_FORMAT_H_
     13 
     14 #include <map>
     15 #include <optional>
     16 #include <string>
     17 
     18 #include "absl/container/inlined_vector.h"
     19 #include "api/array_view.h"
     20 #include "api/rtp_parameters.h"
     21 #include "api/video_codecs/scalability_mode.h"
     22 #include "rtc_base/system/rtc_export.h"
     23 
     24 namespace webrtc {
     25 
     26 // SDP specification for a single video codec.
     27 // NOTE: This class is still under development and may change without notice.
     28 struct RTC_EXPORT SdpVideoFormat {
     29  using Parameters [[deprecated("Use CodecParameterMap")]] =
     30      std::map<std::string, std::string>;
     31 
     32  explicit SdpVideoFormat(const std::string& name);
     33  SdpVideoFormat(const std::string& name, const CodecParameterMap& parameters);
     34  SdpVideoFormat(
     35      const std::string& name,
     36      const CodecParameterMap& parameters,
     37      const absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>&
     38          scalability_modes);
     39  // Creates a new SdpVideoFormat object identical to the supplied
     40  // SdpVideoFormat except the scalability_modes that are set to be the same as
     41  // the supplied scalability modes.
     42  SdpVideoFormat(
     43      const SdpVideoFormat& format,
     44      const absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>&
     45          scalability_modes);
     46 
     47  SdpVideoFormat(const SdpVideoFormat&);
     48  SdpVideoFormat(SdpVideoFormat&&);
     49  SdpVideoFormat& operator=(const SdpVideoFormat&);
     50  SdpVideoFormat& operator=(SdpVideoFormat&&);
     51 
     52  ~SdpVideoFormat();
     53 
     54  // Returns true if the SdpVideoFormats have the same names as well as codec
     55  // specific parameters. Please note that two SdpVideoFormats can represent the
     56  // same codec even though not all parameters are the same.
     57  bool IsSameCodec(const SdpVideoFormat& other) const;
     58  bool IsCodecInList(ArrayView<const SdpVideoFormat> formats) const;
     59 
     60  std::string ToString() const;
     61 
     62  friend RTC_EXPORT bool operator==(const SdpVideoFormat& a,
     63                                    const SdpVideoFormat& b);
     64  friend RTC_EXPORT bool operator!=(const SdpVideoFormat& a,
     65                                    const SdpVideoFormat& b) {
     66    return !(a == b);
     67  }
     68 
     69  std::string name;
     70  CodecParameterMap parameters;
     71  absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes;
     72 
     73  // Well-known video codecs and their format parameters.
     74  static const SdpVideoFormat VP8();
     75  static const SdpVideoFormat H264();
     76  static const SdpVideoFormat H265();
     77  static const SdpVideoFormat VP9Profile0();
     78  static const SdpVideoFormat VP9Profile1();
     79  static const SdpVideoFormat VP9Profile2();
     80  static const SdpVideoFormat VP9Profile3();
     81  static const SdpVideoFormat AV1Profile0();
     82  static const SdpVideoFormat AV1Profile1();
     83 
     84  template <typename Sink>
     85  friend void AbslStringify(Sink& sink, const SdpVideoFormat& format) {
     86    sink.Append(format.ToString());
     87  }
     88 };
     89 
     90 // For not so good reasons sometimes additional parameters are added to an
     91 // SdpVideoFormat, which makes instances that should compare equal to not match
     92 // anymore. Until we stop misusing SdpVideoFormats provide this convenience
     93 // function to perform fuzzy matching.
     94 std::optional<SdpVideoFormat> FuzzyMatchSdpVideoFormat(
     95    ArrayView<const SdpVideoFormat> supported_formats,
     96    const SdpVideoFormat& format);
     97 
     98 }  // namespace webrtc
     99 
    100 #endif  // API_VIDEO_CODECS_SDP_VIDEO_FORMAT_H_