tor-browser

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

WMFEncoderModule.cpp (1796B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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 http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "WMFEncoderModule.h"
      8 
      9 #include "EncoderConfig.h"
     10 #include "WMFMediaDataEncoder.h"
     11 
     12 using mozilla::media::EncodeSupportSet;
     13 
     14 namespace mozilla {
     15 
     16 extern LazyLogModule sPEMLog;
     17 
     18 static EncodeSupportSet IsSupported(const EncoderConfig& aConfig) {
     19  if (CodecToSubtype(aConfig.mCodec) == GUID_NULL) {
     20    return EncodeSupportSet{};
     21  }
     22  return CanCreateWMFEncoder(aConfig);
     23 }
     24 
     25 EncodeSupportSet WMFEncoderModule::SupportsCodec(CodecType aCodecType) const {
     26  gfx::IntSize kDefaultSize(640, 480);
     27  EncoderConfig::CodecSpecific kDefaultCodecSpecific = AsVariant(void_t{});
     28  EncoderConfig cfg;
     29  cfg.mCodec = aCodecType;
     30  cfg.mSize = kDefaultSize;
     31  cfg.mCodecSpecific = kDefaultCodecSpecific;
     32  cfg.mHardwarePreference = HardwarePreference::None;
     33  return IsSupported(cfg);
     34 }
     35 
     36 EncodeSupportSet WMFEncoderModule::Supports(
     37    const EncoderConfig& aConfig) const {
     38  if (!CanLikelyEncode(aConfig)) {
     39    return EncodeSupportSet{};
     40  }
     41  if (aConfig.IsAudio()) {
     42    return EncodeSupportSet{};
     43  }
     44  if (aConfig.mScalabilityMode != ScalabilityMode::None &&
     45      aConfig.mCodec != CodecType::H264) {
     46    return EncodeSupportSet{};
     47  }
     48  return IsSupported(aConfig);
     49 }
     50 
     51 already_AddRefed<MediaDataEncoder> WMFEncoderModule::CreateVideoEncoder(
     52    const EncoderConfig& aConfig, const RefPtr<TaskQueue>& aTaskQueue) const {
     53  RefPtr<MediaDataEncoder> encoder(
     54      new WMFMediaDataEncoder(aConfig, aTaskQueue));
     55  return encoder.forget();
     56 }
     57 
     58 }  // namespace mozilla