Commit 56358f1e authored by alwu's avatar alwu
Browse files

Bug 1821803 - part1 : serialize crypto info over IPC. r=jolin

This patch makes `MFMediaEngineStream::IsEncrypted()` return correct
result by checking the serialized crypto information.

Differential Revision: https://phabricator.services.mozilla.com/D172486
parent 8b0116c8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -337,8 +337,8 @@ void MFMediaEngineWrapper::NotifyEndOfStream(TrackInfo::TrackType aType) {
}

void MFMediaEngineWrapper::SetMediaInfo(const MediaInfo& aInfo) {
  WLOG("SetMediaInfo, hasAudio=%d, hasVideo=%d", aInfo.HasAudio(),
       aInfo.HasVideo());
  WLOG("SetMediaInfo, hasAudio=%d, hasVideo=%d, encrypted=%d", aInfo.HasAudio(),
       aInfo.HasVideo(), aInfo.IsEncrypted());
  MOZ_ASSERT(IsInited());
  Unused << ManagerThread()->Dispatch(NS_NewRunnableFunction(
      "MFMediaEngineWrapper::SetMediaInfo", [engine = mEngine, aInfo] {
+11 −9
Original line number Diff line number Diff line
@@ -392,15 +392,17 @@ mozilla::ipc::IPCResult MFMediaEngineParent::RecvNotifyMediaInfo(
      SUCCEEDED(mMediaEngine->SetSource(SysAllocString(L"MFRendererSrc"))),
      IPC_OK());

  LOG("Finished setup our custom media source to the media engine");
  ENGINE_MARKER_TEXT(
      "MFMediaEngineParent,FinishedSetupMediaSource",
      nsPrintfCString(
          "audio=%s, video=%s",
          aInfo.audioInfo() ? aInfo.audioInfo()->mMimeType.BeginReading()
                            : "none",
          aInfo.videoInfo() ? aInfo.videoInfo()->mMimeType.BeginReading()
                            : "none"));
  nsPrintfCString message(
      "Finished setup our custom media source to the media engine, audio=%s, "
      "video=%s, encrypted-audio=%s, encrypted-video=%s",
      aInfo.audioInfo() ? aInfo.audioInfo()->mMimeType.BeginReading() : "none",
      aInfo.videoInfo() ? aInfo.videoInfo()->mMimeType.BeginReading() : "none",
      aInfo.audioInfo() && aInfo.audioInfo()->mCrypto.IsEncrypted() ? "yes"
                                                                    : "no",
      aInfo.videoInfo() && aInfo.videoInfo()->mCrypto.IsEncrypted() ? "yes"
                                                                    : "no");
  LOG("%s", message.get());
  ENGINE_MARKER_TEXT("MFMediaEngineParent,FinishedSetupMediaSource", message);
  mRequestSampleListener = mMediaSource->RequestSampleEvent().Connect(
      mManagerThread, this, &MFMediaEngineParent::HandleRequestSample);

+20 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "mozilla/EnumSet.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/dom/MFCDMSerializers.h"

namespace IPC {
template <>
@@ -40,6 +41,7 @@ struct ParamTraits<mozilla::VideoInfo> {
    WriteParam(aWriter, aParam.mTransferFunction);
    WriteParam(aWriter, aParam.mColorRange);
    WriteParam(aWriter, aParam.HasAlpha());
    WriteParam(aWriter, aParam.mCrypto);
  }

  static bool Read(MessageReader* aReader, paramType* aResult) {
@@ -58,7 +60,8 @@ struct ParamTraits<mozilla::VideoInfo> {
        ReadParam(aReader, &aResult->mColorPrimaries) &&
        ReadParam(aReader, &aResult->mTransferFunction) &&
        ReadParam(aReader, &aResult->mColorRange) &&
        ReadParam(aReader, &alphaPresent)) {
        ReadParam(aReader, &alphaPresent) &&
        ReadParam(aReader, &aResult->mCrypto)) {
      aResult->SetAlpha(alphaPresent);
      return true;
    }
@@ -182,6 +185,7 @@ struct ParamTraits<mozilla::AudioInfo> {
    WriteParam(aWriter, aParam.mProfile);
    WriteParam(aWriter, aParam.mExtendedProfile);
    WriteParam(aWriter, aParam.mCodecSpecificConfig);
    WriteParam(aWriter, aParam.mCrypto);
  }

  static bool Read(MessageReader* aReader, paramType* aResult) {
@@ -192,7 +196,8 @@ struct ParamTraits<mozilla::AudioInfo> {
        ReadParam(aReader, &aResult->mBitDepth) &&
        ReadParam(aReader, &aResult->mProfile) &&
        ReadParam(aReader, &aResult->mExtendedProfile) &&
        ReadParam(aReader, &aResult->mCodecSpecificConfig)) {
        ReadParam(aReader, &aResult->mCodecSpecificConfig) &&
        ReadParam(aReader, &aResult->mCrypto)) {
      return true;
    }
    return false;
@@ -345,6 +350,19 @@ struct ParamTraits<mozilla::TrackingId> {
  }
};

template <>
struct ParamTraits<mozilla::CryptoTrack> {
  typedef mozilla::CryptoTrack paramType;

  static void Write(MessageWriter* aWriter, const paramType& aParam) {
    WriteParam(aWriter, aParam.mCryptoScheme);
  }

  static bool Read(MessageReader* aReader, paramType* aResult) {
    return ReadParam(aReader, &aResult->mCryptoScheme);
  }
};

}  // namespace IPC

#endif  // mozilla_dom_media_MediaIPCUtils_h
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ EXPORTS.mozilla += [

EXPORTS.mozilla.dom += [
    "MediaIPCUtils.h",
    "MFCDMSerializers.h",
]

SOURCES += [
+3 −2
Original line number Diff line number Diff line
@@ -68,8 +68,9 @@ HRESULT MFMediaEngineAudioStream::CreateMediaType(const TrackInfo& aInfo,
        MF_MT_USER_DATA, mAACUserData.Elements(), mAACUserData.Length()));
  }
  LOGV("Created audio type, subtype=%s, channel=%" PRIu32 ", rate=%" PRIu32
       ", bitDepth=%" PRIu64,
       GUIDToStr(subType), info.mChannels, info.mRate, bitDepth);
       ", bitDepth=%" PRIu64 ", encrypted=%d",
       GUIDToStr(subType), info.mChannels, info.mRate, bitDepth,
       mAudioInfo.mCrypto.IsEncrypted());

  *aMediaType = mediaType.Detach();
  return S_OK;
Loading