ekiga r6162 - in trunk: . lib/engine/audioinput/skel lib/engine/audiooutput/skel lib/engine/vidinput/skel



Author: mschneid
Date: Thu Apr 10 19:35:20 2008
New Revision: 6162
URL: http://svn.gnome.org/viewvc/ekiga?rev=6162&view=rev

Log:
Better checking of gmconf values in the bridges. Moved
gmconf-only "max_frame_rate" to the device settings.



Modified:
   trunk/ChangeLog
   trunk/ekiga.schemas.in.in
   trunk/lib/engine/audioinput/skel/audioinput-core.cpp
   trunk/lib/engine/audioinput/skel/audioinput-core.h
   trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp
   trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
   trunk/lib/engine/audiooutput/skel/audiooutput-core.h
   trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp
   trunk/lib/engine/vidinput/skel/vidinput-core.cpp
   trunk/lib/engine/vidinput/skel/vidinput-core.h
   trunk/lib/engine/vidinput/skel/vidinput-gmconf-bridge.cpp

Modified: trunk/ekiga.schemas.in.in
==============================================================================
--- trunk/ekiga.schemas.in.in	(original)
+++ trunk/ekiga.schemas.in.in	Thu Apr 10 19:35:20 2008
@@ -90,6 +90,17 @@
 	<long>The image to transmit if "Picture" is selected as video plugin or if the opening of the device fails. Leave blank to use the default Ekiga logo.</long>
       </locale>
     </schema>
+    <schema>
+      <key>/schemas/apps/@PACKAGE_NAME@/devices/video/max_frame_rate</key>
+      <applyto>/apps/@PACKAGE_NAME@/devices/video/max_frame_rate</applyto>
+      <owner>Ekiga</owner>
+      <type>int</type>
+      <default>30</default>
+      <locale name="C">
+	<short>Frame Rate</short>
+	<long>The maximum transmitted frame rate in frames/s. This rate may not be reached in case a minimum quality was configure via a TSTO value smaller than 31 and the bitrate selected is not sufficient to support this minimum quality</long>
+      </locale>
+    </schema>
     <schema>	
       <key>/schemas/apps/@PACKAGE_NAME@/devices/audio/lid_output_device_type</key>
       <applyto>/apps/@PACKAGE_NAME@/devices/audio/lid_output_device_type</applyto>
@@ -1108,17 +1119,6 @@
       </locale>
     </schema>
     <schema>
-      <key>/schemas/apps/@PACKAGE_NAME@/codecs/video/max_frame_rate</key>
-      <applyto>/apps/@PACKAGE_NAME@/codecs/video/max_frame_rate</applyto>
-      <owner>Ekiga</owner>
-      <type>int</type>
-      <default>30</default>
-      <locale name="C">
-	<short>Frame Rate</short>
-	<long>The maximum transmitted frame rate in frames/s. This rate may not be reached in case a minimum quality was configure via a TSTO value smaller than 31 and the bitrate selected is not sufficient to support this minimum quality</long>
-      </locale>
-    </schema>
-    <schema>
       <key>/schemas/apps/@PACKAGE_NAME@/codecs/video/temporal_spatial_tradeoff</key>
       <applyto>/apps/@PACKAGE_NAME@/codecs/video/temporal_spatial_tradeoff</applyto>
       <owner>Ekiga</owner>

