Bug 1350246 - [Part6] Use DecoderTraits::IsHttpLiveStreamingType to implement HLSDecoder::IsSupportedType and use HLSDecoder::IsSupportedType to implement the following APIs for mimetype of HLS.
(1) Check if we should instantiate HLSDecoder in DecoderTraits::InstantiateDecoder.
(2) Reply CANPLAY_MAYBE in CanHandleMediaType on Fennec.
MozReview-Commit-ID: 4Y6Ju5yk6ha
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -17,16 +17,19 @@
#include "WebMDecoder.h"
#include "WebMDemuxer.h"
#ifdef MOZ_ANDROID_OMX
#include "AndroidMediaDecoder.h"
#include "AndroidMediaReader.h"
#include "AndroidMediaPluginHost.h"
#endif
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+#include "HLSDecoder.h"
+#endif
#ifdef MOZ_FMP4
#include "MP4Decoder.h"
#include "MP4Demuxer.h"
#endif
#include "MediaFormatReader.h"
#include "MP3Decoder.h"
#include "MP3Demuxer.h"
@@ -160,16 +163,22 @@ CanHandleCodecsType(const MediaContainer
static
CanPlayStatus
CanHandleMediaType(const MediaContainerType& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+ if (HLSDecoder::IsSupportedType(aType)) {
+ return CANPLAY_MAYBE;
+ }
+#endif
+
if (DecoderTraits::IsHttpLiveStreamingType(aType)) {
Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
}
if (aType.ExtendedType().HaveCodecs()) {
CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
if (result == CANPLAY_NO || result == CANPLAY_YES) {
return result;
@@ -258,16 +267,22 @@ static
already_AddRefed<MediaDecoder>
InstantiateDecoder(const MediaContainerType& aType,
MediaDecoderInit& aInit,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<MediaDecoder> decoder;
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+ if (HLSDecoder::IsSupportedType(aType)) {
+ decoder = new HLSDecoder(aInit);
+ return decoder.forget();
+ }
+#endif
#ifdef MOZ_FMP4
if (MP4Decoder::IsSupportedType(aType, aDiagnostics)) {
decoder = new MP4Decoder(aInit);
return decoder.forget();
}
#endif
if (MP3Decoder::IsSupportedType(aType)) {
decoder = new MP3Decoder(aInit);
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -42,12 +42,13 @@ bool
HLSDecoder::IsEnabled()
{
return MediaPrefs::HLSEnabled() && (jni::GetAPIVersion() >= 16);
}
bool
HLSDecoder::IsSupportedType(const MediaContainerType& aContainerType)
{
- return false;
+ return IsEnabled() &&
+ DecoderTraits::IsHttpLiveStreamingType(aContainerType);
}
} // namespace mozilla