Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions Telegram/SourceFiles/calls/calls_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,12 @@ rpl::producer<Webrtc::DeviceResolvedId> Call::captureMuteDeviceId() {

void Call::setMuted(bool mute) {
_muted = mute;
if (_instance) {
if (_screenWithAudio && _screenAudioControl) {
_screenAudioControl->setMicrophoneMuted(mute);
if (_instance) {
_instance->setMuteMicrophone(false);
}
} else if (_instance) {
_instance->setMuteMicrophone(mute);
}
}
Expand Down Expand Up @@ -1187,9 +1192,13 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
sendSignalingData(bytes);
});
},
.createAudioDeviceModule = Webrtc::AudioDeviceModuleCreator(
saveSetDeviceIdCallback),
};

_screenAudioControl = std::make_shared<Webrtc::MixingAudioControl>();
descriptor.createAudioDeviceModule
= Webrtc::MixingAudioDeviceModuleCreator(
Webrtc::AudioDeviceModuleCreator(saveSetDeviceIdCallback),
_screenAudioControl);
if (Logs::DebugEnabled()) {
const auto callLogFolder = cWorkingDir() + u"DebugLogs"_q;
const auto callLogPath = callLogFolder + u"/last_call_log.txt"_q;
Expand Down Expand Up @@ -1493,6 +1502,13 @@ void Call::toggleScreenSharing(
}
_videoCaptureDeviceId = QString();
_videoCaptureIsScreencast = false;
if (_screenWithAudio && _screenAudioControl) {
_screenAudioControl->setMicrophoneMuted(false);
_screenAudioControl->setLoopbackEnabled(false);
if (_muted.current() && _instance) {
_instance->setMuteMicrophone(true);
}
}
_screenWithAudio = false;
if (_systemAudioCapture) {
_systemAudioCapture->stop();
Expand All @@ -1507,6 +1523,15 @@ void Call::toggleScreenSharing(
_videoCaptureIsScreencast = true;
_videoCaptureDeviceId = *uniqueId;
_screenWithAudio = withAudio;
if (_screenAudioControl) {
_screenAudioControl->setLoopbackEnabled(withAudio);
if (withAudio && _muted.current()) {
_screenAudioControl->setMicrophoneMuted(true);
if (_instance) {
_instance->setMuteMicrophone(false);
}
}
}
if (_videoCapture) {
_videoCapture->switchToDevice(uniqueId->toStdString(), true);
if (_instance) {
Expand Down Expand Up @@ -1695,6 +1720,7 @@ void Call::handleControllerError(const QString &error) {
}

void Call::destroyController() {
_screenAudioControl = nullptr;
_instanceLifetime.destroy();
Core::App().mediaDevices().setCaptureMuteTracker(this, false);
if (_systemAudioCapture) {
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/calls/calls_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Webrtc {
enum class VideoState;
class VideoTrack;
struct DeviceResolvedId;
class MixingAudioControl;
} // namespace Webrtc

namespace Calls {
Expand Down Expand Up @@ -387,6 +388,7 @@ class Call final
std::vector<not_null<PeerData*>> _conferenceParticipants;

std::unique_ptr<tgcalls::Instance> _instance;
std::shared_ptr<Webrtc::MixingAudioControl> _screenAudioControl;
std::shared_ptr<tgcalls::VideoCaptureInterface> _videoCapture;
QString _videoCaptureDeviceId;
bool _videoCaptureIsScreencast = false;
Expand Down
2 changes: 1 addition & 1 deletion Telegram/lib_webrtc
Loading