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_decoder_impl.h" | 6 #include "services/media/factory_service/media_decoder_impl.h" |
7 #include "services/media/framework_mojo/mojo_type_conversions.h" | 7 #include "services/media/framework_mojo/mojo_type_conversions.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 // static | 12 // static |
13 std::shared_ptr<MediaDecoderImpl> MediaDecoderImpl::Create( | 13 std::shared_ptr<MediaDecoderImpl> MediaDecoderImpl::Create( |
14 MediaTypePtr input_media_type, | 14 MediaTypePtr input_media_type, |
15 InterfaceRequest<MediaTypeConverter> request, | 15 InterfaceRequest<MediaTypeConverter> request, |
16 MediaFactoryService* owner) { | 16 MediaFactoryService* owner) { |
17 return std::shared_ptr<MediaDecoderImpl>(new MediaDecoderImpl( | 17 return std::shared_ptr<MediaDecoderImpl>( |
18 input_media_type.Pass(), | 18 new MediaDecoderImpl(input_media_type.Pass(), request.Pass(), owner)); |
19 request.Pass(), | |
20 owner)); | |
21 } | 19 } |
22 | 20 |
23 MediaDecoderImpl::MediaDecoderImpl( | 21 MediaDecoderImpl::MediaDecoderImpl(MediaTypePtr input_media_type, |
24 MediaTypePtr input_media_type, | 22 InterfaceRequest<MediaTypeConverter> request, |
25 InterfaceRequest<MediaTypeConverter> request, | 23 MediaFactoryService* owner) |
26 MediaFactoryService* owner) | |
27 : MediaFactoryService::Product(owner), | 24 : MediaFactoryService::Product(owner), |
28 binding_(this, request.Pass()), | 25 binding_(this, request.Pass()), |
29 consumer_(MojoConsumer::Create()), | 26 consumer_(MojoConsumer::Create()), |
30 producer_(MojoProducer::Create()) { | 27 producer_(MojoProducer::Create()) { |
31 DCHECK(input_media_type); | 28 DCHECK(input_media_type); |
32 | 29 |
33 // Go away when the client is no longer connected. | 30 // Go away when the client is no longer connected. |
34 binding_.set_connection_error_handler([this]() { | 31 binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); }); |
35 ReleaseFromOwner(); | |
36 }); | |
37 | 32 |
38 std::unique_ptr<StreamType> input_stream_type = Convert(input_media_type); | 33 std::unique_ptr<StreamType> input_stream_type = Convert(input_media_type); |
39 | 34 |
40 if (Decoder::Create(*input_stream_type, &decoder_) != Result::kOk) { | 35 if (Decoder::Create(*input_stream_type, &decoder_) != Result::kOk) { |
41 LOG(WARNING) << "Couldn't find decoder for stream type"; | 36 LOG(WARNING) << "Couldn't find decoder for stream type"; |
42 if (binding_.is_bound()) { | 37 if (binding_.is_bound()) { |
43 binding_.Close(); | 38 binding_.Close(); |
44 } | 39 } |
45 return; | 40 return; |
46 } | 41 } |
(...skipping 30 matching lines...) Expand all Loading... |
77 void MediaDecoderImpl::GetConsumer( | 72 void MediaDecoderImpl::GetConsumer( |
78 mojo::InterfaceRequest<MediaConsumer> consumer) { | 73 mojo::InterfaceRequest<MediaConsumer> consumer) { |
79 consumer_->AddBinding(consumer.Pass()); | 74 consumer_->AddBinding(consumer.Pass()); |
80 } | 75 } |
81 | 76 |
82 void MediaDecoderImpl::GetProducer( | 77 void MediaDecoderImpl::GetProducer( |
83 mojo::InterfaceRequest<MediaProducer> producer) { | 78 mojo::InterfaceRequest<MediaProducer> producer) { |
84 producer_->AddBinding(producer.Pass()); | 79 producer_->AddBinding(producer.Pass()); |
85 } | 80 } |
86 | 81 |
87 } // namespace media | 82 } // namespace media |
88 } // namespace mojo | 83 } // namespace mojo |
OLD | NEW |