qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
videosource.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <QObject>
23 
24 #include <atomic>
25 #include <memory>
26 
27 class VideoFrame;
28 
29 class VideoSource : public QObject
30 {
31  Q_OBJECT
32 
33 public:
34  // Declare type aliases
35  using IDType = std::uint_fast64_t;
36  using AtomicIDType = std::atomic_uint_fast64_t;
37 
38 public:
40  : id(sourceIDs++)
41  {
42  }
43 
44  virtual ~VideoSource() = default;
49  virtual void subscribe() = 0;
53  virtual void unsubscribe() = 0;
54 
56  const IDType id;
57 signals:
62  void frameAvailable(std::shared_ptr<VideoFrame> frame);
67  void sourceStopped();
68 
69 private:
70  // Used to manage a global ID for all VideoSources
72 };
VideoSource::unsubscribe
virtual void unsubscribe()=0
Stop emitting frameAvailable signals, and free associated resources if necessary.
VideoSource::IDType
std::uint_fast64_t IDType
Definition: videosource.h:35
VideoSource::frameAvailable
void frameAvailable(std::shared_ptr< VideoFrame > frame)
Emitted when new frame available to use.
VideoSource
An abstract source of video frames.
Definition: videosource.h:29
VideoSource::subscribe
virtual void subscribe()=0
If subscribe sucessfully opens the source, it will start emitting frameAvailable signals.
VideoSource::AtomicIDType
std::atomic_uint_fast64_t AtomicIDType
Definition: videosource.h:36
VideoSource::sourceStopped
void sourceStopped()
Emitted when the source is stopped for an indefinite amount of time, but might restart sending frames...
VideoSource::id
const IDType id
ID of this VideoSource.
Definition: videosource.h:56
VideoSource::VideoSource
VideoSource()
Definition: videosource.h:39
VideoFrame
An ownernship and management class for AVFrames.
Definition: videoframe.h:55
VideoSource::sourceIDs
static AtomicIDType sourceIDs
Definition: videosource.h:71
VideoSource::~VideoSource
virtual ~VideoSource()=default