mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-04-21 21:52:03 +02:00
video: add black background in previewrenderer and flow optimization
Change-Id: I979dcc7d7a65029a1ee361579e51575ea813f0e7
This commit is contained in:
parent
d4b5ec4201
commit
3ade8ee12f
6 changed files with 65 additions and 15 deletions
|
@ -66,13 +66,19 @@ AvAdapter::populateVideoDeviceContextMenuItem()
|
|||
void
|
||||
AvAdapter::onVideoContextMenuDeviceItemClicked(const QString& deviceName)
|
||||
{
|
||||
auto* convModel = LRCInstance::getCurrentConversationModel();
|
||||
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
|
||||
auto call = LRCInstance::getCallInfoForConversation(conversation);
|
||||
if (!call)
|
||||
return;
|
||||
|
||||
auto deviceId = LRCInstance::avModel().getDeviceIdFromName(deviceName);
|
||||
if (deviceId.isEmpty()) {
|
||||
qWarning() << "Couldn't find device: " << deviceName;
|
||||
return;
|
||||
}
|
||||
LRCInstance::avModel().switchInputTo(deviceId);
|
||||
LRCInstance::avModel().setCurrentVideoCaptureDevice(deviceId);
|
||||
LRCInstance::avModel().switchInputTo(deviceId, call->id);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,8 +185,9 @@ AvAdapter::slotDeviceEvent()
|
|||
avModel.switchInputTo({}, callId);
|
||||
avModel.stopPreview();
|
||||
} else if (deviceEvent == DeviceEvent::RemovedCurrent && currentDeviceListSize > 0) {
|
||||
avModel.switchInputTo(defaultDevice, callId);
|
||||
avModel.setDefaultDevice(defaultDevice);
|
||||
avModel.setCurrentVideoCaptureDevice(defaultDevice);
|
||||
avModel.switchInputTo(defaultDevice, callId);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -190,14 +197,18 @@ AvAdapter::slotDeviceEvent()
|
|||
[cb] { QtConcurrent::run([cb]() { cb(); }); });
|
||||
} else {
|
||||
if (deviceEvent == DeviceEvent::Added && currentDeviceListSize == 1) {
|
||||
avModel.switchInputTo(defaultDevice, callId);
|
||||
avModel.setDefaultDevice(defaultDevice);
|
||||
avModel.setCurrentVideoCaptureDevice(defaultDevice);
|
||||
if (callId.isEmpty())
|
||||
LRCInstance::renderer()->startPreviewing();
|
||||
else
|
||||
avModel.switchInputTo(defaultDevice, callId);
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
emit videoDeviceListChanged();
|
||||
emit videoDeviceListChanged(currentDeviceListSize == 0);
|
||||
|
||||
deviceListSize_ = currentDeviceListSize;
|
||||
}
|
|
@ -37,7 +37,7 @@ signals:
|
|||
/*
|
||||
* Emitted when the size of the video capture device list changes.
|
||||
*/
|
||||
void videoDeviceListChanged();
|
||||
void videoDeviceListChanged(bool listIsEmpty);
|
||||
|
||||
protected:
|
||||
void safeInit() override {};
|
||||
|
|
|
@ -244,6 +244,14 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AvAdapter
|
||||
|
||||
function onVideoDeviceListChanged(listIsEmpty) {
|
||||
previewRenderer.visible = !listIsEmpty
|
||||
}
|
||||
}
|
||||
|
||||
width: Math.max(videoCallPageMainRect.width / 5, JamiTheme.minimumPreviewWidth)
|
||||
x: videoCallPageMainRect.width - previewRenderer.width - previewMargin
|
||||
y: videoCallPageMainRect.height - previewRenderer.height - previewMargin - 56 // Avoid overlay
|
||||
|
|
|
@ -32,11 +32,16 @@ PreviewRenderer::PreviewRenderer(QQuickItem* parent)
|
|||
previewFrameUpdatedConnection_ = connect(LRCInstance::renderer(),
|
||||
&RenderManager::previewFrameUpdated,
|
||||
[this]() { update(QRect(0, 0, width(), height())); });
|
||||
|
||||
previewRenderingStopped_ = connect(LRCInstance::renderer(),
|
||||
&RenderManager::previewRenderingStopped,
|
||||
[this]() { update(QRect(0, 0, width(), height())); });
|
||||
}
|
||||
|
||||
PreviewRenderer::~PreviewRenderer()
|
||||
{
|
||||
disconnect(previewFrameUpdatedConnection_);
|
||||
disconnect(previewRenderingStopped_);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -63,11 +68,23 @@ PreviewRenderer::paint(QPainter* painter)
|
|||
scaledPreview = previewImage->scaled(size().toSize(), Qt::KeepAspectRatio);
|
||||
painter->drawImage(QRect(0, 0, scaledPreview.width(), scaledPreview.height()),
|
||||
scaledPreview);
|
||||
} else {
|
||||
paintBackground(painter);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PreviewRenderer::paintBackground(QPainter* painter)
|
||||
{
|
||||
QBrush brush(Qt::black);
|
||||
QPainterPath path;
|
||||
path.addRect(QRect(0, 0, width(), height()));
|
||||
painter->fillPath(path, brush);
|
||||
}
|
||||
|
||||
VideoCallPreviewRenderer::VideoCallPreviewRenderer(QQuickItem* parent)
|
||||
: PreviewRenderer(parent) {
|
||||
: PreviewRenderer(parent)
|
||||
{
|
||||
setProperty("previewImageScalingFactor", 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,16 +34,18 @@ public:
|
|||
|
||||
protected:
|
||||
void paint(QPainter* painter) override;
|
||||
void paintBackground(QPainter* painter);
|
||||
|
||||
private:
|
||||
QMetaObject::Connection previewFrameUpdatedConnection_;
|
||||
QMetaObject::Connection previewRenderingStopped_;
|
||||
};
|
||||
|
||||
class VideoCallPreviewRenderer : public PreviewRenderer
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal previewImageScalingFactor MEMBER previewImageScalingFactor_
|
||||
NOTIFY previewImageScalingFactorChanged)
|
||||
Q_PROPERTY(qreal previewImageScalingFactor MEMBER previewImageScalingFactor_ NOTIFY
|
||||
previewImageScalingFactorChanged)
|
||||
public:
|
||||
explicit VideoCallPreviewRenderer(QQuickItem* parent = 0);
|
||||
virtual ~VideoCallPreviewRenderer();
|
||||
|
|
|
@ -49,10 +49,18 @@ ColumnLayout {
|
|||
function populateVideoSettings() {
|
||||
deviceComboBoxSetting.comboModel.reset()
|
||||
|
||||
var count = deviceComboBoxSetting.comboModel.deviceCount() > 0
|
||||
deviceComboBoxSetting.setEnabled(count)
|
||||
resolutionComboBoxSetting.setEnabled(count)
|
||||
fpsComboBoxSetting.setEnabled(count)
|
||||
var count = deviceComboBoxSetting.comboModel.deviceCount()
|
||||
var deviceListIsEmpty = count === 0
|
||||
|
||||
previewWidget.visible = count > 0
|
||||
deviceComboBoxSetting.setEnabled(count > 0)
|
||||
resolutionComboBoxSetting.setEnabled(count > 0)
|
||||
fpsComboBoxSetting.setEnabled(count > 0)
|
||||
|
||||
if (deviceListIsEmpty) {
|
||||
resolutionComboBoxSetting.comboModel.reset()
|
||||
fpsComboBoxSetting.comboModel.reset()
|
||||
}
|
||||
|
||||
deviceComboBoxSetting.setCurrentIndex(
|
||||
deviceComboBoxSetting.comboModel.getCurrentSettingIndex(), true)
|
||||
|
@ -71,8 +79,11 @@ ColumnLayout {
|
|||
return
|
||||
}
|
||||
|
||||
if (AVModel.getCurrentVideoCaptureDevice() !== deviceId) {
|
||||
AVModel.setCurrentVideoCaptureDevice(deviceId)
|
||||
AVModel.setDefaultDevice(deviceId)
|
||||
}
|
||||
|
||||
setFormatListForCurrentDevice()
|
||||
startPreviewing()
|
||||
} catch(err){ console.warn(err.message) }
|
||||
|
@ -99,6 +110,7 @@ ColumnLayout {
|
|||
var resolution
|
||||
var rate
|
||||
if(isResolutionIndex) {
|
||||
fpsComboBoxSetting.comboModel.reset()
|
||||
resolution = resolutionComboBoxSetting.comboModel.data(
|
||||
resolutionComboBoxSetting.comboModel.index(index, 0),
|
||||
VideoFormatResolutionModel.Resolution)
|
||||
|
|
Loading…
Add table
Reference in a new issue