tor-browser

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

DefaultCodecPreferences.cpp (1738B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      6 
      7 #include "DefaultCodecPreferences.h"
      8 
      9 #include "gmp/GMPUtils.h"
     10 #include "libwebrtcglue/VideoConduit.h"
     11 #include "mozilla/StaticPrefs_media.h"
     12 
     13 namespace mozilla {
     14 
     15 bool DefaultCodecPreferences::AV1EnabledStatic() {
     16  return WebrtcVideoConduit::HasAv1() &&
     17         StaticPrefs::media_webrtc_codec_video_av1_enabled();
     18 }
     19 
     20 bool DefaultCodecPreferences::AV1PreferredStatic() {
     21  return StaticPrefs::media_webrtc_codec_video_av1_experimental_preferred();
     22 }
     23 
     24 bool DefaultCodecPreferences::H264EnabledStatic() {
     25  return SoftwareH264EnabledStatic() || HardwareH264EnabledStatic();
     26 }
     27 
     28 bool DefaultCodecPreferences::SoftwareH264EnabledStatic() {
     29 #ifdef MOZ_WIDGET_ANDROID
     30  // Although Play Store policy doesn't allow GMP plugin, Android has H.264 SW
     31  // codec.
     32  MOZ_ASSERT(!HaveGMPFor("encode-video"_ns, {"h264"_ns}),
     33             "GMP plugin not allowed on Android");
     34  return true;
     35 #else
     36  return HaveGMPFor("encode-video"_ns, {"h264"_ns}) &&
     37         HaveGMPFor("decode-video"_ns, {"h264"_ns});
     38 #endif
     39 }
     40 
     41 bool DefaultCodecPreferences::HardwareH264EnabledStatic() {
     42  return WebrtcVideoConduit::HasH264Hardware() &&
     43         Preferences::GetBool("media.webrtc.hw.h264.enabled", false);
     44 }
     45 
     46 bool DefaultCodecPreferences::
     47    SendingH264PacketizationModeZeroSupportedStatic() {
     48  // Packetization mode 0 is unsupported by MediaDataEncoder.
     49  return HaveGMPFor("encode-video"_ns, {"h264"_ns});
     50 }
     51 
     52 }  // namespace mozilla