Streams.hpp 3.94 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
#include <vlc_common.h>
24
#include "StreamFormat.hpp"
25
#include "ChunksSource.hpp"
26
#include "SegmentTracker.hpp"
27
28
29
30
31
32

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

#include <string>
33

34
namespace adaptive
35
{
36
37
    class SegmentTracker;

38
39
40
41
42
    namespace http
    {
        class HTTPConnectionManager;
    }

43
44
45
46
47
    namespace playlist
    {
        class SegmentChunk;
    }

48
    using namespace http;
49
    using namespace playlist;
50

51
    class AbstractStream : public ChunksSource,
52
53
                           public ExtraFMTInfoInterface,
                           public SegmentTrackerListenerInterface
54
55
    {
    public:
56
57
        AbstractStream(demux_t *, const StreamFormat &);
        virtual ~AbstractStream();
58
        void bind(SegmentTracker *, HTTPConnectionManager *);
59

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

82
        virtual block_t *readNextBlock(); /* impl */
83
84

        virtual void fillExtraFMTInfo( es_format_t * ) const; /* impl */
85
        virtual void trackerEvent(const SegmentTrackerEvent &); /* impl */
86
87

    protected:
88
        bool seekAble() const;
89
90
91
92
93
94
95
96
97
98
        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;
99
        StreamFormat format;
100
101

        HTTPConnectionManager *connManager; /* not owned */
102
        SegmentTracker *segmentTracker;
103

104
        SegmentChunk *currentChunk;
105
        bool disabled;
106
        bool eof;
107
108
109
        bool dead;
        bool flushing;
        mtime_t pcr;
110
        std::string language;
111
        std::string description;
112

113
114
115
        AbstractDemuxer *demuxer;
        AbstractSourceStream *demuxersource;
        FakeESOut *fakeesout; /* to intercept/proxy what is sent from demuxstream */
116
117
    };

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