Commit b41f91d4 authored by Andreas Traczyk's avatar Andreas Traczyk

avmodel: optionally switchInput using a callId

Change-Id: I859006b588bf97c0d9a4cd7aaaadc54d8f7eded5
parent db6ca57b
......@@ -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
......
......@@ -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);
}
}
......
/******************************************************************************
* 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();
......
/******************************************************************************
* 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
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment