Drag DirectShow back from the dead, force H264 support

This commit is contained in:
wuggy 2026-09-08 06:59:43 -07:00
commit 96bc206271
19 changed files with 3024 additions and 0 deletions

View file

@ -34,6 +34,11 @@
#include "FlacDecoder.h"
#include "FlacDemuxer.h"
#ifdef MOZ_DIRECTSHOW
#include "DirectShowDecoder.h"
#include "DirectShowReader.h"
#endif
#include "nsPluginHost.h"
#include "MediaPrefs.h"
@ -138,6 +143,14 @@ IsFlacSupportedType(const nsACString& aType,
return FlacDecoder::CanHandleMediaType(aType, aCodecs);
}
#ifdef MOZ_DIRECTSHOW
static bool
IsDirectShowSupportedType(const nsACString& aType)
{
return DirectShowDecoder::GetSupportedCodecs(aType, nullptr);
}
#endif
static
CanPlayStatus
CanHandleCodecsType(const MediaContentType& aType,
@ -197,6 +210,11 @@ CanHandleCodecsType(const MediaContentType& aType,
if (IsFlacSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
return CANPLAY_YES;
}
#ifdef MOZ_DIRECTSHOW
if (IsDirectShowSupportedType(aType.GetMIMEType())) {
return CANPLAY_YES;
}
#endif
if (!codecList) {
return CANPLAY_MAYBE;
}
@ -258,6 +276,11 @@ CanHandleMediaType(const MediaContentType& aType,
if (IsFlacSupportedType(aType.GetMIMEType())) {
return CANPLAY_MAYBE;
}
#ifdef MOZ_DIRECTSHOW
if (IsDirectShowSupportedType(aType.GetMIMEType())) {
return CANPLAY_MAYBE;
}
#endif
return CANPLAY_NO;
}
@ -347,6 +370,13 @@ InstantiateDecoder(const nsACString& aType,
return decoder.forget();
}
#ifdef MOZ_DIRECTSHOW
if (IsDirectShowSupportedType(aType)) {
decoder = new DirectShowDecoder(aOwner);
return decoder.forget();
}
#endif
return nullptr;
}
@ -393,6 +423,11 @@ MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, Abstrac
decoderReader =
new MediaFormatReader(aDecoder, new WebMDemuxer(aDecoder->GetResource()));
}
#ifdef MOZ_DIRECTSHOW
else if (IsDirectShowSupportedType(aType)) {
decoderReader = new DirectShowReader(aDecoder);
}
#endif
return decoderReader;
}
@ -418,6 +453,9 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType)
IsAACSupportedType(aType) ||
IsWaveSupportedType(aType) ||
IsFlacSupportedType(aType) ||
#ifdef MOZ_DIRECTSHOW
IsDirectShowSupportedType(aType) ||
#endif
false;
}