Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: media/filters/pipeline_integration_test.cc

Issue 547223003: MSE: Notify Blink SourceBuffer on init segment received (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Plan is to depend on blink-side CL landing first (https://codereview.chromium.org/55294… Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "media/base/cdm_promise.h" 12 #include "media/base/cdm_promise.h"
13 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
14 #include "media/base/media_keys.h" 14 #include "media/base/media_keys.h"
15 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
16 #include "media/base/test_data_util.h" 16 #include "media/base/test_data_util.h"
17 #include "media/cdm/aes_decryptor.h" 17 #include "media/cdm/aes_decryptor.h"
18 #include "media/cdm/json_web_key.h" 18 #include "media/cdm/json_web_key.h"
19 #include "media/filters/chunk_demuxer.h" 19 #include "media/filters/chunk_demuxer.h"
20 #include "media/filters/renderer_impl.h" 20 #include "media/filters/renderer_impl.h"
21 #include "testing/gmock/include/gmock/gmock.h"
21 22
22 using testing::_; 23 using testing::_;
23 using testing::AnyNumber; 24 using testing::AnyNumber;
25 using testing::AtLeast;
24 using testing::AtMost; 26 using testing::AtMost;
25 using testing::SaveArg; 27 using testing::SaveArg;
26 28
27 namespace media { 29 namespace media {
28 30
29 const char kSourceId[] = "SourceId"; 31 const char kSourceId[] = "SourceId";
30 const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; 32 const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 };
31 33
32 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; 34 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\"";
33 const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; 35 const char kWebMVP9[] = "video/webm; codecs=\"vp9\"";
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 AppendData(seek_append_size); 427 AppendData(seek_append_size);
426 } 428 }
427 429
428 void AppendData(int size) { 430 void AppendData(int size) {
429 DCHECK(chunk_demuxer_); 431 DCHECK(chunk_demuxer_);
430 DCHECK_LT(current_position_, file_data_->data_size()); 432 DCHECK_LT(current_position_, file_data_->data_size());
431 DCHECK_LE(current_position_ + size, file_data_->data_size()); 433 DCHECK_LE(current_position_ + size, file_data_->data_size());
432 434
433 chunk_demuxer_->AppendData( 435 chunk_demuxer_->AppendData(
434 kSourceId, file_data_->data() + current_position_, size, 436 kSourceId, file_data_->data() + current_position_, size,
435 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); 437 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_,
438 base::Bind(&MockMediaSource::InitSegmentReceived,
439 base::Unretained(this)));
436 current_position_ += size; 440 current_position_ += size;
437 } 441 }
438 442
439 void AppendAtTime(base::TimeDelta timestamp_offset, 443 void AppendAtTime(base::TimeDelta timestamp_offset,
440 const uint8* pData, 444 const uint8* pData,
441 int size) { 445 int size) {
442 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 446 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
443 chunk_demuxer_->AppendData(kSourceId, pData, size, 447 chunk_demuxer_->AppendData(kSourceId, pData, size,
444 base::TimeDelta(), kInfiniteDuration(), 448 base::TimeDelta(), kInfiniteDuration(),
445 &timestamp_offset); 449 &timestamp_offset,
450 base::Bind(&MockMediaSource::InitSegmentReceived,
451 base::Unretained(this)));
446 last_timestamp_offset_ = timestamp_offset; 452 last_timestamp_offset_ = timestamp_offset;
447 } 453 }
448 454
449 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, 455 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset,
450 base::TimeDelta append_window_start, 456 base::TimeDelta append_window_start,
451 base::TimeDelta append_window_end, 457 base::TimeDelta append_window_end,
452 const uint8* pData, 458 const uint8* pData,
453 int size) { 459 int size) {
454 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 460 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
455 chunk_demuxer_->AppendData(kSourceId, 461 chunk_demuxer_->AppendData(kSourceId,
456 pData, 462 pData,
457 size, 463 size,
458 append_window_start, 464 append_window_start,
459 append_window_end, 465 append_window_end,
460 &timestamp_offset); 466 &timestamp_offset,
467 base::Bind(&MockMediaSource::InitSegmentReceived,
468 base::Unretained(this)));
461 last_timestamp_offset_ = timestamp_offset; 469 last_timestamp_offset_ = timestamp_offset;
462 } 470 }
463 471
464 void EndOfStream() { 472 void EndOfStream() {
465 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); 473 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK);
466 } 474 }
467 475
468 void Abort() { 476 void Abort() {
469 if (!chunk_demuxer_) 477 if (!chunk_demuxer_)
470 return; 478 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 const std::vector<uint8>& init_data) { 520 const std::vector<uint8>& init_data) {
513 DCHECK(!init_data.empty()); 521 DCHECK(!init_data.empty());
514 CHECK(!need_key_cb_.is_null()); 522 CHECK(!need_key_cb_.is_null());
515 need_key_cb_.Run(type, init_data); 523 need_key_cb_.Run(type, init_data);
516 } 524 }
517 525
518 base::TimeDelta last_timestamp_offset() const { 526 base::TimeDelta last_timestamp_offset() const {
519 return last_timestamp_offset_; 527 return last_timestamp_offset_;
520 } 528 }
521 529
530 MOCK_METHOD0(InitSegmentReceived, void(void));
531
522 private: 532 private:
523 base::FilePath file_path_; 533 base::FilePath file_path_;
524 scoped_refptr<DecoderBuffer> file_data_; 534 scoped_refptr<DecoderBuffer> file_data_;
525 int current_position_; 535 int current_position_;
526 int initial_append_size_; 536 int initial_append_size_;
527 std::string mimetype_; 537 std::string mimetype_;
528 ChunkDemuxer* chunk_demuxer_; 538 ChunkDemuxer* chunk_demuxer_;
529 scoped_ptr<Demuxer> owned_chunk_demuxer_; 539 scoped_ptr<Demuxer> owned_chunk_demuxer_;
530 Demuxer::NeedKeyCB need_key_cb_; 540 Demuxer::NeedKeyCB need_key_cb_;
531 base::TimeDelta last_timestamp_offset_; 541 base::TimeDelta last_timestamp_offset_;
532 }; 542 };
533 543
534 class PipelineIntegrationTest 544 class PipelineIntegrationTest
535 : public testing::Test, 545 : public testing::Test,
536 public PipelineIntegrationTestBase { 546 public PipelineIntegrationTestBase {
537 public: 547 public:
538 void StartPipelineWithMediaSource(MockMediaSource* source) { 548 void StartPipelineWithMediaSource(MockMediaSource* source) {
549 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1));
539 EXPECT_CALL(*this, OnMetadata(_)) 550 EXPECT_CALL(*this, OnMetadata(_))
540 .Times(AtMost(1)) 551 .Times(AtMost(1))
541 .WillRepeatedly(SaveArg<0>(&metadata_)); 552 .WillRepeatedly(SaveArg<0>(&metadata_));
542 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 553 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
543 .Times(AtMost(1)); 554 .Times(AtMost(1));
544 demuxer_ = source->GetDemuxer().Pass(); 555 demuxer_ = source->GetDemuxer().Pass();
545 pipeline_->Start( 556 pipeline_->Start(
546 demuxer_.get(), 557 demuxer_.get(),
547 CreateRenderer(NULL), 558 CreateRenderer(NULL),
548 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 559 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 ASSERT_TRUE(Start(GetTestDataFilePath("bear_audio_shorter_than_video.ogv"), 1589 ASSERT_TRUE(Start(GetTestDataFilePath("bear_audio_shorter_than_video.ogv"),
1579 PIPELINE_OK)); 1590 PIPELINE_OK));
1580 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of 1591 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of
1581 // the two. 1592 // the two.
1582 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); 1593 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds());
1583 Play(); 1594 Play();
1584 ASSERT_TRUE(WaitUntilOnEnded()); 1595 ASSERT_TRUE(WaitUntilOnEnded());
1585 } 1596 }
1586 1597
1587 } // namespace media 1598 } // namespace media
OLDNEW
« media/filters/chunk_demuxer_unittest.cc ('K') | « media/filters/chunk_demuxer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698