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

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

Issue 10823300: Make ChunkDemuxer::SetTimestampOffset take a TimeDelta instead of double (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | « no previous file | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "media/base/audio_decoder_config.h" 7 #include "media/base/audio_decoder_config.h"
8 #include "media/base/decoder_buffer.h" 8 #include "media/base/decoder_buffer.h"
9 #include "media/base/mock_callback.h" 9 #include "media/base/mock_callback.h"
10 #include "media/base/mock_demuxer_host.h" 10 #include "media/base/mock_demuxer_host.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { 71 MATCHER_P(HasTimestamp, timestamp_in_ms, "") {
72 return arg && !arg->IsEndOfStream() && 72 return arg && !arg->IsEndOfStream() &&
73 arg->GetTimestamp().InMilliseconds() == timestamp_in_ms; 73 arg->GetTimestamp().InMilliseconds() == timestamp_in_ms;
74 } 74 }
75 75
76 MATCHER(IsEndOfStream, "") { 76 MATCHER(IsEndOfStream, "") {
77 return arg && arg->IsEndOfStream(); 77 return arg && arg->IsEndOfStream();
78 } 78 }
79 79
80 // Note: This matcher is needed because of a precision error in 32-bit linux.
81 // If 32-bit linux is compiled with -march=pentium4 -msse2 -mfpmath=sse, the
82 // precision error goes away. These flags are turned on in Chromium but off in
83 // Chrome so that people with older CPUs can run Chrome.
84 MATCHER_P(ApproximatelyEquals, timestamp, "") {
85 base::TimeDelta delta = base::TimeDelta::FromMicroseconds(
86 std::abs(timestamp.InMicroseconds() - arg.InMicroseconds()));
87
88 // 5 microseconds is chosen arbitrarily.
89 return delta < base::TimeDelta::FromMicroseconds(5);
90 }
91
80 static void OnReadDone(const base::TimeDelta& expected_time, 92 static void OnReadDone(const base::TimeDelta& expected_time,
81 bool* called, 93 bool* called,
82 DemuxerStream::Status status, 94 DemuxerStream::Status status,
83 const scoped_refptr<DecoderBuffer>& buffer) { 95 const scoped_refptr<DecoderBuffer>& buffer) {
84 EXPECT_EQ(status, DemuxerStream::kOk); 96 EXPECT_EQ(status, DemuxerStream::kOk);
85 EXPECT_EQ(expected_time, buffer->GetTimestamp()); 97 EXPECT_EQ(expected_time, buffer->GetTimestamp());
86 *called = true; 98 *called = true;
87 } 99 }
88 100
89 static void OnReadDone_AbortExpected( 101 static void OnReadDone_AbortExpected(
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 ASSERT_TRUE(AppendData(third_cluster->data(), third_cluster->size())); 2322 ASSERT_TRUE(AppendData(third_cluster->data(), third_cluster->size()));
2311 2323
2312 // See that the range has increased appropriately. 2324 // See that the range has increased appropriately.
2313 CheckExpectedRanges(kSourceId, "{ [201191,201270) }"); 2325 CheckExpectedRanges(kSourceId, "{ [201191,201270) }");
2314 } 2326 }
2315 2327
2316 TEST_F(ChunkDemuxerTest, TestDurationChangeTimestampOffset) { 2328 TEST_F(ChunkDemuxerTest, TestDurationChangeTimestampOffset) {
2317 ASSERT_TRUE(InitDemuxer(true, true, false)); 2329 ASSERT_TRUE(InitDemuxer(true, true, false));
2318 2330
2319 ASSERT_TRUE(demuxer_->SetTimestampOffset(kSourceId, 2331 ASSERT_TRUE(demuxer_->SetTimestampOffset(kSourceId,
2320 kDefaultDuration().InSecondsF())); 2332 kDefaultDuration().InSecondsF()));
Ami GONE FROM CHROMIUM 2012/08/14 00:05:18 Per offline convo: IWBN if ChunkDemuxer dealt only
2321 scoped_ptr<Cluster> cluster = GenerateCluster(0, 4); 2333 scoped_ptr<Cluster> cluster = GenerateCluster(0, 4);
2322 2334
2323 EXPECT_CALL(host_, SetDuration( 2335 base::TimeDelta expected_duration = kDefaultDuration() +
2324 kDefaultDuration() + base::TimeDelta::FromMilliseconds( 2336 base::TimeDelta::FromMilliseconds(kAudioBlockDuration * 2);
2325 kAudioBlockDuration * 2))); 2337
2338 EXPECT_CALL(host_, SetDuration(ApproximatelyEquals(expected_duration)));
2326 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); 2339 ASSERT_TRUE(AppendData(cluster->data(), cluster->size()));
2327 } 2340 }
2328 2341
2329 TEST_F(ChunkDemuxerTest, TestEndOfStreamTruncateDuration) { 2342 TEST_F(ChunkDemuxerTest, TestEndOfStreamTruncateDuration) {
2330 ASSERT_TRUE(InitDemuxer(true, true, false)); 2343 ASSERT_TRUE(InitDemuxer(true, true, false));
2331 2344
2332 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); 2345 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster());
2333 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); 2346 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size()));
2334 2347
2335 EXPECT_CALL(host_, SetDuration( 2348 EXPECT_CALL(host_, SetDuration(
2336 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); 2349 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp)));
2337 demuxer_->EndOfStream(PIPELINE_OK); 2350 demuxer_->EndOfStream(PIPELINE_OK);
2338 } 2351 }
2339 2352
2340 } // namespace media 2353 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698