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

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

Issue 10558011: Fix ChunkDemuxer so it properly outputs buffered ranges. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 const uint8* start = data; 248 const uint8* start = data;
249 const uint8* end = data + length; 249 const uint8* end = data + length;
250 while (start < end) { 250 while (start < end) {
251 int64 old_buffered_bytes = buffered_bytes_; 251 int64 old_buffered_bytes = buffered_bytes_;
252 size_t append_size = std::min(piece_size, 252 size_t append_size = std::min(piece_size,
253 static_cast<size_t>(end - start)); 253 static_cast<size_t>(end - start));
254 if (!AppendData(start, append_size)) 254 if (!AppendData(start, append_size))
255 return false; 255 return false;
256 start += append_size; 256 start += append_size;
257 257
258 EXPECT_GT(buffered_bytes_, old_buffered_bytes); 258 EXPECT_GE(buffered_bytes_, old_buffered_bytes);
Ami GONE FROM CHROMIUM 2012/06/18 16:18:31 Why the change? Rounding?
acolwell GONE FROM CHROMIUM 2012/06/19 06:12:34 Some of the appends are smaller than an actual fra
259 } 259 }
260 return true; 260 return true;
261 } 261 }
262 262
263 bool AppendInitSegment(bool has_audio, bool has_video, 263 bool AppendInitSegment(bool has_audio, bool has_video,
264 bool video_content_encoded) { 264 bool video_content_encoded) {
265 return AppendInitSegment(kSourceId, has_audio, has_video, 265 return AppendInitSegment(kSourceId, has_audio, has_video,
266 video_content_encoded); 266 video_content_encoded);
267 } 267 }
268 268
269 bool AppendInitSegment(const std::string& source_id, 269 bool AppendInitSegment(const std::string& source_id,
270 bool has_audio, bool has_video, 270 bool has_audio, bool has_video,
271 bool video_content_encoded) { 271 bool video_content_encoded) {
272 scoped_array<uint8> info_tracks; 272 scoped_array<uint8> info_tracks;
273 int info_tracks_size = 0; 273 int info_tracks_size = 0;
274 CreateInitSegment(has_audio, has_video, video_content_encoded, 274 CreateInitSegment(has_audio, has_video, video_content_encoded,
275 &info_tracks, &info_tracks_size); 275 &info_tracks, &info_tracks_size);
276 return AppendData(source_id, info_tracks.get(), info_tracks_size); 276 return AppendData(source_id, info_tracks.get(), info_tracks_size);
277 } 277 }
278 278
279 void InitDoneCalled(PipelineStatus expected_status, 279 void InitDoneCalled(PipelineStatus expected_status,
280 PipelineStatus status) { 280 PipelineStatus status) {
281 EXPECT_EQ(status, expected_status); 281 EXPECT_EQ(status, expected_status);
282 } 282 }
283 283
284 PipelineStatusCB CreateInitDoneCB(const base::TimeDelta& expected_duration, 284 PipelineStatusCB CreateInitDoneCB(const base::TimeDelta& expected_duration,
285 PipelineStatus expected_status) { 285 PipelineStatus expected_status) {
286 if (expected_status == PIPELINE_OK) 286 if (expected_status == PIPELINE_OK) {
287 if (expected_duration != kInfiniteDuration())
288 EXPECT_CALL(host_, SetTotalBytes(_));
287 EXPECT_CALL(host_, SetDuration(expected_duration)); 289 EXPECT_CALL(host_, SetDuration(expected_duration));
290 }
288 291
289 return base::Bind(&ChunkDemuxerTest::InitDoneCalled, 292 return base::Bind(&ChunkDemuxerTest::InitDoneCalled,
290 base::Unretained(this), 293 base::Unretained(this),
291 expected_status); 294 expected_status);
292 } 295 }
293 296
294 bool InitDemuxer(bool has_audio, bool has_video, 297 bool InitDemuxer(bool has_audio, bool has_video,
295 bool video_content_encoded) { 298 bool video_content_encoded) {
296 PipelineStatus expected_status = 299 PipelineStatus expected_status =
297 (has_audio || has_video) ? PIPELINE_OK : DEMUXER_ERROR_COULD_NOT_OPEN; 300 (has_audio || has_video) ? PIPELINE_OK : DEMUXER_ERROR_COULD_NOT_OPEN;
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 NewExpectedStatusCB(PIPELINE_OK)); 1619 NewExpectedStatusCB(PIPELINE_OK));
1617 1620
1618 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms 1621 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms
1619 // after the video. 1622 // after the video.
1620 scoped_ptr<Cluster> middle_cluster(GenerateCluster(5025, 5000, 8)); 1623 scoped_ptr<Cluster> middle_cluster(GenerateCluster(5025, 5000, 8));
1621 ASSERT_TRUE(AppendData(middle_cluster->data(), middle_cluster->size())); 1624 ASSERT_TRUE(AppendData(middle_cluster->data(), middle_cluster->size()));
1622 GenerateExpectedReads(5025, 5000, 8, audio, video); 1625 GenerateExpectedReads(5025, 5000, 8, audio, video);
1623 } 1626 }
1624 1627
1625 } // namespace media 1628 } // namespace media
OLDNEW
« media/filters/chunk_demuxer.cc ('K') | « media/filters/chunk_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698