зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1377370. P1 - let HLSDecoder override Load() so it can create an HLSResource directly without going through MediaResource::Create(). r=kikuo
MozReview-Commit-ID: BL8bt2JtKfa --HG-- extra : rebase_source : 70231ab332fee2316e86aa73e834f108183b23d8 extra : source : e97125ebc28890e0d538c4ef4d8abc9232e69bac
This commit is contained in:
Родитель
865bf7b978
Коммит
7d2785b4a8
|
@ -52,6 +52,7 @@ class ChannelMediaDecoder : public MediaDecoder
|
||||||
const RefPtr<AbstractThread> mAbstractMainThread;
|
const RefPtr<AbstractThread> mAbstractMainThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
RefPtr<ResourceCallback> mResourceCallback;
|
RefPtr<ResourceCallback> mResourceCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -63,10 +64,10 @@ public:
|
||||||
// Subclasses must implement this.
|
// Subclasses must implement this.
|
||||||
virtual ChannelMediaDecoder* Clone(MediaDecoderInit& aInit) = 0;
|
virtual ChannelMediaDecoder* Clone(MediaDecoderInit& aInit) = 0;
|
||||||
|
|
||||||
nsresult Load(nsIChannel* aChannel,
|
virtual nsresult Load(nsIChannel* aChannel,
|
||||||
bool aIsPrivateBrowsing,
|
bool aIsPrivateBrowsing,
|
||||||
nsIStreamListener** aStreamListener);
|
nsIStreamListener** aStreamListener);
|
||||||
nsresult Load(MediaResource* aOriginal);
|
virtual nsresult Load(MediaResource* aOriginal);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsresult OpenResource(nsIStreamListener** aStreamListener);
|
nsresult OpenResource(nsIStreamListener** aStreamListener);
|
||||||
|
|
|
@ -131,8 +131,7 @@ public:
|
||||||
// Called if the media file encounters a network error.
|
// Called if the media file encounters a network error.
|
||||||
void NetworkError();
|
void NetworkError();
|
||||||
|
|
||||||
// Get the current MediaResource being used. Its URI will be returned
|
// Get the current MediaResource being used.
|
||||||
// by currentSrc. Returns what was passed to Load(), if Load() has been called.
|
|
||||||
// Note: The MediaResource is refcounted, but it outlives the MediaDecoder,
|
// Note: The MediaResource is refcounted, but it outlives the MediaDecoder,
|
||||||
// so it's OK to use the reference returned by this function without
|
// so it's OK to use the reference returned by this function without
|
||||||
// refcounting, *unless* you need to store and use the reference after the
|
// refcounting, *unless* you need to store and use the reference after the
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "MediaDecoderStateMachine.h"
|
#include "MediaDecoderStateMachine.h"
|
||||||
#include "MediaFormatReader.h"
|
#include "MediaFormatReader.h"
|
||||||
#include "MediaPrefs.h"
|
#include "MediaPrefs.h"
|
||||||
|
#include "MediaShutdownManager.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -56,4 +58,38 @@ HLSDecoder::IsSupportedType(const MediaContainerType& aContainerType)
|
||||||
DecoderTraits::IsHttpLiveStreamingType(aContainerType);
|
DecoderTraits::IsHttpLiveStreamingType(aContainerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
HLSDecoder::Load(nsIChannel* aChannel,
|
||||||
|
bool aIsPrivateBrowsing,
|
||||||
|
nsIStreamListener**)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
MOZ_ASSERT(!mResource);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
mResource = new HLSResource(mResourceCallback, aChannel, uri);
|
||||||
|
|
||||||
|
rv = MediaShutdownManager::Instance().Register(this);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetStateMachine(CreateStateMachine());
|
||||||
|
NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
return InitializeStateMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
HLSDecoder::Load(MediaResource*)
|
||||||
|
{
|
||||||
|
MOZ_CRASH("Clone is not supported");
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -33,6 +33,11 @@ public:
|
||||||
// If provided, codecs are checked for support.
|
// If provided, codecs are checked for support.
|
||||||
static bool IsSupportedType(const MediaContainerType& aContainerType);
|
static bool IsSupportedType(const MediaContainerType& aContainerType);
|
||||||
|
|
||||||
|
nsresult Load(nsIChannel* aChannel,
|
||||||
|
bool aIsPrivateBrowsing,
|
||||||
|
nsIStreamListener**) override;
|
||||||
|
nsresult Load(MediaResource*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<MediaFormatReader> mReader;
|
RefPtr<MediaFormatReader> mReader;
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче