Streams.hpp 3.99 KB
Newer Older
1 2 3
/*
 * Streams.hpp
 *****************************************************************************
4
 * Copyright (C) 2014 - VideoLAN and VLC authors
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * 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.
 *****************************************************************************/
20 21 22
#ifndef STREAM_HPP
#define STREAM_HPP

23 24 25 26 27
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
28
#include "StreamFormat.hpp"
29
#include "ChunksSource.hpp"
30
#include "SegmentTracker.hpp"
31 32 33 34 35 36

#include "plumbing/Demuxer.hpp"
#include "plumbing/SourceStream.hpp"
#include "plumbing/FakeESOut.hpp"

#include <string>
37

38
namespace adaptive
39
{
40 41
    class SegmentTracker;

42 43 44 45 46
    namespace http
    {
        class HTTPConnectionManager;
    }

47 48 49 50 51
    namespace playlist
    {
        class SegmentChunk;
    }

52
    using namespace http;
53
    using namespace playlist;
54

55
    class AbstractStream : public ChunksSource,
56 57
                           public ExtraFMTInfoInterface,
                           public SegmentTrackerListenerInterface
58 59
    {
    public:
60 61
        AbstractStream(demux_t *, const StreamFormat &);
        virtual ~AbstractStream();
62
        void bind(SegmentTracker *, HTTPConnectionManager *);
63

64
        void setLanguage(const std::string &);
65
        void setDescription(const std::string &);
66 67
        bool isEOF() const;
        mtime_t getPCR() const;
68
        mtime_t getBufferingLevel() const;
69
        mtime_t getMinAheadTime() const;
70
        mtime_t getFirstDTS() const;
71 72
        int esCount() const;
        bool seekAble() const;
73
        bool isSelected() const;
74
        virtual bool reactivate(mtime_t);
75
        bool isDisabled() const;
76 77 78 79 80 81
        typedef enum {status_eof,
                      status_eop,
                      status_dis,
                      status_buffering,
                      status_buffering_ahead, /* Special case for live waiting new segments */
                      status_demuxed} status;
82 83
        status demux(mtime_t, bool);
        virtual bool setPosition(mtime_t, bool);
84
        mtime_t getPlaybackTime() const;
85
        void runUpdates();
86

87
        virtual block_t *readNextBlock(); /* impl */
88 89

        virtual void fillExtraFMTInfo( es_format_t * ) const; /* impl */
90
        virtual void trackerEvent(const SegmentTrackerEvent &); /* impl */
91 92 93 94 95 96 97 98 99 100 101 102

    protected:
        virtual block_t *checkBlock(block_t *, bool) = 0;
        virtual AbstractDemuxer * createDemux(const StreamFormat &) = 0;
        virtual bool startDemux();
        virtual bool restartDemux();

        virtual void prepareFormatChange();

        bool discontinuity;

        demux_t *p_realdemux;
103
        StreamFormat format;
104 105

        HTTPConnectionManager *connManager; /* not owned */
106
        SegmentTracker *segmentTracker;
107

108
        SegmentChunk *currentChunk;
109
        bool disabled;
110
        bool eof;
111 112 113
        bool dead;
        bool flushing;
        mtime_t pcr;
114
        std::string language;
115
        std::string description;
116

117 118 119
        AbstractDemuxer *demuxer;
        AbstractSourceStream *demuxersource;
        FakeESOut *fakeesout; /* to intercept/proxy what is sent from demuxstream */
120 121
    };

122 123 124 125 126
    class AbstractStreamFactory
    {
        public:
            virtual ~AbstractStreamFactory() {}
            virtual AbstractStream *create(demux_t*, const StreamFormat &,
127
                                   SegmentTracker *, HTTPConnectionManager *) const = 0;
128
    };
129 130
}
#endif // STREAMS_HPP