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

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: rebase 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
« no previous file with comments | « media/test/pipeline_integration_test_base.h ('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 "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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; 44 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,";
45 45
46 PipelineIntegrationTestBase::PipelineIntegrationTestBase() 46 PipelineIntegrationTestBase::PipelineIntegrationTestBase()
47 : hashing_enabled_(false), 47 : hashing_enabled_(false),
48 clockless_playback_(false), 48 clockless_playback_(false),
49 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())), 49 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())),
50 ended_(false), 50 ended_(false),
51 pipeline_status_(PIPELINE_OK), 51 pipeline_status_(PIPELINE_OK),
52 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), 52 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
53 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) { 53 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) {
54 base::MD5Init(&md5_context_); 54 ResetVideoHash();
55 } 55 }
56 56
57 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { 57 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() {
58 if (pipeline_->IsRunning()) 58 if (pipeline_->IsRunning())
59 Stop(); 59 Stop();
60 60
61 pipeline_.reset(); 61 pipeline_.reset();
62 base::RunLoop().RunUntilIdle(); 62 base::RunLoop().RunUntilIdle();
63 } 63 }
64 64
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 bool PipelineIntegrationTestBase::Seek(base::TimeDelta seek_time) { 207 bool PipelineIntegrationTestBase::Seek(base::TimeDelta seek_time) {
208 ended_ = false; 208 ended_ = false;
209 209
210 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 210 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
211 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); 211 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow));
212 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked, 212 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked,
213 base::Unretained(this), seek_time)); 213 base::Unretained(this), seek_time));
214 base::RunLoop().Run(); 214 base::RunLoop().Run();
215 EXPECT_CALL(*this, OnBufferingStateChange(_)).Times(AnyNumber());
215 return (pipeline_status_ == PIPELINE_OK); 216 return (pipeline_status_ == PIPELINE_OK);
216 } 217 }
217 218
218 bool PipelineIntegrationTestBase::Suspend() { 219 bool PipelineIntegrationTestBase::Suspend() {
219 pipeline_->Suspend(base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, 220 pipeline_->Suspend(base::Bind(&PipelineIntegrationTestBase::OnStatusCallback,
220 base::Unretained(this))); 221 base::Unretained(this)));
221 base::RunLoop().Run(); 222 base::RunLoop().Run();
222 return (pipeline_status_ == PIPELINE_OK); 223 return (pipeline_status_ == PIPELINE_OK);
223 } 224 }
224 225
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 366
366 void PipelineIntegrationTestBase::OnVideoFramePaint( 367 void PipelineIntegrationTestBase::OnVideoFramePaint(
367 const scoped_refptr<VideoFrame>& frame) { 368 const scoped_refptr<VideoFrame>& frame) {
368 last_video_frame_format_ = frame->format(); 369 last_video_frame_format_ = frame->format();
369 int result; 370 int result;
370 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result)) 371 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result))
371 last_video_frame_color_space_ = static_cast<ColorSpace>(result); 372 last_video_frame_color_space_ = static_cast<ColorSpace>(result);
372 if (!hashing_enabled_ || last_frame_ == frame) 373 if (!hashing_enabled_ || last_frame_ == frame)
373 return; 374 return;
374 last_frame_ = frame; 375 last_frame_ = frame;
376 DVLOG(3) << __FUNCTION__ << " pts=" << frame->timestamp().InSecondsF();
375 VideoFrame::HashFrameForTesting(&md5_context_, frame); 377 VideoFrame::HashFrameForTesting(&md5_context_, frame);
376 } 378 }
377 379
380 void PipelineIntegrationTestBase::ResetVideoHash() {
381 DVLOG(1) << __FUNCTION__;
382 base::MD5Init(&md5_context_);
383 }
384
378 std::string PipelineIntegrationTestBase::GetVideoHash() { 385 std::string PipelineIntegrationTestBase::GetVideoHash() {
379 DCHECK(hashing_enabled_); 386 DCHECK(hashing_enabled_);
380 base::MD5Digest digest; 387 base::MD5Digest digest;
381 base::MD5Final(&digest, &md5_context_); 388 base::MD5Final(&digest, &md5_context_);
382 return base::MD5DigestToBase16(digest); 389 return base::MD5DigestToBase16(digest);
383 } 390 }
384 391
385 std::string PipelineIntegrationTestBase::GetAudioHash() { 392 std::string PipelineIntegrationTestBase::GetAudioHash() {
386 DCHECK(hashing_enabled_); 393 DCHECK(hashing_enabled_);
387 394
388 if (clockless_playback_) 395 if (clockless_playback_)
389 return clockless_audio_sink_->GetAudioHashForTesting(); 396 return clockless_audio_sink_->GetAudioHashForTesting();
390 return audio_sink_->GetAudioHashForTesting(); 397 return audio_sink_->GetAudioHashForTesting();
391 } 398 }
392 399
393 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() { 400 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() {
394 DCHECK(clockless_playback_); 401 DCHECK(clockless_playback_);
395 return clockless_audio_sink_->render_time(); 402 return clockless_audio_sink_->render_time();
396 } 403 }
397 404
398 base::TimeTicks DummyTickClock::NowTicks() { 405 base::TimeTicks DummyTickClock::NowTicks() {
399 now_ += base::TimeDelta::FromSeconds(60); 406 now_ += base::TimeDelta::FromSeconds(60);
400 return now_; 407 return now_;
401 } 408 }
402 409
403 } // namespace media 410 } // namespace media
OLDNEW
« no previous file with comments | « 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