From b41f91d43a29da36b8b67abae9d3c930a666bce4 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Wed, 6 Nov 2019 13:48:43 -0500 Subject: [PATCH] avmodel: optionally switchInput using a callId Change-Id: I859006b588bf97c0d9a4cd7aaaadc54d8f7eded5 --- src/api/avmodel.h | 20 ++++++---- src/avmodel.cpp | 63 ++++++++++++++++++++----------- src/qtwrapper/callmanager_wrap.h | 13 ++++++- src/qtwrapper/videomanager_wrap.h | 4 +- 4 files changed, 68 insertions(+), 32 deletions(-) diff --git a/src/api/avmodel.h b/src/api/avmodel.h index 6232f1dd..635df09b 100644 --- a/src/api/avmodel.h +++ b/src/api/avmodel.h @@ -259,25 +259,31 @@ public: const video::Renderer& getRenderer(const std::string& id) const; /** - * Render a file + * Render a file to the call id specified * @param uri the path of the file + * @param callId + * @note callId can be omitted to switch the input of the local recorder */ - void setInputFile(const std::string& uri); + void setInputFile(const std::string& uri, const std::string& callId = {}); /** - * Change the current device rendered + * Change the current device rendered for the call id specified * @param id of the camera - * @note render a black frame if device not found + * @param callId + * @note renders a black frame if device not found or empty + * @note callId can be omitted to switch the input of the local recorder */ - void switchInputTo(const std::string& id); + void switchInputTo(const std::string& id, const std::string& callId = {}); /** - * Render the current display + * Render the current display to the call id specified * @param idx of the display * @param x top left of the area * @param y top up of the area * @param w width of the area * @param h height of the area + * @param callId + * @note callId can be omitted to switch the input of the local recorder */ - void setDisplay(int idx, int x, int y, int w, int h); + void setDisplay(int idx, int x, int y, int w, int h, const std::string& callId = {}); /** * Get informations on the rendered device * @param call_id linked call to the renderer diff --git a/src/avmodel.cpp b/src/avmodel.cpp index 081aaf6d..0e2060bb 100644 --- a/src/avmodel.cpp +++ b/src/avmodel.cpp @@ -568,46 +568,67 @@ AVModel::getRenderer(const std::string& id) const } void -AVModel::setInputFile(const std::string& uri) +AVModel::setInputFile(const std::string& uri, + const std::string& callId) { QString sep = DRing::Media::VideoProtocolPrefix::SEPARATOR; - VideoManager::instance().switchInput( - !uri.empty() ? QString("%1%2%3") - .arg(DRing::Media::VideoProtocolPrefix::FILE) - .arg(sep) - .arg(QUrl(uri.c_str()).toLocalFile()) - : DRing::Media::VideoProtocolPrefix::NONE); + auto resource = !uri.empty() ? QString("%1%2%3") + .arg(DRing::Media::VideoProtocolPrefix::FILE) + .arg(sep) + .arg(QUrl(uri.c_str()).toLocalFile()) + : DRing::Media::VideoProtocolPrefix::NONE; + if (callId.empty()) { + VideoManager::instance().switchInput(resource); + } else { + CallManager::instance() + .switchInput(QString::fromStdString(callId), resource); + } } void -AVModel::setDisplay(int idx, int x, int y, int w, int h) +AVModel::setDisplay(int idx, int x, int y, int w, int h, + const std::string& callId) { QString sep = DRing::Media::VideoProtocolPrefix::SEPARATOR; - VideoManager::instance().switchInput(QString("%1%2:%3+%4,%5 %6x%7") - .arg(DRing::Media::VideoProtocolPrefix::DISPLAY) - .arg(sep) - .arg(idx) - .arg(x) - .arg(y) - .arg(w) - .arg(h)); + auto resource = QString("%1%2:%3+%4,%5 %6x%7") + .arg(DRing::Media::VideoProtocolPrefix::DISPLAY) + .arg(sep) + .arg(idx) + .arg(x) + .arg(y) + .arg(w) + .arg(h); + if (callId.empty()) { + VideoManager::instance().switchInput(resource); + } else { + CallManager::instance() + .switchInput(QString::fromStdString(callId), resource); + } + } void -AVModel::switchInputTo(const std::string& id) +AVModel::switchInputTo(const std::string& id, + const std::string& callId) { + QString resource; auto devices = getDevices(); auto deviceAvailable = std::find( std::begin(devices), std::end(devices), id); if (deviceAvailable != devices.end()) { QString sep = DRing::Media::VideoProtocolPrefix::SEPARATOR; - VideoManager::instance().switchInput(QString("%1%2%3") + resource = QString("%1%2%3") .arg(DRing::Media::VideoProtocolPrefix::CAMERA) .arg(sep) - .arg(id.c_str())); + .arg(id.c_str()); + } else { + resource = QString(DRing::Media::VideoProtocolPrefix::NONE); + } + if (callId.empty()) { + VideoManager::instance().switchInput(resource); } else { - VideoManager::instance() - .switchInput(DRing::Media::VideoProtocolPrefix::NONE); + CallManager::instance() + .switchInput(QString::fromStdString(callId), resource); } } diff --git a/src/qtwrapper/callmanager_wrap.h b/src/qtwrapper/callmanager_wrap.h index 65ea7259..6bb6dcc3 100644 --- a/src/qtwrapper/callmanager_wrap.h +++ b/src/qtwrapper/callmanager_wrap.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (C) 2014-2019 Savoir-faire Linux Inc. * + * Copyright (C) 2014-2019 Savoir-faire Linux Inc. * * Author : Philippe Groarke <philippe.groarke@savoirfairelinux.com> * * Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com> * * * @@ -368,6 +368,17 @@ public Q_SLOTS: // METHODS DRing::stopSmartInfo(); } + bool switchInput(const QString &callId, const QString &resource) + { +#ifdef ENABLE_VIDEO + return DRing::switchInput(callId.toStdString(), resource.toStdString()); +#else + Q_UNUSED(callId) + Q_UNUSED(resource) + return false; +#endif + } + Q_SIGNALS: // SIGNALS void callStateChanged(const QString &callID, const QString &state, int code); void transferFailed(); diff --git a/src/qtwrapper/videomanager_wrap.h b/src/qtwrapper/videomanager_wrap.h index 215ff524..bc798690 100644 --- a/src/qtwrapper/videomanager_wrap.h +++ b/src/qtwrapper/videomanager_wrap.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (C) 2014-2019 Savoir-faire Linux Inc. * + * Copyright (C) 2014-2019 Savoir-faire Linux Inc. * * Author : Philippe Groarke <philippe.groarke@savoirfairelinux.com> * * Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com> * * * @@ -68,8 +68,6 @@ Q_SIGNALS: void stoppedDecoding(const QString &id, const QString &shmPath, bool isMixer); }; - - /* * Proxy class for interface org.ring.Ring.VideoManager */ -- GitLab