qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
corevideosource.h
Go to the documentation of this file.
1 /*
2  Copyright © 2015-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 
21 #pragma once
22 
23 #include "videosource.h"
24 #include <QMutex>
25 #include <atomic>
26 #include <vpx/vpx_image.h>
27 
29 {
30  Q_OBJECT
31 public:
32  // VideoSource interface
33  void subscribe() override;
34  void unsubscribe() override;
35 
36 private:
38 
39  void pushFrame(const vpx_image_t* frame);
40  void setDeleteOnClose(bool newstate);
41 
42  void stopSource();
43  void restartSource();
44 
45 private:
46  std::atomic_int subscribers;
47  std::atomic_bool deleteOnClose;
48  QMutex biglock;
49  std::atomic_bool stopped;
50 
51  friend class CoreAV;
52  friend class ToxFriendCall;
53 };
VideoSource
An abstract source of video frames.
Definition: videosource.h:29
CoreVideoSource::deleteOnClose
std::atomic_bool deleteOnClose
Definition: corevideosource.h:47
CoreVideoSource::stopped
std::atomic_bool stopped
Definition: corevideosource.h:49
CoreVideoSource::unsubscribe
void unsubscribe() override
Stop emitting frameAvailable signals, and free associated resources if necessary.
Definition: corevideosource.cpp:114
CoreVideoSource::biglock
QMutex biglock
Definition: corevideosource.h:48
CoreVideoSource::pushFrame
void pushFrame(const vpx_image_t *frame)
Makes a copy of the vpx_image_t and emits it as a new VideoFrame.
Definition: corevideosource.cpp:60
ToxFriendCall
Definition: toxcall.h:89
CoreVideoSource::CoreVideoSource
CoreVideoSource()
CoreVideoSource constructor.
Definition: corevideosource.cpp:49
CoreVideoSource::subscribers
std::atomic_int subscribers
Definition: corevideosource.h:46
CoreVideoSource::restartSource
void restartSource()
Definition: corevideosource.cpp:151
CoreVideoSource::setDeleteOnClose
void setDeleteOnClose(bool newstate)
Setup delete on close.
Definition: corevideosource.cpp:132
CoreVideoSource::subscribe
void subscribe() override
If subscribe sucessfully opens the source, it will start emitting frameAvailable signals.
Definition: corevideosource.cpp:108
CoreVideoSource
A VideoSource that emits frames received by Core.
Definition: corevideosource.h:28
CoreVideoSource::stopSource
void stopSource()
Stopping the source.
Definition: corevideosource.cpp:144
videosource.h
CoreAV
Definition: coreav.h:47