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