Closed Bug 809554 Opened 12 years ago Closed 12 years ago

Use device name as fallback if capture device doesn't provide uniqueId

Categories

(Core :: WebRTC, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla19

People

(Reporter: ted, Assigned: ted)

References

(Blocks 1 open bug)

Details

(Whiteboard: [getUserMedia], [blocking-gum+])

Attachments

(1 file, 2 obsolete files)

The Linux video code currently uses v4l2_capability::bus_id as the unique ID when enumerating devices. If you have a device that doesn't fill this field in you can't actually use it. I saw this with the v4l2loopback driver that provides a fake video device. This patch makes the code fall back to using the device name if the bus_info field isn't present, which makes things work. I also sent a pull request upstream to v4l2loopback to fill in this field.
Attached patch Replace empty uniqueId's with deviceName (obsolete) (deleted) — Splinter Review
Still unresolved is verifying if the name is unique; we could add an integer to it, for example. Because we're using the uuid as a hash key, we may need it to be really unique; we could also check for a collision first. Mac and Linux don't even try to set the uniqueId for audio devices, which was causing all audio devices to have the same name
FYI, my patch is an alternate to Ted's, but it covers audio as well and doesn't need to be upstreamed (though we can submit a Issue to webrtc.org as well)
with the audio issues this is blocking
Priority: -- → P1
Summary: Use device filename as fallback if v4l device doesn't provide bus_info → Use device name as fallback if capture device doesn't provide uniqueId
Whiteboard: [getUserMedia], [blocking-gum+]
Comment on attachment 680908 [details] [diff] [review] Replace empty uniqueId's with deviceName Including ted mostly to verify this fixes his original problem. Note that devicename and uniqueId are the same length and there are asserts to that in the tree.
Attachment #680908 - Flags: review?(tterribe)
Attachment #680908 - Flags: review?(ted)
Comment on attachment 680908 [details] [diff] [review] Replace empty uniqueId's with deviceName Review of attachment 680908 [details] [diff] [review]: ----------------------------------------------------------------- I'll r+ this as-is, as it does improve the situation, but this code is busted and needs additional follow-up work. > Note that devicename and uniqueId are the same length and there are asserts > to that in the tree. This is not true in the video case. The kMaxDeviceNameLength half the size of kMaxUniqueIdLength (which, in this case, is safe). I don't see what asserts you're talking about. ::: content/media/webrtc/MediaEngineWebRTC.cpp @@ +110,5 @@ > #endif > > + if (uniqueId[0] == '\0') { > + // In case a device doesn't set uniqueId! > + strcpy(uniqueId,deviceName); This is dangerous if the GetCaptureDevice() call fails. You don't know what's in deviceName in that case. For example, the Windows video capture driver passes that pointer directly to WideCharToMultiByte(), and it is not at all clear to me from reading the documentation of that function that it will NUL-terminate the string even when it fails due to an insufficient buffer size. Inside the #ifdef DEBUG we check for an error, log it, and continue. I think we should be doing something like that even in non-DEBUG builds. @@ +177,5 @@ > ptrVoEHw->GetRecordingDeviceName(i, deviceName, uniqueId); > + LOG((" Capture Device Index %d, Name %s Uuid %s", i, deviceName, uniqueId)); > + if (uniqueId[0] == '\0') { > + // Mac and Linux don't set uniqueId! > + strcpy(uniqueId,deviceName); Same problem as above, except now we're not even checking the error return in the DEBUG case.
Attachment #680908 - Flags: review?(tterribe) → review+
Attachment #680908 - Attachment is obsolete: true
Attachment #680908 - Flags: review?(ted)
Comment on attachment 681012 [details] [diff] [review] if a device has no uniqueId, use the name The first patch was a quickie for audio, which has asserts in the webrtc code. I extended it for video and didn't check asserts there. Added error check to audio as well.
Attachment #681012 - Flags: review?(tterribe)
Attachment #681012 - Flags: review?(ted)
Comment on attachment 681012 [details] [diff] [review] if a device has no uniqueId, use the name Review of attachment 681012 [details] [diff] [review]: ----------------------------------------------------------------- We probably still need to do some follow-up investigation to see what we need to do to handle multiple devices with the same name and hotplugged devices. There's some code that explicitly looks up the uuid in a hash table and re-uses it if already there (though it still adds the duplicate to the list: this is what you were seeing originally). But it also passes the loop index in that list. So any devices with duplicate names (if that's possible) will still appear multiple times in the list and all use the first one. Meanwhile hotplugging might invalidate the indices. So I'm not sure this code handles either case the way it should.
Attachment #681012 - Flags: review?(tterribe) → review+
Comment on attachment 681012 [details] [diff] [review] if a device has no uniqueId, use the name I think we just need derf's review here. Ted, please let us know if this fixes your issue as well. We can spin off bugs for remaining issues.
Attachment #681012 - Flags: review?(ted)
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Can't exactly tell if this can be verified from an end-user perspective or not. Sounds like it's possible, but I'm not sure. Randell - Can you clarify?
Flags: needinfo?(rjesup)
Whiteboard: [getUserMedia], [blocking-gum+] → [getUserMedia], [blocking-gum+], [qa?]
Yes. Verify if you see different audio devices offered (with different names) on Mac and Linux. Also try Ted's fake webcam driver for linux.
Flags: needinfo?(rjesup)
Keywords: verifyme
Whiteboard: [getUserMedia], [blocking-gum+], [qa?] → [getUserMedia], [blocking-gum+]
(In reply to Randell Jesup [:jesup] from comment #15) > Yes. Verify if you see different audio devices offered (with different > names) on Mac and Linux. Also try Ted's fake webcam driver for linux. On Mac with 3 different input devices attached, I end up seeing 4 input devices - 3 of the devices attached and 1 duplicated off of the default input device. I'll test this on linux as well.
(In reply to Jason Smith [:jsmith] from comment #16) > (In reply to Randell Jesup [:jesup] from comment #15) > > Yes. Verify if you see different audio devices offered (with different > > names) on Mac and Linux. Also try Ted's fake webcam driver for linux. > > On Mac with 3 different input devices attached, I end up seeing 4 input > devices - 3 of the devices attached and 1 duplicated off of the default > input device. > > I'll test this on linux as well. Yikes. Linux umm....looks wrong? I'm getting somewhere along the lines of 20+ input devices listed off of Ubuntu 12 machine, all of which do not have the device name listed. Err...what's going on here? Same issue or new bug?
Flags: needinfo?(rjesup)
Keywords: verifyme
Whiteboard: [getUserMedia], [blocking-gum+] → [getUserMedia], [blocking-gum+] [qa verification blocked]
That's actually "normal" on Linux because of how it exports audio devices. I'm looking at ways to collapse the list. I have around 18 devices shown, many of which are not openable
Flags: needinfo?(rjesup)
Going to retest on Chrome for comparison.
Keywords: verifyme
Whiteboard: [getUserMedia], [blocking-gum+] [qa verification blocked] → [getUserMedia], [blocking-gum+]
So the mac piece looks to be expected - Chrome does the same behavior as us.
Linux does not - chrome actually provides descriptions of each variable device involved, where as our implementation uses "default" with no device name. In Chrome, I saw my integrated mic broken down into 5 areas, the USB mic had six. Each started with their unique mic device name followed by some extra piece. I'm filing a followup bug for the linux issue. Marking as verified for now, although there's a followup needed.
Filed bug 813382 as the followup.
Status: RESOLVED → VERIFIED
Keywords: verifyme
If we could fake the devices, we might be able to automate this. Although as it stands in the current framework, we don't have this ability. Putting in-testsuite- for now, although if device faking becomes possible at some point, then we should re-evaluate this one for a test.
Flags: in-testsuite-
Attachment #679290 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: