Bug 1248507 - p3. Use DecoderDoctorDiagnostics - r=jya,bz
DecoderDoctorDiagnostics are now used at places where Firefox Chrome and/or websites checks whether some media formats may be played: - audio|video.canPlayType() - audio|video resource loader - MediaSource.IsTypeSupported() - MediaSource.AddSourceBuffer() MozReview-Commit-ID: B1KdjXODq9j
This commit is contained in:
@@ -86,6 +86,7 @@
|
||||
#include "mozilla/dom/TextTrack.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "DecoderDoctorDiagnostics.h"
|
||||
|
||||
#include "ImageContainer.h"
|
||||
#include "nsRange.h"
|
||||
@@ -1061,12 +1062,19 @@ void HTMLMediaElement::LoadFromSourceChildren()
|
||||
|
||||
// If we have a type attribute, it must be a supported type.
|
||||
nsAutoString type;
|
||||
if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type) &&
|
||||
GetCanPlay(type) == CANPLAY_NO) {
|
||||
DispatchAsyncSourceError(child);
|
||||
const char16_t* params[] = { type.get(), src.get() };
|
||||
ReportLoadError("MediaLoadUnsupportedTypeAttribute", params, ArrayLength(params));
|
||||
continue;
|
||||
if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type)) {
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
CanPlayStatus canPlay = GetCanPlay(type, &diagnostics);
|
||||
if (canPlay != CANPLAY_NO) {
|
||||
diagnostics.SetCanPlay();
|
||||
}
|
||||
diagnostics.StoreDiagnostics(OwnerDoc(), type, __func__);
|
||||
if (canPlay == CANPLAY_NO) {
|
||||
DispatchAsyncSourceError(child);
|
||||
const char16_t* params[] = { type.get(), src.get() };
|
||||
ReportLoadError("MediaLoadUnsupportedTypeAttribute", params, ArrayLength(params));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
nsAutoString media;
|
||||
HTMLSourceElement *childSrc = HTMLSourceElement::FromContent(child);
|
||||
@@ -2884,7 +2892,8 @@ void HTMLMediaElement::UnbindFromTree(bool aDeep,
|
||||
|
||||
/* static */
|
||||
CanPlayStatus
|
||||
HTMLMediaElement::GetCanPlay(const nsAString& aType)
|
||||
HTMLMediaElement::GetCanPlay(const nsAString& aType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics)
|
||||
{
|
||||
nsContentTypeParser parser(aType);
|
||||
nsAutoString mimeType;
|
||||
@@ -2899,13 +2908,19 @@ HTMLMediaElement::GetCanPlay(const nsAString& aType)
|
||||
return DecoderTraits::CanHandleMediaType(mimeTypeUTF8.get(),
|
||||
NS_SUCCEEDED(rv),
|
||||
codecs,
|
||||
/* DecoderDoctorDiagnostics* */ nullptr);
|
||||
aDiagnostics);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
|
||||
{
|
||||
switch (GetCanPlay(aType)) {
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
CanPlayStatus canPlay = GetCanPlay(aType, &diagnostics);
|
||||
if (canPlay != CANPLAY_NO) {
|
||||
diagnostics.SetCanPlay();
|
||||
}
|
||||
diagnostics.StoreDiagnostics(OwnerDoc(), aType, __func__);
|
||||
switch (canPlay) {
|
||||
case CANPLAY_NO:
|
||||
aResult.Truncate();
|
||||
break;
|
||||
@@ -2965,9 +2980,15 @@ nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
|
||||
aChannel->GetContentType(mimeType);
|
||||
NS_ASSERTION(!mimeType.IsEmpty(), "We should have the Content-Type.");
|
||||
|
||||
DecoderDoctorDiagnostics diagnostics;
|
||||
RefPtr<MediaDecoder> decoder =
|
||||
DecoderTraits::CreateDecoder(mimeType, this,
|
||||
/* DecoderDoctorDiagnostics* */ nullptr);
|
||||
DecoderTraits::CreateDecoder(mimeType, this, &diagnostics);
|
||||
if (decoder) {
|
||||
diagnostics.SetCanPlay();
|
||||
}
|
||||
diagnostics.StoreDiagnostics(OwnerDoc(),
|
||||
NS_ConvertASCIItoUTF16(mimeType),
|
||||
__func__);
|
||||
if (!decoder) {
|
||||
nsAutoString src;
|
||||
GetCurrentSrc(src);
|
||||
|
||||
Reference in New Issue
Block a user