3 *****************************************************************************
4 * Copyright (C) 2010 - 2011 Klagenfurt University
6 * Created on: Aug 10, 2010
7 * Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
8 * Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
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
12 * by the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
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.
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 *****************************************************************************/
31 #include "ICanonicalUrl.hpp"
32 #include "../http/Chunk.h"
33 #include "../encryption/CommonEncryption.hpp"
34 #include "../tools/Properties.hpp"
39 class SharedResources
;
43 class AbstractConnectionManager
;
48 class BaseRepresentation
;
54 using namespace encryption
;
56 class ISegment
: public ICanonicalUrl
59 ISegment(const ICanonicalUrl
*parent
);
62 * @return true if the segment should be dropped after being read.
63 * That is basically true when using an Url, and false
64 * when using an UrlTemplate
66 virtual SegmentChunk
* toChunk (SharedResources
*, AbstractConnectionManager
*,
67 size_t, BaseRepresentation
*);
68 virtual SegmentChunk
* createChunk (AbstractChunkSource
*, BaseRepresentation
*) = 0;
69 virtual void setByteRange (size_t start
, size_t end
);
70 virtual void setSequenceNumber(uint64_t);
71 virtual uint64_t getSequenceNumber() const;
72 virtual bool isTemplate () const;
73 virtual size_t getOffset () const;
74 virtual void debug (vlc_object_t
*,int = 0) const;
75 virtual bool contains (size_t byte
) const;
76 virtual int compare (ISegment
*) const;
77 void setEncryption (CommonEncryption
&);
78 int getClassId () const;
79 Property
<stime_t
> startTime
;
80 Property
<stime_t
> duration
;
83 static const int CLASSID_ISEGMENT
= 0;
86 virtual bool prepareChunk (SharedResources
*,
88 BaseRepresentation
*);
89 CommonEncryption encryption
;
92 std::string debugName
;
98 class Segment
: public ISegment
101 Segment( ICanonicalUrl
*parent
);
103 virtual SegmentChunk
* createChunk(AbstractChunkSource
*, BaseRepresentation
*); /* impl */
104 virtual void setSourceUrl( const std::string
&url
);
105 virtual Url
getUrlSegment() const; /* impl */
106 virtual const std::vector
<Segment
*> & subSegments() const;
107 virtual void debug(vlc_object_t
*,int = 0) const;
108 virtual void addSubSegment(SubSegment
*);
109 static const int CLASSID_SEGMENT
= 1;
112 std::vector
<Segment
*> subsegments
;
117 class InitSegment
: public Segment
120 InitSegment( ICanonicalUrl
*parent
);
121 static const int CLASSID_INITSEGMENT
= 2;
124 class IndexSegment
: public Segment
127 IndexSegment( ICanonicalUrl
*parent
);
128 static const int CLASSID_INDEXSEGMENT
= 3;
131 class SubSegment
: public Segment
134 SubSegment(Segment
*, size_t start
, size_t end
);
135 static const int CLASSID_SUBSEGMENT
= 4;
140 #endif /* SEGMENT_H_ */