| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "mojo/services/media/common/cpp/linear_transform.h" | 6 #include "mojo/services/media/common/cpp/linear_transform.h" |
| 7 #include "mojo/services/media/common/cpp/local_time.h" | 7 #include "mojo/services/media/common/cpp/local_time.h" |
| 8 #include "services/media/factory_service/media_sink_impl.h" | 8 #include "services/media/factory_service/media_sink_impl.h" |
| 9 #include "services/media/framework/util/conversion_pipeline_builder.h" | 9 #include "services/media/framework/util/conversion_pipeline_builder.h" |
| 10 #include "services/media/framework_mojo/mojo_type_conversions.h" | 10 #include "services/media/framework_mojo/mojo_type_conversions.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 }); | 67 }); |
| 68 | 68 |
| 69 producer_->SetStatusCallback([this](MediaState state) { | 69 producer_->SetStatusCallback([this](MediaState state) { |
| 70 producer_state_ = state; | 70 producer_state_ = state; |
| 71 status_publisher_.SendUpdates(); | 71 status_publisher_.SendUpdates(); |
| 72 if (state == MediaState::ENDED) { | 72 if (state == MediaState::ENDED) { |
| 73 Pause(); | 73 Pause(); |
| 74 } | 74 } |
| 75 }); | 75 }); |
| 76 | 76 |
| 77 // TODO(dalesat): Temporary, remove. |
| 78 if (destination_url == "nowhere") { |
| 79 // Throwing away the content. |
| 80 graph_.ConnectParts(consumer_ref, producer_ref); |
| 81 graph_.Prepare(); |
| 82 ready_.Occur(); |
| 83 return; |
| 84 } |
| 85 |
| 77 if (destination_url != "mojo:audio_server") { | 86 if (destination_url != "mojo:audio_server") { |
| 78 LOG(ERROR) << "mojo:audio_server is the only supported destination"; | 87 LOG(ERROR) << "mojo:audio_server is the only supported destination"; |
| 79 if (binding_.is_bound()) { | 88 if (binding_.is_bound()) { |
| 80 binding_.Close(); | 89 binding_.Close(); |
| 81 } | 90 } |
| 82 return; | 91 return; |
| 83 } | 92 } |
| 84 | 93 |
| 85 // TODO(dalesat): Once we have c++14, get rid of this shared pointer hack. | 94 // TODO(dalesat): Once we have c++14, get rid of this shared pointer hack. |
| 86 std::shared_ptr<StreamType> captured_stream_type( | 95 std::shared_ptr<StreamType> captured_stream_type( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void MediaSinkImpl::Pause() { | 163 void MediaSinkImpl::Pause() { |
| 155 target_rate_ = 0.0; | 164 target_rate_ = 0.0; |
| 156 MaybeSetRate(); | 165 MaybeSetRate(); |
| 157 } | 166 } |
| 158 | 167 |
| 159 void MediaSinkImpl::MaybeSetRate() { | 168 void MediaSinkImpl::MaybeSetRate() { |
| 160 if (producer_state_ < MediaState::PAUSED || rate_ == target_rate_) { | 169 if (producer_state_ < MediaState::PAUSED || rate_ == target_rate_) { |
| 161 return; | 170 return; |
| 162 } | 171 } |
| 163 | 172 |
| 164 DCHECK(rate_control_); | 173 if (!rate_control_) { |
| 174 rate_ = target_rate_; |
| 175 status_publisher_.SendUpdates(); |
| 176 return; |
| 177 } |
| 165 | 178 |
| 166 // Desired rate in frames per second. | 179 // Desired rate in frames per second. |
| 167 LinearTransform::Ratio rate_frames_per_second( | 180 LinearTransform::Ratio rate_frames_per_second( |
| 168 static_cast<uint32_t>(frames_per_second_ * target_rate_), 1); | 181 static_cast<uint32_t>(frames_per_second_ * target_rate_), 1); |
| 169 | 182 |
| 170 // Local time rate in seconds_per_tick. | 183 // Local time rate in seconds_per_tick. |
| 171 LinearTransform::Ratio local_seconds_per_tick(LocalDuration::period::num, | 184 LinearTransform::Ratio local_seconds_per_tick(LocalDuration::period::num, |
| 172 LocalDuration::period::den); | 185 LocalDuration::period::den); |
| 173 | 186 |
| 174 // Desired rate in frames per local tick. | 187 // Desired rate in frames per local tick. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 status_transform_->quad->target_delta = rate_frames_per_tick.denominator; | 263 status_transform_->quad->target_delta = rate_frames_per_tick.denominator; |
| 251 LinearTransform::Ratio::Reduce(&status_transform_->quad->reference_delta, | 264 LinearTransform::Ratio::Reduce(&status_transform_->quad->reference_delta, |
| 252 &status_transform_->quad->target_delta); | 265 &status_transform_->quad->target_delta); |
| 253 | 266 |
| 254 rate_ = target_rate_; | 267 rate_ = target_rate_; |
| 255 status_publisher_.SendUpdates(); | 268 status_publisher_.SendUpdates(); |
| 256 } | 269 } |
| 257 | 270 |
| 258 } // namespace media | 271 } // namespace media |
| 259 } // namespace mojo | 272 } // namespace mojo |
| OLD | NEW |