libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
FrameRate.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_FRAME_RATE_HH_
2#define _BBC_PARSE_DASH_MPD_FRAME_RATE_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: FrameRate class
5 *****************************************************************************
6 * Copyright: (C) 2025 British Broadcasting Corporation
7 * Author(s): Dev Audsin <dev.audsin@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 <string>
14
15#include "macros.hh"
16
19// Forward declarations for types only used by pointer or reference
20namespace xmlpp {
21 class Element;
22 class Node;
23}
26
28
39public:
40 using size_type = size_t;
41
47 : m_numerator(0)
48 , m_denominator(1)
49 {};
50
59 FrameRate(const std::string &frame_rate_str);
60
69 : m_numerator(numerator)
70 , m_denominator(denominator)
71 {};
72
79 FrameRate(const FrameRate &other)
80 : m_numerator(other.m_numerator)
81 , m_denominator(other.m_denominator)
82 {};
83
91 : m_numerator(other.m_numerator)
92 , m_denominator(other.m_denominator)
93 {};
94
97 virtual ~FrameRate() {};
98
107 m_numerator = other.m_numerator;
108 m_denominator = other.m_denominator;
109 return *this;
110 };
111
120 m_numerator = other.m_numerator;
121 m_denominator = other.m_denominator;
122 return *this;
123 };
124
132 bool operator==(const FrameRate &other) const {
133 return m_numerator == other.m_numerator && m_denominator == other.m_denominator;
134 };
135
143 bool operator!=(const FrameRate &other) const { return !(*this == other); };
144
151 operator std::string() const;
152
157 size_type numerator() const { return m_numerator; }
158
164 FrameRate &numerator(size_type num) { m_numerator = num; return *this; }
165
170 size_type denominator() const { return m_denominator; }
171
177 FrameRate &denominator(size_type den) { m_denominator = den; return *this; }
178
180protected:
181 friend class AdaptationSet;
182 // Construct from an XML node; extracts the text content and converts.
183 FrameRate(xmlpp::Node &node);
184
185 // Sets the XML element’s text to the string representation of this frame rate.
186 void setXMLElement(xmlpp::Element &elem) const;
188
189private:
190 // Converts a frame rate string into numeric components.
191 // Throws ParseError if the string is empty or doesn’t follow the pattern.
192 void convertString(const std::string &frame_rate_str);
193
194 size_type m_numerator;
195 size_type m_denominator;
196};
197
198
200
201/* vim:ts=8:sts=4:sw=4:expandtab:
202 */
203#endif /*_BBC_PARSE_DASH_MPD_FRAME_RATE_HH_*/
AdaptationSet class.
Definition AdaptationSet.hh:60
Definition FrameRate.hh:38
FrameRate(const FrameRate &other)
Definition FrameRate.hh:79
FrameRate()
Definition FrameRate.hh:46
bool operator==(const FrameRate &other) const
Definition FrameRate.hh:132
FrameRate & operator=(const FrameRate &other)
Definition FrameRate.hh:106
size_type denominator() const
Definition FrameRate.hh:170
FrameRate(const std::string &frame_rate_str)
FrameRate(FrameRate &&other)
Definition FrameRate.hh:90
FrameRate & denominator(size_type den)
Definition FrameRate.hh:177
virtual ~FrameRate()
Definition FrameRate.hh:97
FrameRate(size_type numerator, size_type denominator=1)
Definition FrameRate.hh:68
bool operator!=(const FrameRate &other) const
Definition FrameRate.hh:143
size_type numerator() const
Definition FrameRate.hh:157
FrameRate & operator=(FrameRate &&other)
Definition FrameRate.hh:119
FrameRate & numerator(size_type num)
Definition FrameRate.hh:164
size_t size_type
Type used to hold numerators and denominators.
Definition FrameRate.hh:40
#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