mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(video): adds an ID parameter to the VideoSource class
This commit is contained in:
parent
57f38e281b
commit
4ac20c7b46
1
qtox.pro
1
qtox.pro
|
@ -414,6 +414,7 @@ SOURCES += \
|
|||
src/persistence/db/rawdatabase.cpp \
|
||||
src/persistence/history.cpp \
|
||||
src/video/videoframe.cpp \
|
||||
src/video/videosource.cpp \
|
||||
src/video/cameradevice.cpp \
|
||||
src/video/camerasource.cpp \
|
||||
src/video/corevideosource.cpp \
|
||||
|
|
23
src/video/videosource.cpp
Normal file
23
src/video/videosource.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
Copyright © 2016 by The qTox Project
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
qTox is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
qTox is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "videosource.h"
|
||||
|
||||
// Initialize sourceIDs to 0
|
||||
VideoSource::AtomicIDType VideoSource::sourceIDs {0};
|
|
@ -21,6 +21,8 @@
|
|||
#define VIDEOSOURCE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
class VideoFrame;
|
||||
|
@ -35,7 +37,12 @@ class VideoSource : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
using IDType = std::uint_fast64_t;
|
||||
using AtomicIDType = std::atomic_uint_fast64_t;
|
||||
|
||||
public:
|
||||
VideoSource() : id(sourceIDs.fetch_add(std::memory_order_relaxed)){}
|
||||
|
||||
virtual ~VideoSource() = default;
|
||||
/**
|
||||
If subscribe sucessfully opens the source, it will start emitting frameAvailable signals.
|
||||
|
@ -46,6 +53,8 @@ public:
|
|||
*/
|
||||
virtual void unsubscribe() = 0;
|
||||
|
||||
/// ID of this VideoSource
|
||||
const IDType id;
|
||||
signals:
|
||||
/**
|
||||
Emitted when new frame available to use.
|
||||
|
@ -57,6 +66,9 @@ signals:
|
|||
but might restart sending frames again later
|
||||
*/
|
||||
void sourceStopped();
|
||||
private:
|
||||
/// Used to manage a global ID for all VideoSources
|
||||
static AtomicIDType sourceIDs;
|
||||
};
|
||||
|
||||
#endif // VIDEOSOURCE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user