[go: nahoru, domu]

media: Remove SetCdmReadyCB and CdmReadyCB (part 1).

RendererImpl and MediaSourceDelegate wait for CDM to be available to start initialization if any stream is encrypted. Since CDM is available, we can simply pass the CdmContext down and thus avoid the SetCdmReadyCB/CdmReadyCB/SetCdm round trip.

Also decoder initialization will not be associated with CdmAttachedCB any more. Instead, we'll only handle it in RendererImpl and MediaSourceDelegate based on the result of audio and video Renderer/Decoder/DecryptingDemuxerStream initialization.

This CL is part 1 where all decoders/renderers are fixed. In the next CL (part 2), DecryptingDemuxerStream and MediaSourceDelegate will be fixed.

TBR=alokp@chromium.org,bbudge@chromium.org
BUG=580250
TEST=Updated unittests.

Review URL: https://codereview.chromium.org/1666653002

Cr-Commit-Position: refs/heads/master@{#374835}
diff --git a/media/renderers/renderer_impl.h b/media/renderers/renderer_impl.h
index fc13ddbe..fc17f6c 100644
--- a/media/renderers/renderer_impl.h
+++ b/media/renderers/renderer_impl.h
@@ -77,7 +77,8 @@
  private:
   enum State {
     STATE_UNINITIALIZED,
-    STATE_INITIALIZING,
+    STATE_INIT_PENDING_CDM,  // Initialization is waiting for the CDM to be set.
+    STATE_INITIALIZING,      // Initializing audio/video renderers.
     STATE_FLUSHING,
     STATE_PLAYING,
     STATE_ERROR
@@ -86,11 +87,9 @@
   bool GetWallClockTimes(const std::vector<base::TimeDelta>& media_timestamps,
                          std::vector<base::TimeTicks>* wall_clock_times);
 
-  // Requests that this object notifies when a CDM is ready through the
-  // |cdm_ready_cb| provided.
-  // If |cdm_ready_cb| is null, the existing callback will be fired with
-  // nullptr immediately and reset.
-  void SetCdmReadyCallback(const CdmReadyCB& cdm_ready_cb);
+  bool HasEncryptedStream();
+
+  void FinishInitialization(PipelineStatus status);
 
   // Helper functions and callbacks for Initialize().
   void InitializeAudioRenderer();
@@ -169,14 +168,7 @@
   bool video_ended_;
 
   CdmContext* cdm_context_;
-
-  // Callback registered by filters (decoder or demuxer) to be informed of a
-  // CDM.
-  // Note: We could have multiple filters registering this callback. One
-  // callback is okay because:
-  // 1, We always initialize filters in sequence.
-  // 2, Filter initialization will not finish until this callback is satisfied.
-  CdmReadyCB cdm_ready_cb_;
+  CdmAttachedCB pending_cdm_attached_cb_;
 
   bool underflow_disabled_for_testing_;
   bool clockless_video_playback_enabled_for_testing_;