| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/media/cma/pipeline/media_pipeline_impl.h" | 5 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 weak_factory_(this) { | 96 weak_factory_(this) { |
| 97 CMALOG(kLogControl) << __FUNCTION__; | 97 CMALOG(kLogControl) << __FUNCTION__; |
| 98 weak_this_ = weak_factory_.GetWeakPtr(); | 98 weak_this_ = weak_factory_.GetWeakPtr(); |
| 99 thread_checker_.DetachFromThread(); | 99 thread_checker_.DetachFromThread(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 MediaPipelineImpl::~MediaPipelineImpl() { | 102 MediaPipelineImpl::~MediaPipelineImpl() { |
| 103 CMALOG(kLogControl) << __FUNCTION__; | 103 CMALOG(kLogControl) << __FUNCTION__; |
| 104 DCHECK(thread_checker_.CalledOnValidThread()); | 104 DCHECK(thread_checker_.CalledOnValidThread()); |
| 105 | 105 |
| 106 weak_factory_.InvalidateWeakPtrs(); | |
| 107 | |
| 108 if (backend_state_ != BACKEND_STATE_UNINITIALIZED && | 106 if (backend_state_ != BACKEND_STATE_UNINITIALIZED && |
| 109 backend_state_ != BACKEND_STATE_INITIALIZED) | 107 backend_state_ != BACKEND_STATE_INITIALIZED) |
| 110 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEvent( | 108 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEvent( |
| 111 "Cast.Platform.Ended"); | 109 "Cast.Platform.Ended"); |
| 112 | |
| 113 // Since av pipeline still need to access device components in their | |
| 114 // destructor, it's important to delete them first. | |
| 115 video_pipeline_.reset(); | |
| 116 audio_pipeline_.reset(); | |
| 117 audio_decoder_.reset(); | |
| 118 media_pipeline_backend_.reset(); | |
| 119 if (!client_.pipeline_backend_destroyed_cb.is_null()) | |
| 120 client_.pipeline_backend_destroyed_cb.Run(); | |
| 121 } | 110 } |
| 122 | 111 |
| 123 void MediaPipelineImpl::Initialize( | 112 void MediaPipelineImpl::Initialize( |
| 124 LoadType load_type, | 113 LoadType load_type, |
| 125 std::unique_ptr<MediaPipelineBackend> media_pipeline_backend) { | 114 std::unique_ptr<MediaPipelineBackend> media_pipeline_backend) { |
| 126 CMALOG(kLogControl) << __FUNCTION__; | 115 CMALOG(kLogControl) << __FUNCTION__; |
| 127 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
| 128 audio_decoder_.reset(); | 117 audio_decoder_.reset(); |
| 129 media_pipeline_backend_.reset(media_pipeline_backend.release()); | 118 media_pipeline_backend_ = std::move(media_pipeline_backend); |
| 130 if (!client_.pipeline_backend_created_cb.is_null()) | |
| 131 client_.pipeline_backend_created_cb.Run(); | |
| 132 | 119 |
| 133 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) { | 120 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) { |
| 134 base::TimeDelta low_threshold(kLowBufferThresholdURL); | 121 base::TimeDelta low_threshold(kLowBufferThresholdURL); |
| 135 base::TimeDelta high_threshold(kHighBufferThresholdURL); | 122 base::TimeDelta high_threshold(kHighBufferThresholdURL); |
| 136 if (load_type == kLoadTypeMediaSource) { | 123 if (load_type == kLoadTypeMediaSource) { |
| 137 low_threshold = kLowBufferThresholdMediaSource; | 124 low_threshold = kLowBufferThresholdMediaSource; |
| 138 high_threshold = kHighBufferThresholdMediaSource; | 125 high_threshold = kHighBufferThresholdMediaSource; |
| 139 } | 126 } |
| 140 scoped_refptr<BufferingConfig> buffering_config( | 127 scoped_refptr<BufferingConfig> buffering_config( |
| 141 new BufferingConfig(low_threshold, high_threshold)); | 128 new BufferingConfig(low_threshold, high_threshold)); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 558 |
| 572 void MediaPipelineImpl::ResetBitrateState() { | 559 void MediaPipelineImpl::ResetBitrateState() { |
| 573 elapsed_time_delta_ = base::TimeDelta::FromSeconds(0); | 560 elapsed_time_delta_ = base::TimeDelta::FromSeconds(0); |
| 574 audio_bytes_for_bitrate_estimation_ = 0; | 561 audio_bytes_for_bitrate_estimation_ = 0; |
| 575 video_bytes_for_bitrate_estimation_ = 0; | 562 video_bytes_for_bitrate_estimation_ = 0; |
| 576 last_sample_time_ = base::TimeTicks::Now(); | 563 last_sample_time_ = base::TimeTicks::Now(); |
| 577 } | 564 } |
| 578 | 565 |
| 579 } // namespace media | 566 } // namespace media |
| 580 } // namespace chromecast | 567 } // namespace chromecast |
| OLD | NEW |