bug 1116382 use MediaSource from resolution of MediaSource urls when set r=bholley

This commit is contained in:
Karl Tomlinson
2015-05-28 14:38:34 +12:00
parent f4305531a7
commit 437bf273d4
2 changed files with 8 additions and 16 deletions

View File

@@ -517,10 +517,7 @@ HTMLMediaElement::IsVideo()
already_AddRefed<MediaSource>
HTMLMediaElement::GetMozMediaSourceObject() const
{
nsRefPtr<MediaSource> source;
if (mLoadingSrc && IsMediaSourceURI(mLoadingSrc)) {
NS_GetSourceForMediaSourceURI(mLoadingSrc, getter_AddRefs(source));
}
nsRefPtr<MediaSource> source = mMediaSource;
return source.forget();
}
@@ -871,6 +868,7 @@ void HTMLMediaElement::SelectResource()
"Should think we're not loading from source children by default");
mLoadingSrc = uri;
mMediaSource = mSrcMediaSource;
UpdatePreloadAction();
if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE &&
!IsMediaStreamURI(mLoadingSrc)) {
@@ -1008,6 +1006,7 @@ void HTMLMediaElement::LoadFromSourceChildren()
}
mLoadingSrc = uri;
mMediaSource = childSrc->GetSrcMediaSource();
NS_ASSERTION(mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING,
"Network state should be loading");
@@ -1202,24 +1201,14 @@ nsresult HTMLMediaElement::LoadResource()
return NS_OK;
}
if (IsMediaSourceURI(mLoadingSrc)) {
nsRefPtr<MediaSource> source;
rv = NS_GetSourceForMediaSourceURI(mLoadingSrc, getter_AddRefs(source));
if (NS_FAILED(rv)) {
nsAutoString spec;
GetCurrentSrc(spec);
const char16_t* params[] = { spec.get() };
ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
return rv;
}
if (mMediaSource) {
nsRefPtr<MediaSourceDecoder> decoder = new MediaSourceDecoder(this);
if (!source->Attach(decoder)) {
if (!mMediaSource->Attach(decoder)) {
// TODO: Handle failure: run "If the media data cannot be fetched at
// all, due to network errors, causing the user agent to give up
// trying to fetch the resource" section of resource fetch algorithm.
return NS_ERROR_FAILURE;
}
mMediaSource = source.forget();
nsRefPtr<MediaResource> resource =
MediaSourceDecoder::CreateResource(mMediaSource->GetPrincipal());
if (IsAutoplayEnabled()) {
@@ -3279,6 +3268,7 @@ void HTMLMediaElement::DecodeError()
ShutdownDecoder();
}
mLoadingSrc = nullptr;
mMediaSource = nullptr;
if (mIsLoadingFromSourceChildren) {
mError = nullptr;
if (mSourceLoadCandidate) {