2018-11-04 10:19:17 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* plugins/VOIP/gui/QVideoDevice.h *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2012 by Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
#include <QLabel>
|
2015-05-11 15:40:07 -04:00
|
|
|
#include "interface/rsVOIP.h"
|
2015-10-03 22:08:24 -04:00
|
|
|
|
|
|
|
#include "opencv2/opencv.hpp"
|
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
#include "gui/VideoProcessor.h"
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
class VideoEncoder ;
|
|
|
|
|
|
|
|
// Responsible from displaying the video. The source of the video is
|
|
|
|
// a VideoDecoder object, which uses a codec.
|
|
|
|
//
|
|
|
|
class QVideoOutputDevice: public QLabel
|
|
|
|
{
|
|
|
|
public:
|
2015-05-11 15:40:07 -04:00
|
|
|
QVideoOutputDevice(QWidget *parent = 0) ;
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
void showFrame(const QImage&) ;
|
2014-07-20 16:50:36 -04:00
|
|
|
void showFrameOff() ;
|
2014-07-13 09:57:25 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Responsible for grabbing the video from the webcam and sending it to the
|
|
|
|
// VideoEncoder object.
|
|
|
|
//
|
|
|
|
class QVideoInputDevice: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-05-11 15:40:07 -04:00
|
|
|
QVideoInputDevice(QWidget *parent = 0) ;
|
2014-07-13 09:57:25 -04:00
|
|
|
~QVideoInputDevice() ;
|
|
|
|
|
|
|
|
// Captured images are sent to this encoder. Can be NULL.
|
|
|
|
//
|
2015-08-14 16:44:20 -04:00
|
|
|
void setVideoProcessor(VideoProcessor *venc) { _video_processor = venc ; }
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
// All images received will be echoed to this target. We could use signal/slots, but it's
|
|
|
|
// probably faster this way. Can be NULL.
|
|
|
|
//
|
|
|
|
void setEchoVideoTarget(QVideoOutputDevice *odev) { _echo_output_device = odev ; }
|
|
|
|
|
2014-07-15 16:04:31 -04:00
|
|
|
// get the next encoded video data chunk.
|
|
|
|
//
|
2015-05-11 15:40:07 -04:00
|
|
|
bool getNextEncodedPacket(RsVOIPDataChunk&) ;
|
2014-07-15 16:04:31 -04:00
|
|
|
|
2015-08-09 18:09:17 -04:00
|
|
|
// gets the estimated current bandwidth required to transmit the encoded data, in B/s
|
|
|
|
//
|
2015-08-24 21:15:33 -04:00
|
|
|
uint32_t currentBandwidth() const ;
|
2015-08-09 18:09:17 -04:00
|
|
|
|
|
|
|
// control
|
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
void start() ;
|
|
|
|
void stop() ;
|
2015-09-02 22:14:04 -04:00
|
|
|
bool stopped();
|
|
|
|
protected slots:
|
2014-07-13 09:57:25 -04:00
|
|
|
void grabFrame() ;
|
|
|
|
|
2014-07-15 16:04:31 -04:00
|
|
|
signals:
|
|
|
|
void networkPacketReady() ;
|
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
private:
|
2015-08-14 16:44:20 -04:00
|
|
|
VideoProcessor *_video_processor ;
|
2014-07-13 09:57:25 -04:00
|
|
|
QTimer *_timer ;
|
2015-10-03 22:08:24 -04:00
|
|
|
cv::VideoCapture *_capture_device ;
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
QVideoOutputDevice *_echo_output_device ;
|
2014-07-15 16:04:31 -04:00
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
std::list<RsVOIPDataChunk> _out_queue ;
|
2014-07-13 09:57:25 -04:00
|
|
|
};
|
|
|
|
|