Bug 1429986 - send telemetry data when users attempt to play mkv file. r?jwwang,liuche draft
authorAlfredo.Yang <ayang@mozilla.com>
Fri, 12 Jan 2018 15:40:52 +0800
changeset 721902 fd786e3878c50af64280d51a27865b5cecc802ef
parent 721830 b7a651281314d6369658eeb58e3bb181cf95016f
child 746478 6af8c3ca2d19c7c813bc19671ec149a0a1762aee
push id95993
push userbmo:ayang@mozilla.com
push dateThu, 18 Jan 2018 02:27:30 +0000
reviewersjwwang, liuche
bugs1429986
milestone59.0a1
Bug 1429986 - send telemetry data when users attempt to play mkv file. r?jwwang,liuche MozReview-Commit-ID: Ah3pXC4cJ7n
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
toolkit/components/telemetry/Histograms.json
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -52,16 +52,25 @@ DecoderTraits::IsHttpLiveStreamingType(c
     mimeType == MEDIAMIMETYPE("application/vnd.apple.mpegurl") ||
     // Some sites serve these as the informal m3u type.
     mimeType == MEDIAMIMETYPE("application/x-mpegurl") ||
     mimeType == MEDIAMIMETYPE("audio/mpegurl") ||
     mimeType == MEDIAMIMETYPE("audio/x-mpegurl");
 }
 
 /* static */ bool
+DecoderTraits::IsMatroskaType(const MediaContainerType& aType)
+{
+  const auto& mimeType = aType.Type();
+  // https://matroska.org/technical/specs/notes.html
+  return mimeType == MEDIAMIMETYPE("audio/x-matroska") ||
+         mimeType == MEDIAMIMETYPE("video/x-matroska");
+}
+
+/* static */ bool
 DecoderTraits::IsMP4SupportedType(const MediaContainerType& aType,
                                   DecoderDoctorDiagnostics* aDiagnostics)
 {
 #ifdef MOZ_FMP4
   return MP4Decoder::IsSupportedType(aType, aDiagnostics);
 #else
   return false;
 #endif
@@ -136,16 +145,18 @@ CanHandleMediaType(const MediaContainerT
 #ifdef MOZ_ANDROID_HLS_SUPPORT
   if (HLSDecoder::IsSupportedType(aType)) {
     return CANPLAY_MAYBE;
   }
 #endif
 
   if (DecoderTraits::IsHttpLiveStreamingType(aType)) {
     Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
+  } else if (DecoderTraits::IsMatroskaType(aType)) {
+    Telemetry::Accumulate(Telemetry::MEDIA_MKV_CANPLAY_REQUESTED, true);
   }
 
   if (aType.ExtendedType().HaveCodecs()) {
     CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
     if (result == CANPLAY_NO || result == CANPLAY_YES) {
       return result;
     }
   }
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -48,15 +48,18 @@ public:
   // Convenience function that returns false if MOZ_FMP4 is not defined,
   // otherwise defers to MP4Decoder::IsSupportedType().
   static bool IsMP4SupportedType(const MediaContainerType& aType,
                                  DecoderDoctorDiagnostics* aDiagnostics);
 
   // Returns true if aType is MIME type of hls.
   static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
 
+  // Returns true if aType is matroska type.
+  static bool IsMatroskaType(const MediaContainerType& aType);
+
   static bool IsSupportedType(const MediaContainerType& aType);
 };
 
 } // namespace mozilla
 
 #endif
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8594,16 +8594,24 @@
   "MEDIA_EME_SECURE_CONTEXT": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com", "jacheng@mozilla.com"],
     "expires_in_version": "63",
     "kind": "boolean",
     "description": "Reports whether a navigator.requestMediaKeySystemAccess() was called in a secure context (i.e. on an origin served over HTTPS) or not.",
     "bug_numbers": [1360438]
   },
+  "MEDIA_MKV_CANPLAY_REQUESTED": {
+    "record_in_processes": ["main", "content"],
+    "alert_emails": ["ayang@mozilla.com"],
+    "expires_in_version": "65",
+    "kind": "boolean",
+    "description": "Reports a true value when a page requests canPlayType for a matroska media type.",
+    "bug_numbers": [1429986]
+  },
   "MEDIA_EME_REQUEST_DEPRECATED_WARNINGS": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com", "jacheng@mozilla.com"],
     "bug_numbers": [1368596],
     "expires_in_version": "63",
     "kind": "enumerated",
     "n_values": 10,
     "description": "Counts types of deprecation warnings logged on every successful call to navigator.requestMediaKeySystemAccess(). 0=No warnings logged, 1=MediaEMENoCapabilitiesDeprecatedWarning, 2=MediaEMENoCodecsDeprecatedWarning."