| 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/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/services/media/common/cpp/timeline_function.h" | |
| 13 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" | 12 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" |
| 14 #include "services/media/common/mojo_publisher.h" | 13 #include "mojo/services/media/core/interfaces/timeline_controller.mojom.h" |
| 15 #include "services/media/factory_service/audio_track_controller.h" | 14 #include "services/media/factory_service/audio_track_controller.h" |
| 16 #include "services/media/factory_service/factory_service.h" | 15 #include "services/media/factory_service/factory_service.h" |
| 17 #include "services/media/framework/graph.h" | 16 #include "services/media/framework/graph.h" |
| 18 #include "services/media/framework/parts/decoder.h" | 17 #include "services/media/framework/parts/decoder.h" |
| 19 #include "services/media/framework/util/incident.h" | 18 #include "services/media/framework/util/incident.h" |
| 20 #include "services/media/framework_mojo/mojo_consumer.h" | 19 #include "services/media/framework_mojo/mojo_consumer.h" |
| 21 #include "services/media/framework_mojo/mojo_producer.h" | 20 #include "services/media/framework_mojo/mojo_producer.h" |
| 22 | 21 |
| 23 namespace mojo { | 22 namespace mojo { |
| 24 namespace media { | 23 namespace media { |
| 25 | 24 |
| 26 // Mojo agent that consumes a stream and delivers it to a destination specified | 25 // Mojo agent that consumes a stream and delivers it to a destination specified |
| 27 // by URL. | 26 // by URL. |
| 28 class MediaSinkImpl : public MediaFactoryService::Product<MediaSink>, | 27 class MediaSinkImpl : public MediaFactoryService::Product<MediaSink>, |
| 29 public MediaSink { | 28 public MediaSink { |
| 30 public: | 29 public: |
| 31 static std::shared_ptr<MediaSinkImpl> Create( | 30 static std::shared_ptr<MediaSinkImpl> Create( |
| 32 const String& destination_url, | 31 const String& destination_url, |
| 33 MediaTypePtr media_type, | 32 MediaTypePtr media_type, |
| 34 InterfaceRequest<MediaSink> request, | 33 InterfaceRequest<MediaSink> request, |
| 35 MediaFactoryService* owner); | 34 MediaFactoryService* owner); |
| 36 | 35 |
| 37 ~MediaSinkImpl() override; | 36 ~MediaSinkImpl() override; |
| 38 | 37 |
| 39 // MediaSink implementation. | 38 // MediaSink implementation. |
| 40 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; | 39 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; |
| 41 | 40 |
| 42 void GetStatus(uint64_t version_last_seen, | 41 void GetTimelineControlSite( |
| 43 const GetStatusCallback& callback) override; | 42 InterfaceRequest<MediaTimelineControlSite> req) override; |
| 44 | |
| 45 void Play() override; | |
| 46 | |
| 47 void Pause() override; | |
| 48 | 43 |
| 49 private: | 44 private: |
| 50 MediaSinkImpl(const String& destination_url, | 45 MediaSinkImpl(const String& destination_url, |
| 51 MediaTypePtr media_type, | 46 MediaTypePtr media_type, |
| 52 InterfaceRequest<MediaSink> request, | 47 InterfaceRequest<MediaSink> request, |
| 53 MediaFactoryService* owner); | 48 MediaFactoryService* owner); |
| 54 | 49 |
| 55 // Sets the rate if the producer is ready and the target rate differs from | |
| 56 // the current rate. | |
| 57 void MaybeSetRate(); | |
| 58 | |
| 59 Incident ready_; | 50 Incident ready_; |
| 60 Graph graph_; | 51 Graph graph_; |
| 61 std::shared_ptr<MojoConsumer> consumer_; | 52 std::shared_ptr<MojoConsumer> consumer_; |
| 62 std::shared_ptr<MojoProducer> producer_; | 53 std::shared_ptr<MojoProducer> producer_; |
| 63 std::unique_ptr<AudioTrackController> controller_; | 54 std::unique_ptr<AudioTrackController> controller_; |
| 64 TimelineConsumerPtr timeline_consumer_; | |
| 65 float rate_ = 0.0f; | |
| 66 float target_rate_ = 0.0f; | |
| 67 MediaState producer_state_ = MediaState::UNPREPARED; | |
| 68 TimelineFunction timeline_function_; | |
| 69 TimelineRate frames_per_ns_; | |
| 70 bool flushed_ = true; | |
| 71 MojoPublisher<GetStatusCallback> status_publisher_; | |
| 72 }; | 55 }; |
| 73 | 56 |
| 74 } // namespace media | 57 } // namespace media |
| 75 } // namespace mojo | 58 } // namespace mojo |
| 76 | 59 |
| 77 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ | 60 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ |
| OLD | NEW |