Skip to content
Snippets Groups Projects
Commit 8d988c33 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin
Browse files

mediasettings: use ordered vector of res/rates instead of map

Change-Id: Iadb9a2d65d19285472e31e203898672e8620cbdf
parent 1dbc0c01
Branches
No related tags found
No related merge requests found
...@@ -179,18 +179,31 @@ CppImpl::drawFramerates() ...@@ -179,18 +179,31 @@ CppImpl::drawFramerates()
g_warning("AVModel not initialized yet"); g_warning("AVModel not initialized yet");
return; return;
} }
using namespace lrc::api;
auto active = 0; auto active = 0;
auto currentDevice = avModel_->getDefaultDeviceName(); auto currentDevice = avModel_->getDefaultDeviceName();
auto deviceCaps = avModel_->getDeviceCapabilities(currentDevice);
std::string currentChannel = "", currentRes = "", currentRate = ""; std::string currentChannel = "", currentRes = "", currentRate = "";
int currentResIndex;
try { try {
currentChannel = avModel_->getDeviceSettings(currentDevice).channel; auto deviceSettings = avModel_->getDeviceSettings(currentDevice);
currentRes = avModel_->getDeviceSettings(currentDevice).size; currentChannel = deviceSettings.channel;
currentRate = std::to_string(avModel_->getDeviceSettings(currentDevice).rate); currentRes = deviceSettings.size;
currentRate = std::to_string(deviceSettings.rate);
auto resRates = deviceCaps.at(currentChannel);
auto it = std::find_if(resRates.begin(), resRates.end(),
[&currentRes](const std::pair<video::Resolution, video::FrameratesList>& element) {
return element.first == currentRes;
});
if (it == resRates.end()) {
throw std::out_of_range("Can't find resolution");
}
currentResIndex = std::distance(resRates.begin(), it);
} catch (const std::out_of_range&) { } catch (const std::out_of_range&) {
g_warning("drawFramerates out_of_range exception"); g_warning("drawFramerates out_of_range exception");
return; return;
} }
auto rates = avModel_->getDeviceCapabilities(currentDevice).at(currentChannel).at(currentRes); auto rates = deviceCaps.at(currentChannel).at(currentResIndex).second;
auto i = 0; auto i = 0;
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->combobox_framerate)); gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->combobox_framerate));
for (const auto& rate : rates) { for (const auto& rate : rates) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment