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 719452 e353a3aa0c8ed9aae0c98dea32ec03848615b4de
parent 719367 f7f5ba2214d2ce7b1ce9647b0e2540490a6098a8
child 745809 83dd2ad560894b9372072f29ce27a4b4580bc62d
push id95270
push userbmo:ayang@mozilla.com
push dateFri, 12 Jan 2018 08:16:53 +0000
reviewersjwwang, liuche
bugs1429986
milestone59.0a1
Bug 1429986 - send telemetry data when users attempt to play mkv file. r?jwwang,liuche MozReview-Commit-ID: BR7aWPTgfcW
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
@@ -138,16 +147,20 @@ CanHandleMediaType(const MediaContainerT
     return CANPLAY_MAYBE;
   }
 #endif
 
   if (DecoderTraits::IsHttpLiveStreamingType(aType)) {
     Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
   }
 
+  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;
     }
   }
 
   // Container type with just the MIME type/subtype, no codecs.
--- 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
@@ -8570,16 +8570,24 @@
   "MEDIA_EME_SECURE_CONTEXT": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com"],
     "expires_in_version": "60",
     "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]
+  },
   "VIDEO_CHROMIUM_CDM_MAX_SHMEMS": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com"],
     "bug_numbers": [1366639],
     "expires_in_version": "60",
     "kind": "enumerated",
     "n_values": 50,
     "description": "Counts of the maximum number of shared memory buffers used for transferring video frames between the CDM and Gecko processes during playback of DRM'd video. Reported once per CDMVideoDecoder instance, i.e., once per JavaScript SourceBuffer during playback of video using EME."