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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 |
| 8 #include <memory> |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
12 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "build/build_config.h" | 18 #include "build/build_config.h" |
17 #include "media/base/cdm_callback_promise.h" | 19 #include "media/base/cdm_callback_promise.h" |
18 #include "media/base/cdm_context.h" | 20 #include "media/base/cdm_context.h" |
19 #include "media/base/cdm_key_information.h" | 21 #include "media/base/cdm_key_information.h" |
20 #include "media/base/decoder_buffer.h" | 22 #include "media/base/decoder_buffer.h" |
21 #include "media/base/media.h" | 23 #include "media/base/media.h" |
22 #include "media/base/media_keys.h" | 24 #include "media/base/media_keys.h" |
23 #include "media/base/media_switches.h" | 25 #include "media/base/media_switches.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 278 |
277 Decryptor* GetDecryptor() final { return decryptor_; } | 279 Decryptor* GetDecryptor() final { return decryptor_; } |
278 int GetCdmId() const final { return kInvalidCdmId; } | 280 int GetCdmId() const final { return kInvalidCdmId; } |
279 | 281 |
280 private: | 282 private: |
281 Decryptor* decryptor_; | 283 Decryptor* decryptor_; |
282 }; | 284 }; |
283 | 285 |
284 scoped_refptr<AesDecryptor> decryptor_; | 286 scoped_refptr<AesDecryptor> decryptor_; |
285 TestCdmContext cdm_context_; | 287 TestCdmContext cdm_context_; |
286 scoped_ptr<AppBase> app_; | 288 std::unique_ptr<AppBase> app_; |
287 }; | 289 }; |
288 | 290 |
289 enum PromiseResult { RESOLVED, REJECTED }; | 291 enum PromiseResult { RESOLVED, REJECTED }; |
290 | 292 |
291 // Provides |kSecretKey| in response to the encrypted event. | 293 // Provides |kSecretKey| in response to the encrypted event. |
292 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { | 294 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { |
293 public: | 295 public: |
294 KeyProvidingApp() {} | 296 KeyProvidingApp() {} |
295 | 297 |
296 void OnResolveWithSession(PromiseResult expected, | 298 void OnResolveWithSession(PromiseResult expected, |
297 const std::string& session_id) { | 299 const std::string& session_id) { |
298 EXPECT_EQ(expected, RESOLVED); | 300 EXPECT_EQ(expected, RESOLVED); |
299 EXPECT_GT(session_id.length(), 0ul); | 301 EXPECT_GT(session_id.length(), 0ul); |
300 current_session_id_ = session_id; | 302 current_session_id_ = session_id; |
301 } | 303 } |
302 | 304 |
303 void OnResolve(PromiseResult expected) { EXPECT_EQ(expected, RESOLVED); } | 305 void OnResolve(PromiseResult expected) { EXPECT_EQ(expected, RESOLVED); } |
304 | 306 |
305 void OnReject(PromiseResult expected, | 307 void OnReject(PromiseResult expected, |
306 media::MediaKeys::Exception exception_code, | 308 media::MediaKeys::Exception exception_code, |
307 uint32_t system_code, | 309 uint32_t system_code, |
308 const std::string& error_message) { | 310 const std::string& error_message) { |
309 EXPECT_EQ(expected, REJECTED) << error_message; | 311 EXPECT_EQ(expected, REJECTED) << error_message; |
310 } | 312 } |
311 | 313 |
312 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) { | 314 std::unique_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) { |
313 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( | 315 std::unique_ptr<media::SimpleCdmPromise> promise( |
314 base::Bind(&KeyProvidingApp::OnResolve, base::Unretained(this), | 316 new media::CdmCallbackPromise<>( |
315 expected), | 317 base::Bind(&KeyProvidingApp::OnResolve, base::Unretained(this), |
316 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), | 318 expected), |
317 expected))); | 319 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), |
| 320 expected))); |
318 return promise; | 321 return promise; |
319 } | 322 } |
320 | 323 |
321 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( | 324 std::unique_ptr<NewSessionCdmPromise> CreateSessionPromise( |
322 PromiseResult expected) { | 325 PromiseResult expected) { |
323 scoped_ptr<media::NewSessionCdmPromise> promise( | 326 std::unique_ptr<media::NewSessionCdmPromise> promise( |
324 new media::CdmCallbackPromise<std::string>( | 327 new media::CdmCallbackPromise<std::string>( |
325 base::Bind(&KeyProvidingApp::OnResolveWithSession, | 328 base::Bind(&KeyProvidingApp::OnResolveWithSession, |
326 base::Unretained(this), expected), | 329 base::Unretained(this), expected), |
327 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), | 330 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), |
328 expected))); | 331 expected))); |
329 return promise; | 332 return promise; |
330 } | 333 } |
331 | 334 |
332 void OnSessionMessage(const std::string& session_id, | 335 void OnSessionMessage(const std::string& session_id, |
333 MediaKeys::MessageType message_type, | 336 MediaKeys::MessageType message_type, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 502 |
500 if (initial_append_size_ == kAppendWholeFile) | 503 if (initial_append_size_ == kAppendWholeFile) |
501 initial_append_size_ = file_data_->data_size(); | 504 initial_append_size_ = file_data_->data_size(); |
502 | 505 |
503 DCHECK_GT(initial_append_size_, 0u); | 506 DCHECK_GT(initial_append_size_, 0u); |
504 DCHECK_LE(initial_append_size_, file_data_->data_size()); | 507 DCHECK_LE(initial_append_size_, file_data_->data_size()); |
505 } | 508 } |
506 | 509 |
507 virtual ~MockMediaSource() {} | 510 virtual ~MockMediaSource() {} |
508 | 511 |
509 scoped_ptr<Demuxer> GetDemuxer() { return std::move(owned_chunk_demuxer_); } | 512 std::unique_ptr<Demuxer> GetDemuxer() { |
| 513 return std::move(owned_chunk_demuxer_); |
| 514 } |
510 | 515 |
511 void set_encrypted_media_init_data_cb( | 516 void set_encrypted_media_init_data_cb( |
512 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { | 517 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { |
513 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 518 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
514 } | 519 } |
515 | 520 |
516 void Seek(base::TimeDelta seek_time, | 521 void Seek(base::TimeDelta seek_time, |
517 size_t new_position, | 522 size_t new_position, |
518 size_t seek_append_size) { | 523 size_t seek_append_size) { |
519 chunk_demuxer_->StartWaitingForSeek(seek_time); | 524 chunk_demuxer_->StartWaitingForSeek(seek_time); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 DCHECK(!init_data.empty()); | 637 DCHECK(!init_data.empty()); |
633 CHECK(!encrypted_media_init_data_cb_.is_null()); | 638 CHECK(!encrypted_media_init_data_cb_.is_null()); |
634 encrypted_media_init_data_cb_.Run(init_data_type, init_data); | 639 encrypted_media_init_data_cb_.Run(init_data_type, init_data); |
635 } | 640 } |
636 | 641 |
637 base::TimeDelta last_timestamp_offset() const { | 642 base::TimeDelta last_timestamp_offset() const { |
638 return last_timestamp_offset_; | 643 return last_timestamp_offset_; |
639 } | 644 } |
640 | 645 |
641 // A workaround for gtest mocks not allowing moving scoped_ptrs. | 646 // A workaround for gtest mocks not allowing moving scoped_ptrs. |
642 void InitSegmentReceivedWrapper(scoped_ptr<MediaTracks> tracks) { | 647 void InitSegmentReceivedWrapper(std::unique_ptr<MediaTracks> tracks) { |
643 InitSegmentReceived(tracks); | 648 InitSegmentReceived(tracks); |
644 } | 649 } |
645 | 650 |
646 MOCK_METHOD1(InitSegmentReceived, void(scoped_ptr<MediaTracks>&)); | 651 MOCK_METHOD1(InitSegmentReceived, void(std::unique_ptr<MediaTracks>&)); |
647 | 652 |
648 private: | 653 private: |
649 scoped_refptr<DecoderBuffer> file_data_; | 654 scoped_refptr<DecoderBuffer> file_data_; |
650 size_t current_position_; | 655 size_t current_position_; |
651 size_t initial_append_size_; | 656 size_t initial_append_size_; |
652 std::string mimetype_; | 657 std::string mimetype_; |
653 ChunkDemuxer* chunk_demuxer_; | 658 ChunkDemuxer* chunk_demuxer_; |
654 scoped_ptr<Demuxer> owned_chunk_demuxer_; | 659 std::unique_ptr<Demuxer> owned_chunk_demuxer_; |
655 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | 660 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
656 base::TimeDelta last_timestamp_offset_; | 661 base::TimeDelta last_timestamp_offset_; |
657 }; | 662 }; |
658 | 663 |
659 #if defined(MOJO_RENDERER) | 664 #if defined(MOJO_RENDERER) |
660 class PipelineIntegrationTestHost : public shell::test::ApplicationTestBase, | 665 class PipelineIntegrationTestHost : public shell::test::ApplicationTestBase, |
661 public PipelineIntegrationTestBase { | 666 public PipelineIntegrationTestBase { |
662 public: | 667 public: |
663 bool ShouldCreateDefaultRunLoop() override { return false; } | 668 bool ShouldCreateDefaultRunLoop() override { return false; } |
664 | 669 |
665 void SetUp() override { | 670 void SetUp() override { |
666 ApplicationTestBase::SetUp(); | 671 ApplicationTestBase::SetUp(); |
667 InitializeMediaLibrary(); | 672 InitializeMediaLibrary(); |
668 } | 673 } |
669 | 674 |
670 protected: | 675 protected: |
671 scoped_ptr<Renderer> CreateRenderer() override { | 676 std::unique_ptr<Renderer> CreateRenderer() override { |
672 connector()->ConnectToInterface("mojo:media", &media_service_factory_); | 677 connector()->ConnectToInterface("mojo:media", &media_service_factory_); |
673 | 678 |
674 interfaces::RendererPtr mojo_renderer; | 679 interfaces::RendererPtr mojo_renderer; |
675 media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer)); | 680 media_service_factory_->CreateRenderer(mojo::GetProxy(&mojo_renderer)); |
676 | 681 |
677 return make_scoped_ptr(new MojoRendererImpl(message_loop_.task_runner(), | 682 return base::WrapUnique(new MojoRendererImpl(message_loop_.task_runner(), |
678 std::move(mojo_renderer))); | 683 std::move(mojo_renderer))); |
679 } | 684 } |
680 | 685 |
681 private: | 686 private: |
682 interfaces::ServiceFactoryPtr media_service_factory_; | 687 interfaces::ServiceFactoryPtr media_service_factory_; |
683 }; | 688 }; |
684 #else | 689 #else |
685 class PipelineIntegrationTestHost : public testing::Test, | 690 class PipelineIntegrationTestHost : public testing::Test, |
686 public PipelineIntegrationTestBase {}; | 691 public PipelineIntegrationTestBase {}; |
687 #endif // defined(MOJO_RENDERER) | 692 #endif // defined(MOJO_RENDERER) |
688 | 693 |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 | 2172 |
2168 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2173 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2169 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2174 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2170 Play(); | 2175 Play(); |
2171 ASSERT_TRUE(WaitUntilOnEnded()); | 2176 ASSERT_TRUE(WaitUntilOnEnded()); |
2172 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2177 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2173 demuxer_->GetStartTime()); | 2178 demuxer_->GetStartTime()); |
2174 } | 2179 } |
2175 | 2180 |
2176 } // namespace media | 2181 } // namespace media |
OLD | NEW |