diff --git a/sflphone-common/src/video/test/test_v4l2.cpp b/sflphone-common/src/video/test/test_v4l2.cpp
index 86799185c1e676da5ec13f9047bdbfc405eaa084..60518af8cbb2d7ebfccef3046f5ab18ad90a8e24 100644
--- a/sflphone-common/src/video/test/test_v4l2.cpp
+++ b/sflphone-common/src/video/test/test_v4l2.cpp
@@ -41,10 +41,14 @@ using namespace sfl_video;
 
 int main()
 {
-    unsigned idx;
+    int idx;
     VideoV4l2List list;
     std::vector<std::string> v = list.getDeviceList();
     idx = list.getDeviceIndex();
+    if (idx < 0) {
+    	cout << "No devices found!" << endl;
+    	return 0;
+    }
     list.setDevice(idx);
 
     size_t i, n = v.size();
diff --git a/sflphone-common/src/video/video_v4l2_list.cpp b/sflphone-common/src/video/video_v4l2_list.cpp
index ec2bc80d5645895a26d4c1064f6e40d11c63d77e..c944309335df2f29ab8a64ef21f7a0e805349b1b 100644
--- a/sflphone-common/src/video/video_v4l2_list.cpp
+++ b/sflphone-common/src/video/video_v4l2_list.cpp
@@ -57,7 +57,7 @@ extern "C" {
 
 namespace sfl_video {
 
-VideoV4l2List::VideoV4l2List() : _currentDevice(0)
+VideoV4l2List::VideoV4l2List() : _currentDevice(-1)
 {
 #ifdef HAVE_UDEV
     struct udev *udev;
@@ -196,6 +196,8 @@ bool VideoV4l2List::addDevice(const std::string &dev)
     VideoV4l2Device v(fd, s);
     GiveUniqueName(v, devices);
     devices.push_back(v);
+    if (_currentDevice < 0)
+    	_currentDevice = 0;
 
     close(fd);
     return true;
@@ -230,7 +232,16 @@ std::vector<std::string> VideoV4l2List::getDeviceList(void)
     return v;
 }
 
-unsigned VideoV4l2List::getDeviceIndex()
+int VideoV4l2List::getDeviceIndex(const std::string &name)
+{
+	for (size_t i = 0; i < devices.size(); i++)
+		if (devices[i].name == name)
+			return i;
+
+	return -1;
+}
+
+int VideoV4l2List::getDeviceIndex()
 {
     return _currentDevice;
 }
diff --git a/sflphone-common/src/video/video_v4l2_list.h b/sflphone-common/src/video/video_v4l2_list.h
index 40c031cc5b5fcabfa13ff40edc6b9e6fa199e617..9e076b8afb979c5d85248cb8af0509d3bf4f8727 100644
--- a/sflphone-common/src/video/video_v4l2_list.h
+++ b/sflphone-common/src/video/video_v4l2_list.h
@@ -43,7 +43,8 @@ class VideoV4l2List {
         VideoV4l2List();
 
         void setDevice(unsigned index);
-        unsigned getDeviceIndex(void);
+        int getDeviceIndex(void);
+        int getDeviceIndex(const std::string &name);
         std::vector<std::string> getDeviceList(void);
         VideoV4l2Device &getDevice(void);
 
@@ -53,7 +54,7 @@ class VideoV4l2List {
          */
         bool addDevice(const std::string &dev);
         std::vector<VideoV4l2Device> devices;
-        unsigned _currentDevice;
+        int _currentDevice;
 };
 
 } // namespace sfl_video