mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
e2bde38358
commit
2d4329767e
|
@ -26,6 +26,7 @@ Camera::Camera()
|
|||
: refcount(0)
|
||||
, workerThread(nullptr)
|
||||
, worker(nullptr)
|
||||
, needsInit(true)
|
||||
{
|
||||
worker = new CameraWorker(0);
|
||||
workerThread = new QThread();
|
||||
|
@ -34,17 +35,11 @@ Camera::Camera()
|
|||
|
||||
connect(workerThread, &QThread::started, worker, &CameraWorker::onStart);
|
||||
connect(workerThread, &QThread::finished, worker, &CameraWorker::deleteLater);
|
||||
connect(worker, &CameraWorker::started, this, &Camera::onWorkerStarted);
|
||||
connect(worker, &CameraWorker::newFrameAvailable, this, &Camera::onNewFrameAvailable);
|
||||
connect(worker, &CameraWorker::resProbingFinished, this, &Camera::onResProbingFinished);
|
||||
workerThread->start();
|
||||
}
|
||||
|
||||
void Camera::onWorkerStarted()
|
||||
{
|
||||
worker->probeResolutions();
|
||||
}
|
||||
|
||||
Camera::~Camera()
|
||||
{
|
||||
workerThread->exit();
|
||||
|
@ -53,6 +48,12 @@ Camera::~Camera()
|
|||
|
||||
void Camera::subscribe()
|
||||
{
|
||||
if (needsInit)
|
||||
{
|
||||
worker->probeResolutions();
|
||||
needsInit = false;
|
||||
}
|
||||
|
||||
if (refcount <= 0)
|
||||
worker->resume();
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ private:
|
|||
QList<QSize> resolutions;
|
||||
|
||||
static Camera* instance;
|
||||
bool needsInit;
|
||||
|
||||
private slots:
|
||||
void onWorkerStarted();
|
||||
void onNewFrameAvailable(const VideoFrame frame);
|
||||
void onResProbingFinished(QList<QSize> res);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user