| OLD | NEW |
| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 void PipelineImpl::SetError(PipelineStatus error) { | 469 void PipelineImpl::SetError(PipelineStatus error) { |
| 470 DCHECK(IsRunning()); | 470 DCHECK(IsRunning()); |
| 471 DCHECK_NE(PIPELINE_OK, error); | 471 DCHECK_NE(PIPELINE_OK, error); |
| 472 VLOG(1) << "Media pipeline error: " << error; | 472 VLOG(1) << "Media pipeline error: " << error; |
| 473 | 473 |
| 474 message_loop_->PostTask(FROM_HERE, | 474 message_loop_->PostTask(FROM_HERE, |
| 475 NewRunnableMethod(this, &PipelineImpl::ErrorChangedTask, error)); | 475 NewRunnableMethod(this, &PipelineImpl::ErrorChangedTask, error)); |
| 476 |
| 477 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error)); |
| 476 } | 478 } |
| 477 | 479 |
| 478 base::TimeDelta PipelineImpl::GetTime() const { | 480 base::TimeDelta PipelineImpl::GetTime() const { |
| 479 DCHECK(IsRunning()); | 481 DCHECK(IsRunning()); |
| 480 return GetCurrentTime(); | 482 return GetCurrentTime(); |
| 481 } | 483 } |
| 482 | 484 |
| 483 base::TimeDelta PipelineImpl::GetDuration() const { | 485 base::TimeDelta PipelineImpl::GetDuration() const { |
| 484 DCHECK(IsRunning()); | 486 DCHECK(IsRunning()); |
| 485 return GetMediaDuration(); | 487 return GetMediaDuration(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 497 waiting_for_clock_update_ = false; | 499 waiting_for_clock_update_ = false; |
| 498 clock_->SetTime(time); | 500 clock_->SetTime(time); |
| 499 clock_->Play(); | 501 clock_->Play(); |
| 500 return; | 502 return; |
| 501 } | 503 } |
| 502 clock_->SetTime(time); | 504 clock_->SetTime(time); |
| 503 } | 505 } |
| 504 | 506 |
| 505 void PipelineImpl::SetDuration(base::TimeDelta duration) { | 507 void PipelineImpl::SetDuration(base::TimeDelta duration) { |
| 506 DCHECK(IsRunning()); | 508 DCHECK(IsRunning()); |
| 509 media_log_->AddEvent( |
| 510 media_log_->CreateTimeEvent( |
| 511 MediaLogEvent::DURATION_SET, "duration", duration)); |
| 512 |
| 507 base::AutoLock auto_lock(lock_); | 513 base::AutoLock auto_lock(lock_); |
| 508 duration_ = duration; | 514 duration_ = duration; |
| 509 } | 515 } |
| 510 | 516 |
| 511 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) { | 517 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) { |
| 512 DCHECK(IsRunning()); | 518 DCHECK(IsRunning()); |
| 513 base::AutoLock auto_lock(lock_); | 519 base::AutoLock auto_lock(lock_); |
| 514 buffered_time_ = buffered_time; | 520 buffered_time_ = buffered_time; |
| 515 } | 521 } |
| 516 | 522 |
| 517 void PipelineImpl::SetTotalBytes(int64 total_bytes) { | 523 void PipelineImpl::SetTotalBytes(int64 total_bytes) { |
| 518 DCHECK(IsRunning()); | 524 DCHECK(IsRunning()); |
| 525 media_log_->AddEvent( |
| 526 media_log_->CreateIntegerEvent( |
| 527 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes)); |
| 528 |
| 519 base::AutoLock auto_lock(lock_); | 529 base::AutoLock auto_lock(lock_); |
| 520 total_bytes_ = total_bytes; | 530 total_bytes_ = total_bytes; |
| 521 } | 531 } |
| 522 | 532 |
| 523 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { | 533 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { |
| 524 DCHECK(IsRunning()); | 534 DCHECK(IsRunning()); |
| 525 base::AutoLock auto_lock(lock_); | 535 base::AutoLock auto_lock(lock_); |
| 526 | 536 |
| 527 // See comments in SetCurrentReadPosition() about capping. | 537 // See comments in SetCurrentReadPosition() about capping. |
| 528 if (buffered_bytes < current_bytes_) | 538 if (buffered_bytes < current_bytes_) |
| 529 current_bytes_ = buffered_bytes; | 539 current_bytes_ = buffered_bytes; |
| 530 buffered_bytes_ = buffered_bytes; | 540 buffered_bytes_ = buffered_bytes; |
| 531 } | 541 } |
| 532 | 542 |
| 533 void PipelineImpl::SetVideoSize(size_t width, size_t height) { | 543 void PipelineImpl::SetVideoSize(size_t width, size_t height) { |
| 534 DCHECK(IsRunning()); | 544 DCHECK(IsRunning()); |
| 545 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(width, height)); |
| 546 |
| 535 base::AutoLock auto_lock(lock_); | 547 base::AutoLock auto_lock(lock_); |
| 536 video_width_ = width; | 548 video_width_ = width; |
| 537 video_height_ = height; | 549 video_height_ = height; |
| 538 } | 550 } |
| 539 | 551 |
| 540 void PipelineImpl::SetStreaming(bool streaming) { | 552 void PipelineImpl::SetStreaming(bool streaming) { |
| 541 DCHECK(IsRunning()); | 553 DCHECK(IsRunning()); |
| 554 media_log_->AddEvent( |
| 555 media_log_->CreateBooleanEvent( |
| 556 MediaLogEvent::STREAMING_SET, "streaming", streaming)); |
| 557 |
| 542 base::AutoLock auto_lock(lock_); | 558 base::AutoLock auto_lock(lock_); |
| 543 streaming_ = streaming; | 559 streaming_ = streaming; |
| 544 } | 560 } |
| 545 | 561 |
| 546 void PipelineImpl::NotifyEnded() { | 562 void PipelineImpl::NotifyEnded() { |
| 547 DCHECK(IsRunning()); | 563 DCHECK(IsRunning()); |
| 548 message_loop_->PostTask(FROM_HERE, | 564 message_loop_->PostTask(FROM_HERE, |
| 549 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask)); | 565 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask)); |
| 566 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED)); |
| 550 } | 567 } |
| 551 | 568 |
| 552 void PipelineImpl::SetLoaded(bool loaded) { | 569 void PipelineImpl::SetLoaded(bool loaded) { |
| 553 DCHECK(IsRunning()); | 570 DCHECK(IsRunning()); |
| 571 media_log_->AddEvent( |
| 572 media_log_->CreateBooleanEvent( |
| 573 MediaLogEvent::LOADED_SET, "loaded", loaded)); |
| 574 |
| 554 base::AutoLock auto_lock(lock_); | 575 base::AutoLock auto_lock(lock_); |
| 555 loaded_ = loaded; | 576 loaded_ = loaded; |
| 556 } | 577 } |
| 557 | 578 |
| 558 void PipelineImpl::SetNetworkActivity(bool network_activity) { | 579 void PipelineImpl::SetNetworkActivity(bool network_activity) { |
| 559 DCHECK(IsRunning()); | 580 DCHECK(IsRunning()); |
| 560 { | 581 { |
| 561 base::AutoLock auto_lock(lock_); | 582 base::AutoLock auto_lock(lock_); |
| 562 network_activity_ = network_activity; | 583 network_activity_ = network_activity; |
| 563 } | 584 } |
| 564 message_loop_->PostTask(FROM_HERE, | 585 message_loop_->PostTask(FROM_HERE, |
| 565 NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask)); | 586 NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask)); |
| 587 media_log_->AddEvent( |
| 588 media_log_->CreateBooleanEvent( |
| 589 MediaLogEvent::NETWORK_ACTIVITY_SET, |
| 590 "network_activity", network_activity)); |
| 566 } | 591 } |
| 567 | 592 |
| 568 void PipelineImpl::DisableAudioRenderer() { | 593 void PipelineImpl::DisableAudioRenderer() { |
| 569 DCHECK(IsRunning()); | 594 DCHECK(IsRunning()); |
| 570 | 595 |
| 571 // Disable renderer on the message loop. | 596 // Disable renderer on the message loop. |
| 572 message_loop_->PostTask(FROM_HERE, | 597 message_loop_->PostTask(FROM_HERE, |
| 573 NewRunnableMethod(this, &PipelineImpl::DisableAudioRendererTask)); | 598 NewRunnableMethod(this, &PipelineImpl::DisableAudioRendererTask)); |
| 599 media_log_->AddEvent( |
| 600 media_log_->CreateEvent(MediaLogEvent::AUDIO_RENDERER_DISABLED)); |
| 574 } | 601 } |
| 575 | 602 |
| 576 // Called from any thread. | 603 // Called from any thread. |
| 577 void PipelineImpl::OnFilterInitialize() { | 604 void PipelineImpl::OnFilterInitialize() { |
| 578 // Continue the initialize task by proceeding to the next stage. | 605 // Continue the initialize task by proceeding to the next stage. |
| 579 message_loop_->PostTask(FROM_HERE, | 606 message_loop_->PostTask(FROM_HERE, |
| 580 NewRunnableMethod(this, &PipelineImpl::InitializeTask)); | 607 NewRunnableMethod(this, &PipelineImpl::InitializeTask)); |
| 581 } | 608 } |
| 582 | 609 |
| 583 // Called from any thread. | 610 // Called from any thread. |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 case kStopping: | 1340 case kStopping: |
| 1314 case kStopped: | 1341 case kStopped: |
| 1315 NOTREACHED() << "Unexpected state for teardown: " << state_; | 1342 NOTREACHED() << "Unexpected state for teardown: " << state_; |
| 1316 break; | 1343 break; |
| 1317 // default: intentionally left out to force new states to cause compiler | 1344 // default: intentionally left out to force new states to cause compiler |
| 1318 // errors. | 1345 // errors. |
| 1319 }; | 1346 }; |
| 1320 } | 1347 } |
| 1321 | 1348 |
| 1322 } // namespace media | 1349 } // namespace media |
| OLD | NEW |