After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 547140 - resolution preference and gconf key can be ambiguos
resolution preference and gconf key can be ambiguos
Status: RESOLVED FIXED
Product: cheese
Classification: Applications
Component: general
2.23.x
Other Linux
: High normal
: 2.24
Assigned To: Cheese Maintainer(s)
Cheese Maintainer(s)
Depends on: 547144
Blocks:
 
 
Reported: 2008-08-10 07:16 UTC by Filippo Argiolas
Modified: 2008-09-08 22:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Filippo Argiolas 2008-08-10 07:16:09 UTC
Here is what cheese -v says with Logitech cam:

Detected webcam: Logitech QuickCam EC
device: /dev/video0
video/x-raw-yuv 160 x 120 num_framerates 1
25/1 
video/x-raw-yuv 320 x 240 num_framerates 1
25/1 
video/x-raw-yuv 352 x 288 num_framerates 1
25/1 
video/x-raw-yuv 176 x 144 num_framerates 1
25/1 
video/x-raw-rgb 160 x 120 num_framerates 1
25/1 
video/x-raw-rgb 320 x 240 num_framerates 1
25/1 
video/x-raw-rgb 352 x 288 num_framerates 1
25/1 
video/x-raw-rgb 176 x 144 num_framerates 1
25/1 
video/x-raw-rgb 160 x 120 num_framerates 1
25/1 
video/x-raw-rgb 320 x 240 num_framerates 1
25/1 
video/x-raw-rgb 352 x 288 num_framerates 1
25/1 
video/x-raw-rgb 176 x 144 num_framerates 1
25/1 
video/x-raw-rgb 160 x 120 num_framerates 1
25/1 
video/x-raw-rgb 320 x 240 num_framerates 1
25/1 
video/x-raw-rgb 352 x 288 num_framerates 1
25/1 
video/x-raw-rgb 176 x 144 num_framerates 1
25/1 
v4lsrc name=video_source device=/dev/video0 ! capsfilter name=capsfilter caps=video/x-raw-rgb,width=352,height=288,framerate=25/1 ! identity

As you can see there are 16 supported formats.
Each resolution appears 4 times (don't care about repeated rgb formats, it's a related issue but I'm going to open a detailed bug about that).
What we do in cheese_webcam_get_webcam_device_data is insert a resolution entry in the resolution hashtable with a key like widthxheight.
This key is not unique. Several videoformats can have the same "widthxheight".
So if the key already exists in the hashtable it gets replaced (with a leak since we're not setting a DestroyFunc for the values).
This conflicts with the behavior of resolution combobox in preferences dialog which lists all 16 resolutions (with ambiguous repetitions).
So if I select the first occurrence of 352x288 the following format is set:
video/x-raw-yuv 352 x 288
but if I close cheese and reopen it the format is the latter occurrence of gconf resolution in formats array:
video/x-raw-rgb 352 x 288
Comment 1 Filippo Argiolas 2008-08-10 07:21:03 UTC
cc-ing James since he wrote that part and might be interested.
Comment 2 Filippo Argiolas 2008-08-10 07:59:10 UTC
maybe bug #547144 should be solved first.
Comment 3 James Liggett 2008-08-10 23:28:19 UTC
Filippo: Having just taken a look at that bug I concur. I don't see any reason whatsoever for this repetition. I sort of put together the hash table scheme on the assumption that this *wouldn't* happen. Solving that bug should fix this one if I understand correctly. 
Comment 4 Filippo Argiolas 2008-08-11 06:19:28 UTC
>Solving that bug should fix this one if I understand correctly. 
Not completely. That bug is about different formats within the same mimetype.
Solving that is needed but wouldn't automatically solve this because x-raw-yuv and x-raw-rgb mimetype can still provide the same resolutions and we'll still have duplicates.

The only way to solve this, imho, is to save both format and resolution in the hashtable (and in gconf).
The hashtable key could have a format like: "x-raw-yuv@640x480".
 
I'm not sure whether gconf is the right place to save that though.
The user shouldn't be able to set a format/resolution out of the preferences dialog since these are not arbitrary and can have only a few possible values that can vary for each camera.

Furthermore, this setting should be camera specific so having a single gconf key is not the best way to handle it.

Anyway that's another issue.. Avoid duplicates should be enough for now.
Comment 5 Filippo Argiolas 2008-09-08 22:20:08 UTC
Closing, fixed with the patches from bug #547144 and bug #546868.