зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1409178 - Move DecoderTraits::CreateDecoder() to ChannelMediaDecoder::Create(). r=jwwang
Now DecoderTraits doesn't need to depend on ChannelMediaDecoder. MozReview-Commit-ID: D4AUiV2eGWy --HG-- extra : rebase_source : 38e6c4cdd0f7e32473c6945550bca6fd0cc72bf2
This commit is contained in:
Родитель
48475f5f0b
Коммит
2ba329dae6
|
@ -5012,7 +5012,7 @@ nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
|
|||
#endif
|
||||
|
||||
RefPtr<ChannelMediaDecoder> decoder =
|
||||
DecoderTraits::CreateDecoder(decoderInit, &diagnostics);
|
||||
ChannelMediaDecoder::Create(decoderInit, &diagnostics);
|
||||
if (!decoder) {
|
||||
reportCanPlay(false);
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -173,6 +173,28 @@ ChannelMediaDecoder::ChannelMediaDecoder(MediaDecoderInit& aInit)
|
|||
mWatchManager.Watch(mLogicallySeeking, &ChannelMediaDecoder::SeekingChanged);
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<ChannelMediaDecoder>
|
||||
ChannelMediaDecoder::Create(MediaDecoderInit& aInit,
|
||||
DecoderDoctorDiagnostics* aDiagnostics)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<ChannelMediaDecoder> decoder;
|
||||
|
||||
const MediaContainerType& type = aInit.mContainerType;
|
||||
if (DecoderTraits::IsSupportedType(type)) {
|
||||
decoder = new ChannelMediaDecoder(aInit);
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
if (DecoderTraits::IsHttpLiveStreamingType(type)) {
|
||||
// We don't have an HLS decoder.
|
||||
Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
ChannelMediaDecoder::CanClone()
|
||||
{
|
||||
|
|
|
@ -66,9 +66,17 @@ protected:
|
|||
RefPtr<ResourceCallback> mResourceCallback;
|
||||
RefPtr<BaseMediaResource> mResource;
|
||||
|
||||
public:
|
||||
explicit ChannelMediaDecoder(MediaDecoderInit& aInit);
|
||||
|
||||
public:
|
||||
|
||||
// Create a decoder for the given aType. Returns null if we were unable
|
||||
// to create the decoder, for example because the requested MIME type in
|
||||
// the init struct was unsupported.
|
||||
static already_AddRefed<ChannelMediaDecoder> Create(
|
||||
MediaDecoderInit& aInit,
|
||||
DecoderDoctorDiagnostics* aDiagnostics);
|
||||
|
||||
void Shutdown() override;
|
||||
|
||||
bool CanClone();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* 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 "ChannelMediaDecoder.h"
|
||||
#include "DecoderTraits.h"
|
||||
#include "MediaContainerType.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
@ -224,28 +223,6 @@ bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType,
|
|||
return CanHandleMediaType(*containerType, aDiagnostics) != CANPLAY_NO;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<ChannelMediaDecoder>
|
||||
DecoderTraits::CreateDecoder(MediaDecoderInit& aInit,
|
||||
DecoderDoctorDiagnostics* aDiagnostics)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<ChannelMediaDecoder> decoder;
|
||||
|
||||
const MediaContainerType& type = aInit.mContainerType;
|
||||
if (DecoderTraits::IsSupportedType(type)) {
|
||||
decoder = new ChannelMediaDecoder(aInit);
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
if (DecoderTraits::IsHttpLiveStreamingType(type)) {
|
||||
// We don't have an HLS decoder.
|
||||
Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* static */
|
||||
MediaFormatReader*
|
||||
DecoderTraits::CreateReader(const MediaContainerType& aType,
|
||||
|
|
|
@ -7,19 +7,14 @@
|
|||
#ifndef DecoderTraits_h_
|
||||
#define DecoderTraits_h_
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ChannelMediaDecoder;
|
||||
class DecoderDoctorDiagnostics;
|
||||
class MediaContainerType;
|
||||
struct MediaDecoderInit;
|
||||
struct MediaFormatReaderInit;
|
||||
class MediaDecoderOwner;
|
||||
class MediaFormatReader;
|
||||
class MediaResource;
|
||||
|
||||
enum CanPlayStatus {
|
||||
CANPLAY_NO,
|
||||
|
@ -40,12 +35,6 @@ public:
|
|||
static bool ShouldHandleMediaType(const char* aMIMEType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics);
|
||||
|
||||
// Create a decoder for the given aType. Returns null if we
|
||||
// were unable to create the decoder.
|
||||
static already_AddRefed<ChannelMediaDecoder> CreateDecoder(
|
||||
MediaDecoderInit& aInit,
|
||||
DecoderDoctorDiagnostics* aDiagnostics);
|
||||
|
||||
// Create a reader for thew given MIME type aType. Returns null
|
||||
// if we were unable to create the reader.
|
||||
static MediaFormatReader* CreateReader(const MediaContainerType& aType,
|
||||
|
|
Загрузка…
Ссылка в новой задаче