| 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 SERVICES_MEDIA_FACTORY_SERVICE_MEDIA_SOURCE_IMPL_H_ |
| 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ | 6 #define SERVICES_MEDIA_FACTORY_SERVICE_MEDIA_SOURCE_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/services/media/control/interfaces/media_source.mojom.h" | 12 #include "mojo/services/media/control/interfaces/media_source.mojom.h" |
| 13 #include "mojo/services/media/core/interfaces/seeking_reader.mojom.h" | 13 #include "mojo/services/media/core/interfaces/seeking_reader.mojom.h" |
| 14 #include "services/media/common/mojo_publisher.h" | 14 #include "services/media/common/mojo_publisher.h" |
| 15 #include "services/media/factory_service/factory_service.h" | 15 #include "services/media/factory_service/factory_service.h" |
| 16 #include "services/media/framework/graph.h" | 16 #include "services/media/framework/graph.h" |
| 17 #include "services/media/framework/parts/decoder.h" | 17 #include "services/media/framework/parts/decoder.h" |
| 18 #include "services/media/framework/parts/demux.h" | 18 #include "services/media/framework/parts/demux.h" |
| 19 #include "services/media/framework/parts/null_sink.h" | 19 #include "services/media/framework/parts/null_sink.h" |
| 20 #include "services/media/framework/parts/reader.h" | 20 #include "services/media/framework/parts/reader.h" |
| 21 #include "services/media/framework_mojo/mojo_producer.h" | 21 #include "services/media/framework_mojo/mojo_packet_producer.h" |
| 22 #include "services/media/framework_mojo/mojo_pull_mode_producer.h" | |
| 23 #include "services/util/cpp/incident.h" | 22 #include "services/util/cpp/incident.h" |
| 24 | 23 |
| 25 namespace mojo { | 24 namespace mojo { |
| 26 namespace media { | 25 namespace media { |
| 27 | 26 |
| 28 // Mojo agent that produces streams from an origin specified by URL. | 27 // Mojo agent that produces streams from an origin specified by URL. |
| 29 class MediaSourceImpl : public MediaFactoryService::Product<MediaSource>, | 28 class MediaSourceImpl : public MediaFactoryService::Product<MediaSource>, |
| 30 public MediaSource { | 29 public MediaSource { |
| 31 public: | 30 public: |
| 32 static std::shared_ptr<MediaSourceImpl> Create( | 31 static std::shared_ptr<MediaSourceImpl> Create( |
| 33 InterfaceHandle<SeekingReader> reader, | 32 InterfaceHandle<SeekingReader> reader, |
| 34 const Array<MediaTypeSetPtr>& allowed_media_types, | 33 const Array<MediaTypeSetPtr>& allowed_media_types, |
| 35 InterfaceRequest<MediaSource> request, | 34 InterfaceRequest<MediaSource> request, |
| 36 MediaFactoryService* owner); | 35 MediaFactoryService* owner); |
| 37 | 36 |
| 38 ~MediaSourceImpl() override; | 37 ~MediaSourceImpl() override; |
| 39 | 38 |
| 40 // MediaSource implementation. | 39 // MediaSource implementation. |
| 41 void GetStreams(const GetStreamsCallback& callback) override; | 40 void GetStreams(const GetStreamsCallback& callback) override; |
| 42 | 41 |
| 43 void GetProducer(uint32_t stream_index, | 42 void GetPacketProducer( |
| 44 InterfaceRequest<MediaProducer> producer) override; | |
| 45 | |
| 46 void GetPullModeProducer( | |
| 47 uint32_t stream_index, | 43 uint32_t stream_index, |
| 48 InterfaceRequest<MediaPullModeProducer> producer) override; | 44 InterfaceRequest<MediaPacketProducer> producer) override; |
| 49 | 45 |
| 50 void GetStatus(uint64_t version_last_seen, | 46 void GetStatus(uint64_t version_last_seen, |
| 51 const GetStatusCallback& callback) override; | 47 const GetStatusCallback& callback) override; |
| 52 | 48 |
| 53 void Prepare(const PrepareCallback& callback) override; | 49 void Prepare(const PrepareCallback& callback) override; |
| 54 | 50 |
| 55 void Prime(const PrimeCallback& callback) override; | 51 void Prime(const PrimeCallback& callback) override; |
| 56 | 52 |
| 57 void Flush(const FlushCallback& callback) override; | 53 void Flush(const FlushCallback& callback) override; |
| 58 | 54 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 | 70 |
| 75 ~Stream(); | 71 ~Stream(); |
| 76 | 72 |
| 77 // Gets the media type of the stream. | 73 // Gets the media type of the stream. |
| 78 MediaTypePtr media_type() const; | 74 MediaTypePtr media_type() const; |
| 79 | 75 |
| 80 // Gets the original stream type of the stream. | 76 // Gets the original stream type of the stream. |
| 81 MediaTypePtr original_media_type() const; | 77 MediaTypePtr original_media_type() const; |
| 82 | 78 |
| 83 // Gets the producer. | 79 // Gets the producer. |
| 84 void GetProducer(InterfaceRequest<MediaProducer> producer); | 80 void GetPacketProducer(InterfaceRequest<MediaPacketProducer> producer); |
| 85 | |
| 86 // Gets the pull mode producer. | |
| 87 void GetPullModeProducer(InterfaceRequest<MediaPullModeProducer> producer); | |
| 88 | 81 |
| 89 // Makes sure the stream has a sink. | 82 // Makes sure the stream has a sink. |
| 90 void EnsureSink(); | 83 void EnsureSink(); |
| 91 | 84 |
| 92 // Tells the producer to prime its connection. | 85 // Tells the producer to prime its connection. |
| 93 void PrimeConnection(const MojoProducer::PrimeConnectionCallback callback); | 86 void PrimeConnection( |
| 87 const MojoPacketProducer::PrimeConnectionCallback callback); |
| 94 | 88 |
| 95 // Tells the producer to flush its connection. | 89 // Tells the producer to flush its connection. |
| 96 void FlushConnection(const MojoProducer::FlushConnectionCallback callback); | 90 void FlushConnection( |
| 91 const MojoPacketProducer::FlushConnectionCallback callback); |
| 97 | 92 |
| 98 private: | 93 private: |
| 99 std::unique_ptr<StreamType> stream_type_; | 94 std::unique_ptr<StreamType> stream_type_; |
| 100 std::unique_ptr<StreamType> original_stream_type_; | 95 std::unique_ptr<StreamType> original_stream_type_; |
| 101 Graph* graph_; | 96 Graph* graph_; |
| 102 OutputRef output_; | 97 OutputRef output_; |
| 103 std::shared_ptr<MojoProducer> producer_; | 98 std::shared_ptr<MojoPacketProducer> producer_; |
| 104 std::shared_ptr<MojoPullModeProducer> pull_mode_producer_; | |
| 105 std::shared_ptr<NullSink> null_sink_; | 99 std::shared_ptr<NullSink> null_sink_; |
| 106 }; | 100 }; |
| 107 | 101 |
| 108 // Handles the completion of demux initialization. | 102 // Handles the completion of demux initialization. |
| 109 void OnDemuxInitialized(Result result); | 103 void OnDemuxInitialized(Result result); |
| 110 | 104 |
| 111 // Runs a seek callback. | 105 // Runs a seek callback. |
| 112 static void RunSeekCallback(const SeekCallback& callback); | 106 static void RunSeekCallback(const SeekCallback& callback); |
| 113 | 107 |
| 114 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 108 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 115 Array<MediaTypeSetPtr> allowed_media_types_; | 109 Array<MediaTypeSetPtr> allowed_media_types_; |
| 116 Graph graph_; | 110 Graph graph_; |
| 117 PartRef demux_part_; | 111 PartRef demux_part_; |
| 118 std::shared_ptr<Demux> demux_; | 112 std::shared_ptr<Demux> demux_; |
| 119 Incident init_complete_; | 113 Incident init_complete_; |
| 120 std::vector<std::unique_ptr<Stream>> streams_; | 114 std::vector<std::unique_ptr<Stream>> streams_; |
| 121 MojoPublisher<GetStatusCallback> status_publisher_; | 115 MojoPublisher<GetStatusCallback> status_publisher_; |
| 122 }; | 116 }; |
| 123 | 117 |
| 124 } // namespace media | 118 } // namespace media |
| 125 } // namespace mojo | 119 } // namespace mojo |
| 126 | 120 |
| 127 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_SOURCE_IMPL_H_ | 121 #endif // SERVICES_MEDIA_FACTORY_SERVICE_MEDIA_SOURCE_IMPL_H_ |
| OLD | NEW |