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 SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |
6 #define SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "services/media/framework/metadata.h" | 11 #include "services/media/framework/metadata.h" |
12 #include "services/media/framework/models/multistream_packet_source.h" | 12 #include "services/media/framework/models/multistream_source.h" |
13 #include "services/media/framework/packet.h" | 13 #include "services/media/framework/packet.h" |
14 #include "services/media/framework/parts/reader.h" | 14 #include "services/media/framework/parts/reader.h" |
15 #include "services/media/framework/result.h" | 15 #include "services/media/framework/result.h" |
16 #include "services/media/framework/stream_type.h" | 16 #include "services/media/framework/stream_type.h" |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 namespace media { | 19 namespace media { |
20 | 20 |
21 class Demux; | |
22 | |
23 typedef SharedPtr<Demux, MultiStreamPacketSource> DemuxPtr; | |
24 | |
25 // Abstract base class for sources that parse input from a reader and | 21 // Abstract base class for sources that parse input from a reader and |
26 // produce one or more output streams. | 22 // produce one or more output streams. |
27 class Demux : public MultiStreamPacketSource { | 23 class Demux : public MultistreamSource { |
28 public: | 24 public: |
29 // Represents a stream produced by the demux. | 25 // Represents a stream produced by the demux. |
30 class DemuxStream { | 26 class DemuxStream { |
31 // TODO(dalesat): Replace this class with stream_type_, unless more stuff | 27 // TODO(dalesat): Replace this class with stream_type_, unless more stuff |
32 // needs to be added. | 28 // needs to be added. |
33 public: | 29 public: |
34 virtual ~DemuxStream() {} | 30 virtual ~DemuxStream() {} |
35 | 31 |
36 virtual uint32_t index() const = 0; | 32 virtual size_t index() const = 0; |
37 | 33 |
38 virtual StreamTypePtr stream_type() const = 0; | 34 virtual std::unique_ptr<StreamType> stream_type() const = 0; |
39 }; | 35 }; |
40 | 36 |
41 // Creates a Demux object for a given reader. | 37 // Creates a Demux object for a given reader. |
42 static Result Create(ReaderPtr reader, DemuxPtr* demux_out); | 38 static Result Create( |
| 39 std::shared_ptr<Reader> reader, |
| 40 std::shared_ptr<Demux>* demux_out); |
43 | 41 |
44 ~Demux() override {} | 42 ~Demux() override {} |
45 | 43 |
46 // TODO(dalesat): Don't let the demux talk to the reader. We're doing it this | 44 // TODO(dalesat): Don't let the demux talk to the reader. We're doing it this |
47 // way now because of ffmpeg's synchronous read call. Ideally, the demux | 45 // way now because of ffmpeg's synchronous read call. Ideally, the demux |
48 // would tell its owner how much data it needs from the reader, and the | 46 // would tell its owner how much data it needs from the reader, and the |
49 // owner would later hand over the data and possibly get a packet back. | 47 // owner would later hand over the data and possibly get a packet back. |
50 | 48 |
51 // TODO(dalesat): Implement seek, etc. | 49 // TODO(dalesat): Implement seek, etc. |
52 | 50 |
53 // TODO(dalesat): Make the demux use an allocator. Ffmpeg demuxes don't | 51 // TODO(dalesat): Make the demux use an allocator. Ffmpeg demuxes don't |
54 // support this. | 52 // support this. |
55 | 53 |
56 // Initializes the demux. | 54 // Initializes the demux. |
57 virtual Result Init(ReaderPtr reader) = 0; | 55 virtual Result Init(std::shared_ptr<Reader> reader) = 0; |
58 | 56 |
59 // Gets the current metadata. | 57 // Gets the current metadata. |
60 virtual MetadataPtr metadata() const = 0; | 58 virtual std::unique_ptr<Metadata> metadata() const = 0; |
61 | 59 |
62 // Gets the stream collection. | 60 // Gets the stream collection. |
63 virtual const std::vector<DemuxStream*>& streams() const = 0; | 61 virtual const std::vector<DemuxStream*>& streams() const = 0; |
64 | |
65 // MultiStreamProducer implementation (deferred to subclasses). | |
66 // bool can_accept_allocator(uint32_t stream_index) const override; | |
67 // void set_allocator(uint32_t stream_index, Allocator* allocator) override; | |
68 | |
69 // MultiStreamPacketSource implementation (deferred to subclasses). | |
70 // uint32_t stream_count() const override; | |
71 // PacketPtr PullPacket(uint32_t* stream_index_out) override; | |
72 }; | 62 }; |
73 | 63 |
74 } // namespace media | 64 } // namespace media |
75 } // namespace mojo | 65 } // namespace mojo |
76 | 66 |
77 #endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ | 67 #endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |
OLD | NEW |