blob: 7b2dec206071257a936e2b00e643cc1c3b4d5b83 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -05002 * Copyright (C) 2015-2016 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret627500d2015-03-27 16:41:40 -040020
21#include <QWidget>
22#include <QPainter>
Edric Milaret1eca0292015-06-29 12:03:36 -040023
24#include <memory>
Edric Milaret7153eed2015-06-03 15:29:03 -040025
26#include "video/renderer.h"
27#include "video/previewmanager.h"
Edric Milaret7153eed2015-06-03 15:29:03 -040028#include "callmodel.h"
Edric Milaret627500d2015-03-27 16:41:40 -040029
30class VideoWidget : public QWidget
31{
32 Q_OBJECT
33public:
Edric Milaret80e0b212015-10-16 10:07:43 -040034 explicit VideoWidget(QWidget* parent = 0);
Edric Milaret627500d2015-03-27 16:41:40 -040035 ~VideoWidget();
36 void paintEvent(QPaintEvent* evt);
Edric Milaret80e0b212015-10-16 10:07:43 -040037 void setPreviewDisplay(bool display);
38 void setDistantRenderer(Video::Renderer* renderer);
Edric Milaret0b7fe5d2016-01-27 11:12:43 -050039 void setIsFullPreview(bool full);
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050040 inline void setResetPreview(bool reset){ resetPreview_ = reset; };
Edric Milaret627500d2015-03-27 16:41:40 -040041
42public slots:
43 void previewStarted(Video::Renderer* renderer);
Edric Milaret72c406d2015-04-28 13:23:54 -040044 void previewStopped();
Edric Milaret627500d2015-03-27 16:41:40 -040045 void frameFromPreview();
Edric Milaret627500d2015-03-27 16:41:40 -040046 void frameFromDistant();
47 void renderingStopped();
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050048 inline QRect& getPreviewRect(){ return previewGeometry_; };
Edric Milaret627500d2015-03-27 16:41:40 -040049
50private:
51 Video::Renderer* previewRenderer_;
52 Video::Renderer* renderer_;
Edric Milaret37157b32015-10-13 18:00:03 -040053 Video::Frame currentPreviewFrame_;
54 Video::Frame currentDistantFrame_;
55 QMutex mutex_;
56 std::unique_ptr<QImage> distantImage_;
57 std::unique_ptr<QImage> previewImage_;
58 std::vector<uint8_t> frameDistant_;
59 std::vector<uint8_t> framePreview_;
Edric Milaret80e0b212015-10-16 10:07:43 -040060 bool isPreviewDisplayed_;
Edric Milaret0b7fe5d2016-01-27 11:12:43 -050061 bool fullPreview_;
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050062 QRect previewGeometry_;
63 bool resetPreview_ = false;
Edric Milaret37157b32015-10-13 18:00:03 -040064
Edric Milareta9f937f2015-06-01 17:10:34 -040065 constexpr static int previewMargin_ = 15;
Edric Milaret627500d2015-03-27 16:41:40 -040066};
67