From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../platforms/agnostic/gmp/GMPDecoderModule.cpp | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp (limited to 'dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp') diff --git a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp new file mode 100644 index 0000000000..f01c7e94e4 --- /dev/null +++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "GMPDecoderModule.h" + +#include "DecoderDoctorDiagnostics.h" +#include "GMPService.h" +#include "GMPUtils.h" +#include "GMPVideoDecoder.h" +#include "MP4Decoder.h" +#include "MediaDataDecoderProxy.h" +#include "VPXDecoder.h" +#include "VideoUtils.h" +#include "gmp-video-decode.h" +#include "mozilla/StaticMutex.h" +#include "nsServiceManagerUtils.h" +#ifdef XP_WIN +# include "WMFDecoderModule.h" +#endif + +namespace mozilla { + +static already_AddRefed CreateDecoderWrapper( + GMPVideoDecoderParams&& aParams) { + RefPtr s( + gmp::GeckoMediaPluginService::GetGeckoMediaPluginService()); + if (!s) { + return nullptr; + } + nsCOMPtr thread(s->GetGMPThread()); + if (!thread) { + return nullptr; + } + + RefPtr decoder(new MediaDataDecoderProxy( + do_AddRef(new GMPVideoDecoder(std::move(aParams))), thread.forget())); + return decoder.forget(); +} + +already_AddRefed GMPDecoderModule::CreateVideoDecoder( + const CreateDecoderParams& aParams) { + if (!MP4Decoder::IsH264(aParams.mConfig.mMimeType) && + !VPXDecoder::IsVP8(aParams.mConfig.mMimeType) && + !VPXDecoder::IsVP9(aParams.mConfig.mMimeType)) { + return nullptr; + } + + return CreateDecoderWrapper(GMPVideoDecoderParams(aParams)); +} + +already_AddRefed GMPDecoderModule::CreateAudioDecoder( + const CreateDecoderParams& aParams) { + return nullptr; +} + +/* static */ +media::DecodeSupportSet GMPDecoderModule::SupportsMimeType( + const nsACString& aMimeType, const nsACString& aApi, + const Maybe& aKeySystem) { + AutoTArray tags; + if (MP4Decoder::IsH264(aMimeType)) { + tags.AppendElement("h264"_ns); + } else if (VPXDecoder::IsVP9(aMimeType)) { + tags.AppendElement("vp9"_ns); + } else if (VPXDecoder::IsVP8(aMimeType)) { + tags.AppendElement("vp8"_ns); + } else { + return media::DecodeSupportSet{}; + } + + // Optional tag for EME GMP plugins. + if (aKeySystem) { + tags.AppendElement(*aKeySystem); + } + + // GMP plugins are always software based. + return HaveGMPFor(aApi, tags) ? media::DecodeSupport::SoftwareDecode + : media::DecodeSupportSet{}; +} + +media::DecodeSupportSet GMPDecoderModule::SupportsMimeType( + const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const { + return SupportsMimeType(aMimeType, "decode-video"_ns, Nothing()); +} + +/* static */ +already_AddRefed GMPDecoderModule::Create() { + return MakeAndAddRef(); +} + +} // namespace mozilla -- cgit v1.2.3