Commit 6791e0bc authored by Andreas Traczyk's avatar Andreas Traczyk

avmodel: use video device id in video settings

Change-Id: If84646714e9f37e3987230cf86acadc7a0089dc4
parent cef0d466
......@@ -85,20 +85,20 @@ public:
std::vector<std::string> getDevices() const;
/**
* Retrieve current default video device
* @return current default video device name
* @return current default video device id
*/
std::string getDefaultDeviceName() const;
std::string getDefaultDevice() const;
/**
* Set new default video device
* @param name of the device
* @param id of the device
*/
void setDefaultDevice(const std::string& name);
void setDefaultDevice(const std::string& deviceId);
/**
* Retrieve current framerate/resolution/etc of a device
* @param name of the device
* @param id of the device
* @return settings of the device
*/
video::Settings getDeviceSettings(const std::string& name) const;
video::Settings getDeviceSettings(const std::string& deviceId) const;
/**
* Set device settings
* @param video::Settings
......@@ -106,10 +106,10 @@ public:
void setDeviceSettings(video::Settings& settings);
/**
* Retrieve all framerate/resolution/etc possibilities of a device
* @param name of the device
* @param id of the device
* @return possibilities of the device
*/
video::Capabilities getDeviceCapabilities(const std::string& name) const;
video::Capabilities getDeviceCapabilities(const std::string& deviceId) const;
/**
* Get supported audio managers
......
......@@ -95,6 +95,7 @@ struct Settings
{
Channel channel = "";
std::string name = "";
std::string id = "";
Framerate rate = 0;
Resolution size = "";
};
......
/****************************************************************************
* Copyright (C) 2018-2019 Savoir-faire Linux Inc. *
* Copyright (C) 2018-2019 Savoir-faire Linux Inc. *
* Author: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com> *
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
......@@ -197,28 +197,32 @@ AVModel::getDevices() const
}
std::string
AVModel::getDefaultDeviceName() const
AVModel::getDefaultDevice() const
{
QString name = VideoManager::instance().getDefaultDevice();
return name.toStdString();
}
void
AVModel::setDefaultDevice(const std::string& name)
AVModel::setDefaultDevice(const std::string& deviceId)
{
VideoManager::instance().setDefaultDevice(name.c_str());
VideoManager::instance().setDefaultDevice(deviceId.c_str());
}
video::Settings
AVModel::getDeviceSettings(const std::string& name) const
AVModel::getDeviceSettings(const std::string& deviceId) const
{
if (deviceId.empty()) {
return video::Settings();
}
MapStringString settings = VideoManager::instance()
.getSettings(name.c_str());
if (settings["name"].toStdString() != name) {
throw std::out_of_range("Device " + name + " not found");
.getSettings(deviceId.c_str());
if (settings["id"].toStdString() != deviceId) {
throw std::out_of_range("Device '" + deviceId + "' not found");
}
video::Settings result;
result.name = settings["name"].toStdString();
result.id = settings["id"].toStdString();
result.channel = settings["channel"].toStdString();
result.size = settings["size"].toStdString();
result.rate = settings["rate"].toFloat();
......@@ -226,11 +230,11 @@ AVModel::getDeviceSettings(const std::string& name) const
}
video::Capabilities
AVModel::getDeviceCapabilities(const std::string& name) const
AVModel::getDeviceCapabilities(const std::string& deviceId) const
{
// Channel x Resolution x Framerate
QMap<QString, QMap<QString, QVector<QString>>> capabilites =
VideoManager::instance().getCapabilities(name.c_str());
VideoManager::instance().getCapabilities(deviceId.c_str());
video::Capabilities result;
for (auto& channel : capabilites.toStdMap()) {
video::ResRateList channelCapabilities;
......@@ -265,9 +269,10 @@ AVModel::setDeviceSettings(video::Settings& settings)
rate = rate.left(rate.length() - 1);
newSettings["channel"] = settings.channel.c_str();
newSettings["name"] = settings.name.c_str();
newSettings["id"] = settings.id.c_str();
newSettings["rate"] = rate;
newSettings["size"] = settings.size.c_str();
VideoManager::instance().applySettings(settings.name.c_str(), newSettings);
VideoManager::instance().applySettings(settings.id.c_str(), newSettings);
// If the preview is running, reload it
// doing this during a call will cause re-invite, this is unwanted
......@@ -639,7 +644,7 @@ AVModelPimpl::AVModelPimpl(AVModel& linked, const CallbacksHandler& callbacksHan
try {
renderers_.insert(std::make_pair(video::PREVIEW_RENDERER_ID,
std::make_unique<video::Renderer>(video::PREVIEW_RENDERER_ID,
linked_.getDeviceSettings(linked_.getDefaultDeviceName()),
linked_.getDeviceSettings(linked_.getDefaultDevice()),
"",
useAVFrame_)));
} catch (const std::out_of_range& e) {
......
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