3 *****************************************************************************
4 * Copyright (C) 2014 - VideoLAN and VLC authors
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.
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.
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 SEGMENTTRACKER_HPP
21 #define SEGMENTTRACKER_HPP
23 #include "StreamFormat.hpp"
24 #include "playlist/CodecDescription.hpp"
25 #include "playlist/Role.hpp"
27 #include <vlc_common.h>
33 class SharedResources
;
37 class AbstractConnectionManager
;
43 class AbstractAdaptationLogic
;
44 class AbstractBufferingLogic
;
49 class BaseAdaptationSet
;
50 class BaseRepresentation
;
54 using namespace playlist
;
55 using namespace logic
;
71 TrackerEvent() = delete;
72 virtual ~TrackerEvent() = 0;
82 class DiscontinuityEvent
: public TrackerEvent
86 virtual ~DiscontinuityEvent() = default;
89 class RepresentationSwitchEvent
: public TrackerEvent
92 RepresentationSwitchEvent() = delete;
93 RepresentationSwitchEvent(BaseRepresentation
*, BaseRepresentation
*);
94 virtual ~RepresentationSwitchEvent() = default;
96 BaseRepresentation
*prev
;
97 BaseRepresentation
*next
;
100 class FormatChangedEvent
: public TrackerEvent
103 FormatChangedEvent() = delete;
104 FormatChangedEvent(const StreamFormat
*);
105 virtual ~FormatChangedEvent() = default;
107 const StreamFormat
*format
;
110 class SegmentChangedEvent
: public TrackerEvent
113 SegmentChangedEvent() = delete;
114 SegmentChangedEvent(const ID
&, vlc_tick_t
);
115 virtual ~SegmentChangedEvent() = default;
121 class BufferingStateUpdatedEvent
: public TrackerEvent
124 BufferingStateUpdatedEvent() = delete;
125 BufferingStateUpdatedEvent(const ID
&, bool);
126 virtual ~BufferingStateUpdatedEvent() = default;
132 class BufferingLevelChangedEvent
: public TrackerEvent
135 BufferingLevelChangedEvent() = delete;
136 BufferingLevelChangedEvent(const ID
&,
137 vlc_tick_t
, vlc_tick_t
, vlc_tick_t
, vlc_tick_t
);
138 virtual ~BufferingLevelChangedEvent() = default;
147 class PositionChangedEvent
: public TrackerEvent
150 PositionChangedEvent();
151 virtual ~PositionChangedEvent() = default;
154 class SegmentTrackerListenerInterface
157 virtual void trackerEvent(const TrackerEvent
&) = 0;
158 virtual ~SegmentTrackerListenerInterface() = default;
164 SegmentTracker(SharedResources
*,
165 AbstractAdaptationLogic
*,
166 const AbstractBufferingLogic
*,
167 BaseAdaptationSet
*);
174 Position(BaseRepresentation
*, uint64_t);
175 Position
& operator++();
176 bool isValid() const;
177 std::string
toString() const;
179 BaseRepresentation
*rep
;
184 StreamFormat
getCurrentFormat() const;
185 void getCodecsDesc(CodecDescriptionList
*) const;
186 const Role
& getStreamRole() const;
188 ChunkInterface
* getNextChunk(bool, AbstractConnectionManager
*);
189 bool setPositionByTime(vlc_tick_t
, bool, bool);
190 void setPosition(const Position
&, bool);
191 bool setStartPosition();
192 Position
getStartPosition() const;
193 vlc_tick_t
getPlaybackTime(bool = false) const; /* Current segment start time if selected */
194 bool getMediaPlaybackRange(vlc_tick_t
*, vlc_tick_t
*, vlc_tick_t
*) const;
195 vlc_tick_t
getMinAheadTime() const;
196 void notifyBufferingState(bool) const;
197 void notifyBufferingLevel(vlc_tick_t
, vlc_tick_t
, vlc_tick_t
, vlc_tick_t
) const;
198 void registerListener(SegmentTrackerListenerInterface
*);
199 void updateSelected();
200 bool bufferingAvailable() const;
207 ChunkEntry(SegmentChunk
*c
, Position p
, vlc_tick_t d
);
208 bool isValid() const;
213 std::list
<ChunkEntry
> chunkssequence
;
214 ChunkEntry
prepareChunk(bool switch_allowed
, Position pos
,
215 AbstractConnectionManager
*connManager
) const;
216 void resetChunksSequence();
217 void setAdaptationLogic(AbstractAdaptationLogic
*);
218 void notify(const TrackerEvent
&) const;
224 SharedResources
*resources
;
225 AbstractAdaptationLogic
*logic
;
226 const AbstractBufferingLogic
*bufferingLogic
;
227 BaseAdaptationSet
*adaptationSet
;
228 std::list
<SegmentTrackerListenerInterface
*> listeners
;
232 #endif // SEGMENTTRACKER_HPP