Camera - emulator - can't open real camera, "Camera device '/dev/video0' is in use"

RESOLVED FIXED

Status

Firefox OS
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: mikeh, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Created attachment 718082 [details] [diff] [review]
Patch to use real camera in emulator

The attached patch is supposed to allow the b2g emulator to use real camera hardware, if present on the host system.

On a Lenovo Thinkpad X220 running Ubuntu 12.10 x86_64, the laptop's webcam shows up as /dev/video0 and works in other applications (e.g. Skype); but on starting the emulator and opening the camera app, the following error is emitted:

emulator: ERROR: _camera_client_create: Camera device '/dev/video0' is in use

Various commands[1] show that no one seems to have /dev/video0 open.

1. http://superuser.com/questions/97844/how-can-i-determine-what-process-has-a-file-open-in-linux
It looks like on Ubuntu 12.10, users are created without belonging to the 'video' group, which is required to access /dev/video0.  The following command addresses this issue:

# sudo usermod -a -G video <userid>

With that done, logcat shows the following:

D(  281:0x119) Emulated camera list: name=/dev/video0 channel=0 pix=1448695129 dir=back framedims=640x480,640x360,352x288,320x240,800x448,960x544,1280x720,424x240
V(  281:0x119) Initialize:
V(  281:0x119)    Name=/dev/video0
V(  281:0x119)    Facing 'back'
V(  281:0x119)    Dimensions=640x480,640x360,352x288,320x240,800x448,960x544,1280x720,424x240
E(  281:0x119) connectClient: Unable to connect to the camera service 'name=/dev/video0': Invalid argument
D(  281:0x119) Initialize: Fake camera is facing none
V(  281:0x119) 1 cameras are being emulated. Fake camera ID is 0
I(  281:0x119) 1074238600[42607160]: getListOfCameras : get_number_of_cameras() returned 1

sotaro, any chance your patch(es) in bug 803471 will address not being able to connect to the camera service?
Flags: needinfo?(sotaro.ikeda.g)
(In reply to Mike Habicher [:mikeh] from comment #1)
> 
> sotaro, any chance your patch(es) in bug 803471 will address not being able
> to connect to the camera service?

After applying the patch, it works!!! And preview screen is rendered correctly.
Flags: needinfo?(sotaro.ikeda.g)
(In reply to Sotaro Ikeda [:sotaro] from comment #2)
> (In reply to Mike Habicher [:mikeh] from comment #1)
> > 
> > sotaro, any chance your patch(es) in bug 803471 will address not being able
> > to connect to the camera service?
> 
> After applying the patch, it works!!! And preview screen is rendered
> correctly.

PC camera's video is rendered on preview. And a taken picture is also image from PC's camera.
(In reply to Sotaro Ikeda [:sotaro] from comment #2)
> 
> After applying the patch, it works!!! And preview screen is rendered
> correctly.

\o/ \o/ \o/ \o/ \o/ \o/ \o/

We should get your patch landed.  :)
Depends on: 803471
Created attachment 723949 [details]
Link to github.com pull request
Attachment #718082 - Attachment is obsolete: true
Attachment #723949 - Flags: review?(mwu)

Updated

5 years ago
Attachment #723949 - Flags: review?(mwu) → review+

Comment 6

5 years ago
Merged.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.