demux: adaptive: remove unused global drain
[vlc.git] / modules / demux / adaptive / PlaylistManager.h
blob3eb900fdff5007775a9dd34250d431ebe0ed0e15
1 /*
2 * PlaylistManager.h
3 *****************************************************************************
4 * Copyright © 2010 - 2011 Klagenfurt University
5 * 2015 VideoLAN and VLC Authors
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
22 #ifndef PLAYLISTMANAGER_H_
23 #define PLAYLISTMANAGER_H_
25 #include "logic/AbstractAdaptationLogic.h"
26 #include "Streams.hpp"
27 #include <vector>
29 #include <vlc_cxx_helpers.hpp>
31 namespace adaptive
33 namespace playlist
35 class BasePlaylist;
36 class BasePeriod;
39 namespace http
41 class AbstractConnectionManager;
44 using namespace playlist;
45 using namespace logic;
47 class PlaylistManager
49 public:
50 PlaylistManager( demux_t *,
51 SharedResources *,
52 BasePlaylist *,
53 AbstractStreamFactory *,
54 AbstractAdaptationLogic::LogicType type );
55 virtual ~PlaylistManager ();
57 bool init();
58 bool start();
59 bool started() const;
60 void stop();
62 AbstractStream::BufferingStatus bufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t);
63 AbstractStream::Status dequeue(vlc_tick_t, vlc_tick_t *);
65 virtual bool needsUpdate() const;
66 virtual bool updatePlaylist();
67 virtual void scheduleNextUpdate();
69 /* static callbacks */
70 static int control_callback(demux_t *, int, va_list);
71 static int demux_callback(demux_t *);
73 protected:
74 /* Demux calls */
75 virtual int doControl(int, va_list);
76 virtual int doDemux(vlc_tick_t);
78 void setLivePause(bool);
79 virtual bool setPosition(vlc_tick_t);
80 vlc_tick_t getResumeTime() const;
81 vlc_tick_t getFirstDTS() const;
82 unsigned getActiveStreamsCount() const;
84 virtual vlc_tick_t getFirstPlaybackTime() const;
85 vlc_tick_t getCurrentDemuxTime() const;
86 vlc_tick_t getMinAheadTime() const;
88 virtual bool reactivateStream(AbstractStream *);
89 bool setupPeriod();
90 void unsetPeriod();
92 void updateControlsPosition();
94 /* local factories */
95 virtual AbstractAdaptationLogic *createLogic(AbstractAdaptationLogic::LogicType,
96 AbstractConnectionManager *);
97 virtual AbstractBufferingLogic *createBufferingLogic() const;
99 SharedResources *resources;
100 AbstractAdaptationLogic::LogicType logicType;
101 AbstractAdaptationLogic *logic;
102 AbstractBufferingLogic *bufferingLogic;
103 BasePlaylist *playlist;
104 AbstractStreamFactory *streamFactory;
105 demux_t *p_demux;
106 std::vector<AbstractStream *> streams;
107 BasePeriod *currentPeriod;
109 /* shared with demux/buffering */
110 struct
112 vlc_tick_t i_nzpcr;
113 vlc_tick_t i_firstpcr;
114 mutable vlc_mutex_t lock;
115 vlc_cond_t cond;
116 } demux;
118 /* buffering process */
119 time_t nextPlaylistupdate;
120 int failedupdates;
122 /* Controls */
123 struct
125 bool b_live;
126 vlc_tick_t i_time;
127 double f_position;
128 mutable vlc_mutex_t lock;
129 vlc_tick_t playlistStart;
130 vlc_tick_t playlistEnd;
131 vlc_tick_t playlistLength;
132 time_t lastupdate;
133 } cached;
135 private:
136 void setBufferingRunState(bool);
137 void Run();
138 static void * managerThread(void *);
139 vlc::threads::mutex lock;
140 vlc::threads::condition_variable waitcond;
141 vlc_thread_t thread;
142 bool b_thread;
143 bool b_buffering;
144 bool b_canceled;
145 vlc_tick_t pause_start;
150 #endif /* PLAYLISTMANAGER_H_ */