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 14 matching lines...) Expand all Loading... |
25 #include "chromecast/media/cma/pipeline/video_pipeline_impl.h" | 25 #include "chromecast/media/cma/pipeline/video_pipeline_impl.h" |
26 #include "chromecast/public/media/media_pipeline_backend.h" | 26 #include "chromecast/public/media/media_pipeline_backend.h" |
27 #include "media/base/timestamp_constants.h" | 27 #include "media/base/timestamp_constants.h" |
28 | 28 |
29 namespace chromecast { | 29 namespace chromecast { |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Buffering parameters when load_type is kLoadTypeUrl. | 34 // Buffering parameters when load_type is kLoadTypeUrl. |
35 constexpr base::TimeDelta kLowBufferThresholdURL( | 35 const base::TimeDelta kLowBufferThresholdURL( |
36 base::TimeDelta::FromMilliseconds(2000)); | 36 base::TimeDelta::FromMilliseconds(2000)); |
37 constexpr base::TimeDelta kHighBufferThresholdURL( | 37 const base::TimeDelta kHighBufferThresholdURL( |
38 base::TimeDelta::FromMilliseconds(6000)); | 38 base::TimeDelta::FromMilliseconds(6000)); |
39 | 39 |
40 // Buffering parameters when load_type is kLoadTypeMediaSource. | 40 // Buffering parameters when load_type is kLoadTypeMediaSource. |
41 constexpr base::TimeDelta kLowBufferThresholdMediaSource( | 41 const base::TimeDelta kLowBufferThresholdMediaSource( |
42 base::TimeDelta::FromMilliseconds(0)); | 42 base::TimeDelta::FromMilliseconds(0)); |
43 constexpr base::TimeDelta kHighBufferThresholdMediaSource( | 43 const base::TimeDelta kHighBufferThresholdMediaSource( |
44 base::TimeDelta::FromMilliseconds(300)); | 44 base::TimeDelta::FromMilliseconds(300)); |
45 | 45 |
46 // Buffering parameters when load_type is kLoadTypeCommunication. | |
47 constexpr base::TimeDelta kLowBufferThresholdCommunication( | |
48 base::TimeDelta::FromMilliseconds(0)); | |
49 constexpr base::TimeDelta kHighBufferThresholdCommunication( | |
50 base::TimeDelta::FromMilliseconds(20)); | |
51 | |
52 // Interval between two updates of the media time. | 46 // Interval between two updates of the media time. |
53 constexpr base::TimeDelta kTimeUpdateInterval( | 47 const base::TimeDelta kTimeUpdateInterval( |
54 base::TimeDelta::FromMilliseconds(250)); | 48 base::TimeDelta::FromMilliseconds(250)); |
55 | 49 |
56 // Interval between two updates of the statistics is equal to: | 50 // Interval between two updates of the statistics is equal to: |
57 // kTimeUpdateInterval * kStatisticsUpdatePeriod. | 51 // kTimeUpdateInterval * kStatisticsUpdatePeriod. |
58 const int kStatisticsUpdatePeriod = 4; | 52 const int kStatisticsUpdatePeriod = 4; |
59 | 53 |
60 // Stall duration threshold that triggers a playback stall event. | 54 // Stall duration threshold that triggers a playback stall event. |
61 constexpr int kPlaybackStallEventThresholdMs = 2500; | 55 constexpr int kPlaybackStallEventThresholdMs = 2500; |
62 | 56 |
63 void LogEstimatedBitrate(int decoded_bytes, | 57 void LogEstimatedBitrate(int decoded_bytes, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
123 audio_decoder_.reset(); | 117 audio_decoder_.reset(); |
124 media_pipeline_backend_ = std::move(media_pipeline_backend); | 118 media_pipeline_backend_ = std::move(media_pipeline_backend); |
125 | 119 |
126 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) { | 120 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) { |
127 base::TimeDelta low_threshold(kLowBufferThresholdURL); | 121 base::TimeDelta low_threshold(kLowBufferThresholdURL); |
128 base::TimeDelta high_threshold(kHighBufferThresholdURL); | 122 base::TimeDelta high_threshold(kHighBufferThresholdURL); |
129 if (load_type == kLoadTypeMediaSource) { | 123 if (load_type == kLoadTypeMediaSource) { |
130 low_threshold = kLowBufferThresholdMediaSource; | 124 low_threshold = kLowBufferThresholdMediaSource; |
131 high_threshold = kHighBufferThresholdMediaSource; | 125 high_threshold = kHighBufferThresholdMediaSource; |
132 } else if (load_type == kLoadTypeCommunication) { | |
133 low_threshold = kLowBufferThresholdCommunication; | |
134 high_threshold = kHighBufferThresholdCommunication; | |
135 } | 126 } |
136 scoped_refptr<BufferingConfig> buffering_config( | 127 scoped_refptr<BufferingConfig> buffering_config( |
137 new BufferingConfig(low_threshold, high_threshold)); | 128 new BufferingConfig(low_threshold, high_threshold)); |
138 buffering_controller_.reset(new BufferingController( | 129 buffering_controller_.reset(new BufferingController( |
139 buffering_config, | 130 buffering_config, |
140 base::Bind(&MediaPipelineImpl::OnBufferingNotification, weak_this_))); | 131 base::Bind(&MediaPipelineImpl::OnBufferingNotification, weak_this_))); |
141 } | 132 } |
142 } | 133 } |
143 | 134 |
144 void MediaPipelineImpl::SetClient(const MediaPipelineClient& client) { | 135 void MediaPipelineImpl::SetClient(const MediaPipelineClient& client) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 524 |
534 void MediaPipelineImpl::ResetBitrateState() { | 525 void MediaPipelineImpl::ResetBitrateState() { |
535 elapsed_time_delta_ = base::TimeDelta::FromSeconds(0); | 526 elapsed_time_delta_ = base::TimeDelta::FromSeconds(0); |
536 audio_bytes_for_bitrate_estimation_ = 0; | 527 audio_bytes_for_bitrate_estimation_ = 0; |
537 video_bytes_for_bitrate_estimation_ = 0; | 528 video_bytes_for_bitrate_estimation_ = 0; |
538 last_sample_time_ = base::TimeTicks::Now(); | 529 last_sample_time_ = base::TimeTicks::Now(); |
539 } | 530 } |
540 | 531 |
541 } // namespace media | 532 } // namespace media |
542 } // namespace chromecast | 533 } // namespace chromecast |
OLD | NEW |