Commit f136b04c authored by Andreas Traczyk's avatar Andreas Traczyk

video settings: only use video device names for display

Change-Id: Ic18599e853708cb7f2ea5b8cc799081fb8571b8b
parent b784e232
...@@ -388,8 +388,8 @@ chat_view_show_recorder(ChatView *self, int pt_x, int pt_y, bool is_video_record ...@@ -388,8 +388,8 @@ chat_view_show_recorder(ChatView *self, int pt_x, int pt_y, bool is_video_record
auto width = .0; auto width = .0;
auto height = .0; auto height = .0;
if (is_video_record) { if (is_video_record) {
auto deviceName = priv->cpp->avModel_->getDefaultDeviceName(); auto deviceId = priv->cpp->avModel_->getDefaultDevice();
auto settings = priv->cpp->avModel_->getDeviceSettings(deviceName); auto settings = priv->cpp->avModel_->getDeviceSettings(deviceId);
auto res = settings.size; auto res = settings.size;
if (res.find("x") == std::string::npos) return; if (res.find("x") == std::string::npos) return;
auto res_width = static_cast<double>(std::stoi(res.substr(0, res.find("x")))); auto res_width = static_cast<double>(std::stoi(res.substr(0, res.find("x"))));
......
...@@ -179,7 +179,7 @@ CppImpl::drawFramerates() ...@@ -179,7 +179,7 @@ CppImpl::drawFramerates()
} }
using namespace lrc::api; using namespace lrc::api;
auto active = 0; auto active = 0;
auto currentDevice = avModel_->getDefaultDeviceName(); auto currentDevice = avModel_->getDefaultDevice();
auto deviceCaps = avModel_->getDeviceCapabilities(currentDevice); auto deviceCaps = avModel_->getDeviceCapabilities(currentDevice);
std::string currentChannel = "", currentRes = "", currentRate = ""; std::string currentChannel = "", currentRes = "", currentRate = "";
int currentResIndex; int currentResIndex;
...@@ -223,7 +223,7 @@ CppImpl::drawResolutions() ...@@ -223,7 +223,7 @@ CppImpl::drawResolutions()
return; return;
} }
auto active = 0; auto active = 0;
auto currentDevice = avModel_->getDefaultDeviceName(); auto currentDevice = avModel_->getDefaultDevice();
std::string currentChannel = "", currentRes = ""; std::string currentChannel = "", currentRes = "";
try { try {
currentChannel = avModel_->getDeviceSettings(currentDevice).channel; currentChannel = avModel_->getDeviceSettings(currentDevice).channel;
...@@ -254,7 +254,7 @@ CppImpl::drawChannels() ...@@ -254,7 +254,7 @@ CppImpl::drawChannels()
return; return;
} }
auto active = 0; auto active = 0;
auto currentDevice = avModel_->getDefaultDeviceName(); auto currentDevice = avModel_->getDefaultDevice();
std::string currentChannel = ""; std::string currentChannel = "";
try { try {
currentChannel = avModel_->getDeviceSettings(currentDevice).channel; currentChannel = avModel_->getDeviceSettings(currentDevice).channel;
...@@ -283,7 +283,7 @@ CppImpl::drawVideoDevices() ...@@ -283,7 +283,7 @@ CppImpl::drawVideoDevices()
return; return;
} }
auto active = 0; auto active = 0;
auto current = avModel_->getDefaultDeviceName(); auto current = avModel_->getDefaultDevice();
if (current == "") { if (current == "") {
// Avoid to draw devices if no camera is selected // Avoid to draw devices if no camera is selected
return; return;
...@@ -294,7 +294,8 @@ CppImpl::drawVideoDevices() ...@@ -294,7 +294,8 @@ CppImpl::drawVideoDevices()
if (device == current) { if (device == current) {
active = i; active = i;
} }
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_device), nullptr, device.c_str()); auto name = avModel_->getDeviceSettings(device).name;
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_device), nullptr, name.c_str());
i++; i++;
} }
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->combobox_device), active); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->combobox_device), active);
...@@ -383,16 +384,27 @@ set_video_device(MediaSettingsView* self) ...@@ -383,16 +384,27 @@ set_video_device(MediaSettingsView* self)
{ {
g_return_if_fail(IS_MEDIA_SETTINGS_VIEW(self)); g_return_if_fail(IS_MEDIA_SETTINGS_VIEW(self));
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self); MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self);
auto* video_device = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_device)); auto* device_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_device));
if (video_device) { if (device_name) {
auto currentDevice = priv->cpp->avModel_->getDefaultDeviceName(); auto devices = priv->cpp->avModel_->getDevices();
if (currentDevice == video_device) return; auto iter = std::find_if(devices.begin(), devices.end(),
priv->cpp->avModel_->setDefaultDevice(video_device); [device_name, &priv](const std::string& d) {
auto settings = priv->cpp->avModel_->getDeviceSettings(d);
return settings.name == device_name;
});
if (iter == devices.end()) {
g_warning("set_video_device couldn't find device: %s", device_name);
return;
}
auto& device_id = *iter;
auto currentDevice = priv->cpp->avModel_->getDefaultDevice();
if (currentDevice == device_id) return;
priv->cpp->avModel_->setDefaultDevice(device_id);
try { try {
auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice); auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice);
priv->cpp->avModel_->setDeviceSettings(settings); priv->cpp->avModel_->setDeviceSettings(settings);
} catch (const std::out_of_range&) { } catch (const std::out_of_range&) {
g_warning("set_resolution out_of_range exception"); g_warning("set_video_device out_of_range exception");
} }
priv->cpp->drawVideoDevices(); priv->cpp->drawVideoDevices();
} }
...@@ -405,7 +417,7 @@ set_channel(MediaSettingsView* self) ...@@ -405,7 +417,7 @@ set_channel(MediaSettingsView* self)
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self); MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self);
auto* video_channel = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_channel)); auto* video_channel = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_channel));
if (video_channel) { if (video_channel) {
auto currentDevice = priv->cpp->avModel_->getDefaultDeviceName(); auto currentDevice = priv->cpp->avModel_->getDefaultDevice();
try { try {
auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice); auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice);
if (settings.channel == video_channel) return; if (settings.channel == video_channel) return;
...@@ -426,7 +438,7 @@ set_resolution(MediaSettingsView* self) ...@@ -426,7 +438,7 @@ set_resolution(MediaSettingsView* self)
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self); MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self);
auto* video_resolution = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_resolution)); auto* video_resolution = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_resolution));
if (video_resolution) { if (video_resolution) {
auto currentDevice = priv->cpp->avModel_->getDefaultDeviceName(); auto currentDevice = priv->cpp->avModel_->getDefaultDevice();
try { try {
auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice); auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice);
if (settings.size == video_resolution) return; if (settings.size == video_resolution) return;
...@@ -447,7 +459,7 @@ set_framerate(MediaSettingsView* self) ...@@ -447,7 +459,7 @@ set_framerate(MediaSettingsView* self)
MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self); MediaSettingsViewPrivate *priv = MEDIA_SETTINGS_VIEW_GET_PRIVATE(self);
auto* video_framerate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_framerate)); auto* video_framerate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(priv->combobox_framerate));
if (video_framerate) { if (video_framerate) {
auto currentDevice = priv->cpp->avModel_->getDefaultDeviceName(); auto currentDevice = priv->cpp->avModel_->getDefaultDevice();
try { try {
auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice); auto settings = priv->cpp->avModel_->getDeviceSettings(currentDevice);
if (settings.rate == std::stoi(video_framerate)) return; if (settings.rate == std::stoi(video_framerate)) return;
......
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