void RtspStreamThread::start(const QUrl &url) { QMutexLocker locker(&m_workerMutex); qDebug() << Q_FUNC_INFO << LoggableUrl(url); if (!m_worker) { Q_ASSERT(!m_thread); m_thread = new QThread(); RtspStreamWorker *worker = new RtspStreamWorker(m_frameQueue); m_worker = worker; worker->moveToThread(m_thread.data()); m_worker.data()->setUrl(url); connect(m_thread.data(), SIGNAL(started()), m_worker.data(), SLOT(run())); connect(m_thread.data(), SIGNAL(finished()), m_thread.data(), SLOT(deleteLater())); connect(m_worker.data(), SIGNAL(fatalError(QString)), this, SIGNAL(fatalError(QString))); connect(m_worker.data(), SIGNAL(destroyed()), this, SLOT(clearWorker()), Qt::DirectConnection); connect(m_worker.data(), SIGNAL(destroyed()), m_thread.data(), SLOT(quit())); connect(m_worker.data(), SIGNAL(audioFormat(enum AVSampleFormat, int, int)), this, SIGNAL(audioFormat(enum AVSampleFormat,int,int)), Qt::DirectConnection); connect(m_worker.data(), SIGNAL(audioSamplesAvailable(void *, int, int)), this, SIGNAL(audioSamplesAvailable(void*,int,int)), Qt::DirectConnection); connect(m_worker.data(), SIGNAL(bytesDownloaded(uint)), bcApp->globalRate, SLOT(addSampleValue(uint))); m_thread.data()->start(); }
void LiveStreamThread::start(const QUrl &url) { QMutexLocker locker(&m_workerMutex); qDebug() << Q_FUNC_INFO << LoggableUrl(url); if (!m_worker) { Q_ASSERT(!m_thread); m_thread = new QThread(); LiveStreamWorker *worker = new LiveStreamWorker(); worker->moveToThread(m_thread.data()); m_worker = worker; m_worker.data()->setUrl(url); connect(m_thread.data(), SIGNAL(started()), m_worker.data(), SLOT(run())); connect(m_thread.data(), SIGNAL(finished()), this, SLOT(threadFinished())); connect(m_worker.data(), SIGNAL(fatalError(QString)), this, SIGNAL(fatalError(QString))); m_thread.data()->start(); } else m_worker.data()->metaObject()->invokeMethod(m_worker.data(), "run"); m_isRunning = true; }
void LiveStream::fatalError(const QString &message) { qDebug() << "Fatal error:" << LoggableUrl(url()) << message; m_errorMessage = message; setState(Error); /* stateTimer will handle reconnection */ }