| 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 "services/media/factory_service/media_player_impl.h" | 6 #include "services/media/factory_service/media_player_impl.h" |
| 7 #include "services/media/framework/callback_joiner.h" | 7 #include "services/media/framework/callback_joiner.h" |
| 8 #include "services/media/framework/parts/reader.h" | 8 #include "services/media/framework/parts/reader.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 HandleDemuxMetadataUpdates(); | 46 HandleDemuxMetadataUpdates(); |
| 47 | 47 |
| 48 demux_->Describe([this](mojo::Array<MediaTypePtr> stream_types) { | 48 demux_->Describe([this](mojo::Array<MediaTypePtr> stream_types) { |
| 49 // Populate streams_ and enable the streams we want. | 49 // Populate streams_ and enable the streams we want. |
| 50 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); | 50 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); |
| 51 | 51 |
| 52 for (MediaTypePtr& stream_type : stream_types) { | 52 for (MediaTypePtr& stream_type : stream_types) { |
| 53 streams_.push_back(std::unique_ptr<Stream>( | 53 streams_.push_back(std::unique_ptr<Stream>( |
| 54 new Stream(streams_.size(), stream_type.Pass()))); | 54 new Stream(streams_.size(), stream_type.Pass()))); |
| 55 Stream& stream = *streams_.back(); | 55 Stream& stream = *streams_.back(); |
| 56 switch (stream.media_type_->scheme) { | 56 switch (stream.media_type_->medium) { |
| 57 case MediaTypeScheme::COMPRESSED_AUDIO: | 57 case MediaTypeMedium::AUDIO: |
| 58 case MediaTypeScheme::LPCM: | |
| 59 stream.enabled_ = true; | 58 stream.enabled_ = true; |
| 60 PrepareStream(streams_.back(), "mojo:audio_server", | 59 PrepareStream(streams_.back(), "mojo:audio_server", |
| 61 callback_joiner->NewCallback()); | 60 callback_joiner->NewCallback()); |
| 62 break; | 61 break; |
| 63 // TODO(dalesat): Enable other stream types. | 62 // TODO(dalesat): Enable other stream types. |
| 64 default: | 63 default: |
| 65 break; | 64 break; |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 Update(); | 248 Update(); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void MediaPlayerImpl::PrepareStream(const std::unique_ptr<Stream>& stream, | 251 void MediaPlayerImpl::PrepareStream(const std::unique_ptr<Stream>& stream, |
| 253 const String& url, | 252 const String& url, |
| 254 const std::function<void()>& callback) { | 253 const std::function<void()>& callback) { |
| 255 DCHECK(factory_); | 254 DCHECK(factory_); |
| 256 | 255 |
| 257 demux_->GetProducer(stream->index_, GetProxy(&stream->encoded_producer_)); | 256 demux_->GetProducer(stream->index_, GetProxy(&stream->encoded_producer_)); |
| 258 | 257 |
| 259 if (stream->media_type_->scheme == MediaTypeScheme::COMPRESSED_AUDIO) { | 258 if (stream->media_type_->encoding != MediaType::kAudioEncodingLpcm) { |
| 260 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); | 259 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); |
| 261 | 260 |
| 262 // Compressed audio. Insert a decoder in front of the sink. The sink would | 261 // Compressed audio. Insert a decoder in front of the sink. The sink would |
| 263 // add its own internal decoder, but we want to test the decoder. | 262 // add its own internal decoder, but we want to test the decoder. |
| 264 factory_->CreateDecoder(stream->media_type_.Clone(), | 263 factory_->CreateDecoder(stream->media_type_.Clone(), |
| 265 GetProxy(&stream->decoder_)); | 264 GetProxy(&stream->decoder_)); |
| 266 | 265 |
| 267 MediaConsumerPtr decoder_consumer; | 266 MediaConsumerPtr decoder_consumer; |
| 268 stream->decoder_->GetConsumer(GetProxy(&decoder_consumer)); | 267 stream->decoder_->GetConsumer(GetProxy(&decoder_consumer)); |
| 269 | 268 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 280 stream->decoder_->GetProducer(GetProxy(&stream->decoded_producer_)); | 279 stream->decoder_->GetProducer(GetProxy(&stream->decoded_producer_)); |
| 281 CreateSink(stream, output_type, url, callback_joiner->NewCallback()); | 280 CreateSink(stream, output_type, url, callback_joiner->NewCallback()); |
| 282 callback_joiner->Complete(); | 281 callback_joiner->Complete(); |
| 283 }); | 282 }); |
| 284 | 283 |
| 285 callback_joiner->WhenJoined(callback); | 284 callback_joiner->WhenJoined(callback); |
| 286 } else { | 285 } else { |
| 287 // Uncompressed audio. Connect the demux stream directly to the sink. This | 286 // Uncompressed audio. Connect the demux stream directly to the sink. This |
| 288 // would work for compressed audio as well (the sink would decode), but we | 287 // would work for compressed audio as well (the sink would decode), but we |
| 289 // want to test the decoder. | 288 // want to test the decoder. |
| 290 DCHECK(stream->media_type_->scheme == MediaTypeScheme::LPCM); | |
| 291 stream->decoded_producer_ = stream->encoded_producer_.Pass(); | 289 stream->decoded_producer_ = stream->encoded_producer_.Pass(); |
| 292 CreateSink(stream, stream->media_type_, url, callback); | 290 CreateSink(stream, stream->media_type_, url, callback); |
| 293 } | 291 } |
| 294 } | 292 } |
| 295 | 293 |
| 296 void MediaPlayerImpl::CreateSink(const std::unique_ptr<Stream>& stream, | 294 void MediaPlayerImpl::CreateSink(const std::unique_ptr<Stream>& stream, |
| 297 const MediaTypePtr& input_media_type, | 295 const MediaTypePtr& input_media_type, |
| 298 const String& url, | 296 const String& url, |
| 299 const std::function<void()>& callback) { | 297 const std::function<void()>& callback) { |
| 300 DCHECK(input_media_type); | 298 DCHECK(input_media_type); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 }); | 352 }); |
| 355 } | 353 } |
| 356 | 354 |
| 357 MediaPlayerImpl::Stream::Stream(size_t index, MediaTypePtr media_type) | 355 MediaPlayerImpl::Stream::Stream(size_t index, MediaTypePtr media_type) |
| 358 : index_(index), media_type_(media_type.Pass()) {} | 356 : index_(index), media_type_(media_type.Pass()) {} |
| 359 | 357 |
| 360 MediaPlayerImpl::Stream::~Stream() {} | 358 MediaPlayerImpl::Stream::~Stream() {} |
| 361 | 359 |
| 362 } // namespace media | 360 } // namespace media |
| 363 } // namespace mojo | 361 } // namespace mojo |
| OLD | NEW |