libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
BaseURL.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_BASE_URL_HH_
2#define _BBC_PARSE_DASH_MPD_BASE_URL_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: BaseURL 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#include <string>
16
17#include "macros.hh"
18#include "URI.hh"
19
22// Forward declarations for types only used by pointer or reference
23namespace xmlpp {
24 class Element;
25 class Node;
26}
29
31
32class MPD;
33class Period;
34class Representation;
35class AdaptationSet;
36
44public:
45 using duration_type = std::chrono::microseconds;
46
52
60 BaseURL(const std::string &url);
61 BaseURL(std::string &&url);
63
70 BaseURL(const BaseURL &other);
71
78 BaseURL(BaseURL &&other);
79
82 virtual ~BaseURL() {};
83
92 BaseURL &operator=(const BaseURL &other);
95
101 bool operator==(const BaseURL &other) const;
102
108 const URI &url() const { return static_cast<const URI&>(*this); };
109 URI &url() { return static_cast<URI&>(*this); };
111
118 BaseURL &url(const URI &_url) { URI::operator=(_url); return *this; };
119 BaseURL &url(URI &&_url) { URI::operator=(std::move(_url)); return *this; };
121
132 BaseURL resolveURL(const std::list<BaseURL> &base_urls) const;
133
134 // @serviceLocation
135
140 bool hasServiceLocation() const { return m_serviceLocation.has_value(); };
141
146 const std::optional<std::string> &serviceLocation() const { return m_serviceLocation; };
147
152 BaseURL &serviceLocation(const std::nullopt_t&) { m_serviceLocation.reset(); return *this; };
153
160 BaseURL &serviceLocation(const std::string &val) { m_serviceLocation = val; return *this; };
161 BaseURL &serviceLocation(std::string &&val) { m_serviceLocation = std::move(val); return *this; };
163
164 // @byteRange
165
170 bool hasByteRange() const { return m_byteRange.has_value(); };
171
176 const std::optional<std::string> &byteRange() const { return m_byteRange; };
177
182 BaseURL &byteRange(const std::nullopt_t&) { m_byteRange.reset(); return *this; };
183
190 BaseURL &byteRange(const std::string &val) { m_byteRange = val; return *this; };
191 BaseURL &byteRange(std::string &&val) { m_byteRange = std::move(val); return *this; };
193
194 // @pvailabilityTimeOffset
195
200 bool hasAvailabilityTimeOffset() const { return m_availabilityTimeOffset.has_value(); };
201
206 const std::optional<double> &availabilityTimeOffset() const { return m_availabilityTimeOffset; };
207
212 BaseURL &availabilityTimeOffset(const std::nullopt_t&) { m_availabilityTimeOffset.reset(); return *this; };
213
219 BaseURL &availabilityTimeOffset(double val) { m_availabilityTimeOffset = val; return *this; };
220
221 // @pvailabilityTimeComplete
222
227 bool hasAvailabilityTimeComplete() const { return m_availabilityTimeComplete.has_value(); };
228
233 const std::optional<bool> &availabilityTimeComplete() const { return m_availabilityTimeComplete; };
234
239 BaseURL &availabilityTimeComplete(const std::nullopt_t&) { m_availabilityTimeComplete.reset(); return *this; };
240
246 BaseURL &availabilityTimeComplete(bool val) { m_availabilityTimeComplete = val; return *this; };
247
248 // @timeShiftBufferDepth
249
254 bool hasTimeShiftBufferDepth() const { return m_timeShiftBufferDepth.has_value(); };
255
260 const std::optional<duration_type> &timeShiftBufferDepth() const { return m_timeShiftBufferDepth; };
261
266 BaseURL &timeShiftBufferDepth(const std::nullopt_t&) { m_timeShiftBufferDepth.reset(); return *this; };
267
274 BaseURL &timeShiftBufferDepth(const duration_type &val) { m_timeShiftBufferDepth = val; return *this; };
275 BaseURL &timeShiftBufferDepth(duration_type &&val) { m_timeShiftBufferDepth = std::move(val); return *this; };
277
278 // @rangeAccess
279
284 bool rangeAccess() const { return m_rangeAccess; };
285
294 BaseURL &rangeAccess(bool val) { m_rangeAccess = val; return *this; };
295
297protected:
298 friend class MPD;
299 friend class Period;
300 friend class Representation;
301 friend class AdaptationSet;
302
309 BaseURL(xmlpp::Node &node);
310
317 void setXMLElement(xmlpp::Element &elem) const;
319
320private:
321 // BaseURL attributes ISO 23009-1:2022 Clause 5.6.3
322 std::optional<std::string> m_serviceLocation;
323 std::optional<std::string> m_byteRange;
324 std::optional<double> m_availabilityTimeOffset;
325 std::optional<bool> m_availabilityTimeComplete;
326 std::optional<duration_type> m_timeShiftBufferDepth;
327 bool m_rangeAccess;
328};
329
331
332/* vim:ts=8:sts=4:sw=4:expandtab:
333 */
334#endif /*_BBC_PARSE_DASH_MPD_BASE_URL_HH_*/
AdaptationSet class.
Definition AdaptationSet.hh:60
Definition BaseURL.hh:43
BaseURL & url(const URI &_url)
Definition BaseURL.hh:118
BaseURL & availabilityTimeOffset(double val)
Definition BaseURL.hh:219
BaseURL & rangeAccess(bool val)
Definition BaseURL.hh:294
BaseURL & operator=(const BaseURL &other)
BaseURL(const std::string &url)
BaseURL & timeShiftBufferDepth(duration_type &&val)
Definition BaseURL.hh:275
const URI & url() const
Definition BaseURL.hh:108
BaseURL & serviceLocation(std::string &&val)
Definition BaseURL.hh:161
BaseURL & availabilityTimeOffset(const std::nullopt_t &)
Definition BaseURL.hh:212
bool hasAvailabilityTimeOffset() const
Definition BaseURL.hh:200
BaseURL & serviceLocation(const std::string &val)
Definition BaseURL.hh:160
BaseURL(BaseURL &&other)
BaseURL & timeShiftBufferDepth(const duration_type &val)
Definition BaseURL.hh:274
virtual ~BaseURL()
Definition BaseURL.hh:82
BaseURL resolveURL(const std::list< BaseURL > &base_urls) const
const std::optional< double > & availabilityTimeOffset() const
Definition BaseURL.hh:206
BaseURL & byteRange(const std::string &val)
Definition BaseURL.hh:190
BaseURL & timeShiftBufferDepth(const std::nullopt_t &)
Definition BaseURL.hh:266
BaseURL & byteRange(const std::nullopt_t &)
Definition BaseURL.hh:182
BaseURL & availabilityTimeComplete(const std::nullopt_t &)
Definition BaseURL.hh:239
bool hasByteRange() const
Definition BaseURL.hh:170
bool hasAvailabilityTimeComplete() const
Definition BaseURL.hh:227
BaseURL & operator=(BaseURL &&other)
const std::optional< std::string > & byteRange() const
Definition BaseURL.hh:176
BaseURL & serviceLocation(const std::nullopt_t &)
Definition BaseURL.hh:152
const std::optional< duration_type > & timeShiftBufferDepth() const
Definition BaseURL.hh:260
BaseURL(std::string &&url)
const std::optional< std::string > & serviceLocation() const
Definition BaseURL.hh:146
BaseURL & availabilityTimeComplete(bool val)
Definition BaseURL.hh:246
BaseURL & byteRange(std::string &&val)
Definition BaseURL.hh:191
const std::optional< bool > & availabilityTimeComplete() const
Definition BaseURL.hh:233
bool operator==(const BaseURL &other) const
std::chrono::microseconds duration_type
The type used to represent durations in this class.
Definition BaseURL.hh:45
BaseURL & url(URI &&_url)
Definition BaseURL.hh:119
bool rangeAccess() const
Definition BaseURL.hh:284
URI & url()
Definition BaseURL.hh:109
BaseURL(const BaseURL &other)
bool hasTimeShiftBufferDepth() const
Definition BaseURL.hh:254
bool hasServiceLocation() const
Definition BaseURL.hh:140
Definition MPD.hh:49
Definition Period.hh:53
Definition Representation.hh:55
URI()
Definition URI.hh:42
URI & operator=(const URI &other)
Definition URI.hh:51
#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