зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299072: P10. Pass decoding error details to media element's error attribute. r=jwwang
MozReview-Commit-ID: 49DurV9WI5S --HG-- extra : rebase_source : 469e6ed4e222fb6d6ac34843c3c3346a044c6023
This commit is contained in:
Родитель
00e8a7dabc
Коммит
6a25692b20
|
@ -4341,7 +4341,7 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
|
|||
}
|
||||
if (mIsEncrypted) {
|
||||
if (!mMediaSource && Preferences::GetBool("media.eme.mse-only", true)) {
|
||||
DecodeError();
|
||||
DecodeError(NS_ERROR_DOM_MEDIA_FATAL_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4416,7 +4416,7 @@ void HTMLMediaElement::NetworkError()
|
|||
Error(nsIDOMMediaError::MEDIA_ERR_NETWORK);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::DecodeError()
|
||||
void HTMLMediaElement::DecodeError(const MediaResult& aError)
|
||||
{
|
||||
nsAutoString src;
|
||||
GetCurrentSrc(src);
|
||||
|
@ -4440,7 +4440,7 @@ void HTMLMediaElement::DecodeError()
|
|||
NS_WARNING("Should know the source we were loading from!");
|
||||
}
|
||||
} else {
|
||||
Error(nsIDOMMediaError::MEDIA_ERR_DECODE);
|
||||
Error(nsIDOMMediaError::MEDIA_ERR_DECODE, aError);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4454,7 +4454,8 @@ void HTMLMediaElement::LoadAborted()
|
|||
Error(nsIDOMMediaError::MEDIA_ERR_ABORTED);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::Error(uint16_t aErrorCode)
|
||||
void HTMLMediaElement::Error(uint16_t aErrorCode,
|
||||
const MediaResult& aErrorDetails)
|
||||
{
|
||||
NS_ASSERTION(aErrorCode == nsIDOMMediaError::MEDIA_ERR_DECODE ||
|
||||
aErrorCode == nsIDOMMediaError::MEDIA_ERR_NETWORK ||
|
||||
|
@ -4467,8 +4468,12 @@ void HTMLMediaElement::Error(uint16_t aErrorCode)
|
|||
if (mError) {
|
||||
return;
|
||||
}
|
||||
nsCString message;
|
||||
if (NS_FAILED(aErrorDetails)) {
|
||||
message = aErrorDetails.Description();
|
||||
}
|
||||
mError = new MediaError(this, aErrorCode, message);
|
||||
|
||||
mError = new MediaError(this, aErrorCode);
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
||||
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_EMPTY);
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
|
||||
// Called by the video decoder object, on the main thread, when the
|
||||
// resource has a decode error during metadata loading or decoding.
|
||||
virtual void DecodeError() final override;
|
||||
virtual void DecodeError(const MediaResult& aError) final override;
|
||||
|
||||
// Return true if error attribute is not null.
|
||||
virtual bool HasError() const final override;
|
||||
|
@ -1116,7 +1116,7 @@ protected:
|
|||
* Resets the media element for an error condition as per aErrorCode.
|
||||
* aErrorCode must be one of nsIDOMHTMLMediaError codes.
|
||||
*/
|
||||
void Error(uint16_t aErrorCode);
|
||||
void Error(uint16_t aErrorCode, const MediaResult& aErrorDetails = NS_OK);
|
||||
|
||||
/**
|
||||
* Returns the URL spec of the currentSrc.
|
||||
|
|
|
@ -21,9 +21,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaError)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMediaError)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MediaError::MediaError(HTMLMediaElement* aParent, uint16_t aCode)
|
||||
MediaError::MediaError(HTMLMediaElement* aParent, uint16_t aCode,
|
||||
const nsACString& aMessage)
|
||||
: mParent(aParent)
|
||||
, mCode(aCode)
|
||||
, mMessage(aMessage)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -37,6 +39,7 @@ NS_IMETHODIMP MediaError::GetCode(uint16_t* aCode)
|
|||
|
||||
NS_IMETHODIMP MediaError::GetMessage(nsAString& aResult)
|
||||
{
|
||||
CopyUTF8toUTF16(mMessage, aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ class MediaError final : public nsIDOMMediaError,
|
|||
~MediaError() {}
|
||||
|
||||
public:
|
||||
MediaError(HTMLMediaElement* aParent, uint16_t aCode);
|
||||
MediaError(HTMLMediaElement* aParent, uint16_t aCode,
|
||||
const nsACString& aMessage = nsCString());
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -48,6 +49,8 @@ private:
|
|||
|
||||
// Error code
|
||||
const uint16_t mCode;
|
||||
// Error details;
|
||||
const nsCString mMessage;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1016,7 +1016,7 @@ MediaDecoder::DecodeError(const MediaResult& aError)
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IsShutdown());
|
||||
mOwner->DecodeError();
|
||||
mOwner->DecodeError(aError);
|
||||
MOZ_ASSERT(IsShutdown());
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
class VideoFrameContainer;
|
||||
class MediaResult;
|
||||
|
||||
namespace dom {
|
||||
class HTMLMediaElement;
|
||||
|
@ -67,7 +68,7 @@ public:
|
|||
// resource has a decode error during metadata loading or decoding.
|
||||
// The decoder owner should call Shutdown() on the decoder and drop the
|
||||
// reference to the decoder to prevent further calls into the decoder.
|
||||
virtual void DecodeError() = 0;
|
||||
virtual void DecodeError(const MediaResult& aError) = 0;
|
||||
|
||||
// Return true if media element error attribute is not null.
|
||||
virtual bool HasError() const = 0;
|
||||
|
|
|
@ -88,7 +88,7 @@ MediaKeys::Terminated()
|
|||
|
||||
// Notify the element about that CDM has terminated.
|
||||
if (mElement) {
|
||||
mElement->DecodeError();
|
||||
mElement->DecodeError(NS_ERROR_DOM_MEDIA_CDM_ERR);
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
{
|
||||
}
|
||||
void NetworkError() override {}
|
||||
void DecodeError() override {}
|
||||
void DecodeError(const MediaResult& aError) override {}
|
||||
bool HasError() const override { return false; }
|
||||
void LoadAborted() override {}
|
||||
void PlaybackEnded() override {}
|
||||
|
|
|
@ -330,7 +330,7 @@ MediaSource::EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, Er
|
|||
mDecoder->NetworkError();
|
||||
break;
|
||||
case MediaSourceEndOfStreamError::Decode:
|
||||
mDecoder->DecodeError();
|
||||
mDecoder->DecodeError(NS_ERROR_DOM_MEDIA_FATAL_ERR);
|
||||
break;
|
||||
default:
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
||||
|
|
Загрузка…
Ссылка в новой задаче