| 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 #ifndef MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ | 5 #ifndef MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ |
| 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ | 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" | 11 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" |
| 12 #include "mojo/services/media/core/interfaces/timeline_controller.mojom.h" | 12 #include "mojo/services/media/core/interfaces/timeline_controller.mojom.h" |
| 13 #include "services/media/factory_service/audio_track_controller.h" | |
| 14 #include "services/media/factory_service/factory_service.h" | 13 #include "services/media/factory_service/factory_service.h" |
| 15 #include "services/media/framework/graph.h" | 14 #include "services/media/framework/graph.h" |
| 16 #include "services/media/framework/parts/decoder.h" | 15 #include "services/media/framework/parts/decoder.h" |
| 17 #include "services/media/framework_mojo/mojo_consumer.h" | 16 #include "services/media/framework_mojo/mojo_consumer.h" |
| 18 #include "services/media/framework_mojo/mojo_producer.h" | 17 #include "services/media/framework_mojo/mojo_producer.h" |
| 19 #include "services/util/cpp/incident.h" | 18 #include "services/util/cpp/incident.h" |
| 20 | 19 |
| 21 namespace mojo { | 20 namespace mojo { |
| 22 namespace media { | 21 namespace media { |
| 23 | 22 |
| 24 // Mojo agent that consumes a stream and delivers it to a destination specified | 23 // Mojo agent that consumes a stream and delivers it to a destination specified |
| 25 // by URL. | 24 // by URL. |
| 26 class MediaSinkImpl : public MediaFactoryService::Product<MediaSink>, | 25 class MediaSinkImpl : public MediaFactoryService::Product<MediaSink>, |
| 27 public MediaSink { | 26 public MediaSink { |
| 28 public: | 27 public: |
| 29 static std::shared_ptr<MediaSinkImpl> Create( | 28 static std::shared_ptr<MediaSinkImpl> Create( |
| 30 const String& destination_url, | 29 InterfaceHandle<MediaRenderer> renderer, |
| 31 MediaTypePtr media_type, | 30 MediaTypePtr media_type, |
| 32 InterfaceRequest<MediaSink> request, | 31 InterfaceRequest<MediaSink> request, |
| 33 MediaFactoryService* owner); | 32 MediaFactoryService* owner); |
| 34 | 33 |
| 35 ~MediaSinkImpl() override; | 34 ~MediaSinkImpl() override; |
| 36 | 35 |
| 37 // MediaSink implementation. | 36 // MediaSink implementation. |
| 38 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; | 37 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; |
| 39 | 38 |
| 40 void GetTimelineControlSite( | 39 void GetTimelineControlSite( |
| 41 InterfaceRequest<MediaTimelineControlSite> req) override; | 40 InterfaceRequest<MediaTimelineControlSite> req) override; |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 MediaSinkImpl(const String& destination_url, | 43 class NullTimelineControlSite : public MediaTimelineControlSite, |
| 44 public TimelineConsumer { |
| 45 public: |
| 46 NullTimelineControlSite( |
| 47 InterfaceRequest<MediaTimelineControlSite> control_site_request); |
| 48 |
| 49 ~NullTimelineControlSite() override; |
| 50 |
| 51 // MediaTimelineControlSite implementation. |
| 52 void GetStatus(uint64_t version_last_seen, |
| 53 const GetStatusCallback& callback) override; |
| 54 |
| 55 void GetTimelineConsumer( |
| 56 InterfaceRequest<TimelineConsumer> timeline_consumer) override; |
| 57 |
| 58 // TimelineConsumer implementation. |
| 59 void SetTimelineTransform( |
| 60 int64_t subject_time, |
| 61 uint32_t reference_delta, |
| 62 uint32_t subject_delta, |
| 63 int64_t effective_reference_time, |
| 64 int64_t effective_subject_time, |
| 65 const SetTimelineTransformCallback& callback) override; |
| 66 |
| 67 private: |
| 68 Binding<MediaTimelineControlSite> control_site_binding_; |
| 69 Binding<TimelineConsumer> consumer_binding_; |
| 70 GetStatusCallback get_status_callback_; |
| 71 }; |
| 72 |
| 73 MediaSinkImpl(InterfaceHandle<MediaRenderer> renderer, |
| 45 MediaTypePtr media_type, | 74 MediaTypePtr media_type, |
| 46 InterfaceRequest<MediaSink> request, | 75 InterfaceRequest<MediaSink> request, |
| 47 MediaFactoryService* owner); | 76 MediaFactoryService* owner); |
| 48 | 77 |
| 49 Incident ready_; | 78 Incident ready_; |
| 50 Graph graph_; | 79 Graph graph_; |
| 51 std::shared_ptr<MojoConsumer> consumer_; | 80 std::shared_ptr<MojoConsumer> consumer_; |
| 52 std::shared_ptr<MojoProducer> producer_; | 81 std::shared_ptr<MojoProducer> producer_; |
| 53 std::unique_ptr<AudioTrackController> controller_; | 82 MediaRendererPtr renderer_; |
| 83 // The following fields are just temporaries used to solve lambda capture |
| 84 // problems. |
| 85 std::unique_ptr<StreamType> input_stream_type_; |
| 54 }; | 86 }; |
| 55 | 87 |
| 56 } // namespace media | 88 } // namespace media |
| 57 } // namespace mojo | 89 } // namespace mojo |
| 58 | 90 |
| 59 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ | 91 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ |
| OLD | NEW |