Native Player  1.0
media_segment_sequence.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // Copyright (c) 2016, Samsung Electronics Co., Ltd
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
20 // , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 //
23 // @author Adam Bujalski
24 //
25 // ----------------------------------------------------------------------------
26 
27 #ifndef SRC_PLAYER_ES_DASH_PLAYER_DASH_MEDIA_SEGMENT_SEQUENCE_H_
28 #define SRC_PLAYER_ES_DASH_PLAYER_DASH_MEDIA_SEGMENT_SEQUENCE_H_
29 
30 #include <memory>
31 #include <vector>
32 
35 
36 namespace dash {
37 namespace mpd {
38 class ISegment;
39 }
40 }
41 
42 class SequenceIterator;
43 
52  public:
53  static constexpr double kInvalidSegmentDuration = -1.0;
54  static constexpr double kInvalidSegmentTimestamp = -1.0;
55 
56  virtual ~MediaSegmentSequence();
57 
64  class Iterator {
65  public:
67  Iterator();
68 
71  explicit Iterator(std::unique_ptr<SequenceIterator>&&);
72 
74  Iterator(const Iterator& other);
75 
78  Iterator(Iterator&& other);
79 
81  ~Iterator();
82 
84  Iterator& operator=(const Iterator& other);
85 
88  Iterator& operator=(Iterator&& other);
89 
92  Iterator& operator++();
93 
96  Iterator operator++(int);
97 
100  Iterator& operator--();
101 
104  Iterator operator--(int);
105 
108  bool operator==(const Iterator&) const;
109 
112  bool operator!=(const Iterator&) const;
113 
116 
120  std::unique_ptr<dash::mpd::ISegment> operator*() const;
121 
125  double SegmentDuration(const MediaSegmentSequence*) const;
126 
130  double SegmentTimestamp(const MediaSegmentSequence*) const;
131 
132  private:
133  std::unique_ptr<SequenceIterator> pimpl_;
134  };
135 
137  virtual Iterator Begin() const = 0;
138 
140  virtual Iterator End() const = 0;
141 
142  // TODO(samsung) use units from nacl-player
145  virtual Iterator MediaSegmentForTime(double time) const = 0;
146 
150  virtual std::unique_ptr<dash::mpd::ISegment> GetInitSegment() const = 0;
151 
155  virtual std::unique_ptr<dash::mpd::ISegment> GetBitstreamSwitchingSegment()
156  const = 0;
157 
160  virtual std::unique_ptr<dash::mpd::ISegment> GetRepresentationIndexSegment()
161  const = 0;
162 
165  virtual std::unique_ptr<dash::mpd::ISegment> GetIndexSegment() const = 0;
166 
171  virtual double AverageSegmentDuration() const = 0;
172 
177  virtual double SegmentDuration(const Iterator& it) const;
178 
183  virtual double SegmentTimestamp(const Iterator& it) const;
184 };
185 
193 bool DownloadSegment(dash::mpd::ISegment* seg, std::vector<uint8_t>* data);
194 
203 inline
204 bool DownloadSegment(std::unique_ptr<dash::mpd::ISegment> seg,
205  std::vector<uint8_t>* data) {
206  return DownloadSegment(seg.get(), data);
207 }
208 
209 #endif // SRC_PLAYER_ES_DASH_PLAYER_DASH_MEDIA_SEGMENT_SEQUENCE_H_
Container of possibly infinite (in case of live streams) sequence of MediaSegments for particular rep...
Constant bidirectional iterator through the sequence.
bool DownloadSegment(dash::mpd::ISegment *seg, std::vector< uint8_t > *data)