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