diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index 79f380a3ad01..a3609e65e38c 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -88,6 +88,41 @@ static bool IsVP9Forced(DecoderDoctorDiagnostics* aDiagnostics) { namespace dom { +static void RecordTypeForTelemetry(const nsAString& aType, + nsPIDOMWindowInner* aWindow) { + Maybe containerType = MakeMediaContainerType(aType); + if (!containerType) { + return; + } + + const MediaMIMEType& mimeType = containerType->Type(); + if (mimeType == MEDIAMIMETYPE(VIDEO_WEBM)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::VideoWebm); + } else if (mimeType == MEDIAMIMETYPE(AUDIO_WEBM)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::AudioWebm); + } else if (mimeType == MEDIAMIMETYPE(VIDEO_MP4)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::VideoMp4); + } else if (mimeType == MEDIAMIMETYPE(AUDIO_MP4)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::AudioMp4); + } else if (mimeType == MEDIAMIMETYPE(VIDEO_MPEG_TS)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::VideoMp2t); + } else if (mimeType == MEDIAMIMETYPE(AUDIO_MPEG_TS)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::AudioMp2t); + } else if (mimeType == MEDIAMIMETYPE(AUDIO_MP3)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::AudioMpeg); + } else if (mimeType == MEDIAMIMETYPE(AUDIO_AAC)) { + AccumulateCategorical( + mozilla::Telemetry::LABELS_MSE_SOURCE_BUFFER_TYPE::AudioAac); + } +} + /* static */ void MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics, @@ -241,6 +276,7 @@ already_AddRefed MediaSource::AddSourceBuffer( MOZ_ASSERT(NS_IsMainThread()); DecoderDoctorDiagnostics diagnostics; IsTypeSupported(aType, &diagnostics, aRv); + RecordTypeForTelemetry(aType, GetOwner()); bool supported = !aRv.Failed(); diagnostics.StoreFormatDiagnostics( GetOwner() ? GetOwner()->GetExtantDoc() : nullptr, aType, supported, @@ -394,6 +430,7 @@ bool MediaSource::IsTypeSupported(const GlobalObject& aOwner, bool supported = !rv.Failed(); nsCOMPtr window = do_QueryInterface(aOwner.GetAsSupports()); + RecordTypeForTelemetry(aType, window); diagnostics.StoreFormatDiagnostics(window ? window->GetExtantDoc() : nullptr, aType, supported, __func__); MOZ_LOG(GetMediaSourceAPILog(), mozilla::LogLevel::Debug, diff --git a/netwerk/mime/nsMimeTypes.h b/netwerk/mime/nsMimeTypes.h index 210e97a09446..6f9ad7f76563 100644 --- a/netwerk/mime/nsMimeTypes.h +++ b/netwerk/mime/nsMimeTypes.h @@ -90,6 +90,7 @@ #define AUDIO_MIDI "audio/x-midi" #define AUDIO_MATROSKA "audio/x-matroska" #define AUDIO_AAC "audio/aac" +#define AUDIO_MPEG_TS "audio/mp2t" #define BINARY_OCTET_STREAM "binary/octet-stream" diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 8477b8810a18..1021507978a6 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -13291,6 +13291,17 @@ "releaseChannelCollection": "opt-out", "description": "Count of use of audio/video codecs in HTMLMediaElements and WebAudio. Those with 'resource' prefix are approximate; report based on HTTP ContentType or sniffing. Those with 'webaudio' prefix are for WebAudio." }, + "MSE_SOURCE_BUFFER_TYPE": { + "products": ["firefox", "geckoview_streaming"], + "record_in_processes": ["main", "content"], + "alert_emails": ["alwu@mozilla.com", "bryce@mozilla.com"], + "bug_numbers": [1699249], + "expires_in_version": "never", + "kind": "categorical", + "labels": ["VideoWebm", "AudioWebm", "VideoMp4", "AudioMp4", "VideoMp2t", "AudioMp2t", "AudioMpeg", "AudioAac"], + "releaseChannelCollection": "opt-out", + "description": "Count the actual or possible (because we don't support some of them for now) usage amount for each media mime type used in MSE. We collect this data in MediaSource's `AddSourceBuffer()` and `IsTypeSupported()`." + }, "FX_SANITIZE_TOTAL": { "record_in_processes": ["main", "content"], "products": ["firefox", "fennec"],