[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/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 4f446b4..2a37b64 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -78,7 +78,6 @@
         decoded_frame_list_() {}
 
   virtual ~DecryptingAudioDecoderTest() {
-    EXPECT_CALL(*this, RequestCdmNotification(_)).Times(testing::AnyNumber());
     Destroy();
   }
 
@@ -97,32 +96,18 @@
                                                     kNoTimestamp());
     decoded_frame_list_.push_back(decoded_frame_);
 
-    decoder_->Initialize(
-        config, base::Bind(&DecryptingAudioDecoderTest::RequestCdmNotification,
-                           base::Unretained(this)),
-        NewExpectedBoolCB(success),
-        base::Bind(&DecryptingAudioDecoderTest::FrameReady,
-                   base::Unretained(this)));
+    decoder_->Initialize(config, cdm_context_.get(), NewExpectedBoolCB(success),
+                         base::Bind(&DecryptingAudioDecoderTest::FrameReady,
+                                    base::Unretained(this)));
     message_loop_.RunUntilIdle();
   }
 
-  enum CdmType { NO_CDM, CDM_WITHOUT_DECRYPTOR, CDM_WITH_DECRYPTOR };
+  enum CdmType { CDM_WITHOUT_DECRYPTOR, CDM_WITH_DECRYPTOR };
 
   void SetCdmType(CdmType cdm_type) {
-    const bool has_cdm = cdm_type != NO_CDM;
     const bool has_decryptor = cdm_type == CDM_WITH_DECRYPTOR;
-
-    EXPECT_CALL(*this, RequestCdmNotification(_))
-        .WillOnce(RunCallback<0>(has_cdm ? cdm_context_.get() : nullptr,
-                                 base::Bind(&DecryptingAudioDecoderTest::CdmSet,
-                                            base::Unretained(this))));
-
-    if (has_cdm) {
-      EXPECT_CALL(*cdm_context_, GetDecryptor())
-          .WillRepeatedly(Return(has_decryptor ? decryptor_.get() : nullptr));
-    }
-
-    EXPECT_CALL(*this, CdmSet(has_decryptor));
+    EXPECT_CALL(*cdm_context_, GetDecryptor())
+        .WillRepeatedly(Return(has_decryptor ? decryptor_.get() : nullptr));
   }
 
   void Initialize() {
@@ -149,7 +134,7 @@
         .WillOnce(RunCallback<1>(true));
     EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _))
               .WillOnce(SaveArg<1>(&key_added_cb_));
-    decoder_->Initialize(new_config, SetCdmReadyCB(), NewExpectedBoolCB(true),
+    decoder_->Initialize(new_config, nullptr, NewExpectedBoolCB(true),
                          base::Bind(&DecryptingAudioDecoderTest::FrameReady,
                                     base::Unretained(this)));
   }
@@ -265,13 +250,9 @@
     message_loop_.RunUntilIdle();
   }
 
-  MOCK_METHOD1(RequestCdmNotification, void(const CdmReadyCB&));
-
   MOCK_METHOD1(FrameReady, void(const scoped_refptr<AudioBuffer>&));
   MOCK_METHOD1(DecodeDone, void(AudioDecoder::Status));
 
-  MOCK_METHOD1(CdmSet, void(bool));
-
   MOCK_METHOD0(OnWaitingForDecryptionKey, void(void));
 
   base::MessageLoop message_loop_;
@@ -330,14 +311,6 @@
   InitializeAndExpectResult(config, false);
 }
 
-TEST_F(DecryptingAudioDecoderTest, Initialize_NoCdm) {
-  SetCdmType(NO_CDM);
-  AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,
-                            CHANNEL_LAYOUT_STEREO, kSampleRate,
-                            EmptyExtraData(), true);
-  InitializeAndExpectResult(config, false);
-}
-
 TEST_F(DecryptingAudioDecoderTest, Initialize_CdmWithoutDecryptor) {
   SetCdmType(CDM_WITHOUT_DECRYPTOR);
   AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32,