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

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

Issue 10692053: Remove buffer duration calculation from WebMClusterParser and update SourceBufferStream accordingly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "media/base/audio_decoder_config.h" 6 #include "media/base/audio_decoder_config.h"
7 #include "media/base/decoder_buffer.h" 7 #include "media/base/decoder_buffer.h"
8 #include "media/base/mock_callback.h" 8 #include "media/base/mock_callback.h"
9 #include "media/base/mock_demuxer_host.h" 9 #include "media/base/mock_demuxer_host.h"
10 #include "media/base/test_data_util.h" 10 #include "media/base/test_data_util.h"
(...skipping 28 matching lines...) Expand all
39 static const int kVideoTrackEntryHeaderSize = kVideoTrackSizeOffset + 39 static const int kVideoTrackEntryHeaderSize = kVideoTrackSizeOffset +
40 kVideoTrackSizeWidth; 40 kVideoTrackSizeWidth;
41 41
42 static const int kVideoTrackNum = 1; 42 static const int kVideoTrackNum = 1;
43 static const int kAudioTrackNum = 2; 43 static const int kAudioTrackNum = 2;
44 44
45 static const int kAudioBlockDuration = 23; 45 static const int kAudioBlockDuration = 23;
46 static const int kVideoBlockDuration = 33; 46 static const int kVideoBlockDuration = 33;
47 47
48 static const char* kSourceId = "SourceId"; 48 static const char* kSourceId = "SourceId";
49 static const char* kDefaultFirstClusterRange = "{ [0,46) }"; 49 static const char* kDefaultFirstClusterRange = "{ [0,23) }";
acolwell GONE FROM CHROMIUM 2012/07/02 17:12:33 ?
vrk (LEFT CHROMIUM) 2012/07/04 02:50:18 Reverted.
50 50
51 base::TimeDelta kDefaultDuration() { 51 base::TimeDelta kDefaultDuration() {
52 return base::TimeDelta::FromMilliseconds(201224); 52 return base::TimeDelta::FromMilliseconds(201224);
53 } 53 }
54 54
55 // Write an integer into buffer in the form of vint that spans 8 bytes. 55 // Write an integer into buffer in the form of vint that spans 8 bytes.
56 // The data pointed by |buffer| should be at least 8 bytes long. 56 // The data pointed by |buffer| should be at least 8 bytes long.
57 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. 57 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF.
58 static void WriteInt64(uint8* buffer, int64 number) { 58 static void WriteInt64(uint8* buffer, int64 number) {
59 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); 59 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const uint8* start = data; 249 const uint8* start = data;
250 const uint8* end = data + length; 250 const uint8* end = data + length;
251 while (start < end) { 251 while (start < end) {
252 base::TimeDelta old_buffered_time = buffered_time_; 252 base::TimeDelta old_buffered_time = buffered_time_;
253 size_t append_size = std::min(piece_size, 253 size_t append_size = std::min(piece_size,
254 static_cast<size_t>(end - start)); 254 static_cast<size_t>(end - start));
255 if (!AppendData(start, append_size)) 255 if (!AppendData(start, append_size))
256 return false; 256 return false;
257 start += append_size; 257 start += append_size;
258 258
259 EXPECT_GE(buffered_time_, old_buffered_time); 259 EXPECT_GE(buffered_time_, old_buffered_time);
vrk (LEFT CHROMIUM) 2012/07/04 02:50:18 Note: Had to delete this because of the duration a
260 } 260 }
261 return true; 261 return true;
262 } 262 }
263 263
264 bool AppendInitSegment(bool has_audio, bool has_video, 264 bool AppendInitSegment(bool has_audio, bool has_video,
265 bool video_content_encoded) { 265 bool video_content_encoded) {
266 return AppendInitSegment(kSourceId, has_audio, has_video, 266 return AppendInitSegment(kSourceId, has_audio, has_video,
267 video_content_encoded); 267 video_content_encoded);
268 } 268 }
269 269
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 AddSimpleBlock(&cb, kAudioTrackNum, 5); 821 AddSimpleBlock(&cb, kAudioTrackNum, 5);
822 AddSimpleBlock(&cb, kVideoTrackNum, 5); 822 AddSimpleBlock(&cb, kVideoTrackNum, 5);
823 AddSimpleBlock(&cb, kAudioTrackNum, 4); 823 AddSimpleBlock(&cb, kAudioTrackNum, 4);
824 AddSimpleBlock(&cb, kVideoTrackNum, 7); 824 AddSimpleBlock(&cb, kVideoTrackNum, 7);
825 scoped_ptr<Cluster> cluster(cb.Finish()); 825 scoped_ptr<Cluster> cluster(cb.Finish());
826 826
827 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE)); 827 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE));
828 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); 828 ASSERT_TRUE(AppendData(cluster->data(), cluster->size()));
829 } 829 }
830 830
831 TEST_F(ChunkDemuxerTest, TestMonotonicallyIncreasingTimestampsAcrossClusters) {
832 ASSERT_TRUE(InitDemuxer(true, true, false));
833
834 ClusterBuilder cb;
835
836 // Test monotonic increasing timestamps on a per stream
837 // basis across clusters.
838 cb.SetClusterTimecode(5);
839 AddSimpleBlock(&cb, kAudioTrackNum, 5);
840 AddSimpleBlock(&cb, kVideoTrackNum, 5);
841 scoped_ptr<Cluster> cluster_a(cb.Finish());
842
843 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size()));
844
845 cb.SetClusterTimecode(4);
846 AddSimpleBlock(&cb, kAudioTrackNum, 4);
847 AddSimpleBlock(&cb, kVideoTrackNum, 7);
848 scoped_ptr<Cluster> cluster_b(cb.Finish());
849
850 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_DECODE));
851 ASSERT_TRUE(AppendData(cluster_b->data(), cluster_b->size()));
852
853 // Verify that AppendData() doesn't accept more data now.
854 scoped_ptr<Cluster> cluster_c(GenerateCluster(10, 2));
855 EXPECT_FALSE(demuxer_->AppendData(kSourceId, cluster_c->data(),
856 cluster_c->size()));
857 }
858
859 // Test the case where a cluster is passed to AppendData() before 831 // Test the case where a cluster is passed to AppendData() before
860 // INFO & TRACKS data. 832 // INFO & TRACKS data.
861 TEST_F(ChunkDemuxerTest, TestClusterBeforeInitSegment) { 833 TEST_F(ChunkDemuxerTest, TestClusterBeforeInitSegment) {
862 EXPECT_CALL(*client_, DemuxerOpened(_)); 834 EXPECT_CALL(*client_, DemuxerOpened(_));
863 demuxer_->Initialize( 835 demuxer_->Initialize(
864 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN)); 836 &host_, NewExpectedStatusCB(DEMUXER_ERROR_COULD_NOT_OPEN));
865 837
866 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); 838 ASSERT_EQ(AddId(), ChunkDemuxer::kOk);
867 839
868 scoped_ptr<Cluster> cluster(GenerateCluster(0, 1)); 840 scoped_ptr<Cluster> cluster(GenerateCluster(0, 1));
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 EXPECT_CALL(*client_, DemuxerOpened(_)); 1682 EXPECT_CALL(*client_, DemuxerOpened(_));
1711 demuxer_->Initialize(&host_, CreateInitDoneCB(PIPELINE_OK)); 1683 demuxer_->Initialize(&host_, CreateInitDoneCB(PIPELINE_OK));
1712 ASSERT_EQ(AddId("audio", true, false), ChunkDemuxer::kOk); 1684 ASSERT_EQ(AddId("audio", true, false), ChunkDemuxer::kOk);
1713 ASSERT_EQ(AddId("video", false, true), ChunkDemuxer::kOk); 1685 ASSERT_EQ(AddId("video", false, true), ChunkDemuxer::kOk);
1714 1686
1715 CheckExpectedRanges("audio", "{ }"); 1687 CheckExpectedRanges("audio", "{ }");
1716 CheckExpectedRanges("video", "{ }"); 1688 CheckExpectedRanges("video", "{ }");
1717 } 1689 }
1718 1690
1719 } // namespace media 1691 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698