mpromonet / webrtc-streamer

WebRTC streamer for V4L2 capture devices, RTSP sources and Screen Capture
https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/?layout=2x2
The Unlicense
2.8k stars 581 forks source link

The videocap:// & audiocap:// pair from getMediaList may not match #605

Open rouxianmantou opened 12 months ago

rouxianmantou commented 12 months ago

Hello @mpromonet , Thanks again for solving the issue #603 , I met another problem: video & audio capture devices mismatch from getMediaList.

Describe the bug Below are clues I found, but I couldn't figure out solutions by now.

  1. In PeerConnectionManager.cpp, m_videoaudiomap now can pair the videocap:// & audiocap:// correctly.

  2. videocap:// & audiocap:// are from /sys/class/video4linux(or sound)

  3. as for the api 'getMediaList', the list is made of 3 parts: GetVideoCaptureDeviceList, GetVideoSourceList, config.json.

  4. in the 1st part, GetVideoCaptureDeviceList: It will call 'CapturerFactory::GetVideoCaptureDeviceList(...)' to get videocap://n, webrtc::VideoCaptureFactory::CreateDeviceInfo(), DeviceInfoV4l2::DeviceInfoV4l2()

  5. then back to the 1st part of api 'getMediaList'. it tries to find the audiocap:// from m_videoaudiomap.

  6. it find one, maybe videocap://1 => audiocap://1

  7. when we try to setup a stream with media devices from 'getMediaList', {video: videocap://1, audiocap://1, options: options}, it could be a wrong pair.

  8. I guess: the pair comes from m_videoaudiomap, but when connecting, the device name is related to the api 'const Json::Value PeerConnectionManager::getAudioDeviceList()'.

  9. the audiocap://1 in m_videoaudiomap(/sys/class/sound) and audiocap://1 in CapturerFactory::GetAudioCaptureDeviceList(...)(webrtc::AudioDeviceModule::RecordingDevices()) may represent different devices.

  10. Then video & audio doesn't match from api 'getMediaList'.

Screenshots image image image image

Desktop (please complete the following information):

rouxianmantou commented 12 months ago

info + Ubuntu 22.04, Laptop, with: an internal webcam with: an external HDMI-USB capture card plugged in