]> git.sesse.net Git - vlc/blob - modules/demux/dash/mpd/SegmentInfoCommon.cpp
demux: dash: simplify MPD set/getters
[vlc] / modules / demux / 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 Timelineable::Timelineable()
37 {
38     segmentTimeline.Set(NULL);
39 }
40
41 Timelineable::~Timelineable()
42 {
43     delete segmentTimeline.Get();
44 }
45
46 SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
47     ICanonicalUrl( parent ), Initializable(),
48     duration( 0 ),
49     startIndex( 0 )
50 {
51 }
52
53 SegmentInfoCommon::~SegmentInfoCommon()
54 {
55 }
56
57 time_t      SegmentInfoCommon::getDuration() const
58 {
59     return this->duration;
60 }
61
62 void        SegmentInfoCommon::setDuration( time_t duration )
63 {
64     if ( duration >= 0 )
65         this->duration = duration;
66 }
67
68 int         SegmentInfoCommon::getStartIndex() const
69 {
70     return this->startIndex;
71 }
72
73 void        SegmentInfoCommon::setStartIndex(int startIndex)
74 {
75     if ( startIndex >= 0 )
76         this->startIndex = startIndex;
77 }
78
79 void SegmentInfoCommon::appendBaseURL(const std::string &url)
80 {
81     this->baseURLs.push_back( url );
82 }
83
84 Url SegmentInfoCommon::getUrlSegment() const
85 {
86     Url ret = getParentUrlSegment();
87     if (!baseURLs.empty())
88         ret.append(baseURLs.front());
89     return ret;
90 }