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

Side by Side Diff: media/base/pipeline_impl.cc

Issue 7587007: Log FilterHost events in PipelineImpl to MediaLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« media/base/media_log_event.h ('K') | « media/base/media_log_event.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names,
6 // potential deadlocks, etc... 6 // potential deadlocks, etc...
7 7
8 #include "media/base/pipeline_impl.h" 8 #include "media/base/pipeline_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 PipelineStatistics PipelineImpl::GetStatistics() const { 335 PipelineStatistics PipelineImpl::GetStatistics() const {
336 base::AutoLock auto_lock(lock_); 336 base::AutoLock auto_lock(lock_);
337 return statistics_; 337 return statistics_;
338 } 338 }
339 339
340 void PipelineImpl::SetClockForTesting(Clock* clock) { 340 void PipelineImpl::SetClockForTesting(Clock* clock) {
341 clock_.reset(clock); 341 clock_.reset(clock);
342 } 342 }
343 343
344 void PipelineImpl::SetCurrentReadPosition(int64 offset) { 344 void PipelineImpl::SetCurrentReadPosition(int64 offset) {
345 media_log_->AddEvent(
346 media_log_->CreateIntegerEvent(
347 MediaLogEvent::CURRENT_READ_POSITION_SET, "read_position", offset));
345 base::AutoLock auto_lock(lock_); 348 base::AutoLock auto_lock(lock_);
346 349
347 // The current read position should never be ahead of the buffered byte 350 // The current read position should never be ahead of the buffered byte
348 // position but threading issues between BufferedDataSource::DoneRead_Locked() 351 // position but threading issues between BufferedDataSource::DoneRead_Locked()
349 // and BufferedDataSource::NetworkEventCallback() can cause them to be 352 // and BufferedDataSource::NetworkEventCallback() can cause them to be
350 // temporarily out of sync. The easiest fix for this is to cap both 353 // temporarily out of sync. The easiest fix for this is to cap both
351 // buffered_bytes_ and current_bytes_ to always be legal values in 354 // buffered_bytes_ and current_bytes_ to always be legal values in
352 // SetCurrentReadPosition() and in SetBufferedBytes(). 355 // SetCurrentReadPosition() and in SetBufferedBytes().
353 if (offset > buffered_bytes_) 356 if (offset > buffered_bytes_)
354 buffered_bytes_ = offset; 357 buffered_bytes_ = offset;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 469 }
467 } 470 }
468 471
469 void PipelineImpl::SetError(PipelineStatus error) { 472 void PipelineImpl::SetError(PipelineStatus error) {
470 DCHECK(IsRunning()); 473 DCHECK(IsRunning());
471 DCHECK_NE(PIPELINE_OK, error); 474 DCHECK_NE(PIPELINE_OK, error);
472 VLOG(1) << "Media pipeline error: " << error; 475 VLOG(1) << "Media pipeline error: " << error;
473 476
474 message_loop_->PostTask(FROM_HERE, 477 message_loop_->PostTask(FROM_HERE,
475 NewRunnableMethod(this, &PipelineImpl::ErrorChangedTask, error)); 478 NewRunnableMethod(this, &PipelineImpl::ErrorChangedTask, error));
479
480 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error));
476 } 481 }
477 482
478 base::TimeDelta PipelineImpl::GetTime() const { 483 base::TimeDelta PipelineImpl::GetTime() const {
479 DCHECK(IsRunning()); 484 DCHECK(IsRunning());
480 return GetCurrentTime(); 485 return GetCurrentTime();
481 } 486 }
482 487
483 base::TimeDelta PipelineImpl::GetDuration() const { 488 base::TimeDelta PipelineImpl::GetDuration() const {
484 DCHECK(IsRunning()); 489 DCHECK(IsRunning());
485 return GetMediaDuration(); 490 return GetMediaDuration();
486 } 491 }
487 492
488 void PipelineImpl::SetTime(base::TimeDelta time) { 493 void PipelineImpl::SetTime(base::TimeDelta time) {
489 DCHECK(IsRunning()); 494 DCHECK(IsRunning());
495 media_log_->AddEvent(
496 media_log_->CreateTimeEvent(MediaLogEvent::TIME_SET, "time", time));
497
490 base::AutoLock auto_lock(lock_); 498 base::AutoLock auto_lock(lock_);
491 499
492 // If we were waiting for a valid timestamp and such timestamp arrives, we 500 // If we were waiting for a valid timestamp and such timestamp arrives, we
493 // need to clear the flag for waiting and start the clock. 501 // need to clear the flag for waiting and start the clock.
494 if (waiting_for_clock_update_) { 502 if (waiting_for_clock_update_) {
495 if (time < clock_->Elapsed()) 503 if (time < clock_->Elapsed())
496 return; 504 return;
497 waiting_for_clock_update_ = false; 505 waiting_for_clock_update_ = false;
498 clock_->SetTime(time); 506 clock_->SetTime(time);
499 clock_->Play(); 507 clock_->Play();
500 return; 508 return;
501 } 509 }
502 clock_->SetTime(time); 510 clock_->SetTime(time);
503 } 511 }
504 512
505 void PipelineImpl::SetDuration(base::TimeDelta duration) { 513 void PipelineImpl::SetDuration(base::TimeDelta duration) {
506 DCHECK(IsRunning()); 514 DCHECK(IsRunning());
515 media_log_->AddEvent(
516 media_log_->CreateTimeEvent(
517 MediaLogEvent::DURATION_SET, "duration", duration));
518
507 base::AutoLock auto_lock(lock_); 519 base::AutoLock auto_lock(lock_);
508 duration_ = duration; 520 duration_ = duration;
509 } 521 }
510 522
511 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) { 523 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) {
512 DCHECK(IsRunning()); 524 DCHECK(IsRunning());
525 media_log_->AddEvent(
526 media_log_->CreateTimeEvent(
527 MediaLogEvent::BUFFERED_TIME_SET, "buffered_time", buffered_time));
528
513 base::AutoLock auto_lock(lock_); 529 base::AutoLock auto_lock(lock_);
514 buffered_time_ = buffered_time; 530 buffered_time_ = buffered_time;
515 } 531 }
516 532
517 void PipelineImpl::SetTotalBytes(int64 total_bytes) { 533 void PipelineImpl::SetTotalBytes(int64 total_bytes) {
518 DCHECK(IsRunning()); 534 DCHECK(IsRunning());
535 media_log_->AddEvent(
536 media_log_->CreateIntegerEvent(
537 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes));
538
519 base::AutoLock auto_lock(lock_); 539 base::AutoLock auto_lock(lock_);
520 total_bytes_ = total_bytes; 540 total_bytes_ = total_bytes;
521 } 541 }
522 542
523 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { 543 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) {
524 DCHECK(IsRunning()); 544 DCHECK(IsRunning());
545 media_log_->AddEvent(
546 media_log_->CreateIntegerEvent(
547 MediaLogEvent::BUFFERED_BYTES_SET, "buffered_bytes", buffered_bytes));
548
525 base::AutoLock auto_lock(lock_); 549 base::AutoLock auto_lock(lock_);
526 550
527 // See comments in SetCurrentReadPosition() about capping. 551 // See comments in SetCurrentReadPosition() about capping.
528 if (buffered_bytes < current_bytes_) 552 if (buffered_bytes < current_bytes_)
529 current_bytes_ = buffered_bytes; 553 current_bytes_ = buffered_bytes;
530 buffered_bytes_ = buffered_bytes; 554 buffered_bytes_ = buffered_bytes;
531 } 555 }
532 556
533 void PipelineImpl::SetVideoSize(size_t width, size_t height) { 557 void PipelineImpl::SetVideoSize(size_t width, size_t height) {
534 DCHECK(IsRunning()); 558 DCHECK(IsRunning());
559 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(width, height));
560
535 base::AutoLock auto_lock(lock_); 561 base::AutoLock auto_lock(lock_);
536 video_width_ = width; 562 video_width_ = width;
537 video_height_ = height; 563 video_height_ = height;
538 } 564 }
539 565
540 void PipelineImpl::SetStreaming(bool streaming) { 566 void PipelineImpl::SetStreaming(bool streaming) {
541 DCHECK(IsRunning()); 567 DCHECK(IsRunning());
568 media_log_->AddEvent(
569 media_log_->CreateBooleanEvent(
570 MediaLogEvent::STREAMING_SET, "streaming", streaming));
571
542 base::AutoLock auto_lock(lock_); 572 base::AutoLock auto_lock(lock_);
543 streaming_ = streaming; 573 streaming_ = streaming;
544 } 574 }
545 575
546 void PipelineImpl::NotifyEnded() { 576 void PipelineImpl::NotifyEnded() {
547 DCHECK(IsRunning()); 577 DCHECK(IsRunning());
548 message_loop_->PostTask(FROM_HERE, 578 message_loop_->PostTask(FROM_HERE,
549 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask)); 579 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask));
580 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED));
550 } 581 }
551 582
552 void PipelineImpl::SetLoaded(bool loaded) { 583 void PipelineImpl::SetLoaded(bool loaded) {
553 DCHECK(IsRunning()); 584 DCHECK(IsRunning());
585 media_log_->AddEvent(
586 media_log_->CreateBooleanEvent(
587 MediaLogEvent::LOADED_SET, "loaded", loaded));
588
554 base::AutoLock auto_lock(lock_); 589 base::AutoLock auto_lock(lock_);
555 loaded_ = loaded; 590 loaded_ = loaded;
556 } 591 }
557 592
558 void PipelineImpl::SetNetworkActivity(bool network_activity) { 593 void PipelineImpl::SetNetworkActivity(bool network_activity) {
559 DCHECK(IsRunning()); 594 DCHECK(IsRunning());
560 { 595 {
561 base::AutoLock auto_lock(lock_); 596 base::AutoLock auto_lock(lock_);
562 network_activity_ = network_activity; 597 network_activity_ = network_activity;
563 } 598 }
564 message_loop_->PostTask(FROM_HERE, 599 message_loop_->PostTask(FROM_HERE,
565 NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask)); 600 NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask));
601 media_log_->AddEvent(
602 media_log_->CreateBooleanEvent(
603 MediaLogEvent::NETWORK_ACTIVITY_SET,
604 "network_activity", network_activity));
566 } 605 }
567 606
568 void PipelineImpl::DisableAudioRenderer() { 607 void PipelineImpl::DisableAudioRenderer() {
569 DCHECK(IsRunning()); 608 DCHECK(IsRunning());
570 609
571 // Disable renderer on the message loop. 610 // Disable renderer on the message loop.
572 message_loop_->PostTask(FROM_HERE, 611 message_loop_->PostTask(FROM_HERE,
573 NewRunnableMethod(this, &PipelineImpl::DisableAudioRendererTask)); 612 NewRunnableMethod(this, &PipelineImpl::DisableAudioRendererTask));
613 media_log_->AddEvent(
614 media_log_->CreateEvent(MediaLogEvent::AUDIO_RENDERER_DISABLED));
574 } 615 }
575 616
576 // Called from any thread. 617 // Called from any thread.
577 void PipelineImpl::OnFilterInitialize() { 618 void PipelineImpl::OnFilterInitialize() {
578 // Continue the initialize task by proceeding to the next stage. 619 // Continue the initialize task by proceeding to the next stage.
579 message_loop_->PostTask(FROM_HERE, 620 message_loop_->PostTask(FROM_HERE,
580 NewRunnableMethod(this, &PipelineImpl::InitializeTask)); 621 NewRunnableMethod(this, &PipelineImpl::InitializeTask));
581 } 622 }
582 623
583 // Called from any thread. 624 // Called from any thread.
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 case kStopping: 1354 case kStopping:
1314 case kStopped: 1355 case kStopped:
1315 NOTREACHED() << "Unexpected state for teardown: " << state_; 1356 NOTREACHED() << "Unexpected state for teardown: " << state_;
1316 break; 1357 break;
1317 // default: intentionally left out to force new states to cause compiler 1358 // default: intentionally left out to force new states to cause compiler
1318 // errors. 1359 // errors.
1319 }; 1360 };
1320 } 1361 }
1321 1362
1322 } // namespace media 1363 } // namespace media
OLDNEW
« media/base/media_log_event.h ('K') | « media/base/media_log_event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698