6 #include "libmythbase/mythversion.h"
9 #define LOC QString("HTTPTSSH[%1](%2): ").arg(m_inputId).arg(m_device)
26 QMap<QString,HTTPTSStreamHandler*>::iterator it =
s_httphandlers.find(devkey);
35 LOG(VB_RECORD, LOG_INFO,
36 QString(
"HTTPTSSH[%1]: Creating new stream handler %2 for %3")
37 .arg(QString::number(inputid), devkey, tuning.
GetDeviceName()));
43 LOG(VB_RECORD, LOG_INFO,
44 QString(
"HTTPTSSH[%1]: Using existing stream handler %2 for %3")
45 .arg(QString::number(inputid), devkey, tuning.
GetDeviceName()) +
46 QString(
" (%1 in use)").arg(rcount));
62 LOG(VB_RECORD, LOG_INFO, QString(
"HTTPTSSH[%1]: Return(%2) has %3 handlers")
63 .arg(inputid).arg(devname).arg(*rit));
72 QMap<QString,HTTPTSStreamHandler*>::iterator it =
s_httphandlers.find(devname);
75 LOG(VB_RECORD, LOG_INFO, QString(
"HTTPTSSH[%1]: Closing handler for %2")
76 .arg(inputid).arg(devname));
83 LOG(VB_GENERAL, LOG_ERR,
84 QString(
"HTTPTSSH[%1] Error: Couldn't find handler for %2")
85 .arg(inputid).arg(devname));
96 LOG(VB_GENERAL, LOG_INFO,
LOC +
"ctor");
101 LOG(VB_GENERAL, LOG_INFO,
LOC +
"dtor");
108 std::chrono::milliseconds open_sleep = 250ms;
109 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- begin");
117 LOG(VB_RECORD, LOG_INFO,
LOC +
"DownloadStream failed to receive bytes from " +
m_tuning.
GetURL(0).toString());
118 std::this_thread::sleep_for(open_sleep);
119 if (open_sleep < 10s)
129 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- done");
134 #define LOC QString("HTTPReader(%1): ").arg(m_url)
138 m_url = url.toString();
140 LOG(VB_RECORD, LOG_INFO,
LOC +
"DownloadStream -- begin");
142 QMutexLocker lock(&
m_lock);
143 QEventLoop event_loop;
151 QNetworkRequest m_req = QNetworkRequest(url);
152 m_req.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
153 QNetworkRequest::NoLessSafeRedirectPolicy);
154 m_req.setHeader(QNetworkRequest::UserAgentHeader,
155 QString(
"MythTV/%1 %2/%3")
156 .arg(MYTH_VERSION_MAJMIN,
157 QSysInfo::productType(),
158 QSysInfo::productVersion()));
180 if (
m_reply->error() != QNetworkReply::NoError)
182 LOG(VB_RECORD, LOG_ERR,
LOC +
"DownloadStream exited with error " +
183 QString(
"%1 '%2'").arg(
m_reply->error()).arg(
m_reply->errorString()));
194 LOG(VB_RECORD, LOG_INFO,
LOC +
"DownloadStream -- end");
215 m_size += (bytesRead > 0 ? bytesRead : 0);
216 LOG(VB_RECORD, LOG_DEBUG,
LOC + QString(
"ReadBytes: %1 bytes received").arg(bytesRead));
234 LOG(VB_RECORD, LOG_DEBUG,
LOC + QString(
"WriteBytes: %1/%2 bytes remain").arg(remainder).arg(
m_size));
246 LOG(VB_RECORD, LOG_INFO,
LOC +
"Cancel: Aborting stream download");