]> git.sesse.net Git - vlc/blob - modules/demux/dash/mpd/SegmentInformation.hpp
msg: simplify msg_GenericVa() macro
[vlc] / modules / demux / dash / mpd / SegmentInformation.hpp
1 /*
2  * SegmentInformation.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 SEGMENTINFORMATION_HPP
21 #define SEGMENTINFORMATION_HPP
22
23 #define __STDC_CONSTANT_MACROS
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include "ICanonicalUrl.hpp"
30 #include "Properties.hpp"
31 #include "SegmentInfoCommon.h"
32 #include <vlc_common.h>
33 #include <vector>
34
35 namespace dash
36 {
37     namespace mpd
38     {
39         class ISegment;
40         class SegmentBase;
41         class SegmentList;
42         class SegmentTemplate;
43         class SegmentTimeline;
44         class MPD;
45
46         /* common segment elements for period/adaptset/rep 5.3.9.1,
47          * with properties inheritance */
48         class SegmentInformation : public ICanonicalUrl,
49                                    public TimescaleAble
50         {
51             friend class IsoffMainParser;
52
53             public:
54                 SegmentInformation( SegmentInformation * = 0 );
55                 explicit SegmentInformation( MPD * );
56                 virtual ~SegmentInformation();
57                 bool canBitswitch() const;
58                 virtual mtime_t getPeriodStart() const;
59
60                 class SplitPoint
61                 {
62                     public:
63                         size_t offset;
64                         mtime_t time;
65                 };
66                 void SplitUsingIndex(std::vector<SplitPoint>&);
67
68                 enum SegmentInfoType
69                 {
70                     INFOTYPE_INIT = 0,
71                     INFOTYPE_MEDIA,
72                     INFOTYPE_INDEX
73                 };
74                 static const int InfoTypeCount = INFOTYPE_INDEX + 1;
75
76                 ISegment * getSegment(SegmentInfoType, uint64_t = 0) const;
77                 bool getSegmentNumberByTime(mtime_t, uint64_t *) const;
78                 mtime_t getPlaybackTimeBySegmentNumber(uint64_t) const;
79                 void collectTimelines(std::vector<SegmentTimeline *> *) const;
80
81             protected:
82                 std::vector<ISegment *> getSegments() const;
83                 std::vector<ISegment *> getSegments(SegmentInfoType) const;
84                 std::vector<SegmentInformation *> childs;
85
86             private:
87                 void init();
88                 void setSegmentList(SegmentList *);
89                 void setSegmentBase(SegmentBase *);
90                 void setSegmentTemplate(MediaSegmentTemplate *);
91                 void setBitstreamSwitching(bool);
92
93                 SegmentBase *     inheritSegmentBase() const;
94                 SegmentList *     inheritSegmentList() const;
95                 MediaSegmentTemplate * inheritSegmentTemplate() const;
96
97                 SegmentInformation *parent;
98                 SegmentBase     *segmentBase;
99                 SegmentList     *segmentList;
100                 MediaSegmentTemplate *mediaSegmentTemplate;
101
102                 enum BitswitchPolicy
103                 {
104                     BITSWITCH_INHERIT,
105                     BITSWITCH_YES,
106                     BITSWITCH_NO
107                 } bitswitch_policy;
108         };
109     }
110 }
111
112 #endif // SEGMENTINFORMATION_HPP