demux: adaptive: rework profile specific types for global timeline
[vlc.git] / modules / demux / adaptive / playlist / Segment.h
blob0c6258b919a9c9c55b7e1ddaebf43d68648101cb
1 /*
2 * Segment.h
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 *****************************************************************************/
25 #ifndef SEGMENT_H_
26 #define SEGMENT_H_
28 #include <string>
29 #include <sstream>
30 #include <vector>
31 #include "ICanonicalUrl.hpp"
32 #include "../http/Chunk.h"
33 #include "../encryption/CommonEncryption.hpp"
34 #include "../tools/Properties.hpp"
35 #include "Time.hpp"
37 namespace adaptive
39 class SharedResources;
41 namespace http
43 class AbstractConnectionManager;
46 namespace playlist
48 class BaseRepresentation;
49 class SubSegment;
50 class Segment;
51 class SegmentChunk;
53 using namespace http;
54 using namespace encryption;
56 class ISegment : public ICanonicalUrl
58 public:
59 ISegment(const ICanonicalUrl *parent);
60 virtual ~ISegment();
61 /**
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;
81 bool discontinuity;
83 static const int CLASSID_ISEGMENT = 0;
85 protected:
86 virtual bool prepareChunk (SharedResources *,
87 SegmentChunk *,
88 BaseRepresentation *);
89 CommonEncryption encryption;
90 size_t startByte;
91 size_t endByte;
92 std::string debugName;
93 int classId;
94 bool templated;
95 uint64_t sequence;
98 class Segment : public ISegment
100 public:
101 Segment( ICanonicalUrl *parent );
102 ~Segment();
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;
111 protected:
112 std::vector<Segment *> subsegments;
113 Url sourceUrl;
114 int size;
117 class InitSegment : public Segment
119 public:
120 InitSegment( ICanonicalUrl *parent );
121 static const int CLASSID_INITSEGMENT = 2;
124 class IndexSegment : public Segment
126 public:
127 IndexSegment( ICanonicalUrl *parent );
128 static const int CLASSID_INDEXSEGMENT = 3;
131 class SubSegment : public Segment
133 public:
134 SubSegment(Segment *, size_t start, size_t end);
135 static const int CLASSID_SUBSEGMENT = 4;
140 #endif /* SEGMENT_H_ */