Commit ddea6907 authored by Marian-Vasile Laza's avatar Marian-Vasile Laza
Browse files

Backed out 4 changesets (bug 1821803) for build bustages on MFMediaEngineParent.cpp. CLOSED TREE

Backed out changeset 75db8a0db46f (bug 1821803)
Backed out changeset ec91bc6abbd4 (bug 1821803)
Backed out changeset a2ddd3db75c2 (bug 1821803)
Backed out changeset 14892860eaee (bug 1821803)
parent b9acf99c
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
@@ -448,9 +448,6 @@ RefPtr<ShutdownPromise> ExternalEngineStateMachine::Shutdown() {

  mMetadataManager.Disconnect();

  mSetCDMProxyPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_ABORT_ERR, __func__);
  mSetCDMProxyRequest.DisconnectIfExists();

  mEngine->Shutdown();

  auto* state = mState.AsShutdownEngine();
@@ -1033,38 +1030,10 @@ void ExternalEngineStateMachine::UpdateSecondaryVideoContainer() {

RefPtr<SetCDMPromise> ExternalEngineStateMachine::SetCDMProxy(
    CDMProxy* aProxy) {
  if (mState.IsShutdownEngine()) {
    return SetCDMPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
  }

  if (mState.IsInitEngine() && mState.AsInitEngine()->mInitPromise) {
    LOG("SetCDMProxy is called before init");
    mState.AsInitEngine()->mInitPromise->Then(
        OwnerThread(), __func__,
        [self = RefPtr{this}, proxy = RefPtr{aProxy},
         this](const GenericNonExclusivePromise::ResolveOrRejectValue& aVal) {
          SetCDMProxy(proxy)
              ->Then(OwnerThread(), __func__,
                     [self = RefPtr{this},
                      this](const SetCDMPromise::ResolveOrRejectValue& aVal) {
                       mSetCDMProxyRequest.Complete();
                       if (aVal.IsResolve()) {
                         mSetCDMProxyPromise.Resolve(true, __func__);
                       } else {
                         mSetCDMProxyPromise.Reject(NS_ERROR_DOM_MEDIA_CDM_ERR,
                                                    __func__);
                       }
                     })
              ->Track(mSetCDMProxyRequest);
        });
    return mSetCDMProxyPromise.Ensure(__func__);
  }

  // TODO : set CDM proxy again if we recreate the media engine after crash.
  LOG("SetCDMProxy=%p", aProxy);
  MOZ_DIAGNOSTIC_ASSERT(mEngine);
  if (!mEngine->SetCDMProxy(aProxy)) {
    LOG("Failed to set CDM proxy on the engine");
    return SetCDMPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CDM_ERR, __func__);
  }
  return MediaDecoderStateMachineBase::SetCDMProxy(aProxy);
+0 −4
Original line number Diff line number Diff line
@@ -286,10 +286,6 @@ class ExternalEngineStateMachine final
  bool mHasEnoughVideo = false;
  bool mSentPlaybackEndedEvent = false;
  bool mHasReceivedFirstDecodedVideoFrame = false;

  // Only used if setting CDM happens before the engine finishes initialization.
  MozPromiseHolder<SetCDMPromise> mSetCDMProxyPromise;
  MozPromiseRequestHolder<SetCDMPromise> mSetCDMProxyRequest;
};

class ExternalPlaybackEngine {
+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, encrypted=%d", aInfo.HasAudio(),
       aInfo.HasVideo(), aInfo.IsEncrypted());
  WLOG("SetMediaInfo, hasAudio=%d, hasVideo=%d", aInfo.HasAudio(),
       aInfo.HasVideo());
  MOZ_ASSERT(IsInited());
  Unused << ManagerThread()->Dispatch(NS_NewRunnableFunction(
      "MFMediaEngineWrapper::SetMediaInfo", [engine = mEngine, aInfo] {
+16 −48
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ mozilla::ipc::IPCResult MFMediaEngineParent::RecvNotifyMediaInfo(

  auto errorExit = MakeScopeExit([&] {
    MediaResult error(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                      "Failed to create media source");
                      "Failed to setup media source");
    DestroyEngineIfExists(Some(error));
  });

@@ -384,59 +384,28 @@ mozilla::ipc::IPCResult MFMediaEngineParent::RecvNotifyMediaInfo(
      SUCCEEDED(MakeAndInitialize<MFMediaSource>(
          &mMediaSource, aInfo.audioInfo(), aInfo.videoInfo(), mManagerThread)),
      IPC_OK());

  const bool isEncryted = mMediaSource->IsEncrypted();
  ENGINE_MARKER("MFMediaEngineParent,CreatedMediaSource");
  nsPrintfCString message(
      "Created the media source, audio=%s, video=%s, encrypted-audio=%s, "
      "encrypted-video=%s, isEncrypted=%d",
      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",
      isEncryted);
  LOG("%s", message.get());

  mRequestSampleListener = mMediaSource->RequestSampleEvent().Connect(
      mManagerThread, this, &MFMediaEngineParent::HandleRequestSample);
  errorExit.release();

  if (isEncryted && !mContentProtectionManager) {
    // We will set the source later when the CDM proxy is ready.
    return IPC_OK();
  }

  if (isEncryted && mContentProtectionManager) {
    auto* proxy = mContentProtectionManager->GetCDMProxy();
    MOZ_ASSERT(proxy);
    mMediaSource->SetCDMProxy(proxy);
  }
  SetMediaSourceOnEngine();
  return IPC_OK();
}

void MFMediaEngineParent::SetMediaSourceOnEngine() {
  AssertOnManagerThread();
  MOZ_ASSERT(mMediaSource);

  auto errorExit = MakeScopeExit([&] {
    MediaResult error(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                      "Failed to set media source");
    DestroyEngineIfExists(Some(error));
  });

  mMediaEngineExtension->SetMediaSource(mMediaSource.Get());

  // We use the source scheme in order to let the media engine to load our
  // custom source.
  RETURN_VOID_IF_FAILED(
      mMediaEngine->SetSource(SysAllocString(L"MFRendererSrc")));
  NS_ENSURE_TRUE(
      SUCCEEDED(mMediaEngine->SetSource(SysAllocString(L"MFRendererSrc"))),
      IPC_OK());

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

  errorExit.release();
  return IPC_OK();
}

mozilla::ipc::IPCResult MFMediaEngineParent::RecvPlay() {
@@ -521,7 +490,6 @@ mozilla::ipc::IPCResult MFMediaEngineParent::RecvSetCDMProxyId(
  // handle that as well.
  if (mMediaSource) {
    mMediaSource->SetCDMProxy(proxy);
    SetMediaSourceOnEngine();
  }
  LOG("Set CDM Proxy successfully on the media engine!");
#endif
+0 −2
Original line number Diff line number Diff line
@@ -86,8 +86,6 @@ class MFMediaEngineParent final : public PMFMediaEngineParent {

  void UpdateStatisticsData();

  void SetMediaSourceOnEngine();

  // This generates unique id for each MFMediaEngineParent instance, and it
  // would be increased monotonically.
  static inline uint64_t sMediaEngineIdx = 0;
Loading