| 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_DEMUX_IMPL_H_ | 5 #ifndef MOJO_SERVICES_MEDIA_FACTORY_MEDIA_DEMUX_IMPL_H_ |
| 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_DEMUX_IMPL_H_ | 6 #define MOJO_SERVICES_MEDIA_FACTORY_MEDIA_DEMUX_IMPL_H_ |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/services/media/core/interfaces/media_demux.mojom.h" | 14 #include "mojo/services/media/core/interfaces/media_demux.mojom.h" |
| 15 #include "mojo/services/media/core/interfaces/seeking_reader.mojom.h" | 15 #include "mojo/services/media/core/interfaces/seeking_reader.mojom.h" |
| 16 #include "services/media/common/mojo_publisher.h" | 16 #include "services/media/common/mojo_publisher.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/demux.h" | 19 #include "services/media/framework/parts/demux.h" |
| 20 #include "services/media/framework_mojo/mojo_producer.h" | 20 #include "services/media/framework_mojo/mojo_packet_producer.h" |
| 21 #include "services/util/cpp/incident.h" | 21 #include "services/util/cpp/incident.h" |
| 22 | 22 |
| 23 namespace mojo { | 23 namespace mojo { |
| 24 namespace media { | 24 namespace media { |
| 25 | 25 |
| 26 // Mojo agent that decodes a stream. | 26 // Mojo agent that decodes a stream. |
| 27 class MediaDemuxImpl : public MediaFactoryService::Product<MediaDemux>, | 27 class MediaDemuxImpl : public MediaFactoryService::Product<MediaDemux>, |
| 28 public MediaDemux { | 28 public MediaDemux { |
| 29 public: | 29 public: |
| 30 static std::shared_ptr<MediaDemuxImpl> Create( | 30 static std::shared_ptr<MediaDemuxImpl> Create( |
| 31 InterfaceHandle<SeekingReader> reader, | 31 InterfaceHandle<SeekingReader> reader, |
| 32 InterfaceRequest<MediaDemux> request, | 32 InterfaceRequest<MediaDemux> request, |
| 33 MediaFactoryService* owner); | 33 MediaFactoryService* owner); |
| 34 | 34 |
| 35 ~MediaDemuxImpl() override; | 35 ~MediaDemuxImpl() override; |
| 36 | 36 |
| 37 // MediaDemux implementation. | 37 // MediaDemux implementation. |
| 38 void Describe(const DescribeCallback& callback) override; | 38 void Describe(const DescribeCallback& callback) override; |
| 39 | 39 |
| 40 void GetProducer(uint32_t stream_index, | 40 void GetPacketProducer( |
| 41 InterfaceRequest<MediaProducer> producer) override; | 41 uint32_t stream_index, |
| 42 InterfaceRequest<MediaPacketProducer> producer) override; |
| 42 | 43 |
| 43 void GetMetadata(uint64_t version_last_seen, | 44 void GetMetadata(uint64_t version_last_seen, |
| 44 const GetMetadataCallback& callback) override; | 45 const GetMetadataCallback& callback) override; |
| 45 | 46 |
| 46 void Prime(const PrimeCallback& callback) override; | 47 void Prime(const PrimeCallback& callback) override; |
| 47 | 48 |
| 48 void Flush(const FlushCallback& callback) override; | 49 void Flush(const FlushCallback& callback) override; |
| 49 | 50 |
| 50 void Seek(int64_t position, const SeekCallback& callback) override; | 51 void Seek(int64_t position, const SeekCallback& callback) override; |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 MediaDemuxImpl(InterfaceHandle<SeekingReader> reader, | 54 MediaDemuxImpl(InterfaceHandle<SeekingReader> reader, |
| 54 InterfaceRequest<MediaDemux> request, | 55 InterfaceRequest<MediaDemux> request, |
| 55 MediaFactoryService* owner); | 56 MediaFactoryService* owner); |
| 56 | 57 |
| 57 class Stream { | 58 class Stream { |
| 58 public: | 59 public: |
| 59 Stream(OutputRef output, | 60 Stream(OutputRef output, |
| 60 std::unique_ptr<StreamType> stream_type, | 61 std::unique_ptr<StreamType> stream_type, |
| 61 Graph* graph); | 62 Graph* graph); |
| 62 | 63 |
| 63 ~Stream(); | 64 ~Stream(); |
| 64 | 65 |
| 65 // Gets the media type of the stream. | 66 // Gets the media type of the stream. |
| 66 MediaTypePtr media_type() const; | 67 MediaTypePtr media_type() const; |
| 67 | 68 |
| 68 // Gets the producer. | 69 // Gets the producer. |
| 69 void GetProducer(InterfaceRequest<MediaProducer> producer); | 70 void GetPacketProducer(InterfaceRequest<MediaPacketProducer> producer); |
| 70 | 71 |
| 71 // Tells the producer to prime its connection. | 72 // Tells the producer to prime its connection. |
| 72 void PrimeConnection(const MojoProducer::PrimeConnectionCallback callback); | 73 void PrimeConnection( |
| 74 const MojoPacketProducer::PrimeConnectionCallback callback); |
| 73 | 75 |
| 74 // Tells the producer to flush its connection. | 76 // Tells the producer to flush its connection. |
| 75 void FlushConnection(const MojoProducer::FlushConnectionCallback callback); | 77 void FlushConnection( |
| 78 const MojoPacketProducer::FlushConnectionCallback callback); |
| 76 | 79 |
| 77 private: | 80 private: |
| 78 std::unique_ptr<StreamType> stream_type_; | 81 std::unique_ptr<StreamType> stream_type_; |
| 79 Graph* graph_; | 82 Graph* graph_; |
| 80 OutputRef output_; | 83 OutputRef output_; |
| 81 std::shared_ptr<MojoProducer> producer_; | 84 std::shared_ptr<MojoPacketProducer> producer_; |
| 82 }; | 85 }; |
| 83 | 86 |
| 84 // Handles the completion of demux initialization. | 87 // Handles the completion of demux initialization. |
| 85 void OnDemuxInitialized(Result result); | 88 void OnDemuxInitialized(Result result); |
| 86 | 89 |
| 87 static void RunSeekCallback(const SeekCallback& callback); | 90 static void RunSeekCallback(const SeekCallback& callback); |
| 88 | 91 |
| 89 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 90 Graph graph_; | 93 Graph graph_; |
| 91 PartRef demux_part_; | 94 PartRef demux_part_; |
| 92 std::shared_ptr<Demux> demux_; | 95 std::shared_ptr<Demux> demux_; |
| 93 Incident init_complete_; | 96 Incident init_complete_; |
| 94 std::vector<std::unique_ptr<Stream>> streams_; | 97 std::vector<std::unique_ptr<Stream>> streams_; |
| 95 MojoPublisher<GetMetadataCallback> metadata_publisher_; | 98 MojoPublisher<GetMetadataCallback> metadata_publisher_; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 } // namespace media | 101 } // namespace media |
| 99 } // namespace mojo | 102 } // namespace mojo |
| 100 | 103 |
| 101 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_DEMUX_IMPL_H_ | 104 #endif // MOJO_SERVICES_MEDIA_FACTORY_MEDIA_DEMUX_IMPL_H_ |
| OLD | NEW |