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

Side by Side Diff: media/test/pipeline_integration_test_base.cc

Issue 1935873002: Implement disabling and enabling media tracks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control2
Patch Set: Added tests to verify no rendering happens for disabled tracks Created 4 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/test/pipeline_integration_test_base.h" 5 #include "media/test/pipeline_integration_test_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; 42 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,";
43 43
44 PipelineIntegrationTestBase::PipelineIntegrationTestBase() 44 PipelineIntegrationTestBase::PipelineIntegrationTestBase()
45 : hashing_enabled_(false), 45 : hashing_enabled_(false),
46 clockless_playback_(false), 46 clockless_playback_(false),
47 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())), 47 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())),
48 ended_(false), 48 ended_(false),
49 pipeline_status_(PIPELINE_OK), 49 pipeline_status_(PIPELINE_OK),
50 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), 50 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
51 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) { 51 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) {
52 base::MD5Init(&md5_context_); 52 ResetVideoHash();
53 } 53 }
54 54
55 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { 55 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() {
56 if (pipeline_->IsRunning()) 56 if (pipeline_->IsRunning())
57 Stop(); 57 Stop();
58 58
59 pipeline_.reset(); 59 pipeline_.reset();
60 message_loop_.RunUntilIdle(); 60 message_loop_.RunUntilIdle();
61 } 61 }
62 62
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 void PipelineIntegrationTestBase::OnVideoFramePaint( 361 void PipelineIntegrationTestBase::OnVideoFramePaint(
362 const scoped_refptr<VideoFrame>& frame) { 362 const scoped_refptr<VideoFrame>& frame) {
363 last_video_frame_format_ = frame->format(); 363 last_video_frame_format_ = frame->format();
364 int result; 364 int result;
365 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result)) 365 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result))
366 last_video_frame_color_space_ = static_cast<ColorSpace>(result); 366 last_video_frame_color_space_ = static_cast<ColorSpace>(result);
367 if (!hashing_enabled_ || last_frame_ == frame) 367 if (!hashing_enabled_ || last_frame_ == frame)
368 return; 368 return;
369 last_frame_ = frame; 369 last_frame_ = frame;
370 DVLOG(3) << __FUNCTION__ << " pts=" << frame->timestamp().InSecondsF();
370 VideoFrame::HashFrameForTesting(&md5_context_, frame); 371 VideoFrame::HashFrameForTesting(&md5_context_, frame);
371 } 372 }
372 373
374 void PipelineIntegrationTestBase::ResetVideoHash() {
375 base::MD5Init(&md5_context_);
376 }
377
373 std::string PipelineIntegrationTestBase::GetVideoHash() { 378 std::string PipelineIntegrationTestBase::GetVideoHash() {
374 DCHECK(hashing_enabled_); 379 DCHECK(hashing_enabled_);
375 base::MD5Digest digest; 380 base::MD5Digest digest;
376 base::MD5Final(&digest, &md5_context_); 381 base::MD5Final(&digest, &md5_context_);
377 return base::MD5DigestToBase16(digest); 382 return base::MD5DigestToBase16(digest);
378 } 383 }
379 384
380 std::string PipelineIntegrationTestBase::GetAudioHash() { 385 std::string PipelineIntegrationTestBase::GetAudioHash() {
381 DCHECK(hashing_enabled_); 386 DCHECK(hashing_enabled_);
382 387
383 if (clockless_playback_) 388 if (clockless_playback_)
384 return clockless_audio_sink_->GetAudioHashForTesting(); 389 return clockless_audio_sink_->GetAudioHashForTesting();
385 return audio_sink_->GetAudioHashForTesting(); 390 return audio_sink_->GetAudioHashForTesting();
386 } 391 }
387 392
388 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() { 393 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() {
389 DCHECK(clockless_playback_); 394 DCHECK(clockless_playback_);
390 return clockless_audio_sink_->render_time(); 395 return clockless_audio_sink_->render_time();
391 } 396 }
392 397
393 base::TimeTicks DummyTickClock::NowTicks() { 398 base::TimeTicks DummyTickClock::NowTicks() {
394 now_ += base::TimeDelta::FromSeconds(60); 399 now_ += base::TimeDelta::FromSeconds(60);
395 return now_; 400 return now_;
396 } 401 }
397 402
398 } // namespace media 403 } // namespace media
OLDNEW
« media/test/pipeline_integration_test.cc ('K') | « media/test/pipeline_integration_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698