20 QString durationStr =
"P%1%2";
24 dayStr = QString(
"D%1").arg((msec % 24h).count());
28 return durationStr.arg(dayStr, timeStr);
33 QString timeStr = time.toString(
"HH:mm:ss");
39 QTime time = QTime::fromMSecsSinceStartOfDay(msec.count());
40 return time.toString(
"HH:mm:ss");
45 QString dateTimeStr = dateTime.toString(
Qt::ISODate);
60 switch (date.dayOfWeek())
91 QTime time = QTime::fromMSecsSinceStartOfDay(msec.count());
92 return time.toString(
"H:mm:ss.zzz");
101 const double ,
const QString &container,
102 const QString &vidCodec,
const QString &audioCodec)
104 QString sProfileName;
105 bool isHD = (resolution.height() >= 720) || (resolution.width() > 720);
112 bool isNorthAmerica = (sCountryCode ==
"us" || sCountryCode ==
"ca" ||
113 sCountryCode ==
"mx");
115 if (container ==
"MPEG2-PS")
117 if (isHD && audioCodec ==
"DTS")
119 sProfileName =
"MPEG_PS_HD_DTS";
125 else if (audioCodec ==
"DTS")
127 sProfileName =
"MPEG_PS_SD_DTS";
132 sProfileName =
"MPEG_PS_NTSC";
134 sProfileName =
"MPEG_PS_PAL";
137 else if (container ==
"MPEG2-TS")
141 if (vidCodec ==
"H264")
142 sProfileName =
"AVC_TS_NA_ISO";
144 sProfileName =
"MPEG_TS_HD_NA_ISO";
146 sProfileName =
"MPEG_TS_SD_NA_ISO";
150 if (vidCodec ==
"H264" || isHD)
151 sProfileName =
"AVC_TS_EU_ISO";
153 sProfileName =
"MPEG_TS_SD_EU_ISO";
156 else if (mimeType ==
"video/x-matroska" || container ==
"MATROSKA")
162 if (vidCodec ==
"H264")
167 if (audioCodec ==
"AAC")
169 sProfileName =
"AVC_MKV_HP_HD_AAC_MULT5";
171 else if (audioCodec ==
"AC3")
173 sProfileName =
"AVC_MKV_HP_HD_AC3";
175 else if (audioCodec ==
"E-AC3")
177 sProfileName =
"AVC_MKV_HP_HD_EAC3";
179 else if (audioCodec ==
"MP3")
181 sProfileName =
"AVC_MKV_HP_HD_MPEG1_L3";
183 else if (audioCodec ==
"DTS")
185 sProfileName =
"AVC_MKV_HP_HD_DTS";
187 else if (audioCodec ==
"MLP")
189 sProfileName =
"AVC_MKV_HP_HD_MLP";
193 else if (mimeType ==
"audio/mpeg")
195 sProfileName =
"MP3X";
197 else if (mimeType ==
"audio/x-ms-wma")
199 sProfileName =
"WMAFULL";
201 else if (mimeType ==
"audio/vnd.dolby.dd-raw")
203 sProfileName =
"AC3";
205 else if (mimeType ==
"audio/mp4")
207 sProfileName =
"AAC_ISO_320";
209 else if (mimeType ==
"image/jpeg")
211 if (resolution.width() <= 160 && resolution.height() <= 160)
212 sProfileName =
"JPEG_TN";
213 else if (resolution.width() <= 640 && resolution.height() <= 480)
214 sProfileName =
"JPEG_SM";
215 else if (resolution.width() <= 1024 && resolution.height() <= 768)
216 sProfileName =
"JPEG_MED";
217 else if (resolution.width() <= 4096 && resolution.height() <= 4096)
218 sProfileName =
"JPEG_LRG";
220 else if (mimeType ==
"image/png")
222 if (resolution.width() <= 160 && resolution.height() <= 160)
223 sProfileName =
"PNG_TN";
224 else if (resolution.width() <= 4096 && resolution.height() <= 4096)
225 sProfileName =
"PNG_LRG";
227 else if (mimeType ==
"image/gif")
229 if (resolution.width() <= 1600 && resolution.height() <= 1200)
230 sProfileName =
"GIF_LRG";
241 const QString &mimeType,
const QSize resolution,
242 double videoFrameRate,
const QString &container,
243 const QString &videoCodec,
const QString &audioCodec,
247 QStringList sAdditionalInfoList;
255 QString sProfileName =
DLNAProfileName(mimeType, resolution, videoFrameRate,
256 container, videoCodec, audioCodec);
257 if (!sProfileName.isEmpty())
258 sAdditionalInfoList << QString(
"DLNA.ORG_PN=%1").arg(sProfileName);
280 if (mimeType.startsWith(
"audio") || mimeType.startsWith(
"video"))
297 QString sAdditionalInfo =
"*";
310 if (!sAdditionalInfoList.isEmpty() &&
311 sAdditionalInfoList.first().startsWith(
"DLNA.ORG_PN"))
312 sAdditionalInfo = sAdditionalInfoList.join(
";");
314 return sAdditionalInfo;
320 const QString &mimeType,
const QSize resolution,
321 double videoFrameRate,
const QString &container,
322 const QString &videoCodec,
const QString &audioCodec,
325 QStringList protocolInfoFields;
332 protocolInfoFields <<
"http-get";
334 protocolInfoFields <<
"rtsp-rtp-udp";
341 protocolInfoFields <<
"*";
346 protocolInfoFields << mimeType;
352 videoFrameRate, container,
353 videoCodec, audioCodec,
356 if (protocolInfoFields.size() != 4)
357 LOG(VB_GENERAL, LOG_CRIT,
"DLNA::ProtocolInfoString() : Invalid number of fields in string");
359 QString str = protocolInfoFields.join(
":");
361 if (str.length() > 256)
363 LOG(VB_GENERAL, LOG_WARNING,
"DLNA::ProtocolInfoString() : ProtocolInfo string exceeds "
364 "256 byte limit for compatibility with older UPnP devices. "
365 "Consider omitting optional DLNA information such as ci-param");
381 LOG(VB_GENERAL, LOG_ERR,
"Programmer Error: 'Streaming' and 'Interactive' mode flags are mutally exclusive");
389 return QString(
"DLNA.ORG_FLAGS=%1")
390 .arg(flags,8,10,QChar(
'0')) +
"000000000000000000000000";
395 QString str =
"DLNA.ORG_OP=%1%2";
415 QString str =
"DLNA.ORG_CI=%1";
417 return str.arg(wasConverted ?
"1" :
"0");
MythLocale * GetLocale(void) const
QString GetCountryCode() const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Helpers for building DLNA flag, strings and profiles.
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.
Helpers for formatting dates and times to UPnP, DLNA and Dublin Core specifications.
QString resDurationFormat(std::chrono::milliseconds msec)
res@duration Format B.2.1.4 res@duration - UPnP ContentDirectory Service 2008, 2013
QString NamedDayFormat(const QDateTime &dateTime)
Named-Day Format.
QString TimeFormat(const QTime time)
Time Format.
QString DurationFormat(std::chrono::milliseconds msec)
Duration Format.
QString DateTimeFormat(const QDateTime &dateTime)
Date-Time Format.