MythTV master
upnphelpers.h
Go to the documentation of this file.
1#ifndef UPNP_HELPERS_H
2#define UPNP_HELPERS_H
3
4#include <QString>
5#include <QDateTime>
6#include <QDate>
7#include <QTime>
8#include <QSize>
9
10#include <chrono>
11#include <cstdint>
12
13#include "libmythbase/compat.h"
14
15#include "upnpexp.h"
16
17using namespace std::chrono_literals;
18
19// NOTE These are for formatting to the UPnP related specs or extracting data
20// from UPnP formatted strings ONLY.
21//
22// * Do NOT clutter it up with stuff which is unrelated to those tasks.
23//
24// * If adding or editing please cite the reference to the corresponding
25// part of the specification or RFC alongside the changes and in any
26// commit message.
27//
28// * Any changes which fail to cite the specs may be reverted.
29
44namespace UPnPDateTime
45{
46 //-----------------------------------------------------------------------
47 // UPnP ContentDirectory Service 2008, 2013
48 //-----------------------------------------------------------------------
49
50 //-----------------------------------------------------------------------
51 // Appendix B. AV Working Committee Properties
52 // B.2 Resource Encoding Characteristics Properties
53 //-----------------------------------------------------------------------
54
59 UPNP_PUBLIC QString resDurationFormat(std::chrono::milliseconds msec);
60
61 //-----------------------------------------------------------------------
62 // Appendix D. EBNF Syntax Definitions
63 // D.1 Date&Time Syntax
64 //-----------------------------------------------------------------------
65
72 UPNP_PUBLIC QString DurationFormat(std::chrono::milliseconds msec);
73
80 UPNP_PUBLIC QString TimeFormat(QTime time);
81
88 UPNP_PUBLIC QString TimeFormat(std::chrono::milliseconds msec);
89
96 UPNP_PUBLIC QString DateTimeFormat(const QDateTime &dateTime);
97
104 UPNP_PUBLIC QString NamedDayFormat(const QDateTime &dateTime);
105
112 UPNP_PUBLIC QString NamedDayFormat(QDate date);
113};
114
130{
131 enum TransferProtocol : std::uint8_t
132 {
134 kRTP
135 };
136}
137
152namespace DLNA
153{
162 UPNP_PUBLIC QString DLNAProfileName( const QString &mimeType,
163 QSize resolution = QSize(),
164 double videoFrameRate = 0.0,
165 const QString &container = "",
166 const QString &vidCodec = "",
167 const QString &audioCodec = "");
168
169
182 const QString &mimeType,
183 QSize resolution,
184 double videoFrameRate,
185 const QString &container,
186 const QString &vidCodec,
187 const QString &audioCodec,
188 bool isTranscoded);
189
202 const QString &mimeType,
203 QSize resolution = QSize(),
204 double videoFrameRate = 0.0,
205 const QString &container = "",
206 const QString &vidCodec = "",
207 const QString &audioCodec = "",
208 bool isTranscoded = false);
209
225 {
226 // NAME BIT BIT # REFERENCE
227
228 // Sender Pacing (server controls the playback speed)
229 //
230 // Not currently applicable to MythTV. We don't control the rate of data
231 // to the client.
232 ksp_flag = 0x80000000, // #31 : 7.4.1.3.28 MM sp-flag (sender paced flag)
233
234 // Limited Operations Model
235 //
236 // NOTE The following are for use under the Limited Operations Model ONLY
237 // where the server only supports seeking within limited ranges
238 //
239 // They don't apply to MythTV which supports the Full Operations Model
240 klop_npt = 0x40000000, // #30 : 7.4.1.3.29 MM lop-npt (limited operations flags)
241 klop_bytes = 0x20000000, // #29 : 7.4.1.3.29 MM lop-bytes (limited operations flags)
242
243 // DLNA Play Container support
244 kplaycontainer_param = 0x10000000, // #28 : 7.4.1.3.32 MM playcontainer-param (DLNA PlayContainer flag)
245
246 // In-progress recording or sliding window (circular buffer)
247 ks0_increasing = 0x8000000, // #27 : 7.4.1.3.33 MM s0-increasing (UCDAM s0 increasing flag)
248 ksn_increasing = 0x4000000, // #26 : 7.4.1.3.34 MM sn-increasing (UCDAM sn increasing flag)
249
250 // RTP Only
251 krtsp_pause = 0x2000000, // #25 : (Pause media operation support for RTP Serving Endpoints)
252
253 // Transfer Modes
254 ktm_s = 0x1000000, // #24 : 7.4.1.3.35 MM tm-s (Streaming Mode Transfer flag)
255 ktm_i = 0x800000, // #23 : 7.4.1.3.36 MM tm-i (Interactive Mode Transfer flag)
256 ktm_b = 0x400000, // #22 : 7.4.1.3.37 MM tm-b (Background Mode Transfer flag)
257
258 // TCP Flow & Keep-Alive support
259 khttp_stalling = 0x200000, // #21 : 7.4.1.3.38 MM http-stalling (HTTP Connection Stalling flag)
260
261 // DLNA 1.5+ Support - Should always be enabled
262 kv1_5_flag = 0x100000, // #20 : 7.4.1.3.25 MM dlna-v1.5-flag (DLNAv1.5 version flag)
263
264 //
265 // Bits 19-18 are currently unused but reserved
266 //
267
268 // Link Protection related. DRM basically, not relevant to MythTV
269 kLP_flag = 0x10000, // #16 : 7.5.3.5 in IEC 62481-3:2013 (Link Protection flag)
270 kcleartextbyteseek_full = 0x8000, // #15 : 7.5.3.6 (GUN TLQ89) in IEC 62481-3:2013 (Byte based full seek data availability with the Cleartext Byte Seek Request Header)
271 klop_cleartextbytes = 0x4000, // #14 : 7.4.1.3.29 MM lop-cleartextbytes (limited operations flags)
272
273 //
274 // Bits 13-1 are currently unused but reserved
275 //
276 };
277
286 UPNP_PUBLIC QString FlagsString(uint32_t flags);
287
302
315 UPNP_PUBLIC QString ConversionIndicatorString(bool wasConverted);
316};
317
318#endif // UPNP_HELPERS_H
Helpers for building DLNA flag, strings and profiles.
Definition: upnphelpers.cpp:98
QString ProtocolInfoString(UPNPProtocol::TransferProtocol protocol, const QString &mimeType, const QSize resolution, double videoFrameRate, const QString &container, const QString &videoCodec, const QString &audioCodec, bool isTranscoded)
Create a properly formatted string for the 4th field of res@protocolInfo.
QString OpParamString(UPNPProtocol::TransferProtocol protocol)
Create a properly formatted Operations Parameter (op-param) string for the given transport protocol b...
QString DLNAProfileName(const QString &mimeType, const QSize resolution, const double, const QString &container, const QString &vidCodec, const QString &audioCodec)
Try to determine a valid DLNA profile name for the file based on the supplied metadata.
QString FlagsString(uint32_t flags)
Convert an integer composed of DNLA_Flags to a properly formatted string for use in XML.
QString DLNAFourthField(UPNPProtocol::TransferProtocol protocol, const QString &mimeType, const QSize resolution, double videoFrameRate, const QString &container, const QString &videoCodec, const QString &audioCodec, bool isTranscoded)
Create a properly formatted string for the 4th field of res@protocolInfo.
QString ConversionIndicatorString(bool wasConverted)
Create a properly formatted Conversion Indicator (ci-param) String.
DLNA_Flags
DLNA FLAGS.
Definition: upnphelpers.h:225
@ klop_bytes
Definition: upnphelpers.h:241
@ ktm_i
Definition: upnphelpers.h:255
@ khttp_stalling
Definition: upnphelpers.h:259
@ kv1_5_flag
Definition: upnphelpers.h:262
@ kplaycontainer_param
Definition: upnphelpers.h:244
@ kcleartextbyteseek_full
Definition: upnphelpers.h:270
@ krtsp_pause
Definition: upnphelpers.h:251
@ ks0_increasing
Definition: upnphelpers.h:247
@ kLP_flag
Definition: upnphelpers.h:269
@ ksn_increasing
Definition: upnphelpers.h:248
@ ksp_flag
Definition: upnphelpers.h:232
@ klop_cleartextbytes
Definition: upnphelpers.h:271
@ ktm_b
Definition: upnphelpers.h:256
@ ktm_s
Definition: upnphelpers.h:254
@ klop_npt
Definition: upnphelpers.h:240
Helpers for UPnP Protocol 'stuff'.
Definition: upnphelpers.h:130
Helpers for formatting dates and times to UPnP, DLNA and Dublin Core specifications.
Definition: upnphelpers.cpp:8
QString resDurationFormat(std::chrono::milliseconds msec)
res@duration Format B.2.1.4 res@duration - UPnP ContentDirectory Service 2008, 2013
Definition: upnphelpers.cpp:81
QString NamedDayFormat(const QDateTime &dateTime)
Named-Day Format.
Definition: upnphelpers.cpp:49
QString TimeFormat(const QTime time)
Time Format.
Definition: upnphelpers.cpp:31
QString DurationFormat(std::chrono::milliseconds msec)
Duration Format.
Definition: upnphelpers.cpp:10
QString DateTimeFormat(const QDateTime &dateTime)
Date-Time Format.
Definition: upnphelpers.cpp:43
#define UPNP_PUBLIC
Definition: upnpexp.h:9