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/conversion_pipeline_builder.h" | 9 #include "services/media/framework/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 &graph_, &out, &producer_stream_type); | 105 &graph_, &out, &producer_stream_type); |
106 if (!result) { | 106 if (!result) { |
107 // Failed to build conversion pipeline. | 107 // Failed to build conversion pipeline. |
108 producer_state_ = MediaState::FAULT; | 108 producer_state_ = MediaState::FAULT; |
109 status_publisher_.SendUpdates(); | 109 status_publisher_.SendUpdates(); |
110 return; | 110 return; |
111 } | 111 } |
112 | 112 |
113 graph_.ConnectOutputToPart(out, producer_ref); | 113 graph_.ConnectOutputToPart(out, producer_ref); |
114 | 114 |
115 switch (producer_stream_type->scheme()) { | 115 if (producer_stream_type->medium() == StreamType::Medium::kAudio) { |
116 case StreamType::Scheme::kLpcm: | 116 frames_per_second_ = producer_stream_type->audio()->frames_per_second(); |
117 frames_per_second_ = producer_stream_type->lpcm()->frames_per_second(); | 117 } else { |
118 break; | 118 // Unsupported producer stream type. |
119 case StreamType::Scheme::kCompressedAudio: | 119 LOG(ERROR) << "unsupported producer stream type"; |
120 frames_per_second_ = | 120 abort(); |
121 producer_stream_type->compressed_audio()->frames_per_second(); | |
122 break; | |
123 default: | |
124 // Unsupported producer stream type. | |
125 producer_state_ = MediaState::FAULT; | |
126 status_publisher_.SendUpdates(); | |
127 return; | |
128 } | 121 } |
129 | 122 |
130 controller_->Configure( | 123 controller_->Configure( |
131 std::move(producer_stream_type), | 124 std::move(producer_stream_type), |
132 [this](MediaConsumerPtr consumer, RateControlPtr rate_control) { | 125 [this](MediaConsumerPtr consumer, RateControlPtr rate_control) { |
133 DCHECK(consumer); | 126 DCHECK(consumer); |
134 DCHECK(rate_control); | 127 DCHECK(rate_control); |
135 rate_control_ = rate_control.Pass(); | 128 rate_control_ = rate_control.Pass(); |
136 producer_->Connect(consumer.Pass(), [this]() { | 129 producer_->Connect(consumer.Pass(), [this]() { |
137 graph_.Prepare(); | 130 graph_.Prepare(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 status_transform_->quad->target_delta = rate_frames_per_tick.denominator; | 250 status_transform_->quad->target_delta = rate_frames_per_tick.denominator; |
258 LinearTransform::Ratio::Reduce(&status_transform_->quad->reference_delta, | 251 LinearTransform::Ratio::Reduce(&status_transform_->quad->reference_delta, |
259 &status_transform_->quad->target_delta); | 252 &status_transform_->quad->target_delta); |
260 | 253 |
261 rate_ = target_rate_; | 254 rate_ = target_rate_; |
262 status_publisher_.SendUpdates(); | 255 status_publisher_.SendUpdates(); |
263 } | 256 } |
264 | 257 |
265 } // namespace media | 258 } // namespace media |
266 } // namespace mojo | 259 } // namespace mojo |
OLD | NEW |