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

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

Issue 134883002: Let WebSourceBufferImpl::setMode() update SourceState::sequence_mode_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 ASSERT_TRUE(demuxer_->SetTimestampOffset( 2624 ASSERT_TRUE(demuxer_->SetTimestampOffset(
2625 video_id, base::TimeDelta::FromMilliseconds(27300))); 2625 video_id, base::TimeDelta::FromMilliseconds(27300)));
2626 AppendCluster(audio_id, GenerateSingleStreamCluster( 2626 AppendCluster(audio_id, GenerateSingleStreamCluster(
2627 0, kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration)); 2627 0, kAudioBlockDuration * 4, kAudioTrackNum, kAudioBlockDuration));
2628 AppendCluster(video_id, GenerateSingleStreamCluster( 2628 AppendCluster(video_id, GenerateSingleStreamCluster(
2629 0, kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration)); 2629 0, kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration));
2630 GenerateVideoStreamExpectedReads(27300, 4); 2630 GenerateVideoStreamExpectedReads(27300, 4);
2631 GenerateAudioStreamExpectedReads(27300, 4); 2631 GenerateAudioStreamExpectedReads(27300, 4);
2632 } 2632 }
2633 2633
2634 TEST_F(ChunkDemuxerTest, TimestampOffsetMidParse) { 2634 TEST_F(ChunkDemuxerTest, TimestampOffsetMidMediaSegment) {
2635 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2635 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2636 2636
2637 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2); 2637 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2);
2638 // Append only part of the cluster data. 2638 // Append only part of the cluster data.
2639 AppendData(cluster->data(), cluster->size() - 13); 2639 AppendData(cluster->data(), cluster->size() - 13);
2640 2640
2641 // Setting a timestamp should fail because we're in the middle of a cluster. 2641 // Setting a timestamp should fail because we're in the middle of a cluster.
2642 ASSERT_FALSE(demuxer_->SetTimestampOffset( 2642 ASSERT_FALSE(demuxer_->SetTimestampOffset(
2643 kSourceId, base::TimeDelta::FromSeconds(25))); 2643 kSourceId, base::TimeDelta::FromSeconds(25)));
2644 2644
2645 demuxer_->Abort(kSourceId); 2645 demuxer_->Abort(kSourceId);
2646 // After Abort(), setting a timestamp should succeed since we're no longer 2646 // After Abort(), setting a timestamp should succeed since we're no longer
2647 // in the middle of a cluster 2647 // in the middle of a cluster
2648 ASSERT_TRUE(demuxer_->SetTimestampOffset( 2648 ASSERT_TRUE(demuxer_->SetTimestampOffset(
2649 kSourceId, base::TimeDelta::FromSeconds(25))); 2649 kSourceId, base::TimeDelta::FromSeconds(25)));
2650 } 2650 }
2651 2651
2652 TEST_F(ChunkDemuxerTest, SetSequenceModeMidMediaSegment) {
2653 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2654
2655 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2);
2656 // Append only part of the cluster data.
2657 AppendData(cluster->data(), cluster->size() - 13);
2658
2659 // Setting append mode should fail because we're in the middle of a cluster.
2660 ASSERT_FALSE(demuxer_->SetSequenceMode(kSourceId, true));
2661 ASSERT_FALSE(demuxer_->SetSequenceMode(kSourceId, false));
2662
2663 demuxer_->Abort(kSourceId);
2664 // After Abort(), setting append mode should succeed since we're no longer
2665 // in the middle of a cluster.
2666 ASSERT_TRUE(demuxer_->SetSequenceMode(kSourceId, true));
2667 ASSERT_TRUE(demuxer_->SetSequenceMode(kSourceId, false));
2668 }
2669
2652 TEST_F(ChunkDemuxerTest, DurationChange) { 2670 TEST_F(ChunkDemuxerTest, DurationChange) {
2653 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 2671 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
2654 const int kStreamDuration = kDefaultDuration().InMilliseconds(); 2672 const int kStreamDuration = kDefaultDuration().InMilliseconds();
2655 2673
2656 // Add data leading up to the currently set duration. 2674 // Add data leading up to the currently set duration.
2657 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration, 2675 AppendCluster(GenerateCluster(kStreamDuration - kAudioBlockDuration,
2658 kStreamDuration - kVideoBlockDuration, 2676 kStreamDuration - kVideoBlockDuration,
2659 2)); 2677 2));
2660 2678
2661 CheckExpectedRanges(kSourceId, "{ [201191,201224) }"); 2679 CheckExpectedRanges(kSourceId, "{ [201191,201224) }");
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3088 // NOTE: we start at 175 here because the buffer at 125 was returned 3106 // NOTE: we start at 175 here because the buffer at 125 was returned
3089 // to the pending read initiated above. 3107 // to the pending read initiated above.
3090 CheckExpectedBuffers(text_stream, "175 225"); 3108 CheckExpectedBuffers(text_stream, "175 225");
3091 3109
3092 // Verify that audio & video streams contiue to return expected values. 3110 // Verify that audio & video streams contiue to return expected values.
3093 CheckExpectedBuffers(audio_stream, "160 180"); 3111 CheckExpectedBuffers(audio_stream, "160 180");
3094 CheckExpectedBuffers(video_stream, "180 210"); 3112 CheckExpectedBuffers(video_stream, "180 210");
3095 } 3113 }
3096 3114
3097 } // namespace media 3115 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698