Chromium Code Reviews| Index: services/media/framework/parts/demux.h |
| diff --git a/services/media/framework/parts/demux.h b/services/media/framework/parts/demux.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a522cda0925ce6a714d2d267a8dbaf68b713935e |
| --- /dev/null |
| +++ b/services/media/framework/parts/demux.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |
| +#define SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "services/media/framework/metadata.h" |
| +#include "services/media/framework/models/multistream_packet_source.h" |
| +#include "services/media/framework/packet.h" |
| +#include "services/media/framework/parts/reader.h" |
| +#include "services/media/framework/result.h" |
| +#include "services/media/framework/stream_type.h" |
| + |
| +namespace mojo { |
| +namespace media { |
| + |
| +class Demux; |
| + |
| +typedef SharedPtr<Demux, MultiStreamPacketSource> DemuxPtr; |
| + |
| +// Abstract base class for sources that parse input from a reader and |
| +// produce one or more output streams. |
| +class Demux : public MultiStreamPacketSource { |
| + public: |
| + // Represents a stream produced by the demux. |
| + class DemuxStream { |
| + // TODO(dalesat): Replace this class with stream_type_, unless more stuff |
| + // needs to be added. |
| + public: |
| + virtual ~DemuxStream() {} |
| + |
| + virtual uint32_t index() const = 0; |
| + |
| + virtual StreamTypePtr stream_type() const = 0; |
| + }; |
| + |
| + // Creates a Demux object for a given reader. |
| + static Result Create(ReaderPtr reader, DemuxPtr* demux_out); |
| + |
| + ~Demux() override {} |
| + |
| + // TODO(dalesat): Don't let the demux talk to the reader. We're doing it this |
| + // way now because of ffmpeg's synchronous read call. Ideally, the demux |
| + // would tell its owner how much data it needs from the reader, and the |
| + // owner would later hand over the data and possibly get a packet back. |
| + |
| + // TODO(dalesat): Implement seek, etc. |
| + |
| + // TODO(dalesat): Make the demux use an allocator. Ffmpeg demuxes don't |
| + // support this. |
| + |
| + // Initializes the demux. |
| + virtual Result Init(ReaderPtr reader) = 0; |
| + |
| + // Gets the current metadata. |
| + virtual MetadataPtr metadata() const = 0; |
|
jeffbrown
2016/02/02 05:35:48
same style nits here for accessors
Is this data i
dalesat
2016/02/02 21:46:39
Currently, there's no support for mutability. That
|
| + |
| + // Gets the stream collection. |
| + virtual const std::vector<DemuxStream*>& streams() const = 0; |
|
jeffbrown
2016/02/02 05:35:48
Ok, I think you're overusing virtual throughout th
dalesat
2016/02/02 21:46:39
Given that 'parts' such as these are always hosted
|
| + |
| + // MultiStreamProducer implementation (deferred to subclasses). |
| + // bool can_accept_allocator(uint32_t stream_index) const override; |
| + // void set_allocator(uint32_t stream_index, Allocator* allocator) override; |
| + |
| + // MultiStreamPacketSource implementation (deferred to subclasses). |
| + // uint32_t stream_count() const override; |
| + // PacketPtr PullPacket(uint32_t* stream_index_out) override; |
| +}; |
| + |
| +} // namespace media |
| +} // namespace mojo |
| + |
| +#endif // SERVICES_MEDIA_FRAMEWORK_PARTS_DEMUX_H_ |