| OLD | NEW |
| 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/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 volume_(1.0f), | 39 volume_(1.0f), |
| 40 playback_rate_(0.0), | 40 playback_rate_(0.0), |
| 41 status_(PIPELINE_OK), | 41 status_(PIPELINE_OK), |
| 42 state_(kCreated), | 42 state_(kCreated), |
| 43 renderer_ended_(false), | 43 renderer_ended_(false), |
| 44 text_renderer_ended_(false), | 44 text_renderer_ended_(false), |
| 45 demuxer_(NULL), | 45 demuxer_(NULL), |
| 46 pending_cdm_context_(nullptr), | 46 pending_cdm_context_(nullptr), |
| 47 weak_factory_(this) { | 47 weak_factory_(this) { |
| 48 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated)); | 48 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated)); |
| 49 |
| 50 // By default these values are initialized to -1 to indicate no data, but |
| 51 // Pipeline clients should always see a zero value in these cases. |
| 52 statistics_.audio_memory_usage = 0; |
| 53 statistics_.video_memory_usage = 0; |
| 49 } | 54 } |
| 50 | 55 |
| 51 Pipeline::~Pipeline() { | 56 Pipeline::~Pipeline() { |
| 52 DCHECK(thread_checker_.CalledOnValidThread()) | 57 DCHECK(thread_checker_.CalledOnValidThread()) |
| 53 << "Pipeline must be destroyed on same thread that created it"; | 58 << "Pipeline must be destroyed on same thread that created it"; |
| 54 DCHECK(!running_) << "Stop() must complete before destroying object"; | 59 DCHECK(!running_) << "Stop() must complete before destroying object"; |
| 55 DCHECK(stop_cb_.is_null()); | 60 DCHECK(stop_cb_.is_null()); |
| 56 DCHECK(seek_cb_.is_null()); | 61 DCHECK(seek_cb_.is_null()); |
| 57 } | 62 } |
| 58 | 63 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 did_loading_progress_ = true; | 470 did_loading_progress_ = true; |
| 466 } | 471 } |
| 467 | 472 |
| 468 // Called from any thread. | 473 // Called from any thread. |
| 469 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { | 474 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { |
| 470 base::AutoLock auto_lock(lock_); | 475 base::AutoLock auto_lock(lock_); |
| 471 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 476 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
| 472 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 477 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
| 473 statistics_.video_frames_decoded += stats.video_frames_decoded; | 478 statistics_.video_frames_decoded += stats.video_frames_decoded; |
| 474 statistics_.video_frames_dropped += stats.video_frames_dropped; | 479 statistics_.video_frames_dropped += stats.video_frames_dropped; |
| 480 |
| 481 if (stats.audio_memory_usage >= 0) |
| 482 statistics_.audio_memory_usage = stats.audio_memory_usage; |
| 483 if (stats.video_memory_usage >= 0) |
| 484 statistics_.video_memory_usage = stats.video_memory_usage; |
| 475 } | 485 } |
| 476 | 486 |
| 477 void Pipeline::StartTask() { | 487 void Pipeline::StartTask() { |
| 478 DCHECK(task_runner_->BelongsToCurrentThread()); | 488 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 479 | 489 |
| 480 CHECK_EQ(kCreated, state_) | 490 CHECK_EQ(kCreated, state_) |
| 481 << "Media pipeline cannot be started more than once"; | 491 << "Media pipeline cannot be started more than once"; |
| 482 | 492 |
| 483 text_renderer_ = CreateTextRenderer(); | 493 text_renderer_ = CreateTextRenderer(); |
| 484 if (text_renderer_) { | 494 if (text_renderer_) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 metadata_cb_.Run(metadata); | 737 metadata_cb_.Run(metadata); |
| 728 } | 738 } |
| 729 | 739 |
| 730 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { | 740 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { |
| 731 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; | 741 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; |
| 732 DCHECK(task_runner_->BelongsToCurrentThread()); | 742 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 733 buffering_state_cb_.Run(new_buffering_state); | 743 buffering_state_cb_.Run(new_buffering_state); |
| 734 } | 744 } |
| 735 | 745 |
| 736 } // namespace media | 746 } // namespace media |
| OLD | NEW |