]> git.sesse.net Git - vlc/blob - modules/demux/dash/Streams.hpp
10404f43580704060f8d5a9751f6d62ba0c61dd4
[vlc] / modules / demux / dash / Streams.hpp
1 /*
2  * Streams.hpp
3  *****************************************************************************
4  * Copyright (C) 2014 - VideoLAN authors
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20 #ifndef STREAM_HPP
21 #define STREAM_HPP
22
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include <string>
28 #include <vlc_common.h>
29 #include "StreamsType.hpp"
30 #include "adaptationlogic/AbstractAdaptationLogic.h"
31 #include "http/HTTPConnectionManager.h"
32 #include "http/Chunk.h"
33
34 namespace dash
35 {
36     class SegmentTracker;
37
38     namespace Streams
39     {
40         class AbstractStreamOutput;
41
42         class Stream
43         {
44             public:
45                 Stream(const std::string &mime);
46                 Stream(const Type, const Format);
47                 ~Stream();
48                 bool operator==(const Stream &) const;
49                 static Type mimeToType(const std::string &mime);
50                 static Format mimeToFormat(const std::string &mime);
51                 void create(demux_t *, logic::AbstractAdaptationLogic *, SegmentTracker *);
52                 bool isEOF() const;
53                 mtime_t getPCR() const;
54                 int getGroup() const;
55                 int esCount() const;
56                 bool seekAble() const;
57                 size_t read(http::HTTPConnectionManager *);
58                 bool setPosition(mtime_t, bool);
59
60             private:
61                 http::Chunk *getChunk();
62                 void init(const Type, const Format);
63                 Type type;
64                 Format format;
65                 AbstractStreamOutput *output;
66                 logic::AbstractAdaptationLogic *adaptationLogic;
67                 SegmentTracker *segmentTracker;
68                 http::Chunk *currentChunk;
69                 bool eof;
70         };
71
72         class AbstractStreamOutput
73         {
74             public:
75                 AbstractStreamOutput(demux_t *);
76                 virtual ~AbstractStreamOutput();
77
78                 virtual void pushBlock(block_t *);
79                 mtime_t getPCR() const;
80                 int getGroup() const;
81                 int esCount() const;
82                 bool seekAble() const;
83                 void setPosition(mtime_t);
84
85             protected:
86                 mtime_t   pcr;
87                 int       group;
88                 int       escount;
89                 es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
90                 stream_t *demuxstream;
91                 bool      seekable;
92
93             private:
94                 demux_t  *realdemux;
95                 static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
96                 static int esOutSend(es_out_t *, es_out_id_t *, block_t *);
97                 static void esOutDel(es_out_t *, es_out_id_t *);
98                 static int esOutControl(es_out_t *, int, va_list);
99                 static void esOutDestroy(es_out_t *);
100         };
101
102         class MP4StreamOutput : public AbstractStreamOutput
103         {
104             public:
105                 MP4StreamOutput(demux_t *);
106                 virtual ~MP4StreamOutput(){}
107         };
108
109         class MPEG2TSStreamOutput : public AbstractStreamOutput
110         {
111             public:
112                 MPEG2TSStreamOutput(demux_t *);
113                 virtual ~MPEG2TSStreamOutput(){}
114         };
115     }
116 }
117 #endif // STREAMS_HPP