| 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 <deque> | 8 #include <deque> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "mojo/public/cpp/application/application_impl.h" | 11 #include "mojo/public/cpp/application/application_impl.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "mojo/services/media/common/cpp/linear_transform.h" | 13 #include "mojo/services/media/common/cpp/linear_transform.h" |
| 14 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" | 14 #include "mojo/services/media/control/interfaces/media_sink.mojom.h" |
| 15 #include "services/media/factory_service/audio_track_controller.h" | 15 #include "services/media/factory_service/audio_track_controller.h" |
| 16 #include "services/media/factory_service/event.h" | 16 #include "services/media/factory_service/event.h" |
| 17 #include "services/media/factory_service/factory_service.h" | 17 #include "services/media/factory_service/factory_service.h" |
| 18 #include "services/media/framework/graph.h" | 18 #include "services/media/framework/graph.h" |
| 19 #include "services/media/framework/parts/decoder.h" | 19 #include "services/media/framework/parts/decoder.h" |
| 20 #include "services/media/framework_mojo/mojo_consumer.h" | 20 #include "services/media/framework_mojo/mojo_consumer.h" |
| 21 #include "services/media/framework_mojo/mojo_producer.h" | 21 #include "services/media/framework_mojo/mojo_producer.h" |
| 22 | 22 |
| 23 namespace mojo { | 23 namespace mojo { |
| 24 namespace media { | 24 namespace media { |
| 25 | 25 |
| 26 // Mojo agent that consumes a stream and delivers it to a destination specified | 26 // Mojo agent that consumes a stream and delivers it to a destination specified |
| 27 // by URL. | 27 // by URL. |
| 28 class MediaSinkImpl | 28 class MediaSinkImpl : public MediaFactoryService::Product, public MediaSink { |
| 29 : public MediaFactoryService::Product, | |
| 30 public MediaSink { | |
| 31 public: | 29 public: |
| 32 static std::shared_ptr<MediaSinkImpl> Create( | 30 static std::shared_ptr<MediaSinkImpl> Create( |
| 33 const String& destination_url, | 31 const String& destination_url, |
| 34 MediaTypePtr media_type, | 32 MediaTypePtr media_type, |
| 35 InterfaceRequest<MediaSink> request, | 33 InterfaceRequest<MediaSink> request, |
| 36 MediaFactoryService* owner); | 34 MediaFactoryService* owner); |
| 37 | 35 |
| 38 ~MediaSinkImpl() override; | 36 ~MediaSinkImpl() override; |
| 39 | 37 |
| 40 // MediaSink implementation. | 38 // MediaSink implementation. |
| 41 void GetClockDisposition(const GetClockDispositionCallback& callback) | 39 void GetClockDisposition( |
| 42 override; | 40 const GetClockDispositionCallback& callback) override; |
| 43 | 41 |
| 44 void GetMasterClock(InterfaceRequest<Clock> master_clock) override; | 42 void GetMasterClock(InterfaceRequest<Clock> master_clock) override; |
| 45 | 43 |
| 46 void SetMasterClock(InterfaceHandle<Clock> master_clock) override; | 44 void SetMasterClock(InterfaceHandle<Clock> master_clock) override; |
| 47 | 45 |
| 48 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; | 46 void GetConsumer(InterfaceRequest<MediaConsumer> consumer) override; |
| 49 | 47 |
| 50 void GetStatus(uint64_t version_last_seen, const GetStatusCallback& callback) | 48 void GetStatus(uint64_t version_last_seen, |
| 51 override; | 49 const GetStatusCallback& callback) override; |
| 52 | 50 |
| 53 void Play() override; | 51 void Play() override; |
| 54 | 52 |
| 55 void Pause() override; | 53 void Pause() override; |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 MediaSinkImpl( | 56 MediaSinkImpl(const String& destination_url, |
| 59 const String& destination_url, | 57 MediaTypePtr media_type, |
| 60 MediaTypePtr media_type, | 58 InterfaceRequest<MediaSink> request, |
| 61 InterfaceRequest<MediaSink> request, | 59 MediaFactoryService* owner); |
| 62 MediaFactoryService* owner); | |
| 63 | 60 |
| 64 // Increments the status version and runs pending status request callbacks. | 61 // Increments the status version and runs pending status request callbacks. |
| 65 void StatusUpdated(); | 62 void StatusUpdated(); |
| 66 | 63 |
| 67 // Runs status request callback. | 64 // Runs status request callback. |
| 68 void RunStatusCallback(const GetStatusCallback& callback) const; | 65 void RunStatusCallback(const GetStatusCallback& callback) const; |
| 69 | 66 |
| 70 // Sets the rate if the producer is ready and the target rate differs from | 67 // Sets the rate if the producer is ready and the target rate differs from |
| 71 // the current rate. | 68 // the current rate. |
| 72 void MaybeSetRate(); | 69 void MaybeSetRate(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 86 TimelineTransformPtr status_transform_; | 83 TimelineTransformPtr status_transform_; |
| 87 std::deque<GetStatusCallback> pending_status_requests_; | 84 std::deque<GetStatusCallback> pending_status_requests_; |
| 88 uint32_t frames_per_second_ = 0u; | 85 uint32_t frames_per_second_ = 0u; |
| 89 bool flushed_ = true; | 86 bool flushed_ = true; |
| 90 }; | 87 }; |
| 91 | 88 |
| 92 } // namespace media | 89 } // namespace media |
| 93 } // namespace mojo | 90 } // namespace mojo |
| 94 | 91 |
| 95 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ | 92 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SINK_IMPL_H_ |
| OLD | NEW |