Demuxer.hpp 3.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * Demuxer.hpp
 *****************************************************************************
 * Copyright © 2015 - VideoLAN and VLC Authors
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
#ifndef DEMUXER_HPP
#define DEMUXER_HPP

#include <vlc_common.h>
#include <string>

26
namespace adaptive
27
{
28
    class AbstractSourceStream;
29 30
    class DemuxerFactoryInterface;
    class StreamFormat;
31 32 33 34 35 36

    class AbstractDemuxer
    {
        public:
            AbstractDemuxer();
            virtual ~AbstractDemuxer();
37
            virtual int demux(mtime_t) = 0;
38 39
            virtual void drain() = 0;
            virtual bool create() = 0;
40
            virtual void destroy() = 0;
41
            bool alwaysStartsFromZero() const;
42 43
            bool needsRestartOnSeek() const;
            bool needsRestartOnSwitch() const;
44
            bool needsRestartOnEachSegment() const;
45
            void setCanDetectSwitches(bool);
46
            void setRestartsOnEachSegment(bool);
47 48 49 50

        protected:
            bool b_startsfromzero;
            bool b_reinitsonseek;
51
            bool b_alwaysrestarts;
52
            bool b_candetectswitches;
53 54
    };

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    class MimeDemuxer : public AbstractDemuxer
    {
        public:
            MimeDemuxer(demux_t *, const DemuxerFactoryInterface *,
                        es_out_t *, AbstractSourceStream *);
            virtual ~MimeDemuxer();
            virtual int demux(mtime_t); /* impl */
            virtual void drain(); /* impl */
            virtual bool create(); /* impl */
            virtual void destroy(); /* impl */

        protected:
            AbstractSourceStream *sourcestream;
            demux_t *p_realdemux;
            AbstractDemuxer *demuxer;
            const DemuxerFactoryInterface *factory;
            es_out_t *p_es_out;
    };

74
    class Demuxer : public AbstractDemuxer
75 76
    {
        public:
77 78
            Demuxer(demux_t *, const std::string &, es_out_t *, AbstractSourceStream *);
            virtual ~Demuxer();
79
            virtual int demux(mtime_t); /* impl */
80 81
            virtual void drain(); /* impl */
            virtual bool create(); /* impl */
82
            virtual void destroy(); /* impl */
83

84
        protected:
85
            AbstractSourceStream *sourcestream;
86
            demux_t *p_realdemux;
87
            demux_t *p_demux;
88 89
            std::string name;
            es_out_t *p_es_out;
90
            bool b_eof;
91 92
    };

93 94 95 96 97 98 99 100 101 102 103 104
    class SlaveDemuxer : public Demuxer
    {
        public:
            SlaveDemuxer(demux_t *, const std::string &, es_out_t *, AbstractSourceStream *);
            virtual ~SlaveDemuxer();
            virtual bool create(); /* reimpl */
            virtual int demux(mtime_t); /* reimpl */

        private:
            mtime_t length;
    };

105 106 107 108 109 110
    class DemuxerFactoryInterface
    {
        public:
            virtual AbstractDemuxer * newDemux(demux_t *, const StreamFormat &,
                                               es_out_t *, AbstractSourceStream *) const = 0;
    };
111 112 113
}

#endif // DEMUXER_HPP