Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Edric Milaret | bab169d | 2016-01-07 15:13:33 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 by Savoir-faire Linux * |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 3 | * 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 Milaret | 5f316da | 2015-09-28 11:57:42 -0400 | [diff] [blame] | 19 | #pragma once |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 20 | |
| 21 | #include <QWidget> |
| 22 | #include <QPainter> |
Edric Milaret | 1eca029 | 2015-06-29 12:03:36 -0400 | [diff] [blame] | 23 | |
| 24 | #include <memory> |
Edric Milaret | 7153eed | 2015-06-03 15:29:03 -0400 | [diff] [blame] | 25 | |
| 26 | #include "video/renderer.h" |
| 27 | #include "video/previewmanager.h" |
Edric Milaret | 7153eed | 2015-06-03 15:29:03 -0400 | [diff] [blame] | 28 | #include "callmodel.h" |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 29 | |
| 30 | class VideoWidget : public QWidget |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | public: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 34 | explicit VideoWidget(QWidget* parent = 0); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 35 | ~VideoWidget(); |
| 36 | void paintEvent(QPaintEvent* evt); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 37 | void setPreviewDisplay(bool display); |
| 38 | void setDistantRenderer(Video::Renderer* renderer); |
Edric Milaret | 0b7fe5d | 2016-01-27 11:12:43 -0500 | [diff] [blame] | 39 | void setIsFullPreview(bool full); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 40 | |
| 41 | public slots: |
| 42 | void previewStarted(Video::Renderer* renderer); |
Edric Milaret | 72c406d | 2015-04-28 13:23:54 -0400 | [diff] [blame] | 43 | void previewStopped(); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 44 | void frameFromPreview(); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 45 | void frameFromDistant(); |
| 46 | void renderingStopped(); |
| 47 | |
| 48 | private: |
| 49 | Video::Renderer* previewRenderer_; |
| 50 | Video::Renderer* renderer_; |
Edric Milaret | 37157b3 | 2015-10-13 18:00:03 -0400 | [diff] [blame] | 51 | Video::Frame currentPreviewFrame_; |
| 52 | Video::Frame currentDistantFrame_; |
| 53 | QMutex mutex_; |
| 54 | std::unique_ptr<QImage> distantImage_; |
| 55 | std::unique_ptr<QImage> previewImage_; |
| 56 | std::vector<uint8_t> frameDistant_; |
| 57 | std::vector<uint8_t> framePreview_; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 58 | bool isPreviewDisplayed_; |
Edric Milaret | 0b7fe5d | 2016-01-27 11:12:43 -0500 | [diff] [blame] | 59 | bool fullPreview_; |
Edric Milaret | 37157b3 | 2015-10-13 18:00:03 -0400 | [diff] [blame] | 60 | |
Edric Milaret | a9f937f | 2015-06-01 17:10:34 -0400 | [diff] [blame] | 61 | constexpr static int previewMargin_ = 15; |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 62 | }; |
| 63 | |