| 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 "services/media/factory_service/factory_service.h" | 5 #include "services/media/factory_service/factory_service.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/factory_service/media_player_impl.h" | 7 #include "services/media/factory_service/media_player_impl.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/factory_service/media_source_impl.h" | 9 #include "services/media/factory_service/media_source_impl.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 MediaFactoryService::Product::Product(MediaFactoryService* owner) | 14 MediaFactoryService::Product::Product(MediaFactoryService* owner) |
| 15 : owner_(owner) { | 15 : owner_(owner) { |
| 16 DCHECK(owner_); | 16 DCHECK(owner_); |
| 17 } | 17 } |
| 18 | 18 |
| 19 MediaFactoryService::Product::~Product() {} | 19 MediaFactoryService::Product::~Product() {} |
| 20 | 20 |
| 21 MediaFactoryService::MediaFactoryService() {} | 21 MediaFactoryService::MediaFactoryService() {} |
| 22 | 22 |
| 23 MediaFactoryService::~MediaFactoryService() {} | 23 MediaFactoryService::~MediaFactoryService() {} |
| 24 | 24 |
| 25 void MediaFactoryService::Initialize(ApplicationImpl* app) { | 25 void MediaFactoryService::Initialize(ApplicationImpl* app) { |
| 26 app_ = app; | 26 app_ = app; |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool MediaFactoryService::ConfigureIncomingConnection( | 29 bool MediaFactoryService::ConfigureIncomingConnection( |
| 30 ApplicationConnection* connection) { | 30 ApplicationConnection* connection) { |
| 31 connection->AddService<MediaFactory>(this); | 31 connection->AddService<MediaFactory>(this); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void MediaFactoryService::Create(ApplicationConnection* connection, | 35 void MediaFactoryService::Create(ApplicationConnection* connection, |
| 36 InterfaceRequest<MediaFactory> request) { | 36 InterfaceRequest<MediaFactory> request) { |
| 37 bindings_.AddBinding(this, request.Pass()); | 37 bindings_.AddBinding(this, request.Pass()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void MediaFactoryService::CreatePlayer( | 40 void MediaFactoryService::CreatePlayer(const String& origin_url, |
| 41 const String& origin_url, | 41 InterfaceRequest<MediaPlayer> player) { |
| 42 InterfaceRequest<MediaPlayer> player) { | |
| 43 products_.insert(std::static_pointer_cast<Product>( | 42 products_.insert(std::static_pointer_cast<Product>( |
| 44 MediaPlayerImpl::Create(origin_url, player.Pass(), this))); | 43 MediaPlayerImpl::Create(origin_url, player.Pass(), this))); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void MediaFactoryService::CreateSource( | 46 void MediaFactoryService::CreateSource(const String& origin_url, |
| 48 const String& origin_url, | 47 Array<MediaTypeSetPtr> media_types, |
| 49 Array<MediaTypeSetPtr> media_types, | 48 InterfaceRequest<MediaSource> source) { |
| 50 InterfaceRequest<MediaSource> source) { | |
| 51 products_.insert(std::static_pointer_cast<Product>( | 49 products_.insert(std::static_pointer_cast<Product>( |
| 52 MediaSourceImpl::Create(origin_url, media_types, source.Pass(), this))); | 50 MediaSourceImpl::Create(origin_url, media_types, source.Pass(), this))); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void MediaFactoryService::CreateSink( | 53 void MediaFactoryService::CreateSink(const String& destination_url, |
| 56 const String& destination_url, | 54 MediaTypePtr media_type, |
| 57 MediaTypePtr media_type, | 55 InterfaceRequest<MediaSink> sink) { |
| 58 InterfaceRequest<MediaSink> sink) { | 56 products_.insert(std::static_pointer_cast<Product>(MediaSinkImpl::Create( |
| 59 products_.insert(std::static_pointer_cast<Product>( | 57 destination_url, media_type.Pass(), sink.Pass(), this))); |
| 60 MediaSinkImpl::Create( | |
| 61 destination_url, | |
| 62 media_type.Pass(), | |
| 63 sink.Pass(), | |
| 64 this))); | |
| 65 } | 58 } |
| 66 | 59 |
| 67 void MediaFactoryService::CreateDecoder( | 60 void MediaFactoryService::CreateDecoder( |
| 68 MediaTypePtr input_media_type, | 61 MediaTypePtr input_media_type, |
| 69 InterfaceRequest<MediaTypeConverter> decoder) { | 62 InterfaceRequest<MediaTypeConverter> decoder) { |
| 70 products_.insert(std::static_pointer_cast<Product>( | 63 products_.insert(std::static_pointer_cast<Product>( |
| 71 MediaDecoderImpl::Create(input_media_type.Pass(), decoder.Pass(), this))); | 64 MediaDecoderImpl::Create(input_media_type.Pass(), decoder.Pass(), this))); |
| 72 } | 65 } |
| 73 | 66 |
| 74 } // namespace media | 67 } // namespace media |
| 75 } // namespace mojo | 68 } // namespace mojo |
| OLD | NEW |