libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
SegmentBase.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_SEGMENT_BASE_HH_
2#define _BBC_PARSE_DASH_MPD_SEGMENT_BASE_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: SegmentBase class
5 *****************************************************************************
6 * Copyright: (C) 2025 British Broadcasting Corporation
7 * Author(s): David Waring <david.waring2@bbc.co.uk>
8 * License: LGPLv3
9 *
10 * For full license terms please see the LICENSE file distributed with this
11 * library or refer to: https://www.gnu.org/licenses/lgpl-3.0.txt.
12 */
13#include <chrono>
14#include <optional>
15
16#include "macros.hh"
17#include "FailoverContent.hh"
18#include "SingleRFC7233Range.hh"
19#include "URL.hh"
20
23// Forward declarations for types only used by pointer or reference
24namespace xmlpp {
25 class Element;
26 class Node;
27}
30
32
33class AdaptationSet;
34class Representation;
35
42public:
43 using duration_type = std::chrono::microseconds;
44
46 SegmentBase(const SegmentBase &other);
48
49 virtual ~SegmentBase() {};
50
53
54 bool operator==(const SegmentBase &other) const;
55
56 // @timescale
57 bool hasTimescale() const { return m_timescale.has_value(); };
58 const std::optional<unsigned int> &timescale() const { return m_timescale; };
59 SegmentBase &timescale(const std::nullopt_t&) { m_timescale.reset(); return *this; };
60 SegmentBase &timescale(unsigned int val) { m_timescale = val; return *this; };
61
62 // @eptDelta
63 bool hasEptDelta() const { return m_eptDelta.has_value(); };
64 const std::optional<int> &eptDelta() const { return m_eptDelta; };
65 SegmentBase &eptDelta(const std::nullopt_t&) { m_eptDelta.reset(); return *this; };
66 SegmentBase &eptDelta(int val) { m_eptDelta = val; return *this; };
67
68 // @pdDelta
69 bool hasPdDelta() const { return m_pdDelta.has_value(); };
70 const std::optional<int> &pdDelta() const { return m_pdDelta; };
71 SegmentBase &pdDelta(const std::nullopt_t&) { m_pdDelta.reset(); return *this; };
72 SegmentBase &pdDelta(int val) { m_pdDelta = val; return *this; };
73
74 // @presentationTimeOffest
75 bool hasPresentationTimeOffest() const { return m_presentationTimeOffset.has_value(); };
76 const std::optional<unsigned long> &presentationTimeOffest() const { return m_presentationTimeOffset; };
77 SegmentBase &presentationTimeOffest(const std::nullopt_t&) { m_presentationTimeOffset.reset(); return *this; };
78 SegmentBase &presentationTimeOffest(unsigned long val) { m_presentationTimeOffset = val; return *this; };
79
80 // @presentationDuration
81 bool hasPresentationDuration() const { return m_presentationDuration.has_value(); };
82 const std::optional<unsigned long> &presentationDuration() const { return m_presentationDuration; };
83 SegmentBase &presentationDuration(const std::nullopt_t&) { m_presentationDuration.reset(); return *this; };
84 SegmentBase &presentationDuration(unsigned long val) { m_presentationDuration = val; return *this; };
85
86 // @timeShiftBufferDepth
87 bool hasTimeShiftBufferDepth() const { return m_timeShiftBufferDepth.has_value(); };
88 const std::optional<duration_type> &timeShiftBufferDepth() const { return m_timeShiftBufferDepth; };
89 SegmentBase &timeShiftBufferDepth(const std::nullopt_t&) { m_timeShiftBufferDepth.reset(); return *this; };
90 SegmentBase &timeShiftBufferDepth(const duration_type &val) { m_timeShiftBufferDepth = val; return *this; };
91 SegmentBase &timeShiftBufferDepth(duration_type &&val) { m_timeShiftBufferDepth = std::move(val); return *this; };
92
93 // @indexRange
94 bool hasIndexRange() const { return m_indexRange.has_value(); };
95 const std::optional<SingleRFC7233Range> &indexRange() const { return m_indexRange; };
96 SegmentBase &indexRange(const std::nullopt_t&) { m_indexRange.reset(); return *this; };
97 SegmentBase &indexRange(const SingleRFC7233Range &val) { m_indexRange = val; return *this; };
98 SegmentBase &indexRange(SingleRFC7233Range &&val) { m_indexRange = std::move(val); return *this; };
99
100 // @indexRangeExact
101 bool indexRangeExact() const { return m_indexRangeExact; };
102 SegmentBase &indexRangeExact(bool val) { m_indexRangeExact = val; return *this; };
103
104 // @pvailabilityTimeOffset
105 bool hasAvailabilityTimeOffset() const { return m_availabilityTimeOffset.has_value(); };
106 const std::optional<double> &availabilityTimeOffset() const { return m_availabilityTimeOffset; };
107 SegmentBase &availabilityTimeOffset(const std::nullopt_t&) { m_availabilityTimeOffset.reset(); return *this; };
108 SegmentBase &availabilityTimeOffset(double val) { m_availabilityTimeOffset = val; return *this; };
109
110 // @pvailabilityTimeComplete
111 bool availabilityTimeComplete() const { return m_availabilityTimeComplete; };
112 SegmentBase &availabilityTimeComplete(bool val) { m_availabilityTimeComplete = val; return *this; };
113
114 // Initialization child
115 bool hasInitialization() const { return m_initialization.has_value(); };
116 const std::optional<URL> &initialization() const { return m_initialization; };
117 SegmentBase &initialization(const std::nullopt_t&) { m_initialization.reset(); return *this; };
118 SegmentBase &initialization(const URL &val) { m_initialization = val; return *this; };
119 SegmentBase &initialization(URL &&val) { m_initialization = std::move(val); return *this; };
120
121 // RepresentationIndex child
122 bool hasRepresentationIndex() const { return m_representationIndex.has_value(); };
123 const std::optional<URL> &representationIndex() const { return m_representationIndex; };
124 SegmentBase &representationIndex(const std::nullopt_t&) { m_representationIndex.reset(); return *this; };
125 SegmentBase &representationIndex(const URL &val) { m_representationIndex = val; return *this; };
126 SegmentBase &representationIndex(URL &&val) { m_representationIndex = std::move(val); return *this; };
127
128 // FailoverContent child
129 bool hasFailoverContent() const { return m_failoverContent.has_value(); };
130 const std::optional<FailoverContent> &failoverContent() const { return m_failoverContent; };
131 SegmentBase &failoverContent(const std::nullopt_t&) { m_failoverContent.reset(); return *this; };
132 SegmentBase &failoverContent(const FailoverContent &val) { m_failoverContent = val; return *this; };
133 SegmentBase &failoverContent(FailoverContent &&val) { m_failoverContent = std::move(val); return *this; };
134
136protected:
137 friend class Period;
138 friend class Representation;
139 friend class AdaptationSet;
140 SegmentBase(xmlpp::Node&);
141 void setXMLElement(xmlpp::Element&) const;
143
144private:
145 // SegmentBase element from ISO 23009-1:2022 Clause 5.3.9.2.3
146 // Attributes
147 std::optional<unsigned int> m_timescale;
148 std::optional<int> m_eptDelta;
149 std::optional<int> m_pdDelta;
150 std::optional<unsigned long> m_presentationTimeOffset;
151 std::optional<unsigned long> m_presentationDuration;
152 std::optional<duration_type> m_timeShiftBufferDepth;
153 std::optional<SingleRFC7233Range> m_indexRange;
154 bool m_indexRangeExact;
155 std::optional<double> m_availabilityTimeOffset;
156 bool m_availabilityTimeComplete;
157 // Elements
158 std::optional<URL> m_initialization;
159 std::optional<URL> m_representationIndex;
160 std::optional<FailoverContent> m_failoverContent;
161};
162
164
165/* vim:ts=8:sts=4:sw=4:expandtab:
166 */
167#endif /*_BBC_PARSE_DASH_MPD_SEGMENT_BASE_HH_*/
AdaptationSet class.
Definition AdaptationSet.hh:60
Definition FailoverContent.hh:39
Definition Period.hh:53
Definition Representation.hh:55
Definition SegmentBase.hh:41
SegmentBase & availabilityTimeComplete(bool val)
Definition SegmentBase.hh:112
SegmentBase & initialization(const std::nullopt_t &)
Definition SegmentBase.hh:117
bool hasTimeShiftBufferDepth() const
Definition SegmentBase.hh:87
SegmentBase & representationIndex(const std::nullopt_t &)
Definition SegmentBase.hh:124
const std::optional< int > & eptDelta() const
Definition SegmentBase.hh:64
SegmentBase & timeShiftBufferDepth(const duration_type &val)
Definition SegmentBase.hh:90
SegmentBase & eptDelta(const std::nullopt_t &)
Definition SegmentBase.hh:65
SegmentBase & timescale(unsigned int val)
Definition SegmentBase.hh:60
SegmentBase & failoverContent(const std::nullopt_t &)
Definition SegmentBase.hh:131
bool indexRangeExact() const
Definition SegmentBase.hh:101
SegmentBase & presentationTimeOffest(unsigned long val)
Definition SegmentBase.hh:78
const std::optional< FailoverContent > & failoverContent() const
Definition SegmentBase.hh:130
SegmentBase(const SegmentBase &other)
const std::optional< duration_type > & timeShiftBufferDepth() const
Definition SegmentBase.hh:88
SegmentBase & pdDelta(const std::nullopt_t &)
Definition SegmentBase.hh:71
SegmentBase & representationIndex(URL &&val)
Definition SegmentBase.hh:126
SegmentBase & presentationDuration(unsigned long val)
Definition SegmentBase.hh:84
const std::optional< URL > & initialization() const
Definition SegmentBase.hh:116
virtual ~SegmentBase()
Definition SegmentBase.hh:49
SegmentBase & failoverContent(FailoverContent &&val)
Definition SegmentBase.hh:133
bool hasRepresentationIndex() const
Definition SegmentBase.hh:122
SegmentBase & availabilityTimeOffset(const std::nullopt_t &)
Definition SegmentBase.hh:107
SegmentBase & availabilityTimeOffset(double val)
Definition SegmentBase.hh:108
const std::optional< URL > & representationIndex() const
Definition SegmentBase.hh:123
SegmentBase & representationIndex(const URL &val)
Definition SegmentBase.hh:125
SegmentBase & indexRange(SingleRFC7233Range &&val)
Definition SegmentBase.hh:98
const std::optional< unsigned long > & presentationTimeOffest() const
Definition SegmentBase.hh:76
bool hasEptDelta() const
Definition SegmentBase.hh:63
bool hasInitialization() const
Definition SegmentBase.hh:115
bool hasFailoverContent() const
Definition SegmentBase.hh:129
const std::optional< int > & pdDelta() const
Definition SegmentBase.hh:70
bool hasTimescale() const
Definition SegmentBase.hh:57
SegmentBase & indexRange(const SingleRFC7233Range &val)
Definition SegmentBase.hh:97
SegmentBase & operator=(const SegmentBase &other)
bool hasAvailabilityTimeOffset() const
Definition SegmentBase.hh:105
SegmentBase & failoverContent(const FailoverContent &val)
Definition SegmentBase.hh:132
SegmentBase(SegmentBase &&other)
const std::optional< double > & availabilityTimeOffset() const
Definition SegmentBase.hh:106
bool hasPresentationTimeOffest() const
Definition SegmentBase.hh:75
bool hasPdDelta() const
Definition SegmentBase.hh:69
const std::optional< SingleRFC7233Range > & indexRange() const
Definition SegmentBase.hh:95
std::chrono::microseconds duration_type
Definition SegmentBase.hh:43
bool hasIndexRange() const
Definition SegmentBase.hh:94
SegmentBase & timescale(const std::nullopt_t &)
Definition SegmentBase.hh:59
SegmentBase & pdDelta(int val)
Definition SegmentBase.hh:72
bool operator==(const SegmentBase &other) const
SegmentBase & presentationTimeOffest(const std::nullopt_t &)
Definition SegmentBase.hh:77
bool availabilityTimeComplete() const
Definition SegmentBase.hh:111
SegmentBase & initialization(const URL &val)
Definition SegmentBase.hh:118
SegmentBase & operator=(SegmentBase &&other)
SegmentBase & indexRange(const std::nullopt_t &)
Definition SegmentBase.hh:96
SegmentBase & presentationDuration(const std::nullopt_t &)
Definition SegmentBase.hh:83
SegmentBase & eptDelta(int val)
Definition SegmentBase.hh:66
const std::optional< unsigned int > & timescale() const
Definition SegmentBase.hh:58
const std::optional< unsigned long > & presentationDuration() const
Definition SegmentBase.hh:82
SegmentBase & indexRangeExact(bool val)
Definition SegmentBase.hh:102
SegmentBase & initialization(URL &&val)
Definition SegmentBase.hh:119
SegmentBase & timeShiftBufferDepth(duration_type &&val)
Definition SegmentBase.hh:91
SegmentBase & timeShiftBufferDepth(const std::nullopt_t &)
Definition SegmentBase.hh:89
bool hasPresentationDuration() const
Definition SegmentBase.hh:81
Definition SingleRFC7233Range.hh:35
Definition URL.hh:37
#define LIBMPDPP_NAMESPACE_END
Definition macros.hh:54
#define LIBMPDPP_PUBLIC_API
Used to mark something as part of the public API.
Definition macros.hh:21
#define LIBMPDPP_NAMESPACE_BEGIN
Definition macros.hh:50