Bug 1262659 - Report HTTP Live Streaming playback requests. r?cpearce
Identify HLS media types (and related m3u playlists) and report
telemetry about how often we fail to play them. This is designed
to measure popularity to inform decisions about support for this.
MozReview-Commit-ID: Fp8lNMOJKyA
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -4,16 +4,17 @@
* 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 "DecoderTraits.h"
#include "MediaDecoder.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsMimeTypes.h"
#include "mozilla/Preferences.h"
+#include "mozilla/Telemetry.h"
#include "OggDecoder.h"
#include "OggReader.h"
#include "WebMDecoder.h"
#include "WebMDemuxer.h"
#ifdef MOZ_RAW
@@ -167,16 +168,31 @@ DecoderTraits::IsWebMTypeAndEnabled(cons
}
/* static */ bool
DecoderTraits::IsWebMAudioType(const nsACString& aType)
{
return aType.EqualsASCII("audio/webm");
}
+static char const *const gHttpLiveStreamingTypes[] = {
+ // For m3u8.
+ // https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10
+ "application/vnd.apple.mpegurl",
+ // Some sites serve these as the informal m3u type.
+ "audio/x-mpegurl",
+ nullptr
+};
+
+static bool
+IsHttpLiveStreamingType(const nsACString& aType)
+{
+ return CodecListContains(gHttpLiveStreamingTypes, aType);
+}
+
#ifdef MOZ_OMX_DECODER
static const char* const gOmxTypes[] = {
"audio/mpeg",
"audio/mp4",
"audio/amr",
"audio/3gpp",
"audio/flac",
"video/mp4",
@@ -466,16 +482,20 @@ DecoderTraits::CanHandleCodecsType(const
/* static */
CanPlayStatus
DecoderTraits::CanHandleMediaType(const char* aMIMEType,
bool aHaveRequestedCodecs,
const nsAString& aRequestedCodecs)
{
MOZ_ASSERT(NS_IsMainThread());
+ if (IsHttpLiveStreamingType(nsDependentCString(aMIMEType))) {
+ Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
+ }
+
if (aHaveRequestedCodecs) {
CanPlayStatus result = CanHandleCodecsType(aMIMEType, aRequestedCodecs);
if (result == CANPLAY_NO || result == CANPLAY_YES) {
return result;
}
}
#ifdef MOZ_RAW
if (IsRawType(nsDependentCString(aMIMEType))) {
@@ -606,16 +626,21 @@ InstantiateDecoder(const nsACString& aTy
// Note: DirectShow should come before WMF, so that we prefer DirectShow's
// MP3 support over WMF's.
if (IsDirectShowSupportedType(aType)) {
decoder = new DirectShowDecoder(aOwner);
return decoder.forget();
}
#endif
+ if (IsHttpLiveStreamingType(aType)) {
+ // We don't have an HLS decoder.
+ Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false);
+ }
+
return nullptr;
}
/* static */
already_AddRefed<MediaDecoder>
DecoderTraits::CreateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner)
{
MOZ_ASSERT(NS_IsMainThread());
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6221,16 +6221,31 @@
},
"MEDIA_OGG_LOADED_IS_CHAINED": {
"alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "53",
"kind": "boolean",
"description": "Whether Ogg audio/video encountered are chained or not.",
"bug_numbers": [1230295]
},
+ "MEDIA_HLS_CANPLAY_REQUESTED": {
+ "alert_emails": ["ajones@mozilla.com", "giles@mozilla.com"],
+ "expires_in_version": "50",
+ "kind": "boolean",
+ "description": "Reports a true value when a page requests canPlayType for an HTTP Live Streaming media type (or generic m3u playlist).",
+ "bug_numbers": [1262659]
+ },
+ "MEDIA_HLS_DECODER_SUCCESS": {
+ "alert_emails": ["ajones@mozilla.com", "giles@mozilla.com"],
+ "expires_in_version": "50",
+ "kind": "boolean",
+ "description": "Reports whether a decoder for an HTTP Live Streaming media type was created when requested.",
+ "bug_numbers": [1262659]
+
+ },
"VIDEO_MFT_OUTPUT_NULL_SAMPLES": {
"alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "53",
"kind": "enumerated",
"n_values": 10,
"description": "Does the WMF video decoder return success but null output? 0 = playback successful, 1 = excessive null output but able to decode some frames, 2 = excessive null output and gave up, 3 = null output but recovered, 4 = non-excessive null output without being able to decode frames.",
"bug_numbers": [1176071]
},