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

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

27
#include <string>
28
#include <list>
29
#include <vlc_common.h>
30
31
#include "StreamsType.hpp"

32
namespace adaptative
33
{
34
35
    class SegmentTracker;

36
37
38
39
40
41
42
43
44
45
46
    namespace http
    {
        class HTTPConnectionManager;
        class Chunk;
    }

    namespace logic
    {
        class AbstractAdaptationLogic;
    }

47
48
49
50
    namespace Streams
    {
        class AbstractStreamOutput;

51
52
53
        using namespace http;
        using namespace logic;

54
55
56
57
        class Stream
        {
            public:
                Stream(const std::string &mime);
58
                Stream(const Type, const Format);
59
                ~Stream();
60
61
                bool operator==(const Stream &) const;
                static Type mimeToType(const std::string &mime);
62
                static Format mimeToFormat(const std::string &mime);
63
                void create(demux_t *, AbstractAdaptationLogic *, SegmentTracker *);
64
65
66
67
                bool isEOF() const;
                mtime_t getPCR() const;
                int getGroup() const;
                int esCount() const;
68
                bool seekAble() const;
69
70
                typedef enum {status_eof, status_buffering, status_demuxed} status;
                status demux(HTTPConnectionManager *, mtime_t);
71
                bool setPosition(mtime_t, bool);
72
                mtime_t getPosition() const;
73
74

            private:
75
                Chunk *getChunk();
76
                void init(const Type, const Format);
77
                size_t read(HTTPConnectionManager *);
78
                Type type;
79
                Format format;
80
                AbstractStreamOutput *output;
81
                AbstractAdaptationLogic *adaptationLogic;
82
                SegmentTracker *segmentTracker;
83
84
85
86
87
88
89
90
91
92
93
94
95
96
                http::Chunk *currentChunk;
                bool eof;
        };

        class AbstractStreamOutput
        {
            public:
                AbstractStreamOutput(demux_t *);
                virtual ~AbstractStreamOutput();

                virtual void pushBlock(block_t *);
                mtime_t getPCR() const;
                int getGroup() const;
                int esCount() const;
97
98
                bool seekAble() const;
                void setPosition(mtime_t);
99
100
                void sendToDecoder(mtime_t);
                void dropQueues();
101
102
103
104
105
106

            protected:
                mtime_t   pcr;
                int       group;
                es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
                stream_t *demuxstream;
107
                bool      seekable;
108
109
110
111
112
113
114
115

            private:
                demux_t  *realdemux;
                static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
                static int esOutSend(es_out_t *, es_out_id_t *, block_t *);
                static void esOutDel(es_out_t *, es_out_id_t *);
                static int esOutControl(es_out_t *, int, va_list);
                static void esOutDestroy(es_out_t *);
116
117
118
119
120
121
122
123
124
125
126
127

                class Demuxed
                {
                    friend class AbstractStreamOutput;
                    Demuxed();
                    ~Demuxed();
                    void drop();
                    es_out_id_t *es_id;
                    block_t  *p_queue;
                    block_t **pp_queue_last;
                };
                std::list<Demuxed *> queues;
128
        };
129

130
131
132
133
134
135
        class MP4StreamOutput : public AbstractStreamOutput
        {
            public:
                MP4StreamOutput(demux_t *);
                virtual ~MP4StreamOutput(){}
        };
136
137
138
139
140
141
142

        class MPEG2TSStreamOutput : public AbstractStreamOutput
        {
            public:
                MPEG2TSStreamOutput(demux_t *);
                virtual ~MPEG2TSStreamOutput(){}
        };
143
144
145
    }
}
#endif // STREAMS_HPP