]> git.sesse.net Git - vlc/blob - modules/stream_filter/dash/mpd/SegmentInfoCommon.cpp
stream_filter: dash: deduplicate parser code
[vlc] / modules / stream_filter / dash / mpd / SegmentInfoCommon.cpp
1 /*****************************************************************************
2  * SegmentInfoCommon.cpp: Implement the common part for both SegmentInfoDefault
3  *                        and SegmentInfo
4  *****************************************************************************
5  * Copyright (C) 1998-2007 VLC authors and VideoLAN
6  * $Id$
7  *
8  * Authors: Hugo BeauzĂ©e-Luyssen <beauze.h@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include "SegmentInfoCommon.h"
30
31 #include "Segment.h"
32 #include "SegmentTimeline.h"
33
34 using namespace dash::mpd;
35
36 SegmentInfoCommon::SegmentInfoCommon() :
37     duration( -1 ),
38     initialisationSegment( NULL ),
39     segmentTimeline( NULL )
40 {
41 }
42
43 SegmentInfoCommon::~SegmentInfoCommon()
44 {
45     delete this->segmentTimeline;
46     delete this->initialisationSegment;
47 }
48
49 time_t      SegmentInfoCommon::getDuration() const
50 {
51     return this->duration;
52 }
53
54 void        SegmentInfoCommon::setDuration( time_t duration )
55 {
56     if ( duration >= 0 )
57         this->duration = duration;
58 }
59
60 int         SegmentInfoCommon::getStartIndex() const
61 {
62     return this->startIndex;
63 }
64
65 void        SegmentInfoCommon::setStartIndex(int startIndex)
66 {
67     if ( startIndex >= 0 )
68         this->startIndex = startIndex;
69 }
70
71 Segment*  SegmentInfoCommon::getInitialisationSegment() const
72 {
73     return this->initialisationSegment;
74 }
75
76 void SegmentInfoCommon::setInitialisationSegment(Segment *seg)
77 {
78     if ( seg != NULL )
79         this->initialisationSegment = seg;
80 }
81
82 const std::list<std::string>&   SegmentInfoCommon::getBaseURL() const
83 {
84     return this->baseURLs;
85 }
86
87 void SegmentInfoCommon::appendBaseURL(const std::string &url)
88 {
89     this->baseURLs.push_back( url );
90 }
91
92 const SegmentTimeline *SegmentInfoCommon::getSegmentTimeline() const
93 {
94     return this->segmentTimeline;
95 }
96
97 void SegmentInfoCommon::setSegmentTimeline( const SegmentTimeline *segTl )
98 {
99     if ( segTl != NULL )
100         this->segmentTimeline = segTl;
101 }