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

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

Issue 379693002: Update SourceBufferStream and its unit tests to always expect valid durations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/source_buffer_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 13 matching lines...) Expand all
24 typedef StreamParser::BufferQueue BufferQueue; 24 typedef StreamParser::BufferQueue BufferQueue;
25 25
26 static const int kDefaultFramesPerSecond = 30; 26 static const int kDefaultFramesPerSecond = 30;
27 static const int kDefaultKeyframesPerSecond = 6; 27 static const int kDefaultKeyframesPerSecond = 6;
28 static const uint8 kDataA = 0x11; 28 static const uint8 kDataA = 0x11;
29 static const uint8 kDataB = 0x33; 29 static const uint8 kDataB = 0x33;
30 static const int kDataSize = 1; 30 static const int kDataSize = 1;
31 31
32 class SourceBufferStreamTest : public testing::Test { 32 class SourceBufferStreamTest : public testing::Test {
33 protected: 33 protected:
34 SourceBufferStreamTest() 34 SourceBufferStreamTest() {
35 : accurate_durations_(false) {
36 video_config_ = TestVideoConfig::Normal(); 35 video_config_ = TestVideoConfig::Normal();
37 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); 36 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond);
38 stream_.reset(new SourceBufferStream(video_config_, log_cb(), true)); 37 stream_.reset(new SourceBufferStream(video_config_, log_cb(), true));
39 } 38 }
40 39
41 void SetMemoryLimit(int buffers_of_data) { 40 void SetMemoryLimit(int buffers_of_data) {
42 stream_->set_memory_limit_for_testing(buffers_of_data * kDataSize); 41 stream_->set_memory_limit_for_testing(buffers_of_data * kDataSize);
43 } 42 }
44 43
45 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { 44 void SetStreamInfo(int frames_per_second, int keyframes_per_second) {
46 frames_per_second_ = frames_per_second; 45 frames_per_second_ = frames_per_second;
47 keyframes_per_second_ = keyframes_per_second; 46 keyframes_per_second_ = keyframes_per_second;
48 frame_duration_ = ConvertToFrameDuration(frames_per_second); 47 frame_duration_ = ConvertToFrameDuration(frames_per_second);
49 } 48 }
50 49
51 void SetTextStream() { 50 void SetTextStream() {
52 video_config_ = TestVideoConfig::Invalid(); 51 video_config_ = TestVideoConfig::Invalid();
53 TextTrackConfig config(kTextSubtitles, "", "", ""); 52 TextTrackConfig config(kTextSubtitles, "", "", "");
54 stream_.reset(new SourceBufferStream(config, LogCB(), true)); 53 stream_.reset(new SourceBufferStream(config, LogCB(), true));
55 SetStreamInfo(2, 2); 54 SetStreamInfo(2, 2);
56 } 55 }
57 56
58 void SetAudioStream() { 57 void SetAudioStream() {
59 video_config_ = TestVideoConfig::Invalid(); 58 video_config_ = TestVideoConfig::Invalid();
60 accurate_durations_ = true;
61 audio_config_.Initialize(kCodecVorbis, 59 audio_config_.Initialize(kCodecVorbis,
62 kSampleFormatPlanarF32, 60 kSampleFormatPlanarF32,
63 CHANNEL_LAYOUT_STEREO, 61 CHANNEL_LAYOUT_STEREO,
64 1000, 62 1000,
65 NULL, 63 NULL,
66 0, 64 0,
67 false, 65 false,
68 false, 66 false,
69 base::TimeDelta(), 67 base::TimeDelta(),
70 0); 68 0);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 stream_->GetCurrentVideoDecoderConfig(); 269 stream_->GetCurrentVideoDecoderConfig();
272 break; 270 break;
273 case SourceBufferStream::kAudio: 271 case SourceBufferStream::kAudio:
274 stream_->GetCurrentAudioDecoderConfig(); 272 stream_->GetCurrentAudioDecoderConfig();
275 break; 273 break;
276 case SourceBufferStream::kText: 274 case SourceBufferStream::kText:
277 stream_->GetCurrentTextTrackConfig(); 275 stream_->GetCurrentTextTrackConfig();
278 break; 276 break;
279 } 277 }
280 278
281 if (timestamps[i] == "C") 279 if (timestamps[i] == "C")
wolenetz 2014/07/09 22:42:18 Something seems wrong here, too. We're checking th
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 I just changed this to EXPECT_EQ("C", timestamps[i
wolenetz 2014/07/15 21:05:37 Acknowledged.
282 EXPECT_EQ(SourceBufferStream::kConfigChange, status); 280 EXPECT_EQ(SourceBufferStream::kConfigChange, status);
283 281
284 ss << "C"; 282 ss << "C";
285 continue; 283 continue;
286 } 284 }
287 285
288 EXPECT_EQ(SourceBufferStream::kSuccess, status); 286 EXPECT_EQ(SourceBufferStream::kSuccess, status);
289 if (status != SourceBufferStream::kSuccess) 287 if (status != SourceBufferStream::kSuccess)
290 break; 288 break;
291 289
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 << "Expected: " << config.AsHumanReadableString() 347 << "Expected: " << config.AsHumanReadableString()
350 << "\nActual: " << actual.AsHumanReadableString(); 348 << "\nActual: " << actual.AsHumanReadableString();
351 } 349 }
352 350
353 const LogCB log_cb() { 351 const LogCB log_cb() {
354 return base::Bind(&SourceBufferStreamTest::DebugMediaLog, 352 return base::Bind(&SourceBufferStreamTest::DebugMediaLog,
355 base::Unretained(this)); 353 base::Unretained(this));
356 } 354 }
357 355
358 base::TimeDelta frame_duration() const { return frame_duration_; } 356 base::TimeDelta frame_duration() const { return frame_duration_; }
357 void set_frame_duration(base::TimeDelta frame_duration) {
358 frame_duration_ = frame_duration;
359 }
359 360
360 scoped_ptr<SourceBufferStream> stream_; 361 scoped_ptr<SourceBufferStream> stream_;
361 VideoDecoderConfig video_config_; 362 VideoDecoderConfig video_config_;
362 AudioDecoderConfig audio_config_; 363 AudioDecoderConfig audio_config_;
363 364
364 private: 365 private:
365 base::TimeDelta ConvertToFrameDuration(int frames_per_second) { 366 base::TimeDelta ConvertToFrameDuration(int frames_per_second) {
366 return base::TimeDelta::FromMicroseconds( 367 return base::TimeDelta::FromMicroseconds(
367 base::Time::kMicrosecondsPerSecond / frames_per_second); 368 base::Time::kMicrosecondsPerSecond / frames_per_second);
368 } 369 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 if (is_keyframe) { 401 if (is_keyframe) {
401 presentation_timestamp = timestamp; 402 presentation_timestamp = timestamp;
402 } else if ((position - 1) % keyframe_interval == 0) { 403 } else if ((position - 1) % keyframe_interval == 0) {
403 // This is the P-frame (first frame following the I-frame) 404 // This is the P-frame (first frame following the I-frame)
404 presentation_timestamp = 405 presentation_timestamp =
405 (timestamp + frame_duration_ * (keyframe_interval - 2)); 406 (timestamp + frame_duration_ * (keyframe_interval - 2));
406 } else { 407 } else {
407 presentation_timestamp = timestamp - frame_duration_; 408 presentation_timestamp = timestamp - frame_duration_;
408 } 409 }
409 buffer->set_timestamp(presentation_timestamp); 410 buffer->set_timestamp(presentation_timestamp);
410 if (accurate_durations_) 411 buffer->set_duration(frame_duration_);
411 buffer->set_duration(frame_duration_);
412 412
413 queue.push_back(buffer); 413 queue.push_back(buffer);
414 } 414 }
415 if (!queue.empty()) 415 if (!queue.empty())
416 EXPECT_EQ(expect_success, stream_->Append(queue)); 416 EXPECT_EQ(expect_success, stream_->Append(queue));
417 } 417 }
418 418
419 void UpdateLastBufferDuration(base::TimeDelta current_dts,
420 BufferQueue* buffers) {
421 if (buffers->empty() || buffers->back()->duration() > base::TimeDelta())
422 return;
423
424 base::TimeDelta last_dts = buffers->back()->GetDecodeTimestamp();
425 DCHECK(current_dts >= last_dts);
426 buffers->back()->set_duration(current_dts - last_dts);
427 }
428
419 // StringToBufferQueue() allows for the generation of StreamParserBuffers from 429 // StringToBufferQueue() allows for the generation of StreamParserBuffers from
420 // coded strings of timestamps separated by spaces. Supported syntax: 430 // coded strings of timestamps separated by spaces. Supported syntax:
421 // 431 //
422 // ##: 432 // ##:
423 // Generates a StreamParserBuffer with decode timestamp ##. E.g., "0 1 2 3". 433 // Generates a StreamParserBuffer with decode timestamp ##. E.g., "0 1 2 3".
424 // 434 //
425 // ##K: 435 // ##K:
426 // Indicates the buffer with timestamp ## reflects a keyframe. E.g., "0K 1". 436 // Indicates the buffer with timestamp ## reflects a keyframe. E.g., "0K 1".
427 // 437 //
428 // S(a# ... y# z#) 438 // S(a# ... y# z#)
429 // Indicates a splice frame buffer should be created with timestamp z#. The 439 // Indicates a splice frame buffer should be created with timestamp z#. The
430 // preceding timestamps a# ... y# will be treated as the fade out preroll for 440 // preceding timestamps a# ... y# will be treated as the fade out preroll for
431 // the splice frame. If a timestamp within the preroll ends with C the config 441 // the splice frame. If a timestamp within the preroll ends with C the config
432 // id to use for that and subsequent preroll appends is incremented by one. 442 // id to use for that and subsequent preroll appends is incremented by one.
433 // The config id for non-splice frame appends will not be affected. 443 // The config id for non-splice frame appends will not be affected.
wolenetz 2014/07/09 22:42:17 nit: Update comment for new ..D##.. syntax
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Done.
434 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { 444 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) {
435 std::vector<std::string> timestamps; 445 std::vector<std::string> timestamps;
436 base::SplitString(buffers_to_append, ' ', &timestamps); 446 base::SplitString(buffers_to_append, ' ', &timestamps);
437 447
438 CHECK_GT(timestamps.size(), 0u); 448 CHECK_GT(timestamps.size(), 0u);
439 449
440 bool splice_frame = false; 450 bool splice_frame = false;
441 size_t splice_config_id = stream_->append_config_index_; 451 size_t splice_config_id = stream_->append_config_index_;
442 BufferQueue pre_splice_buffers; 452 BufferQueue pre_splice_buffers;
443 BufferQueue buffers; 453 BufferQueue buffers;
(...skipping 28 matching lines...) Expand all
472 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); 482 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1);
473 } 483 }
474 // Handle preroll buffers. 484 // Handle preroll buffers.
475 if (EndsWith(timestamps[i], "P", true)) { 485 if (EndsWith(timestamps[i], "P", true)) {
476 is_keyframe = true; 486 is_keyframe = true;
477 has_preroll = true; 487 has_preroll = true;
478 // Remove the "P" off of the token. 488 // Remove the "P" off of the token.
479 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1); 489 timestamps[i] = timestamps[i].substr(0, timestamps[i].length() - 1);
480 } 490 }
481 491
482 int time_in_ms; 492 int time_in_ms = 0;
493 int duration_in_ms = 0;
494 size_t duration_pos = timestamps[i].find('D');
495 if (duration_pos != std::string::npos) {
496 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1),
497 &duration_in_ms));
498 timestamps[i] = timestamps[i].substr(0, duration_pos );
wolenetz 2014/07/09 22:42:16 nit: s/ )/)/
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:28 Done.
499 }
500
483 CHECK(base::StringToInt(timestamps[i], &time_in_ms)); 501 CHECK(base::StringToInt(timestamps[i], &time_in_ms));
484 502
485 // Create buffer. Buffer type and track ID are meaningless to these tests. 503 // Create buffer. Buffer type and track ID are meaningless to these tests.
486 scoped_refptr<StreamParserBuffer> buffer = 504 scoped_refptr<StreamParserBuffer> buffer =
487 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe, 505 StreamParserBuffer::CopyFrom(&kDataA, kDataSize, is_keyframe,
488 DemuxerStream::AUDIO, 0); 506 DemuxerStream::AUDIO, 0);
489 base::TimeDelta timestamp = 507 base::TimeDelta timestamp =
490 base::TimeDelta::FromMilliseconds(time_in_ms); 508 base::TimeDelta::FromMilliseconds(time_in_ms);
491 buffer->set_timestamp(timestamp); 509 buffer->set_timestamp(timestamp);
492 if (accurate_durations_) 510 if (duration_in_ms)
493 buffer->set_duration(frame_duration_); 511 buffer->set_duration(base::TimeDelta::FromMilliseconds(duration_in_ms));
494 buffer->SetDecodeTimestamp(timestamp); 512 buffer->SetDecodeTimestamp(timestamp);
495 513
496 // Simulate preroll buffers by just generating another buffer and sticking 514 // Simulate preroll buffers by just generating another buffer and sticking
497 // it as the preroll. 515 // it as the preroll.
498 if (has_preroll) { 516 if (has_preroll) {
499 scoped_refptr<StreamParserBuffer> preroll_buffer = 517 scoped_refptr<StreamParserBuffer> preroll_buffer =
500 StreamParserBuffer::CopyFrom( 518 StreamParserBuffer::CopyFrom(
501 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0); 519 &kDataA, kDataSize, is_keyframe, DemuxerStream::AUDIO, 0);
502 preroll_buffer->set_duration(frame_duration_); 520 preroll_buffer->set_duration(frame_duration_);
503 buffer->SetPrerollBuffer(preroll_buffer); 521 buffer->SetPrerollBuffer(preroll_buffer);
504 } 522 }
505 523
506 if (splice_frame) { 524 if (splice_frame) {
507 if (!pre_splice_buffers.empty()) { 525 if (!pre_splice_buffers.empty()) {
508 // Enforce strictly monotonically increasing timestamps. 526 // Enforce strictly monotonically increasing timestamps.
509 CHECK_GT( 527 CHECK_GT(
510 timestamp.InMicroseconds(), 528 timestamp.InMicroseconds(),
511 pre_splice_buffers.back()->GetDecodeTimestamp().InMicroseconds()); 529 pre_splice_buffers.back()->GetDecodeTimestamp().InMicroseconds());
512 } 530 }
513 buffer->SetConfigId(splice_config_id); 531 buffer->SetConfigId(splice_config_id);
532 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(),
533 &pre_splice_buffers);
514 pre_splice_buffers.push_back(buffer); 534 pre_splice_buffers.push_back(buffer);
515 continue; 535 continue;
516 } 536 }
517 537
518 if (last_splice_frame) { 538 if (last_splice_frame) {
519 // Require at least one additional buffer for a splice. 539 // Require at least one additional buffer for a splice.
520 CHECK(!pre_splice_buffers.empty()); 540 CHECK(!pre_splice_buffers.empty());
521 buffer->SetConfigId(splice_config_id); 541 buffer->SetConfigId(splice_config_id);
522 buffer->ConvertToSpliceBuffer(pre_splice_buffers); 542 buffer->ConvertToSpliceBuffer(pre_splice_buffers);
wolenetz 2014/07/09 22:42:17 Something seems wrong to me, or I've lost my clari
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 This sounds like a question for Dale and should be
wolenetz 2014/07/15 21:05:37 I've pinged Dale in email. Thanks.
DaleCurtis 2014/07/15 21:06:41 1. These tests were written before the splice fram
523 pre_splice_buffers.clear(); 543 pre_splice_buffers.clear();
524 } 544 }
525 545
546 UpdateLastBufferDuration(buffer->GetDecodeTimestamp(), &buffers);
526 buffers.push_back(buffer); 547 buffers.push_back(buffer);
527 } 548 }
549
550 // If the last buffer doesn't have a duration, assume it is the
551 // same as the second to last buffer.
552 if (buffers.size() >= 2 &&
553 buffers.back()->duration() <= base::TimeDelta()) {
554 buffers.back()->set_duration(
555 buffers[buffers.size() - 2]->duration());
556 }
557
528 return buffers; 558 return buffers;
529 } 559 }
530 560
531 void AppendBuffers(const std::string& buffers_to_append, 561 void AppendBuffers(const std::string& buffers_to_append,
532 bool start_new_segment, 562 bool start_new_segment,
533 base::TimeDelta segment_start_timestamp, 563 base::TimeDelta segment_start_timestamp,
534 bool one_by_one, 564 bool one_by_one,
535 bool expect_success) { 565 bool expect_success) {
536 BufferQueue buffers = StringToBufferQueue(buffers_to_append); 566 BufferQueue buffers = StringToBufferQueue(buffers_to_append);
537 567
(...skipping 20 matching lines...) Expand all
558 } 588 }
559 } 589 }
560 590
561 void DebugMediaLog(const std::string& log) { 591 void DebugMediaLog(const std::string& log) {
562 DVLOG(1) << log; 592 DVLOG(1) << log;
563 } 593 }
564 594
565 int frames_per_second_; 595 int frames_per_second_;
566 int keyframes_per_second_; 596 int keyframes_per_second_;
567 base::TimeDelta frame_duration_; 597 base::TimeDelta frame_duration_;
568 // TODO(dalecurtis): It's silly to have this, all tests should use accurate
569 // durations instead. However, currently all tests are written with an
570 // expectation of 0 duration, so it's an involved change.
571 bool accurate_durations_;
572 DISALLOW_COPY_AND_ASSIGN(SourceBufferStreamTest); 598 DISALLOW_COPY_AND_ASSIGN(SourceBufferStreamTest);
573 }; 599 };
574 600
575 TEST_F(SourceBufferStreamTest, Append_SingleRange) { 601 TEST_F(SourceBufferStreamTest, Append_SingleRange) {
576 // Append 15 buffers at positions 0 through 14. 602 // Append 15 buffers at positions 0 through 14.
577 NewSegmentAppend(0, 15); 603 NewSegmentAppend(0, 15);
578 604
579 // Check expected range. 605 // Check expected range.
580 CheckExpectedRanges("{ [0,14) }"); 606 CheckExpectedRanges("{ [0,14) }");
581 // Check buffers in range. 607 // Check buffers in range.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // Append a segment with a start timestamp of 0, but the first 710 // Append a segment with a start timestamp of 0, but the first
685 // buffer starts at 30ms. This can happen in muxed content where the 711 // buffer starts at 30ms. This can happen in muxed content where the
686 // audio starts before the first frame. 712 // audio starts before the first frame.
687 NewSegmentAppend(base::TimeDelta::FromMilliseconds(0), "30K 60K 90K 120K"); 713 NewSegmentAppend(base::TimeDelta::FromMilliseconds(0), "30K 60K 90K 120K");
688 714
689 CheckExpectedRangesByTimestamp("{ [0,150) }"); 715 CheckExpectedRangesByTimestamp("{ [0,150) }");
690 716
691 // Completely overlap the old buffers, with a segment that starts 717 // Completely overlap the old buffers, with a segment that starts
692 // after the old segment start timestamp, but before the timestamp 718 // after the old segment start timestamp, but before the timestamp
693 // of the first buffer in the segment. 719 // of the first buffer in the segment.
694 NewSegmentAppend("20K 50K 80K 110K"); 720 NewSegmentAppend("20K 50K 80K 110D10K");
695 721
696 // Verify that the buffered ranges are updated properly and we don't crash. 722 // Verify that the buffered ranges are updated properly and we don't crash.
697 CheckExpectedRangesByTimestamp("{ [20,150) }"); 723 CheckExpectedRangesByTimestamp("{ [20,150) }");
698 724
699 SeekToTimestamp(base::TimeDelta::FromMilliseconds(20)); 725 SeekToTimestamp(base::TimeDelta::FromMilliseconds(20));
700 CheckExpectedBuffers("20K 50K 80K 110K 120K"); 726 CheckExpectedBuffers("20K 50K 80K 110K 120K");
701 } 727 }
702 728
703 TEST_F(SourceBufferStreamTest, Complete_Overlap_EdgeCase) { 729 TEST_F(SourceBufferStreamTest, Complete_Overlap_EdgeCase) {
704 // Make each frame a keyframe so that it's okay to overlap frames at any point 730 // Make each frame a keyframe so that it's okay to overlap frames at any point
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 CheckExpectedBuffers(15, 19); 792 CheckExpectedBuffers(15, 19);
767 } 793 }
768 794
769 // Test an end overlap edge case where a single buffer overlaps the 795 // Test an end overlap edge case where a single buffer overlaps the
770 // beginning of a range. 796 // beginning of a range.
771 // old : *0K* 30 60 90 120K 150 797 // old : *0K* 30 60 90 120K 150
772 // new : *0K* 798 // new : *0K*
773 // after: *0K* *120K* 150K 799 // after: *0K* *120K* 150K
774 // track: 800 // track:
775 TEST_F(SourceBufferStreamTest, End_Overlap_SingleBuffer) { 801 TEST_F(SourceBufferStreamTest, End_Overlap_SingleBuffer) {
802 set_frame_duration(base::TimeDelta::FromMilliseconds(30));
803
776 // Seek to start of stream. 804 // Seek to start of stream.
777 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); 805 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
778 806
779 NewSegmentAppend("0K 30 60 90 120K 150"); 807 NewSegmentAppend("0K 30 60 90 120K 150");
780 CheckExpectedRangesByTimestamp("{ [0,180) }"); 808 CheckExpectedRangesByTimestamp("{ [0,180) }");
781 809
782 NewSegmentAppend("0K"); 810 NewSegmentAppend("0D30K");
wolenetz 2014/07/09 22:42:18 curious: without D30 and frame_duration_ set to 30
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Removed the set_frame_duration() call since it was
wolenetz 2014/07/15 21:05:37 Acknowledged.
783 CheckExpectedRangesByTimestamp("{ [0,30) [120,180) }"); 811 CheckExpectedRangesByTimestamp("{ [0,30) [120,180) }");
784 812
785 CheckExpectedBuffers("0K"); 813 CheckExpectedBuffers("0K");
786 CheckNoNextBuffer(); 814 CheckNoNextBuffer();
787 } 815 }
788 816
789 TEST_F(SourceBufferStreamTest, Complete_Overlap_Several) { 817 TEST_F(SourceBufferStreamTest, Complete_Overlap_Several) {
790 // Append 2 buffers at positions 5 through 6. 818 // Append 2 buffers at positions 5 through 6.
791 NewSegmentAppend(5, 2); 819 NewSegmentAppend(5, 2);
792 820
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 CheckExpectedBuffers(0, 9, &kDataB); 1569 CheckExpectedBuffers(0, 9, &kDataB);
1542 } 1570 }
1543 1571
1544 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_DeleteGroup) { 1572 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_DeleteGroup) {
1545 NewSegmentAppendOneByOne("10K 40 70 100 130K"); 1573 NewSegmentAppendOneByOne("10K 40 70 100 130K");
1546 CheckExpectedRangesByTimestamp("{ [10,160) }"); 1574 CheckExpectedRangesByTimestamp("{ [10,160) }");
1547 1575
1548 // Seek to 130ms. 1576 // Seek to 130ms.
1549 SeekToTimestamp(base::TimeDelta::FromMilliseconds(130)); 1577 SeekToTimestamp(base::TimeDelta::FromMilliseconds(130));
1550 1578
1551 // Overlap with a new segment from 0 to 120ms. 1579 // Overlap with a new segment from 0 to 120ms.
wolenetz 2014/07/09 22:42:17 nit: s/120/130?
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Done.
1552 NewSegmentAppendOneByOne("0K 120"); 1580 NewSegmentAppendOneByOne("0K 120D10");
1553 1581
1554 // Next buffer should still be 130ms. 1582 // Next buffer should still be 130ms.
1555 CheckExpectedBuffers("130K"); 1583 CheckExpectedBuffers("130K");
1556 1584
1557 // Check the final buffers is correct. 1585 // Check the final buffers is correct.
1558 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); 1586 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
1559 CheckExpectedBuffers("0K 120 130K"); 1587 CheckExpectedBuffers("0K 120 130K");
1560 } 1588 }
1561 1589
1562 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_BetweenMediaSegments) { 1590 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_BetweenMediaSegments) {
(...skipping 10 matching lines...) Expand all
1573 // Check the final buffers is correct; the keyframe at 110ms should be 1601 // Check the final buffers is correct; the keyframe at 110ms should be
1574 // deleted. 1602 // deleted.
1575 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); 1603 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
1576 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210"); 1604 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210");
1577 } 1605 }
1578 1606
1579 // old : 10K 40 *70* 100K 125 130K 1607 // old : 10K 40 *70* 100K 125 130K
1580 // new : 0K 30 60 90 120K 1608 // new : 0K 30 60 90 120K
1581 // after: 0K 30 60 90 *120K* 130K 1609 // after: 0K 30 60 90 *120K* 130K
1582 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer) { 1610 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer) {
1583 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); 1611 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K");
1584 CheckExpectedRangesByTimestamp("{ [10,160) }"); 1612 CheckExpectedRangesByTimestamp("{ [10,160) }");
1585 1613
1586 // Seek to 70ms. 1614 // Seek to 70ms.
1587 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1615 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1588 CheckExpectedBuffers("10K 40"); 1616 CheckExpectedBuffers("10K 40");
1589 1617
1590 // Overlap with a new segment from 0 to 120ms. 1618 // Overlap with a new segment from 0 to 120ms.
wolenetz 2014/07/09 22:42:16 nit: s/120/130? (or 125, see next comment)
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Done.
1591 NewSegmentAppendOneByOne("0K 30 60 90 120K"); 1619 NewSegmentAppendOneByOne("0K 30 60 90 120D10K");
wolenetz 2014/07/09 22:42:17 s/120D10K/120D5K/ to better test that old buffer a
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 I'm just trying to explicitly document the origina
wolenetz 2014/07/15 21:05:37 Acknowledged.
1592 CheckExpectedRangesByTimestamp("{ [0,160) }"); 1620 CheckExpectedRangesByTimestamp("{ [0,160) }");
1593 1621
1594 // Should return frames 70ms and 100ms from the track buffer, then switch 1622 // Should return frame 70ms from the track buffer, then switch
1595 // to the new data at 120K, then switch back to the old data at 130K. The 1623 // to the new data at 120K, then switch back to the old data at 130K. The
1596 // frame at 125ms that depended on keyframe 100ms should have been deleted. 1624 // frame at 125ms that depended on keyframe 100ms should have been deleted.
1597 CheckExpectedBuffers("70 100K 120K 130K"); 1625 CheckExpectedBuffers("70 120K 130K");
acolwell GONE FROM CHROMIUM 2014/07/09 02:07:02 I haven't 100% convinced myself that this particul
wolenetz 2014/07/09 22:42:17 I think your analysis is correct, and the new beha
1598 1626
1599 // Check the final result: should not include data from the track buffer. 1627 // Check the final result: should not include data from the track buffer.
1600 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); 1628 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
1601 CheckExpectedBuffers("0K 30 60 90 120K 130K"); 1629 CheckExpectedBuffers("0K 30 60 90 120K 130K");
1602 } 1630 }
1603 1631
1604 // Overlap the next keyframe after the end of the track buffer with a new 1632 // Overlap the next keyframe after the end of the track buffer with a new
1605 // keyframe. 1633 // keyframe.
1606 // old : 10K 40 *70* 100K 125 130K 1634 // old : 10K 40 *70* 100K 125 130K
1607 // new : 0K 30 60 90 120K 1635 // new : 0K 30 60 90 120K
1608 // after: 0K 30 60 90 *120K* 130K 1636 // after: 0K 30 60 90 *120K* 130K
1609 // track: 70 100K 1637 // track: 70
1610 // new : 110K 130 1638 // new : 110K 130
1611 // after: 0K 30 60 90 *110K* 130 1639 // after: 0K 30 60 90 *110K* 130
1612 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer2) { 1640 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer2) {
1613 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); 1641 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K");
1614 CheckExpectedRangesByTimestamp("{ [10,160) }"); 1642 CheckExpectedRangesByTimestamp("{ [10,160) }");
1615 1643
1616 // Seek to 70ms. 1644 // Seek to 70ms.
1617 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1645 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1618 CheckExpectedBuffers("10K 40"); 1646 CheckExpectedBuffers("10K 40");
1619 1647
1620 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track 1648 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track
1621 // buffer. 1649 // buffer.
1622 NewSegmentAppendOneByOne("0K 30 60 90 120K"); 1650 NewSegmentAppendOneByOne("0K 30 60 90 120D10K");
1623 CheckExpectedRangesByTimestamp("{ [0,160) }"); 1651 CheckExpectedRangesByTimestamp("{ [0,160) }");
1624 1652
1625 // Now overlap the keyframe at 120ms. 1653 // Now overlap the keyframe at 120ms.
1626 NewSegmentAppendOneByOne("110K 130"); 1654 NewSegmentAppendOneByOne("110K 130");
1627 1655
1628 // Should expect buffers 70ms and 100ms from the track buffer. Then it should 1656 // Should expect buffers 70ms and 100ms from the track buffer. Then it should
wolenetz 2014/07/09 22:42:17 nit: s/expect buffers 70ms and 100ms/return frame
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 Done.
1629 // return the keyframe after the track buffer, which is at 110ms. 1657 // return the keyframe after the track buffer, which is at 110ms.
1630 CheckExpectedBuffers("70 100K 110K 130"); 1658 CheckExpectedBuffers("70 110K 130");
1631 } 1659 }
1632 1660
1633 // Overlap the next keyframe after the end of the track buffer without a 1661 // Overlap the next keyframe after the end of the track buffer without a
1634 // new keyframe. 1662 // new keyframe.
1635 // old : 10K 40 *70* 100K 125 130K 1663 // old : 10K 40 *70* 100K 125 130K
1636 // new : 0K 30 60 90 120K 1664 // new : 0K 30 60 90 120K
1637 // after: 0K 30 60 90 *120K* 130K 1665 // after: 0K 30 60 90 *120K* 130K
1638 // track: 70 100K 1666 // track: 70
1639 // new : 50K 80 110 140 1667 // new : 50K 80 110 140
1640 // after: 0K 30 50K 80 110 140 * (waiting for keyframe) 1668 // after: 0K 30 50K 80 110 140 * (waiting for keyframe)
1641 // track: 70 100K 120K 130K 1669 // track: 70
1642 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer3) { 1670 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer3) {
1643 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); 1671 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K");
1644 CheckExpectedRangesByTimestamp("{ [10,160) }"); 1672 CheckExpectedRangesByTimestamp("{ [10,160) }");
1645 1673
1646 // Seek to 70ms. 1674 // Seek to 70ms.
1647 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1675 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1648 CheckExpectedBuffers("10K 40"); 1676 CheckExpectedBuffers("10K 40");
1649 1677
1650 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track 1678 // Overlap with a new segment from 0 to 120ms; 70ms goes in track buffer.
1651 // buffer. 1679 NewSegmentAppendOneByOne("0K 30 60 90 120D10K");
1652 NewSegmentAppendOneByOne("0K 30 60 90 120K");
1653 CheckExpectedRangesByTimestamp("{ [0,160) }"); 1680 CheckExpectedRangesByTimestamp("{ [0,160) }");
1654 1681
1655 // Now overlap the keyframe at 120ms. There's no keyframe after 70ms, so 120ms 1682 // Now overlap the keyframe at 120ms. There's no keyframe after 70ms, so 120ms
wolenetz 2014/07/09 22:42:17 nit: s/*/Now overlap the keyframes at 120ms and 13
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 Done.
1656 // and 130ms go into the track buffer. 1683 // and 130ms go into the track buffer.
1657 NewSegmentAppendOneByOne("50K 80 110 140"); 1684 NewSegmentAppendOneByOne("50K 80 110 140");
1685 CheckExpectedRangesByTimestamp("{ [0,170) }");
1658 1686
1659 // Should have all the buffers from the track buffer, then stall. 1687 // Should have all the buffers from the track buffer, then stall.
1660 CheckExpectedBuffers("70 100K 120K 130K"); 1688 CheckExpectedBuffers("70");
1661 CheckNoNextBuffer(); 1689 CheckNoNextBuffer();
1662 1690
1663 // Appending a keyframe should fulfill the read. 1691 // Appending a keyframe should fulfill the read.
1664 AppendBuffersOneByOne("150K"); 1692 AppendBuffersOneByOne("150D30K");
1665 CheckExpectedBuffers("150K"); 1693 CheckExpectedBuffers("150K");
1666 CheckNoNextBuffer(); 1694 CheckNoNextBuffer();
1667 } 1695 }
1668 1696
1669 // Overlap the next keyframe after the end of the track buffer with a keyframe 1697 // Overlap the next keyframe after the end of the track buffer with a keyframe
1670 // that comes before the end of the track buffer. 1698 // that comes before the end of the track buffer.
1671 // old : 10K 40 *70* 100K 125 130K 1699 // old : 10K 40 *70* 100K 125 130K
1672 // new : 0K 30 60 90 120K 1700 // new : 0K 30 60 90 120K
1673 // after: 0K 30 60 90 *120K* 130K 1701 // after: 0K 30 60 90 *120K* 130K
1674 // track: 70 100K 1702 // track: 70 100K
wolenetz 2014/07/09 22:42:17 nit: s/100K//
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 Done.
1675 // new : 80K 110 140 1703 // new : 80K 110 140
1676 // after: 0K 30 60 *80K* 110 140 1704 // after: 0K 30 60 *80K* 110 140
1677 // track: 70 1705 // track: 70
1678 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer4) { 1706 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer4) {
1679 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); 1707 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K");
1680 CheckExpectedRangesByTimestamp("{ [10,160) }"); 1708 CheckExpectedRangesByTimestamp("{ [10,160) }");
1681 1709
1682 // Seek to 70ms. 1710 // Seek to 70ms.
1683 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1711 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1684 CheckExpectedBuffers("10K 40"); 1712 CheckExpectedBuffers("10K 40");
1685 1713
1686 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track 1714 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track
1687 // buffer. 1715 // buffer.
1688 NewSegmentAppendOneByOne("0K 30 60 90 120K"); 1716 NewSegmentAppendOneByOne("0K 30 60 90 120D10K");
1689 CheckExpectedRangesByTimestamp("{ [0,160) }"); 1717 CheckExpectedRangesByTimestamp("{ [0,160) }");
1690 1718
1691 // Now append a keyframe at 80ms. 1719 // Now append a keyframe at 80ms.
1692 NewSegmentAppendOneByOne("80K 110 140"); 1720 NewSegmentAppendOneByOne("80K 110 140");
1693 1721
1694 CheckExpectedBuffers("70 80K 110 140"); 1722 CheckExpectedBuffers("70 80K 110 140");
1695 CheckNoNextBuffer(); 1723 CheckNoNextBuffer();
1696 } 1724 }
1697 1725
1698 // Overlap the next keyframe after the end of the track buffer with a keyframe 1726 // Overlap the next keyframe after the end of the track buffer with a keyframe
1699 // that comes before the end of the track buffer, when the selected stream was 1727 // that comes before the end of the track buffer, when the selected stream was
1700 // waiting for the next keyframe. 1728 // waiting for the next keyframe.
1701 // old : 10K 40 *70* 100K 1729 // old : 10K 40 *70* 100K
1702 // new : 0K 30 60 90 120 1730 // new : 0K 30 60 90 120
1703 // after: 0K 30 60 90 120 * (waiting for keyframe) 1731 // after: 0K 30 60 90 120 * (waiting for keyframe)
1704 // track: 70 100K 1732 // track: 70 100K
wolenetz 2014/07/09 22:42:17 nit: s/100K//
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Done.
1705 // new : 80K 110 140 1733 // new : 80K 110 140
1706 // after: 0K 30 60 *80K* 110 140 1734 // after: 0K 30 60 *80K* 110 140
1707 // track: 70 1735 // track: 70
1708 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer5) { 1736 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer5) {
1709 NewSegmentAppendOneByOne("10K 40 70 100K"); 1737 NewSegmentAppendOneByOne("10K 40 70 100K");
wolenetz 2014/07/09 22:42:17 nit: is s/100K/100D30K/ necessary to match my othe
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 The D30 is not needed because the duration is impl
wolenetz 2014/07/15 21:05:37 Acknowledged.
1710 CheckExpectedRangesByTimestamp("{ [10,130) }"); 1738 CheckExpectedRangesByTimestamp("{ [10,130) }");
1711 1739
1712 // Seek to 70ms. 1740 // Seek to 70ms.
1713 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1741 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1714 CheckExpectedBuffers("10K 40"); 1742 CheckExpectedBuffers("10K 40");
1715 1743
1716 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track 1744 // Overlap with a new segment from 0 to 120ms; 70ms and 100ms go in track
wolenetz 2014/07/09 22:42:17 nit: s/and 100ms go/goes/
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 Done.
1717 // buffer. 1745 // buffer.
1718 NewSegmentAppendOneByOne("0K 30 60 90 120"); 1746 NewSegmentAppendOneByOne("0K 30 60 90 120");
1719 CheckExpectedRangesByTimestamp("{ [0,150) }"); 1747 CheckExpectedRangesByTimestamp("{ [0,150) }");
1720 1748
1721 // Now append a keyframe at 80ms. The buffer at 100ms should be deleted from 1749 // Now append a keyframe at 80ms. The buffer at 100ms should be deleted from
wolenetz 2014/07/09 22:42:16 nit s/The...//
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Done.
1722 // the track buffer. 1750 // the track buffer.
1723 NewSegmentAppendOneByOne("80K 110 140"); 1751 NewSegmentAppendOneByOne("80K 110 140");
1724 1752
1725 CheckExpectedBuffers("70 80K 110 140"); 1753 CheckExpectedBuffers("70 80K 110 140");
1726 CheckNoNextBuffer(); 1754 CheckNoNextBuffer();
1727 } 1755 }
1728 1756
1729 // Test that appending to a different range while there is data in 1757 // Test that appending to a different range while there is data in
1730 // the track buffer doesn't affect the selected range or track buffer state. 1758 // the track buffer doesn't affect the selected range or track buffer state.
1731 // old : 10K 40 *70* 100K 125 130K ... 200K 230 1759 // old : 10K 40 *70* 100K 125 130K ... 200K 230
1732 // new : 0K 30 60 90 120K 1760 // new : 0K 30 60 90 120K
1733 // after: 0K 30 60 90 *120K* 130K ... 200K 230 1761 // after: 0K 30 60 90 *120K* 130K ... 200K 230
1734 // track: 70 100K 1762 // track: 70
1735 // old : 0K 30 60 90 *120K* 130K ... 200K 230 1763 // old : 0K 30 60 90 *120K* 130K ... 200K 230
1736 // new : 260K 290 1764 // new : 260K 290
1737 // after: 0K 30 60 90 *120K* 130K ... 200K 230 260K 290 1765 // after: 0K 30 60 90 *120K* 130K ... 200K 230 260K 290
1738 // track: 70 100K 1766 // track: 70
1739 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer6) { 1767 TEST_F(SourceBufferStreamTest, Overlap_OneByOne_TrackBuffer6) {
1740 NewSegmentAppendOneByOne("10K 40 70 100K 125 130K"); 1768 NewSegmentAppendOneByOne("10K 40 70 100K 125 130D30K");
1741 NewSegmentAppendOneByOne("200K 230"); 1769 NewSegmentAppendOneByOne("200K 230");
1742 CheckExpectedRangesByTimestamp("{ [10,160) [200,260) }"); 1770 CheckExpectedRangesByTimestamp("{ [10,160) [200,260) }");
1743 1771
1744 // Seek to 70ms. 1772 // Seek to 70ms.
1745 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70)); 1773 SeekToTimestamp(base::TimeDelta::FromMilliseconds(70));
1746 CheckExpectedBuffers("10K 40"); 1774 CheckExpectedBuffers("10K 40");
1747 1775
1748 // Overlap with a new segment from 0 to 120ms. 1776 // Overlap with a new segment from 0 to 120ms.
1749 NewSegmentAppendOneByOne("0K 30 60 90 120K"); 1777 NewSegmentAppendOneByOne("0K 30 60 90 120D10K");
1750 CheckExpectedRangesByTimestamp("{ [0,160) [200,260) }"); 1778 CheckExpectedRangesByTimestamp("{ [0,160) [200,260) }");
1751 1779
1752 // Verify that 70 gets read out of the track buffer. 1780 // Verify that 70 gets read out of the track buffer.
1753 CheckExpectedBuffers("70"); 1781 CheckExpectedBuffers("70");
1754 1782
1755 // Append more data to the unselected range. 1783 // Append more data to the unselected range.
1756 NewSegmentAppendOneByOne("260K 290"); 1784 NewSegmentAppendOneByOne("260K 290");
1757 CheckExpectedRangesByTimestamp("{ [0,160) [200,320) }"); 1785 CheckExpectedRangesByTimestamp("{ [0,160) [200,320) }");
1758 1786
1759 CheckExpectedBuffers("100K 120K 130K"); 1787 CheckExpectedBuffers("120K 130K");
1760 CheckNoNextBuffer(); 1788 CheckNoNextBuffer();
1761 1789
1762 // Check the final result: should not include data from the track buffer. 1790 // Check the final result: should not include data from the track buffer.
1763 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0)); 1791 SeekToTimestamp(base::TimeDelta::FromMilliseconds(0));
1764 CheckExpectedBuffers("0K 30 60 90 120K 130K"); 1792 CheckExpectedBuffers("0K 30 60 90 120K 130K");
1765 CheckNoNextBuffer(); 1793 CheckNoNextBuffer();
1766 } 1794 }
1767 1795
1768 TEST_F(SourceBufferStreamTest, Seek_Keyframe) { 1796 TEST_F(SourceBufferStreamTest, Seek_Keyframe) {
1769 // Append 6 buffers at positions 0 through 5. 1797 // Append 6 buffers at positions 0 through 5.
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 // GetNextBuffer() skips to second GOP in the newly appended data instead 2143 // GetNextBuffer() skips to second GOP in the newly appended data instead
2116 // of returning two buffers with the same timestamp. 2144 // of returning two buffers with the same timestamp.
2117 TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap2) { 2145 TEST_F(SourceBufferStreamTest, GetNextBuffer_ExhaustThenStartOverlap2) {
2118 NewSegmentAppend("0K 30 60 90 120"); 2146 NewSegmentAppend("0K 30 60 90 120");
2119 2147
2120 Seek(0); 2148 Seek(0);
2121 CheckExpectedBuffers("0K 30 60 90 120"); 2149 CheckExpectedBuffers("0K 30 60 90 120");
2122 CheckNoNextBuffer(); 2150 CheckNoNextBuffer();
2123 2151
2124 // Append a keyframe with the same timestamp as the last buffer output. 2152 // Append a keyframe with the same timestamp as the last buffer output.
2125 NewSegmentAppend("120K"); 2153 NewSegmentAppend("120D30K");
2126 CheckNoNextBuffer(); 2154 CheckNoNextBuffer();
2127 2155
2128 // Append the rest of the segment and make sure that buffers are returned 2156 // Append the rest of the segment and make sure that buffers are returned
2129 // from the first GOP after 120. 2157 // from the first GOP after 120.
2130 AppendBuffers("150 180 210K 240"); 2158 AppendBuffers("150 180 210K 240");
2131 CheckExpectedBuffers("210K 240"); 2159 CheckExpectedBuffers("210K 240");
2132 2160
2133 // Seek to the beginning and verify the contents of the source buffer. 2161 // Seek to the beginning and verify the contents of the source buffer.
2134 Seek(0); 2162 Seek(0);
2135 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210K 240"); 2163 CheckExpectedBuffers("0K 30 60 90 120K 150 180 210K 240");
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 // Test saving the last GOP appended when this GOP is the only GOP in its range. 2571 // Test saving the last GOP appended when this GOP is the only GOP in its range.
2544 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP) { 2572 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP) {
2545 // Set memory limit to 3 and make sure the 4-byte GOP is not garbage 2573 // Set memory limit to 3 and make sure the 4-byte GOP is not garbage
2546 // collected. 2574 // collected.
2547 SetMemoryLimit(3); 2575 SetMemoryLimit(3);
2548 NewSegmentAppend("0K 30 60 90"); 2576 NewSegmentAppend("0K 30 60 90");
2549 CheckExpectedRangesByTimestamp("{ [0,120) }"); 2577 CheckExpectedRangesByTimestamp("{ [0,120) }");
2550 2578
2551 // Make sure you can continue appending data to this GOP; again, GC should not 2579 // Make sure you can continue appending data to this GOP; again, GC should not
2552 // wipe out anything. 2580 // wipe out anything.
2553 AppendBuffers("120"); 2581 AppendBuffers("120D30");
2554 CheckExpectedRangesByTimestamp("{ [0,150) }"); 2582 CheckExpectedRangesByTimestamp("{ [0,150) }");
2555 2583
2556 // Set memory limit to 100 and append a 2nd range after this without 2584 // Set memory limit to 100 and append a 2nd range after this without
2557 // triggering GC. 2585 // triggering GC.
2558 SetMemoryLimit(100); 2586 SetMemoryLimit(100);
2559 NewSegmentAppend("200K 230 260 290K 320 350"); 2587 NewSegmentAppend("200K 230 260 290K 320 350");
2560 CheckExpectedRangesByTimestamp("{ [0,150) [200,380) }"); 2588 CheckExpectedRangesByTimestamp("{ [0,150) [200,380) }");
2561 2589
2562 // Seek to 290ms. 2590 // Seek to 290ms.
2563 SeekToTimestamp(base::TimeDelta::FromMilliseconds(290)); 2591 SeekToTimestamp(base::TimeDelta::FromMilliseconds(290));
2564 2592
2565 // Now set memory limit to 3 and append a GOP in a separate range after the 2593 // Now set memory limit to 3 and append a GOP in a separate range after the
2566 // selected range. Because it is after 290ms, this tests that the GOP is saved 2594 // selected range. Because it is after 290ms, this tests that the GOP is saved
2567 // when deleting from the back. 2595 // when deleting from the back.
2568 SetMemoryLimit(3); 2596 SetMemoryLimit(3);
2569 NewSegmentAppend("500K 530 560 590"); 2597 NewSegmentAppend("500K 530 560 590");
2570 2598
2571 // Should save GOP with 290ms and last GOP appended. 2599 // Should save GOP with 290ms and last GOP appended.
2572 CheckExpectedRangesByTimestamp("{ [290,380) [500,620) }"); 2600 CheckExpectedRangesByTimestamp("{ [290,380) [500,620) }");
2573 2601
2574 // Continue appending to this GOP after GC. 2602 // Continue appending to this GOP after GC.
2575 AppendBuffers("620"); 2603 AppendBuffers("620D30");
2576 CheckExpectedRangesByTimestamp("{ [290,380) [500,650) }"); 2604 CheckExpectedRangesByTimestamp("{ [290,380) [500,650) }");
2577 } 2605 }
2578 2606
2579 // Test saving the last GOP appended when this GOP is in the middle of a 2607 // Test saving the last GOP appended when this GOP is in the middle of a
2580 // non-selected range. 2608 // non-selected range.
2581 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Middle) { 2609 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Middle) {
2582 // Append 3 GOPs starting at 0ms, 30ms apart. 2610 // Append 3 GOPs starting at 0ms, 30ms apart.
2583 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); 2611 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240");
2584 CheckExpectedRangesByTimestamp("{ [0,270) }"); 2612 CheckExpectedRangesByTimestamp("{ [0,270) }");
2585 2613
2586 // Now set the memory limit to 1 and overlap the middle of the range with a 2614 // Now set the memory limit to 1 and overlap the middle of the range with a
2587 // new GOP. 2615 // new GOP.
2588 SetMemoryLimit(1); 2616 SetMemoryLimit(1);
2589 NewSegmentAppend("80K 110 140"); 2617 NewSegmentAppend("80K 110 140");
2590 2618
2591 // This whole GOP should be saved, and should be able to continue appending 2619 // This whole GOP should be saved, and should be able to continue appending
2592 // data to it. 2620 // data to it.
2593 CheckExpectedRangesByTimestamp("{ [80,170) }"); 2621 CheckExpectedRangesByTimestamp("{ [80,170) }");
2594 AppendBuffers("170"); 2622 AppendBuffers("170D30");
2595 CheckExpectedRangesByTimestamp("{ [80,200) }"); 2623 CheckExpectedRangesByTimestamp("{ [80,200) }");
2596 2624
2597 // Set memory limit to 100 and append a 2nd range after this without 2625 // Set memory limit to 100 and append a 2nd range after this without
2598 // triggering GC. 2626 // triggering GC.
2599 SetMemoryLimit(100); 2627 SetMemoryLimit(100);
2600 NewSegmentAppend("400K 430 460 490K 520 550 580K 610 640"); 2628 NewSegmentAppend("400K 430 460 490K 520 550 580K 610 640");
2601 CheckExpectedRangesByTimestamp("{ [80,200) [400,670) }"); 2629 CheckExpectedRangesByTimestamp("{ [80,200) [400,670) }");
2602 2630
2603 // Seek to 80ms to make the first range the selected range. 2631 // Seek to 80ms to make the first range the selected range.
2604 SeekToTimestamp(base::TimeDelta::FromMilliseconds(80)); 2632 SeekToTimestamp(base::TimeDelta::FromMilliseconds(80));
2605 2633
2606 // Now set memory limit to 3 and append a GOP in the middle of the second 2634 // Now set memory limit to 3 and append a GOP in the middle of the second
2607 // range. Because it is after the selected range, this tests that the GOP is 2635 // range. Because it is after the selected range, this tests that the GOP is
2608 // saved when deleting from the back. 2636 // saved when deleting from the back.
2609 SetMemoryLimit(3); 2637 SetMemoryLimit(3);
2610 NewSegmentAppend("500K 530 560 590"); 2638 NewSegmentAppend("500K 530 560 590");
2611 2639
2612 // Should save the GOP containing the seek point and GOP that was last 2640 // Should save the GOP containing the seek point and GOP that was last
2613 // appended. 2641 // appended.
2614 CheckExpectedRangesByTimestamp("{ [80,200) [500,620) }"); 2642 CheckExpectedRangesByTimestamp("{ [80,200) [500,620) }");
2615 2643
2616 // Continue appending to this GOP after GC. 2644 // Continue appending to this GOP after GC.
2617 AppendBuffers("620"); 2645 AppendBuffers("620D30");
2618 CheckExpectedRangesByTimestamp("{ [80,200) [500,650) }"); 2646 CheckExpectedRangesByTimestamp("{ [80,200) [500,650) }");
2619 } 2647 }
2620 2648
2621 // Test saving the last GOP appended when the GOP containing the next buffer is 2649 // Test saving the last GOP appended when the GOP containing the next buffer is
2622 // adjacent to the last GOP appended. 2650 // adjacent to the last GOP appended.
2623 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected1) { 2651 TEST_F(SourceBufferStreamTest, GarbageCollection_SaveAppendGOP_Selected1) {
2624 // Append 3 GOPs at 0ms, 90ms, and 180ms. 2652 // Append 3 GOPs at 0ms, 90ms, and 180ms.
2625 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240"); 2653 NewSegmentAppend("0K 30 60 90K 120 150 180K 210 240");
2626 CheckExpectedRangesByTimestamp("{ [0,270) }"); 2654 CheckExpectedRangesByTimestamp("{ [0,270) }");
2627 2655
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 Seek(0); 3650 Seek(0);
3623 CheckExpectedBuffers("0K 500K 1000K 3000K 3500K 4000K"); 3651 CheckExpectedBuffers("0K 500K 1000K 3000K 3500K 4000K");
3624 } 3652 }
3625 3653
3626 TEST_F(SourceBufferStreamTest, Text_CompleteOverlap) { 3654 TEST_F(SourceBufferStreamTest, Text_CompleteOverlap) {
3627 SetTextStream(); 3655 SetTextStream();
3628 NewSegmentAppend("3000K 3500K 4000K"); 3656 NewSegmentAppend("3000K 3500K 4000K");
3629 CheckExpectedRangesByTimestamp("{ [3000,4500) }"); 3657 CheckExpectedRangesByTimestamp("{ [3000,4500) }");
3630 NewSegmentAppend("0K 501K 1001K 1501K 2001K 2501K " 3658 NewSegmentAppend("0K 501K 1001K 1501K 2001K 2501K "
3631 "3001K 3501K 4001K 4501K 5001K"); 3659 "3001K 3501K 4001K 4501K 5001K");
3632 CheckExpectedRangesByTimestamp("{ [0,5502) }"); 3660 CheckExpectedRangesByTimestamp("{ [0,5501) }");
3633 3661
3634 Seek(0); 3662 Seek(0);
3635 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2501K " 3663 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2501K "
3636 "3001K 3501K 4001K 4501K 5001K"); 3664 "3001K 3501K 4001K 4501K 5001K");
3637 } 3665 }
3638 3666
3639 TEST_F(SourceBufferStreamTest, Text_OverlapAfter) { 3667 TEST_F(SourceBufferStreamTest, Text_OverlapAfter) {
3640 SetTextStream(); 3668 SetTextStream();
3641 NewSegmentAppend("0K 500K 1000K 1500K 2000K"); 3669 NewSegmentAppend("0K 500K 1000K 1500K 2000K");
3642 CheckExpectedRangesByTimestamp("{ [0,2500) }"); 3670 CheckExpectedRangesByTimestamp("{ [0,2500) }");
3643 NewSegmentAppend("1499K 2001K 2501K 3001K"); 3671 NewSegmentAppend("1499K 2001K 2501K 3001K");
3644 CheckExpectedRangesByTimestamp("{ [0,3503) }"); 3672 CheckExpectedRangesByTimestamp("{ [0,3501) }");
3645 3673
3646 Seek(0); 3674 Seek(0);
3647 CheckExpectedBuffers("0K 500K 1000K 1499K 2001K 2501K 3001K"); 3675 CheckExpectedBuffers("0K 500K 1000K 1499K 2001K 2501K 3001K");
3648 } 3676 }
3649 3677
3650 TEST_F(SourceBufferStreamTest, Text_OverlapBefore) { 3678 TEST_F(SourceBufferStreamTest, Text_OverlapBefore) {
3651 SetTextStream(); 3679 SetTextStream();
3652 NewSegmentAppend("1500K 2000K 2500K 3000K 3500K"); 3680 NewSegmentAppend("1500K 2000K 2500K 3000K 3500K");
3653 CheckExpectedRangesByTimestamp("{ [1500,4000) }"); 3681 CheckExpectedRangesByTimestamp("{ [1500,4000) }");
3654 NewSegmentAppend("0K 501K 1001K 1501K 2001K"); 3682 NewSegmentAppend("0K 501K 1001K 1501K 2001K");
3655 CheckExpectedRangesByTimestamp("{ [0,4001) }"); 3683 CheckExpectedRangesByTimestamp("{ [0,4000) }");
3656 3684
3657 Seek(0); 3685 Seek(0);
3658 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 2500K 3000K 3500K"); 3686 CheckExpectedBuffers("0K 501K 1001K 1501K 2001K 3000K 3500K");
3659 } 3687 }
3660 3688
3661 TEST_F(SourceBufferStreamTest, SpliceFrame_Basic) { 3689 TEST_F(SourceBufferStreamTest, SpliceFrame_Basic) {
3662 Seek(0); 3690 Seek(0);
3663 NewSegmentAppend("0K S(3K 6 9 10) 15 20 S(25K 30 35) 40"); 3691 NewSegmentAppend("0K S(3K 6 9D3 10D5) 15 20 S(25K 30D5 35D5) 40");
3664 CheckExpectedBuffers("0K 3K 6 9 C 10 15 20 25K 30 C 35 40"); 3692 CheckExpectedBuffers("0K 3K 6 9 C 10 15 20 25K 30 C 35 40");
3665 CheckNoNextBuffer(); 3693 CheckNoNextBuffer();
3666 } 3694 }
3667 3695
3668 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSplice) { 3696 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSplice) {
3669 Seek(0); 3697 Seek(0);
3670 NewSegmentAppend("0K S(3K 6 9 10) 15K 20"); 3698 NewSegmentAppend("0K S(3K 6 9D3 10D5) 15K 20");
3671 CheckExpectedBuffers("0K 3K 6"); 3699 CheckExpectedBuffers("0K 3K 6");
3672 3700
3673 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); 3701 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15));
3674 CheckExpectedBuffers("15K 20"); 3702 CheckExpectedBuffers("15K 20");
3675 CheckNoNextBuffer(); 3703 CheckNoNextBuffer();
3676 } 3704 }
3677 3705
3678 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSpliceFromTrackBuffer) { 3706 TEST_F(SourceBufferStreamTest, SpliceFrame_SeekClearsSpliceFromTrackBuffer) {
3679 Seek(0); 3707 Seek(0);
3680 NewSegmentAppend("0K 2K S(3K 6 9 10) 15K 20"); 3708 NewSegmentAppend("0K 2K S(3K 6 9D3 10D5) 15K 20");
3681 CheckExpectedBuffers("0K 2K"); 3709 CheckExpectedBuffers("0K 2K");
3682 3710
3683 // Overlap the existing segment. 3711 // Overlap the existing segment.
3684 NewSegmentAppend("5K 15K 20"); 3712 NewSegmentAppend("5K 15K 20");
3685 CheckExpectedBuffers("3K 6"); 3713 CheckExpectedBuffers("3K 6");
3686 3714
3687 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15)); 3715 SeekToTimestamp(base::TimeDelta::FromMilliseconds(15));
3688 CheckExpectedBuffers("15K 20"); 3716 CheckExpectedBuffers("15K 20");
3689 CheckNoNextBuffer(); 3717 CheckNoNextBuffer();
3690 } 3718 }
3691 3719
3692 TEST_F(SourceBufferStreamTest, SpliceFrame_ConfigChangeWithinSplice) { 3720 TEST_F(SourceBufferStreamTest, SpliceFrame_ConfigChangeWithinSplice) {
3693 VideoDecoderConfig new_config = TestVideoConfig::Large(); 3721 VideoDecoderConfig new_config = TestVideoConfig::Large();
3694 ASSERT_FALSE(new_config.Matches(video_config_)); 3722 ASSERT_FALSE(new_config.Matches(video_config_));
3695 3723
3696 // Add a new video config, then reset the config index back to the original. 3724 // Add a new video config, then reset the config index back to the original.
3697 stream_->UpdateVideoConfig(new_config); 3725 stream_->UpdateVideoConfig(new_config);
3698 stream_->UpdateVideoConfig(video_config_); 3726 stream_->UpdateVideoConfig(video_config_);
3699 3727
3700 Seek(0); 3728 Seek(0);
3701 CheckVideoConfig(video_config_); 3729 CheckVideoConfig(video_config_);
3702 NewSegmentAppend("0K S(3K 6C 9 10) 15"); 3730 NewSegmentAppend("0K S(3K 6C 9D3 10D5) 15");
3703 3731
3704 CheckExpectedBuffers("0K 3K C"); 3732 CheckExpectedBuffers("0K 3K C");
3705 CheckVideoConfig(new_config); 3733 CheckVideoConfig(new_config);
3706 CheckExpectedBuffers("6 9 C"); 3734 CheckExpectedBuffers("6 9 C");
3707 CheckExpectedBuffers("10 C"); 3735 CheckExpectedBuffers("10 C");
3708 CheckVideoConfig(video_config_); 3736 CheckVideoConfig(video_config_);
3709 CheckExpectedBuffers("15"); 3737 CheckExpectedBuffers("15");
3710 CheckNoNextBuffer(); 3738 CheckNoNextBuffer();
3711 } 3739 }
3712 3740
3713 TEST_F(SourceBufferStreamTest, SpliceFrame_BasicFromTrackBuffer) { 3741 TEST_F(SourceBufferStreamTest, SpliceFrame_BasicFromTrackBuffer) {
3714 Seek(0); 3742 Seek(0);
3715 NewSegmentAppend("0K 5K S(8K 9 10) 20"); 3743 NewSegmentAppend("0K 5K S(8K 9D1 10D10) 20");
3716 CheckExpectedBuffers("0K 5K"); 3744 CheckExpectedBuffers("0K 5K");
3717 3745
3718 // Overlap the existing segment. 3746 // Overlap the existing segment.
3719 NewSegmentAppend("5K 20"); 3747 NewSegmentAppend("5K 20");
3720 CheckExpectedBuffers("8K 9 C 10 20"); 3748 CheckExpectedBuffers("8K 9 C 10 20");
3721 CheckNoNextBuffer(); 3749 CheckNoNextBuffer();
3722 } 3750 }
3723 3751
3724 TEST_F(SourceBufferStreamTest, 3752 TEST_F(SourceBufferStreamTest,
3725 SpliceFrame_ConfigChangeWithinSpliceFromTrackBuffer) { 3753 SpliceFrame_ConfigChangeWithinSpliceFromTrackBuffer) {
3726 VideoDecoderConfig new_config = TestVideoConfig::Large(); 3754 VideoDecoderConfig new_config = TestVideoConfig::Large();
3727 ASSERT_FALSE(new_config.Matches(video_config_)); 3755 ASSERT_FALSE(new_config.Matches(video_config_));
3728 3756
3729 // Add a new video config, then reset the config index back to the original. 3757 // Add a new video config, then reset the config index back to the original.
3730 stream_->UpdateVideoConfig(new_config); 3758 stream_->UpdateVideoConfig(new_config);
3731 stream_->UpdateVideoConfig(video_config_); 3759 stream_->UpdateVideoConfig(video_config_);
3732 3760
3733 Seek(0); 3761 Seek(0);
3734 CheckVideoConfig(video_config_); 3762 CheckVideoConfig(video_config_);
3735 NewSegmentAppend("0K 5K S(7K 8C 9 10) 20"); 3763 NewSegmentAppend("0K 5K S(7K 8C 9D1 10D10) 20");
3736 CheckExpectedBuffers("0K 5K"); 3764 CheckExpectedBuffers("0K 5K");
3737 3765
3738 // Overlap the existing segment. 3766 // Overlap the existing segment.
3739 NewSegmentAppend("5K 20"); 3767 NewSegmentAppend("5K 20");
3740 CheckExpectedBuffers("7K C"); 3768 CheckExpectedBuffers("7K C");
3741 CheckVideoConfig(new_config); 3769 CheckVideoConfig(new_config);
3742 CheckExpectedBuffers("8 9 C"); 3770 CheckExpectedBuffers("8 9 C");
3743 CheckExpectedBuffers("10 C"); 3771 CheckExpectedBuffers("10 C");
3744 CheckVideoConfig(video_config_); 3772 CheckVideoConfig(video_config_);
3745 CheckExpectedBuffers("20"); 3773 CheckExpectedBuffers("20");
(...skipping 24 matching lines...) Expand all
3770 Seek(0); 3798 Seek(0);
3771 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); 3799 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K");
3772 NewSegmentAppend("11K 13K 15K 17K"); 3800 NewSegmentAppend("11K 13K 15K 17K");
3773 3801
3774 // Verify the splice was created. 3802 // Verify the splice was created.
3775 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K"); 3803 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11K 13K 15K 17K");
3776 CheckNoNextBuffer(); 3804 CheckNoNextBuffer();
3777 Seek(0); 3805 Seek(0);
3778 3806
3779 // Create a splice before the first splice which would include it. 3807 // Create a splice before the first splice which would include it.
3780 NewSegmentAppend("9K"); 3808 NewSegmentAppend("9D2K");
wolenetz 2014/07/09 22:42:17 Is D2 necessary since SetAudioStream()->SetStreamI
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 Yes. frame_duration_ is not used by string based a
wolenetz 2014/07/15 21:05:37 Acknowledged.
3781 3809
3782 // A splice on top of a splice should result in a discard of the original 3810 // A splice on top of a splice should result in a discard of the original
3783 // splice and no new splice frame being generated. 3811 // splice and no new splice frame being generated.
3784 CheckExpectedBuffers("0K 2K 4K 6K 8K 9K 13K 15K 17K"); 3812 CheckExpectedBuffers("0K 2K 4K 6K 8K 9K 13K 15K 17K");
3785 CheckNoNextBuffer(); 3813 CheckNoNextBuffer();
3786 } 3814 }
3787 3815
3788 // Test that a splice is not created if an end timestamp and start timestamp 3816 // Test that a splice is not created if an end timestamp and start timestamp
3789 // overlap. 3817 // overlap.
3790 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) { 3818 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoSplice) {
3791 SetAudioStream(); 3819 SetAudioStream();
3792 Seek(0); 3820 Seek(0);
3793 NewSegmentAppend("0K 2K 4K 6K 8K 10K"); 3821 NewSegmentAppend("0K 2K 4K 6K 8K 10K");
3794 NewSegmentAppend("12K 14K 16K 18K"); 3822 NewSegmentAppend("12K 14K 16K 18K");
3795 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K 14K 16K 18K"); 3823 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K 14K 16K 18K");
3796 CheckNoNextBuffer(); 3824 CheckNoNextBuffer();
3797 } 3825 }
3798 3826
3799 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_CorrectMediaSegmentStartTime) { 3827 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_CorrectMediaSegmentStartTime) {
3800 SetAudioStream(); 3828 SetAudioStream();
3801 Seek(0); 3829 Seek(0);
3802 NewSegmentAppend("0K 2K 4K"); 3830 NewSegmentAppend("0K 2K 4K");
3803 CheckExpectedRangesByTimestamp("{ [0,6) }"); 3831 CheckExpectedRangesByTimestamp("{ [0,6) }");
3804 NewSegmentAppend("6K 8K 10K"); 3832 NewSegmentAppend("6K 8K 10K");
3805 CheckExpectedRangesByTimestamp("{ [0,12) }"); 3833 CheckExpectedRangesByTimestamp("{ [0,12) }");
3806 NewSegmentAppend("1K 4K"); 3834 NewSegmentAppend("1K 4D2K");
wolenetz 2014/07/09 22:42:16 ditto
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 The duration is only specified here because the no
wolenetz 2014/07/15 21:05:37 Acknowledged.
3807 CheckExpectedRangesByTimestamp("{ [0,12) }"); 3835 CheckExpectedRangesByTimestamp("{ [0,12) }");
3808 CheckExpectedBuffers("0K 2K 4K C 1K 4K 6K 8K 10K"); 3836 CheckExpectedBuffers("0K 2K 4K C 1K 4K 6K 8K 10K");
3809 CheckNoNextBuffer(); 3837 CheckNoNextBuffer();
3810 } 3838 }
3811 3839
3812 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) { 3840 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_ConfigChange) {
3813 SetAudioStream(); 3841 SetAudioStream();
3814 3842
3815 AudioDecoderConfig new_config(kCodecVorbis, 3843 AudioDecoderConfig new_config(kCodecVorbis,
3816 kSampleFormatPlanarF32, 3844 kSampleFormatPlanarF32,
(...skipping 16 matching lines...) Expand all
3833 3861
3834 // Ensure splices are not created if there are not enough frames to crossfade. 3862 // Ensure splices are not created if there are not enough frames to crossfade.
3835 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) { 3863 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) {
3836 SetAudioStream(); 3864 SetAudioStream();
3837 Seek(0); 3865 Seek(0);
3838 3866
3839 // Overlap the range [0, 2) with [1, 3). Since each frame has a duration of 3867 // Overlap the range [0, 2) with [1, 3). Since each frame has a duration of
3840 // 2ms this results in an overlap of 1ms between the ranges. A splice frame 3868 // 2ms this results in an overlap of 1ms between the ranges. A splice frame
3841 // should not be generated since it requires at least 2 frames, or 2ms in this 3869 // should not be generated since it requires at least 2 frames, or 2ms in this
3842 // case, of data to crossfade. 3870 // case, of data to crossfade.
3843 NewSegmentAppend("0K"); 3871 NewSegmentAppend("0D2K");
wolenetz 2014/07/09 22:42:17 ditto
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:27 ditto re: making 1 buffer case explicit.
wolenetz 2014/07/15 21:05:37 Acknowledged.
3844 CheckExpectedRangesByTimestamp("{ [0,2) }"); 3872 CheckExpectedRangesByTimestamp("{ [0,2) }");
3845 NewSegmentAppend("1K"); 3873 NewSegmentAppend("1D2K");
wolenetz 2014/07/09 22:42:17 ditto
acolwell GONE FROM CHROMIUM 2014/07/15 18:49:26 ditto re: making 1 buffer case explicit.
wolenetz 2014/07/15 21:05:37 Acknowledged.
3846 CheckExpectedRangesByTimestamp("{ [0,3) }"); 3874 CheckExpectedRangesByTimestamp("{ [0,3) }");
3847 CheckExpectedBuffers("0K 1K"); 3875 CheckExpectedBuffers("0K 1K");
3848 CheckNoNextBuffer(); 3876 CheckNoNextBuffer();
3849 } 3877 }
3850 3878
3851 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) { 3879 TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) {
3852 SetAudioStream(); 3880 SetAudioStream();
3853 Seek(0); 3881 Seek(0);
3854 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K"); 3882 NewSegmentAppend("0K 2K 4K 6K 8K 10K 12K");
3855 NewSegmentAppend("11P 13K 15K 17K"); 3883 NewSegmentAppend("11P 13K 15K 17K");
3856 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11P 13K 15K 17K"); 3884 CheckExpectedBuffers("0K 2K 4K 6K 8K 10K 12K C 11P 13K 15K 17K");
3857 CheckNoNextBuffer(); 3885 CheckNoNextBuffer();
3858 } 3886 }
3859 3887
3860 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) { 3888 TEST_F(SourceBufferStreamTest, Audio_PrerollFrame) {
3861 Seek(0); 3889 Seek(0);
3862 NewSegmentAppend("0K 3P 6K"); 3890 NewSegmentAppend("0K 3P 6K");
3863 CheckExpectedBuffers("0K 3P 6K"); 3891 CheckExpectedBuffers("0K 3P 6K");
3864 CheckNoNextBuffer(); 3892 CheckNoNextBuffer();
3865 } 3893 }
3866 3894
3867 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. 3895 // TODO(vrk): Add unit tests where keyframes are unaligned between streams.
3868 // (crbug.com/133557) 3896 // (crbug.com/133557)
3869 3897
3870 // TODO(vrk): Add unit tests with end of stream being called at interesting 3898 // TODO(vrk): Add unit tests with end of stream being called at interesting
3871 // times. 3899 // times.
3872 3900
3873 } // namespace media 3901 } // namespace media
OLDNEW
« media/base/stream_parser_buffer.cc ('K') | « media/filters/source_buffer_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698