mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
d720cca969
commit
d86912eacd
@ -103,6 +103,7 @@ CameraSource::CameraSource()
|
|||||||
, _isNone{true}
|
, _isNone{true}
|
||||||
, subscriptions{0}
|
, subscriptions{0}
|
||||||
{
|
{
|
||||||
|
qRegisterMetaType<VideoMode>("VideoMode");
|
||||||
deviceThread->setObjectName("Device thread");
|
deviceThread->setObjectName("Device thread");
|
||||||
deviceThread->start();
|
deviceThread->start();
|
||||||
moveToThread(deviceThread);
|
moveToThread(deviceThread);
|
||||||
@ -155,6 +156,12 @@ void CameraSource::setupDefault()
|
|||||||
*/
|
*/
|
||||||
void CameraSource::setupDevice(const QString& DeviceName, const VideoMode& Mode)
|
void CameraSource::setupDevice(const QString& DeviceName, const VideoMode& Mode)
|
||||||
{
|
{
|
||||||
|
if (QThread::currentThread() != deviceThread) {
|
||||||
|
QMetaObject::invokeMethod(this, "setupDevice", Q_ARG(const QString&, DeviceName),
|
||||||
|
Q_ARG(const VideoMode&, Mode));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QWriteLocker locker{&deviceMutex};
|
QWriteLocker locker{&deviceMutex};
|
||||||
|
|
||||||
if (DeviceName == deviceName && Mode == mode) {
|
if (DeviceName == deviceName && Mode == mode) {
|
||||||
@ -240,6 +247,11 @@ void CameraSource::unsubscribe()
|
|||||||
*/
|
*/
|
||||||
void CameraSource::openDevice()
|
void CameraSource::openDevice()
|
||||||
{
|
{
|
||||||
|
if (QThread::currentThread() != deviceThread) {
|
||||||
|
QMetaObject::invokeMethod(this, "openDevice");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QWriteLocker locker{&streamMutex};
|
QWriteLocker locker{&streamMutex};
|
||||||
qDebug() << "Opening device " << deviceName;
|
qDebug() << "Opening device " << deviceName;
|
||||||
|
|
||||||
@ -347,6 +359,11 @@ void CameraSource::openDevice()
|
|||||||
*/
|
*/
|
||||||
void CameraSource::closeDevice()
|
void CameraSource::closeDevice()
|
||||||
{
|
{
|
||||||
|
if (QThread::currentThread() != deviceThread) {
|
||||||
|
QMetaObject::invokeMethod(this, "closeDevice");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QWriteLocker locker{&streamMutex};
|
QWriteLocker locker{&streamMutex};
|
||||||
qDebug() << "Closing device " << deviceName;
|
qDebug() << "Closing device " << deviceName;
|
||||||
|
|
||||||
|
@ -40,13 +40,15 @@ public:
|
|||||||
static CameraSource& getInstance();
|
static CameraSource& getInstance();
|
||||||
static void destroyInstance();
|
static void destroyInstance();
|
||||||
void setupDefault();
|
void setupDefault();
|
||||||
void setupDevice(const QString& deviceName, const VideoMode& mode);
|
|
||||||
bool isNone() const;
|
bool isNone() const;
|
||||||
|
|
||||||
// VideoSource interface
|
// VideoSource interface
|
||||||
virtual void subscribe() override;
|
virtual void subscribe() override;
|
||||||
virtual void unsubscribe() override;
|
virtual void unsubscribe() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setupDevice(const QString& deviceName, const VideoMode& mode);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceOpened();
|
void deviceOpened();
|
||||||
void openFailed();
|
void openFailed();
|
||||||
@ -55,6 +57,8 @@ private:
|
|||||||
CameraSource();
|
CameraSource();
|
||||||
~CameraSource();
|
~CameraSource();
|
||||||
void stream();
|
void stream();
|
||||||
|
|
||||||
|
private slots:
|
||||||
void openDevice();
|
void openDevice();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user