Modified: trunk/lib/engine/audioinput/skel/audioinput-core.cpp
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.cpp	(original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.cpp	Thu Apr 10 19:35:20 2008
@@ -41,10 +41,6 @@
 #include "audioinput-core.h"
 #include "audioinput-manager.h"
 
-#define FALLBACK_DEVICE_TYPE "NULL"
-#define FALLBACK_DEVICE_SOURCE "NULL"
-#define FALLBACK_DEVICE_DEVICE "NULL"
-
 using namespace Ekiga;
 
 AudioPreviewManager::AudioPreviewManager (AudioInputCore& _audio_input_core, AudioOutputCore& _audio_output_core)
@@ -462,10 +458,10 @@
 
 void AudioInputCore::internal_set_fallback()
 {
-    PTRACE(1, "AudioInputCore\tFalling back to " << FALLBACK_DEVICE_TYPE << "/" << FALLBACK_DEVICE_SOURCE << "/" << FALLBACK_DEVICE_DEVICE);
-    current_device.type = FALLBACK_DEVICE_TYPE;
-    current_device.source = FALLBACK_DEVICE_SOURCE;
-    current_device.device = FALLBACK_DEVICE_DEVICE;
+    PTRACE(1, "AudioInputCore\tFalling back to " << AUDIO_INPUT_FALLBACK_DEVICE_TYPE << "/" << AUDIO_INPUT_FALLBACK_DEVICE_SOURCE << "/" << AUDIO_INPUT_FALLBACK_DEVICE_DEVICE);
+    current_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+    current_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+    current_device.device = AUDIO_INPUT_FALLBACK_DEVICE_DEVICE;
     internal_set_device (current_device);
 }
 

Modified: trunk/lib/engine/audioinput/skel/audioinput-core.h
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.h	(original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.h	Thu Apr 10 19:35:20 2008
@@ -51,6 +51,10 @@
 #include "ptbuildopts.h"
 #include "ptlib.h"
 
+#define AUDIO_INPUT_FALLBACK_DEVICE_TYPE "NULL"
+#define AUDIO_INPUT_FALLBACK_DEVICE_SOURCE "NULL"
+#define AUDIO_INPUT_FALLBACK_DEVICE_DEVICE "NULL"
+
 namespace Ekiga
 {
   typedef struct AudioDeviceConfig {

Modified: trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp	(original)
+++ trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp	Thu Apr 10 19:35:20 2008
@@ -51,7 +51,6 @@
   property_changed.connect (sigc::mem_fun (this, &AudioInputCoreConfBridge::on_property_changed));
 
   keys.push_back (AUDIO_DEVICES_KEY "input_device"); 
-  keys.push_back (AUDIO_DEVICES_KEY "plugin"); 
   load (keys);
 }
 
@@ -62,15 +61,31 @@
   if (key == AUDIO_DEVICES_KEY "input_device") {
 
     PTRACE(4, "AudioInputCoreConfBridge\tUpdating device");
-    std::string config_string = gm_conf_entry_get_string (entry);
-    AudioInputDevice audioinput_device;
 
-    unsigned type_sep = config_string.find_first_of("/");
-    unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+    AudioInputDevice audioinput_device;
+    if (gm_conf_entry_get_string (entry) == NULL) {
+      PTRACE(1, "AudioInputCoreConfBridge\t" << AUDIO_DEVICES_KEY "input_device" << " is NULL");
+    }
+    else {
+      std::string config_string = gm_conf_entry_get_string (entry);
+  
+      unsigned type_sep = config_string.find_first_of("/");
+      unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+  
+      audioinput_device.type   = config_string.substr ( 0, type_sep );
+      audioinput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
+      audioinput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    }
+
+    if ( (audioinput_device.type == "" )   ||
+         (audioinput_device.source == "")  ||
+         (audioinput_device.device == "" ) ) {
+      PTRACE(1, "AudioInputCore\tTried to set malformed device");
+      audioinput_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+      audioinput_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+      audioinput_device.device = AUDIO_INPUT_FALLBACK_DEVICE_DEVICE;
+    }
 
-    audioinput_device.type   = config_string.substr ( 0, type_sep );
-    audioinput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
-    audioinput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
     audioinput_core.set_audioinput_device (audioinput_device);
   }
 }

Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp	(original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp	Thu Apr 10 19:35:20 2008
@@ -38,10 +38,6 @@
 #include <algorithm>
 #include <math.h>
 
-#define FALLBACK_DEVICE_TYPE "NULL"
-#define FALLBACK_DEVICE_SOURCE "NULL"
-#define FALLBACK_DEVICE_DEVICE "NULL"
-
 using namespace Ekiga;
 AudioOutputCore::AudioOutputCore (Ekiga::Runtime & _runtime)
 :  runtime (_runtime),
@@ -448,10 +444,10 @@
 
 void AudioOutputCore::internal_set_primary_fallback()
 {
-  PTRACE(1, "AudioOutputCore\tFalling back to " << FALLBACK_DEVICE_TYPE << "/" << FALLBACK_DEVICE_SOURCE << "/" << FALLBACK_DEVICE_DEVICE);
-  current_device[primary].type = FALLBACK_DEVICE_TYPE;
-  current_device[primary].source = FALLBACK_DEVICE_SOURCE;
-  current_device[primary].device = FALLBACK_DEVICE_DEVICE;
+  PTRACE(1, "AudioOutputCore\tFalling back to " << AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE << "/" << AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE << "/" << AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE);
+  current_device[primary].type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+  current_device[primary].source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+  current_device[primary].device = AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE;
   internal_set_device(primary, current_device[primary]);
 }
 

Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.h	(original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.h	Thu Apr 10 19:35:20 2008
@@ -51,6 +51,10 @@
 #include "ptbuildopts.h"
 #include "ptlib.h"
 
+#define AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE "NULL"
+#define AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE "NULL"
+#define AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE "NULL"
+
 namespace Ekiga
 {
   typedef struct AudioOutputDeviceConfig {

Modified: trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp	(original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp	Thu Apr 10 19:35:20 2008
@@ -53,7 +53,6 @@
 
   keys.push_back (AUDIO_DEVICES_KEY "output_device"); 
   keys.push_back (SOUND_EVENTS_KEY "output_device"); 
-  keys.push_back (AUDIO_DEVICES_KEY "plugin"); 
   keys.push_back (SOUND_EVENTS_KEY "busy_tone_sound"); 
   keys.push_back (SOUND_EVENTS_KEY "incoming_call_sound"); 
   keys.push_back (SOUND_EVENTS_KEY "new_message_sound"); 
@@ -79,33 +78,72 @@
   if (key == AUDIO_DEVICES_KEY "output_device") {
 
     PTRACE(4, "AudioOutputCoreConfBridge\tUpdating device");
-    std::string config_string = gm_conf_entry_get_string (entry);
+
     AudioOutputDevice audiooutput_device;
-    unsigned type_sep = config_string.find_first_of("/");
-    unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
 
-    audiooutput_device.type   = config_string.substr ( 0, type_sep );
-    audiooutput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
-    audiooutput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    if (gm_conf_entry_get_string (entry) == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" << AUDIO_DEVICES_KEY "output_device" << " is NULL");
+    }
+    else {
+      std::string config_string = gm_conf_entry_get_string (entry);
+      unsigned type_sep = config_string.find_first_of("/");
+      unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+
+      audiooutput_device.type   = config_string.substr ( 0, type_sep );
+      audiooutput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
+      audiooutput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );  
+    }
+  
+    if ( (audiooutput_device.type == "" )   ||
+         (audiooutput_device.source == "")  ||
+         (audiooutput_device.device == "" ) ) {
+      PTRACE(1, "AudioOutputCore\tTried to set malformed device");
+      audiooutput_device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+      audiooutput_device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+      audiooutput_device.device = AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE;
+    }
+
     audioinput_core.set_audiooutput_device (primary, audiooutput_device);
   }
 
   if (key == SOUND_EVENTS_KEY "output_device") {
 
     PTRACE(4, "AudioOutputCoreConfBridge\tUpdating device");
-    std::string config_string = gm_conf_entry_get_string (entry);
     AudioOutputDevice audiooutput_device;
-    unsigned type_sep = config_string.find_first_of("/");
-    unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
 
-    audiooutput_device.type   = config_string.substr ( 0, type_sep );
-    audiooutput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
-    audiooutput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    if (gm_conf_entry_get_string (entry) == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" << AUDIO_DEVICES_KEY "output_device" << " is NULL");
+    }
+    else {
+      std::string config_string = gm_conf_entry_get_string (entry);
+
+      unsigned type_sep = config_string.find_first_of("/");
+      unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+
+      audiooutput_device.type   = config_string.substr ( 0, type_sep );
+      audiooutput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
+      audiooutput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    }
+
+    if ( (audiooutput_device.type == "" )   ||
+         (audiooutput_device.source == "")  ||
+         (audiooutput_device.device == "" ) ) {
+      PTRACE(1, "AudioOutputCore\tTried to set malformed device");
+      audiooutput_device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+      audiooutput_device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+      audiooutput_device.device = AUDIO_OUTPUT_FALLBACK_DEVICE_DEVICE;
+    }
     audioinput_core.set_audiooutput_device (secondary, audiooutput_device);
   }
 
   if ( (key == SOUND_EVENTS_KEY "busy_tone_sound") ||
        (key == SOUND_EVENTS_KEY "enable_busy_tone_sound") ) {
+
+    if (gm_conf_get_string (SOUND_EVENTS_KEY "busy_tone_sound") == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "busy_tone_sound" << " is NULL");
+      return;
+    }
+
     name = "busy_tone_sound";
     file_name = gm_conf_get_string (SOUND_EVENTS_KEY "busy_tone_sound");
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_busy_tone_sound");
@@ -114,6 +152,12 @@
 
   if ( (key == SOUND_EVENTS_KEY "incoming_call_sound") ||
        (key == SOUND_EVENTS_KEY "enable_incoming_call_sound") ) {
+
+    if (gm_conf_get_string (SOUND_EVENTS_KEY "incoming_call_sound") == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" <<  SOUND_EVENTS_KEY "incoming_call_sound" << " is NULL");
+      return;
+    }
+
     name = "incoming_call_sound";
     file_name = gm_conf_get_string (SOUND_EVENTS_KEY "incoming_call_sound");
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_incoming_call_sound");
@@ -122,6 +166,12 @@
 
   if ( (key == SOUND_EVENTS_KEY "new_message_sound") ||
        (key == SOUND_EVENTS_KEY "enable_new_message_sound") ) {
+
+    if (gm_conf_get_string (SOUND_EVENTS_KEY "new_message_sound") == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" <<  SOUND_EVENTS_KEY "new_message_sound" << " is NULL");
+      return;
+    }
+
     name = "new_message_sound";
     file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_message_sound");
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound");
@@ -131,6 +181,12 @@
 
   if ( (key == SOUND_EVENTS_KEY "new_voicemail_sound") ||
        (key == SOUND_EVENTS_KEY "enable_new_voicemail_sound") ) {
+
+    if (gm_conf_get_string (SOUND_EVENTS_KEY "new_voicemail_sound") == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" <<  SOUND_EVENTS_KEY "new_voicemail_sound" << " is NULL");
+      return;
+    }
+
     name = "new_voicemail_sound";
     file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_voicemail_sound");
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_voicemail_sound");
@@ -139,6 +195,12 @@
 
   if ( (key == SOUND_EVENTS_KEY "ring_tone_sound") ||
        (key == SOUND_EVENTS_KEY "enable_ring_tone_sound") ) {
+
+    if (gm_conf_get_string (SOUND_EVENTS_KEY "ring_tone_sound") == NULL) {
+      PTRACE(1, "AudioOutputCoreConfBridge\t" <<  SOUND_EVENTS_KEY "ring_tone_sound" << " is NULL");
+      return;
+    }
+
     name = "ring_tone_sound";
     file_name = gm_conf_get_string (SOUND_EVENTS_KEY "ring_tone_sound");
     enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_ring_tone_sound");

Modified: trunk/lib/engine/vidinput/skel/vidinput-core.cpp
==============================================================================
--- trunk/lib/engine/vidinput/skel/vidinput-core.cpp	(original)
+++ trunk/lib/engine/vidinput/skel/vidinput-core.cpp	Thu Apr 10 19:35:20 2008
@@ -42,10 +42,6 @@
 #include "vidinput-core.h"
 #include "vidinput-manager.h"
 
-#define FALLBACK_DEVICE_TYPE "Moving Logo"
-#define FALLBACK_DEVICE_SOURCE "Moving Logo"
-#define FALLBACK_DEVICE_DEVICE "Moving Logo"
-
 using namespace Ekiga;
 
 PreviewManager::PreviewManager (VidInputCore& _vidinput_core, DisplayCore& _display_core)
@@ -541,10 +537,10 @@
 
 void VidInputCore::internal_set_fallback ()
 {
-  PTRACE(3, "VidInputCore\tFalling back to " << FALLBACK_DEVICE_TYPE << "/" << FALLBACK_DEVICE_SOURCE << "/" << FALLBACK_DEVICE_DEVICE);
-  current_device.type = FALLBACK_DEVICE_TYPE;
-  current_device.source = FALLBACK_DEVICE_SOURCE;
-  current_device.device = FALLBACK_DEVICE_DEVICE;
+  PTRACE(3, "VidInputCore\tFalling back to " << VIDEO_INPUT_FALLBACK_DEVICE_TYPE << "/" << VIDEO_INPUT_FALLBACK_DEVICE_SOURCE << "/" << VIDEO_INPUT_FALLBACK_DEVICE_DEVICE);
+  current_device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
+  current_device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
+  current_device.device = VIDEO_INPUT_FALLBACK_DEVICE_DEVICE;
 
   internal_set_device(current_device, current_channel, current_format);
 }

Modified: trunk/lib/engine/vidinput/skel/vidinput-core.h
==============================================================================
--- trunk/lib/engine/vidinput/skel/vidinput-core.h	(original)
+++ trunk/lib/engine/vidinput/skel/vidinput-core.h	Thu Apr 10 19:35:20 2008
@@ -51,6 +51,10 @@
 #include "ptbuildopts.h"
 #include "ptlib.h"
 
+#define VIDEO_INPUT_FALLBACK_DEVICE_TYPE "Moving Logo"
+#define VIDEO_INPUT_FALLBACK_DEVICE_SOURCE "Moving Logo"
+#define VIDEO_INPUT_FALLBACK_DEVICE_DEVICE "Moving Logo"
+
 namespace Ekiga
 {
   typedef struct DeviceConfig {

Modified: trunk/lib/engine/vidinput/skel/vidinput-gmconf-bridge.cpp
==============================================================================
--- trunk/lib/engine/vidinput/skel/vidinput-gmconf-bridge.cpp	(original)
+++ trunk/lib/engine/vidinput/skel/vidinput-gmconf-bridge.cpp	Thu Apr 10 19:35:20 2008
@@ -53,7 +53,6 @@
   keys.push_back (VIDEO_DEVICES_KEY "size"); 
   keys.push_back (VIDEO_CODECS_KEY "max_frame_rate"); 
   keys.push_back (VIDEO_DEVICES_KEY "input_device"); 
-  keys.push_back (VIDEO_DEVICES_KEY "plugin"); 
   keys.push_back (VIDEO_DEVICES_KEY "channel"); 
   keys.push_back (VIDEO_DEVICES_KEY "format"); 
   keys.push_back (VIDEO_DEVICES_KEY "image"); 
@@ -61,7 +60,7 @@
   load (keys);
 }
 
-void VidInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
+void VidInputCoreConfBridge::on_property_changed (std::string key, GmConfEntry * /*entry*/)
 {
   VidInputCore & vidinput_core = (VidInputCore &) service;
 
@@ -70,21 +69,20 @@
 
     PTRACE(4, "VidInputCoreConfBridge\tUpdating preview size and fps");
 
-    if ( (gm_conf_get_int (VIDEO_DEVICES_KEY "size") < 0 ) || 
-         (gm_conf_get_int (VIDEO_DEVICES_KEY "size") >= NB_VIDEO_SIZES )) {
+    unsigned size = gm_conf_get_int (VIDEO_DEVICES_KEY "size");
+    if (size >= NB_VIDEO_SIZES) {
       PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "size" << " out of range, ajusting to 0");
-      gm_conf_set_int (VIDEO_DEVICES_KEY "size", 0);
+      size = 0;
     }
 
-    if ( (gm_conf_get_int (VIDEO_DEVICES_KEY "max_frame_rate") < 0 ) || 
-         (gm_conf_get_int (VIDEO_DEVICES_KEY "max_frame_rate") > 30)) {
+    unsigned max_frame_rate = gm_conf_get_int (VIDEO_DEVICES_KEY "max_frame_rate");
+    if ( (max_frame_rate < 1) || (max_frame_rate > 30) ) {
       PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "max_frame_rate" << " out of range, ajusting to 30");
-      gm_conf_set_int (VIDEO_DEVICES_KEY "max_frame_rate", 30);
+      max_frame_rate = 30;
     }
-
-    vidinput_core.set_preview_config (VideoSizes[gm_conf_get_int (VIDEO_DEVICES_KEY "size")].width,
-                                      VideoSizes[gm_conf_get_int (VIDEO_DEVICES_KEY "size")].height,
-                                      gm_conf_get_int (VIDEO_CODECS_KEY "max_frame_rate"));
+    vidinput_core.set_preview_config (VideoSizes[size].width,
+                                      VideoSizes[size].height,
+                                      max_frame_rate);
   }
   else if ( (key == VIDEO_DEVICES_KEY "input_device") ||
             (key == VIDEO_DEVICES_KEY "channel") ||
@@ -92,18 +90,39 @@
 
     PTRACE(4, "VidInputCoreConfBridge\tUpdating device");
 
-    std::string config_string = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
     VidInputDevice vidinput_device;
-    unsigned type_sep = config_string.find_first_of("/");
-    unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+    if (gm_conf_get_string (VIDEO_DEVICES_KEY "input_device") == NULL) {
+      PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "input_device" << " is NULL");
+    }
+    else {
+      std::string config_string = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
+  
+      unsigned type_sep = config_string.find_first_of("/");
+      unsigned source_sep = config_string.find_first_of("/", type_sep + 1);
+
+      vidinput_device.type   = config_string.substr ( 0, type_sep );
+      vidinput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
+      vidinput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    }
 
-    vidinput_device.type   = config_string.substr ( 0, type_sep );
-    vidinput_device.source = config_string.substr ( type_sep + 1, source_sep - type_sep - 1);
-    vidinput_device.device = config_string.substr ( source_sep + 1, config_string.size() - source_sep );
+    if ( (vidinput_device.type == "" )   ||
+         (vidinput_device.source == "")  ||
+         (vidinput_device.device == "" ) ) {
+      PTRACE(1, "VidinputCore\tTried to set malformed device");
+      vidinput_device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
+      vidinput_device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
+      vidinput_device.device = VIDEO_INPUT_FALLBACK_DEVICE_DEVICE;
+    }
+
+    unsigned video_format = gm_conf_get_int (VIDEO_DEVICES_KEY "format");
+    if (video_format >= NumVideoFormats) {
+      PTRACE(1, "VidInputCoreConfBridge\t" << VIDEO_DEVICES_KEY "format" << " out of range, ajusting to 3");
+      video_format = 3;
+    }
 
     vidinput_core.set_vidinput_device (vidinput_device,
                                        gm_conf_get_int (VIDEO_DEVICES_KEY "channel"),
-                                       (VideoFormat) gm_conf_get_int (VIDEO_DEVICES_KEY "format"));
+                                       (VideoFormat) video_format);
   }
   else if (key == VIDEO_DEVICES_KEY "enable_preview") {
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]