Commit 61fa12f8 authored by Alexandre Lissy's avatar Alexandre Lissy
Browse files

Bug 1831052 - Record audio codec process when FinishDecodeFirstFrame() runs r=padenot

parent 4652dce5
Loading
Loading
Loading
Loading
+24 −14
Original line number Diff line number Diff line
@@ -477,20 +477,8 @@ void MediaFormatReader::DecoderFactory::DoInitDecoder(Data& aData) {
                  ownerData.GetCurrentInfo()->mMimeType);
            }
            if (aTrack == TrackInfo::kAudioTrack) {
              nsCString processName = ownerData.mDecoder->GetProcessName();
              nsCString audioProcessPerCodecName(
                  processName + ","_ns + ownerData.mDecoder->GetCodecName());
              if (processName != "utility"_ns) {
                if (!StaticPrefs::media_rdd_process_enabled()) {
                  audioProcessPerCodecName += ",rdd-disabled"_ns;
                }
                if (!StaticPrefs::media_utility_process_enabled()) {
                  audioProcessPerCodecName += ",utility-disabled"_ns;
                }
              }
              Telemetry::ScalarAdd(
                  Telemetry::ScalarID::MEDIA_AUDIO_PROCESS_PER_CODEC_NAME,
                  NS_ConvertUTF8toUTF16(audioProcessPerCodecName), 1);
              ownerData.mProcessName = ownerData.mDecoder->GetProcessName();
              ownerData.mCodecName = ownerData.mDecoder->GetCodecName();
            }
          },
          [this, &aData, &ownerData](const MediaResult& aError) {
@@ -1373,6 +1361,10 @@ void MediaFormatReader::ReadUpdatedMetadata(MediaInfo* aInfo) {
    MutexAutoLock lock(mAudio.mMutex);
    if (HasAudio()) {
      aInfo->mAudio = *mAudio.GetWorkingInfo()->GetAsAudioInfo();
      nsCString audioProcessPerCodecName = GetAudioProcessPerCodec();
      Telemetry::ScalarAdd(
          Telemetry::ScalarID::MEDIA_AUDIO_PROCESS_PER_CODEC_NAME,
          NS_ConvertUTF8toUTF16(audioProcessPerCodecName), 1);
    }
  }
}
@@ -3248,6 +3240,24 @@ RefPtr<GenericPromise> MediaFormatReader::RequestDebugInfo(
  return GenericPromise::CreateAndResolve(true, __func__);
}

nsCString MediaFormatReader::GetAudioProcessPerCodec() {
  MOZ_ASSERT(mAudio.mProcessName.Length() > 0,
             "Should have had a process name");
  MOZ_ASSERT(mAudio.mCodecName.Length() > 0, "Should have had a codec name");

  nsCString processName = mAudio.mProcessName;
  nsCString audioProcessPerCodecName(processName + ","_ns + mAudio.mCodecName);
  if (processName != "utility"_ns) {
    if (!StaticPrefs::media_rdd_process_enabled()) {
      audioProcessPerCodecName += ",rdd-disabled"_ns;
    }
    if (!StaticPrefs::media_utility_process_enabled()) {
      audioProcessPerCodecName += ",utility-disabled"_ns;
    }
  }
  return audioProcessPerCodecName;
}

void MediaFormatReader::GetDebugInfo(dom::MediaFormatReaderDebugInfo& aInfo) {
  MOZ_ASSERT(OnTaskQueue(),
             "Don't call this off the task queue, it's going to touch a lot of "
+8 −2
Original line number Diff line number Diff line
@@ -194,6 +194,8 @@ class MediaFormatReader final
  RefPtr<GenericPromise> RequestDebugInfo(
      dom::MediaFormatReaderDebugInfo& aInfo);

  nsCString GetAudioProcessPerCodec();

  // Switch the video decoder to NullDecoderModule. It might takes effective
  // since a few samples later depends on how much demuxed samples are already
  // queued in the original video decoder.
@@ -364,6 +366,8 @@ class MediaFormatReader final
          mType(aType),
          mMutex("DecoderData"),
          mDescription("shutdown"),
          mProcessName(""),
          mCodecName(""),
          mUpdateScheduled(false),
          mDemuxEOS(false),
          mWaitingForData(false),
@@ -407,14 +411,16 @@ class MediaFormatReader final
    // Only non-null up until the decoder is created.
    RefPtr<TaskQueue> mTaskQueue;

    // Mutex protecting mDescription, mDecoder, mTrackDemuxer and mWorkingInfo
    // as those can be read outside the TaskQueue.
    // Mutex protecting mDescription, mDecoder, mTrackDemuxer, mWorkingInfo,
    // mProcessName and mCodecName as those can be read outside the TaskQueue.
    // They are only written on the TaskQueue however, as such mMutex doesn't
    // need to be held when those members are read on the TaskQueue.
    Mutex mMutex MOZ_UNANNOTATED;
    // The platform decoder.
    RefPtr<MediaDataDecoder> mDecoder;
    nsCString mDescription;
    nsCString mProcessName;
    nsCString mCodecName;
    void ShutdownDecoder();

    // Only accessed from reader's task queue.
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ async function verifyTelemetryForProcess(process, codecNames, extraKey = "") {
  // But we dont care really we just want to ensure 0 on RDD, Content and others
  // in the wild.[${codecName}]
  codecNames.forEach(codecName => {
    Assert.greaterOrEqual(
    Assert.equal(
      telemetry[MEDIA_AUDIO_PROCESS][`${process},${codecName}${extraKey}`],
      1,
      `${MEDIA_AUDIO_PROCESS} must have the correct value (${process}, ${codecName}).`