Skip to content

Conversation

@MHTBeelal
Copy link

Description

This PR improves webcam initialization on Linux when starting video message recording.

Some USB webcams (notably devices exposing both RGB and IR entries, e.g. Lenovo 510) take longer to initialize or expose multiple device names (… I / … R). Telegram Desktop may time out or select the IR entry first, causing “Could not start video recording. Please check your camera.” even though the camera works correctly.

Changes

  • Add a small retry/backoff when creating VideoCaptureInterface to tolerate slower camera startup
  • Try safe device-name fallbacks before giving up (prefer RGB / non-IR variants when available)
  • Keep existing behavior for explicitly selected devices.

Results:
NOT TESTED YET

@CLAassistant
Copy link

CLAassistant commented Dec 16, 2025

CLA assistant check
All committers have signed the CLA.

if (s.empty()) {
// empty means "default" — keep it as the first option if nothing else
// but avoid duplicate empties
if (std::find(candidates.begin(), candidates.end(), std::string()) == candidates.end())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ranges::find

// Build candidate device IDs: original first, then simple heuristics to
// prefer non-IR / RGB variants (common naming pattern: "... I" vs "... R",
// or "IR" tokens). These heuristics are intentionally conservative.
const std::string base = startDeviceId.toStdString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto ...

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Dec 17, 2025

Results:
NOT TESTED YET

Please report back when you test, most likely the code has to be moved to lib_webrtc, that's where the logic of creating the camera list resides

@MHTBeelal
Copy link
Author

MHTBeelal commented Dec 19, 2025

Results:
NOT TESTED YET

Please report back when you test, most likely the code has to be moved to lib_webrtc, that's where the logic of creating the camera list resides

Sorry I am replying really late, I am not able to build the telegram on my machine because I am really confused about getting the API access to build and test the program! I tried to submit my application but there was an error which I don't know. can you please help me with that???

@ilya-fedin
Copy link
Contributor

Use -D TDESKTOP_API_TEST=ON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants