| 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_SOURCE_IMPL_H_ | 5 #ifndef MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ |
| 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ | 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 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_source.mojom.h" | 11 #include "mojo/services/media/control/interfaces/media_source.mojom.h" |
| 12 #include "services/media/factory_service/factory_service.h" | 12 #include "services/media/factory_service/factory_service.h" |
| 13 #include "services/media/framework/graph.h" | 13 #include "services/media/framework/graph.h" |
| 14 #include "services/media/framework/parts/decoder.h" | 14 #include "services/media/framework/parts/decoder.h" |
| 15 #include "services/media/framework/parts/demux.h" | 15 #include "services/media/framework/parts/demux.h" |
| 16 #include "services/media/framework/parts/null_sink.h" | 16 #include "services/media/framework/parts/null_sink.h" |
| 17 #include "services/media/framework/parts/reader.h" | 17 #include "services/media/framework/parts/reader.h" |
| 18 #include "services/media/framework_mojo/mojo_producer.h" | 18 #include "services/media/framework_mojo/mojo_producer.h" |
| 19 #include "services/media/framework_mojo/mojo_pull_mode_producer.h" | 19 #include "services/media/framework_mojo/mojo_pull_mode_producer.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 namespace media { | 22 namespace media { |
| 23 | 23 |
| 24 // Mojo agent that produces streams from an origin specified by URL. | 24 // Mojo agent that produces streams from an origin specified by URL. |
| 25 class MediaSourceImpl | 25 class MediaSourceImpl : public MediaFactoryService::Product, |
| 26 : public MediaFactoryService::Product, | 26 public MediaSource { |
| 27 public MediaSource { | |
| 28 public: | 27 public: |
| 29 static std::shared_ptr<MediaSourceImpl> Create( | 28 static std::shared_ptr<MediaSourceImpl> Create( |
| 30 const String& origin_url, | 29 const String& origin_url, |
| 31 const Array<MediaTypeSetPtr>& allowed_media_types, | 30 const Array<MediaTypeSetPtr>& allowed_media_types, |
| 32 InterfaceRequest<MediaSource> request, | 31 InterfaceRequest<MediaSource> request, |
| 33 MediaFactoryService* owner); | 32 MediaFactoryService* owner); |
| 34 | 33 |
| 35 ~MediaSourceImpl() override; | 34 ~MediaSourceImpl() override; |
| 36 | 35 |
| 37 // MediaSource implementation. | 36 // MediaSource implementation. |
| 38 void GetStreams(const GetStreamsCallback& callback) override; | 37 void GetStreams(const GetStreamsCallback& callback) override; |
| 39 | 38 |
| 40 void GetClockDisposition(const GetClockDispositionCallback& callback) | 39 void GetClockDisposition( |
| 41 override; | 40 const GetClockDispositionCallback& callback) override; |
| 42 | 41 |
| 43 void GetMasterClock(InterfaceRequest<Clock> master_clock) override; | 42 void GetMasterClock(InterfaceRequest<Clock> master_clock) override; |
| 44 | 43 |
| 45 void SetMasterClock(InterfaceHandle<Clock> master_clock) override; | 44 void SetMasterClock(InterfaceHandle<Clock> master_clock) override; |
| 46 | 45 |
| 47 void GetProducer( | 46 void GetProducer(uint32_t stream_index, |
| 48 uint32_t stream_index, | 47 InterfaceRequest<MediaProducer> producer) override; |
| 49 InterfaceRequest<MediaProducer> producer) override; | |
| 50 | 48 |
| 51 void GetPullModeProducer( | 49 void GetPullModeProducer( |
| 52 uint32_t stream_index, | 50 uint32_t stream_index, |
| 53 InterfaceRequest<MediaPullModeProducer> producer) override; | 51 InterfaceRequest<MediaPullModeProducer> producer) override; |
| 54 | 52 |
| 55 void GetStatus(uint64_t version_last_seen, const GetStatusCallback& callback) | 53 void GetStatus(uint64_t version_last_seen, |
| 56 override; | 54 const GetStatusCallback& callback) override; |
| 57 | 55 |
| 58 void Prepare(const PrepareCallback& callback) override; | 56 void Prepare(const PrepareCallback& callback) override; |
| 59 | 57 |
| 60 void Prime(const PrimeCallback& callback) override; | 58 void Prime(const PrimeCallback& callback) override; |
| 61 | 59 |
| 62 void Flush(const FlushCallback& callback) override; | 60 void Flush(const FlushCallback& callback) override; |
| 63 | 61 |
| 64 void Seek(int64_t position, const SeekCallback& callback) override; | 62 void Seek(int64_t position, const SeekCallback& callback) override; |
| 65 | 63 |
| 66 private: | 64 private: |
| 67 MediaSourceImpl( | 65 MediaSourceImpl(const String& origin_url, |
| 68 const String& origin_url, | 66 const Array<MediaTypeSetPtr>& allowed_media_types, |
| 69 const Array<MediaTypeSetPtr>& allowed_media_types, | 67 InterfaceRequest<MediaSource> request, |
| 70 InterfaceRequest<MediaSource> request, | 68 MediaFactoryService* owner); |
| 71 MediaFactoryService* owner); | |
| 72 | 69 |
| 73 class Stream { | 70 class Stream { |
| 74 public: | 71 public: |
| 75 Stream( | 72 Stream(OutputRef output, |
| 76 OutputRef output, | 73 std::unique_ptr<StreamType> stream_type, |
| 77 std::unique_ptr<StreamType> stream_type, | 74 const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& |
| 78 const std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>& | 75 allowed_stream_types, |
| 79 allowed_stream_types, | 76 Graph* graph); |
| 80 Graph* graph); | |
| 81 | 77 |
| 82 ~Stream(); | 78 ~Stream(); |
| 83 | 79 |
| 84 // Gets the stream type of the stream. | 80 // Gets the stream type of the stream. |
| 85 MediaTypePtr media_type() const; | 81 MediaTypePtr media_type() const; |
| 86 | 82 |
| 87 // Gets the original stream type of the stream. | 83 // Gets the original stream type of the stream. |
| 88 MediaTypePtr original_media_type() const; | 84 MediaTypePtr original_media_type() const; |
| 89 | 85 |
| 90 // Gets the producer. | 86 // Gets the producer. |
| 91 void GetProducer(InterfaceRequest<MediaProducer> producer); | 87 void GetProducer(InterfaceRequest<MediaProducer> producer); |
| 92 | 88 |
| 93 // Gets the pull mode producer. | 89 // Gets the pull mode producer. |
| 94 void GetPullModeProducer( | 90 void GetPullModeProducer(InterfaceRequest<MediaPullModeProducer> producer); |
| 95 InterfaceRequest<MediaPullModeProducer> producer); | |
| 96 | 91 |
| 97 // Makes sure the stream has a sink. | 92 // Makes sure the stream has a sink. |
| 98 void EnsureSink(); | 93 void EnsureSink(); |
| 99 | 94 |
| 100 // Tells the producer to prime its connection. | 95 // Tells the producer to prime its connection. |
| 101 void PrimeConnection(const MojoProducer::PrimeConnectionCallback callback); | 96 void PrimeConnection(const MojoProducer::PrimeConnectionCallback callback); |
| 102 | 97 |
| 103 // Tells the producer to flush its connection. | 98 // Tells the producer to flush its connection. |
| 104 void FlushConnection(const MojoProducer::FlushConnectionCallback callback); | 99 void FlushConnection(const MojoProducer::FlushConnectionCallback callback); |
| 105 | 100 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 127 std::vector<std::unique_ptr<Stream>> streams_; | 122 std::vector<std::unique_ptr<Stream>> streams_; |
| 128 uint64_t status_version_ = 1; | 123 uint64_t status_version_ = 1; |
| 129 MediaState state_ = MediaState::UNPREPARED; | 124 MediaState state_ = MediaState::UNPREPARED; |
| 130 std::deque<GetStatusCallback> pending_status_requests_; | 125 std::deque<GetStatusCallback> pending_status_requests_; |
| 131 }; | 126 }; |
| 132 | 127 |
| 133 } // namespace media | 128 } // namespace media |
| 134 } // namespace mojo | 129 } // namespace mojo |
| 135 | 130 |
| 136 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ | 131 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ |
| OLD | NEW |