| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "media/filters/pipeline_integration_test_base.h" |    5 #include "media/filters/pipeline_integration_test_base.h" | 
|    6  |    6  | 
|    7 #include "base/bind.h" |    7 #include "base/bind.h" | 
|    8 #include "media/base/decoder_buffer.h" |    8 #include "media/base/decoder_buffer.h" | 
 |    9 #include "media/base/decryptor_client.h" | 
|    9 #include "media/base/mock_filters.h" |   10 #include "media/base/mock_filters.h" | 
|   10 #include "media/base/test_data_util.h" |   11 #include "media/base/test_data_util.h" | 
|   11 #include "media/crypto/aes_decryptor.h" |   12 #include "media/crypto/aes_decryptor.h" | 
|   12 #include "media/crypto/decryptor_client.h" |  | 
|   13 #include "media/filters/chunk_demuxer_client.h" |   13 #include "media/filters/chunk_demuxer_client.h" | 
|   14  |   14  | 
|   15 namespace media { |   15 namespace media { | 
|   16  |   16  | 
|   17 static const char kSourceId[] = "SourceId"; |   17 static const char kSourceId[] = "SourceId"; | 
|   18 static const char kClearKeySystem[] = "org.w3.clearkey"; |   18 static const char kClearKeySystem[] = "org.w3.clearkey"; | 
|   19 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; |   19 static const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; | 
|   20  |   20  | 
|   21 // Helper class that emulates calls made on the ChunkDemuxer by the |   21 // Helper class that emulates calls made on the ChunkDemuxer by the | 
|   22 // Media Source API. |   22 // Media Source API. | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  105   std::string url_; |  105   std::string url_; | 
|  106   scoped_refptr<DecoderBuffer> file_data_; |  106   scoped_refptr<DecoderBuffer> file_data_; | 
|  107   int current_position_; |  107   int current_position_; | 
|  108   int initial_append_size_; |  108   int initial_append_size_; | 
|  109   bool has_audio_; |  109   bool has_audio_; | 
|  110   bool has_video_; |  110   bool has_video_; | 
|  111   scoped_refptr<ChunkDemuxer> chunk_demuxer_; |  111   scoped_refptr<ChunkDemuxer> chunk_demuxer_; | 
|  112   DecryptorClient* decryptor_client_; |  112   DecryptorClient* decryptor_client_; | 
|  113 }; |  113 }; | 
|  114  |  114  | 
|  115 class MockDecryptorClientImpl : public DecryptorClient { |  115 class FakeDecryptorClient : public DecryptorClient { | 
|  116  public: |  116  public: | 
|  117   MockDecryptorClientImpl() : decryptor_(this) {} |  117   FakeDecryptorClient() : decryptor_(this) {} | 
|  118  |  118  | 
|  119   AesDecryptor* decryptor() { |  119   AesDecryptor* decryptor() { | 
|  120     return &decryptor_; |  120     return &decryptor_; | 
|  121   } |  121   } | 
|  122  |  122  | 
|  123   // DecryptorClient implementation. |  123   // DecryptorClient implementation. | 
|  124   virtual void KeyAdded(const std::string& key_system, |  124   virtual void KeyAdded(const std::string& key_system, | 
|  125                         const std::string& session_id) { |  125                         const std::string& session_id) { | 
|  126     EXPECT_EQ(kClearKeySystem, key_system); |  126     EXPECT_EQ(kClearKeySystem, key_system); | 
|  127     EXPECT_FALSE(session_id.empty()); |  127     EXPECT_FALSE(session_id.empty()); | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), |  189         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | 
|  190         QuitOnStatusCB(PIPELINE_OK)); |  190         QuitOnStatusCB(PIPELINE_OK)); | 
|  191  |  191  | 
|  192     ASSERT_TRUE(decoder_.get()); |  192     ASSERT_TRUE(decoder_.get()); | 
|  193  |  193  | 
|  194     message_loop_.Run(); |  194     message_loop_.Run(); | 
|  195   } |  195   } | 
|  196  |  196  | 
|  197   void StartPipelineWithEncryptedMedia( |  197   void StartPipelineWithEncryptedMedia( | 
|  198       MockMediaSource* source, |  198       MockMediaSource* source, | 
|  199       MockDecryptorClientImpl* encrypted_media) { |  199       FakeDecryptorClient* encrypted_media) { | 
|  200     pipeline_->Start( |  200     pipeline_->Start( | 
|  201         CreateFilterCollection(source), |  201         CreateFilterCollection(source), | 
|  202         base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), |  202         base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), | 
|  203         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), |  203         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | 
|  204         QuitOnStatusCB(PIPELINE_OK)); |  204         QuitOnStatusCB(PIPELINE_OK)); | 
|  205  |  205  | 
|  206     ASSERT_TRUE(decoder_.get()); |  206     ASSERT_TRUE(decoder_.get()); | 
|  207     decoder_->set_decryptor(encrypted_media->decryptor()); |  207     decoder_->set_decryptor(encrypted_media->decryptor()); | 
|  208     source->set_decryptor_client(encrypted_media); |  208     source->set_decryptor_client(encrypted_media); | 
|  209  |  209  | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  258   Play(); |  258   Play(); | 
|  259  |  259  | 
|  260   ASSERT_TRUE(WaitUntilOnEnded()); |  260   ASSERT_TRUE(WaitUntilOnEnded()); | 
|  261  |  261  | 
|  262   EXPECT_EQ(GetVideoHash(), "f0be120a90a811506777c99a2cdf7cc1"); |  262   EXPECT_EQ(GetVideoHash(), "f0be120a90a811506777c99a2cdf7cc1"); | 
|  263   EXPECT_EQ(GetAudioHash(), "6138555be3389e6aba4c8e6f70195d50"); |  263   EXPECT_EQ(GetAudioHash(), "6138555be3389e6aba4c8e6f70195d50"); | 
|  264 } |  264 } | 
|  265  |  265  | 
|  266 TEST_F(PipelineIntegrationTest, EncryptedPlayback) { |  266 TEST_F(PipelineIntegrationTest, EncryptedPlayback) { | 
|  267   MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); |  267   MockMediaSource source("bear-320x240-encrypted.webm", 219726, true, true); | 
|  268   MockDecryptorClientImpl encrypted_media; |  268   FakeDecryptorClient encrypted_media; | 
|  269   StartPipelineWithEncryptedMedia(&source, &encrypted_media); |  269   StartPipelineWithEncryptedMedia(&source, &encrypted_media); | 
|  270  |  270  | 
|  271   source.EndOfStream(); |  271   source.EndOfStream(); | 
|  272   ASSERT_EQ(PIPELINE_OK, pipeline_status_); |  272   ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 
|  273  |  273  | 
|  274   Play(); |  274   Play(); | 
|  275  |  275  | 
|  276   ASSERT_TRUE(WaitUntilOnEnded()); |  276   ASSERT_TRUE(WaitUntilOnEnded()); | 
|  277   source.Abort(); |  277   source.Abort(); | 
|  278   Stop(); |  278   Stop(); | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  332  |  332  | 
|  333 // Verify video decoder & renderer can handle aborted demuxer reads. |  333 // Verify video decoder & renderer can handle aborted demuxer reads. | 
|  334 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |  334 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 
|  335   ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, |  335   ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, | 
|  336                                  base::TimeDelta::FromMilliseconds(200), |  336                                  base::TimeDelta::FromMilliseconds(200), | 
|  337                                  base::TimeDelta::FromMilliseconds(1668), |  337                                  base::TimeDelta::FromMilliseconds(1668), | 
|  338                                  0x1C896, 65536, false, true)); |  338                                  0x1C896, 65536, false, true)); | 
|  339 } |  339 } | 
|  340  |  340  | 
|  341 }  // namespace media |  341 }  // namespace media | 
| OLD | NEW |