TelegramMessenger / tgcalls

GNU Lesser General Public License v3.0
166 stars 106 forks source link

Fix: incorrectly named parameters #12

Open juteman opened 2 years ago

juteman commented 2 years ago

Change two function parameter name to deviceIdkey.

DesktopCaptureSource DesktopCaptureSourceForKey(
    const std::string &uniqueKey);
bool ShouldBeDesktopCapture(const std::string &uniqueKey);

These function parameters has named "uniqueKey".

But in context of VideoCapturerInterfaceImpl, we get

VideoCapturerInterfaceImpl::VideoCapturerInterfaceImpl(
    rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source,
    std::string deviceId,
    std::function<void(VideoState)> stateUpdated,
    std::shared_ptr<PlatformContext> platformContext,
    std::pair<int, int> &outResolution)
: _source(source)
, _sink(GetSink(source))
, _stateUpdated(stateUpdated) {

    if (const auto source = DesktopCaptureSourceForKey(deviceId)) {
        const auto data = DesktopCaptureSourceData{
            /*.aspectSize = */{ 1280, 720 },
            /*.fps = */24.,
            /*.captureMouse = */(deviceId != "desktop_capturer_pipewire"),
        };
        _desktopCapturer = std::make_unique<DesktopCaptureSourceHelper>(
            source,
            data);
        _desktopCapturer->setOutput(_sink);
        _desktopCapturer->start();
        outResolution = { 1280, 960 };
    } else if (!ShouldBeDesktopCapture(deviceId))
    {
        _cameraCapturer = std::make_unique<VideoCameraCapturer>(_sink);
        _cameraCapturer->setDeviceId(deviceId);
        _cameraCapturer->setState(VideoState::Active);
        outResolution = _cameraCapturer->resolution();
    }
}

We pass "device id" to DesktopCaptureSourceForKey(). So this naming is very confusing.