mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Support AirPods Mute/Unmute toggle.
This commit is contained in:
@@ -420,6 +420,14 @@ void Call::actuallyAnswer() {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Call::captureMuteChanged(bool mute) {
|
||||
setMuted(mute);
|
||||
}
|
||||
|
||||
rpl::producer<Webrtc::DeviceResolvedId> Call::captureMuteDeviceId() {
|
||||
return _captureDeviceId.value();
|
||||
}
|
||||
|
||||
void Call::setMuted(bool mute) {
|
||||
_muted = mute;
|
||||
if (_instance) {
|
||||
@@ -1033,6 +1041,20 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
|
||||
raw->setIncomingVideoOutput(_videoIncoming->sink());
|
||||
raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
|
||||
|
||||
_state.value() | rpl::start_with_next([=](State state) {
|
||||
const auto track = (state != State::FailedHangingUp)
|
||||
&& (state != State::Failed)
|
||||
&& (state != State::HangingUp)
|
||||
&& (state != State::Ended)
|
||||
&& (state != State::EndedByOtherDevice)
|
||||
&& (state != State::Busy);
|
||||
Core::App().mediaDevices().setCaptureMuteTracker(this, track);
|
||||
}, _instanceLifetime);
|
||||
|
||||
_muted.value() | rpl::start_with_next([=](bool muted) {
|
||||
Core::App().mediaDevices().setCaptureMuted(muted);
|
||||
}, _instanceLifetime);
|
||||
}
|
||||
|
||||
void Call::handleControllerStateChange(tgcalls::State state) {
|
||||
@@ -1375,6 +1397,9 @@ void Call::handleControllerError(const QString &error) {
|
||||
}
|
||||
|
||||
void Call::destroyController() {
|
||||
_instanceLifetime.destroy();
|
||||
Core::App().mediaDevices().setCaptureMuteTracker(this, false);
|
||||
|
||||
if (_instance) {
|
||||
_instance->stop([](tgcalls::FinalState) {
|
||||
});
|
||||
|
@@ -59,7 +59,9 @@ enum class CallType {
|
||||
Outgoing,
|
||||
};
|
||||
|
||||
class Call : public base::has_weak_ptr {
|
||||
class Call final
|
||||
: public base::has_weak_ptr
|
||||
, private Webrtc::CaptureMuteTracker {
|
||||
public:
|
||||
class Delegate {
|
||||
public:
|
||||
@@ -249,6 +251,9 @@ private:
|
||||
void setSignalBarCount(int count);
|
||||
void destroyController();
|
||||
|
||||
void captureMuteChanged(bool mute) override;
|
||||
rpl::producer<Webrtc::DeviceResolvedId> captureMuteDeviceId() override;
|
||||
|
||||
void setupMediaDevices();
|
||||
void setupOutgoingVideo();
|
||||
void updateRemoteMediaState(
|
||||
@@ -298,6 +303,7 @@ private:
|
||||
|
||||
std::unique_ptr<Media::Audio::Track> _waitingTrack;
|
||||
|
||||
rpl::lifetime _instanceLifetime;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
@@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/random.h"
|
||||
#include "webrtc/webrtc_video_track.h"
|
||||
#include "webrtc/webrtc_create_adm.h"
|
||||
#include "webrtc/webrtc_environment.h"
|
||||
|
||||
#include <tgcalls/group/GroupInstanceCustomImpl.h>
|
||||
#include <tgcalls/VideoCaptureInterface.h>
|
||||
@@ -667,6 +668,8 @@ GroupCall::GroupCall(
|
||||
GroupCall::~GroupCall() {
|
||||
destroyScreencast();
|
||||
destroyController();
|
||||
|
||||
Core::App().mediaDevices().setCaptureMuteTracker(this, false);
|
||||
}
|
||||
|
||||
bool GroupCall::isSharingScreen() const {
|
||||
@@ -2087,6 +2090,32 @@ void GroupCall::setupMediaDevices() {
|
||||
}) | rpl::start_with_next([=](const Webrtc::DeviceResolvedId &deviceId) {
|
||||
_cameraCapture->switchToDevice(deviceId.value.toStdString(), false);
|
||||
}, _lifetime);
|
||||
|
||||
_muted.value() | rpl::start_with_next([=](MuteState state) {
|
||||
const auto devices = &Core::App().mediaDevices();
|
||||
const auto muted = (state != MuteState::Active)
|
||||
&& (state != MuteState::PushToTalk);
|
||||
const auto track = !muted || (state == MuteState::Muted);
|
||||
devices->setCaptureMuteTracker(this, track);
|
||||
devices->setCaptureMuted(muted);
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void GroupCall::captureMuteChanged(bool mute) {
|
||||
const auto oldState = muted();
|
||||
if (mute
|
||||
&& (oldState == MuteState::ForceMuted
|
||||
|| oldState == MuteState::RaisedHand
|
||||
|| oldState == MuteState::Muted)) {
|
||||
return;
|
||||
} else if (!mute && oldState != MuteState::Muted) {
|
||||
return;
|
||||
}
|
||||
setMutedAndUpdate(mute ? MuteState::Muted : MuteState::Active);
|
||||
}
|
||||
|
||||
rpl::producer<Webrtc::DeviceResolvedId> GroupCall::captureMuteDeviceId() {
|
||||
return _captureDeviceId.value();
|
||||
}
|
||||
|
||||
int GroupCall::activeVideoSendersCount() const {
|
||||
|
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/bytes.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "mtproto/mtproto_auth_key.h"
|
||||
#include "webrtc/webrtc_device_common.h"
|
||||
#include "webrtc/webrtc_device_resolver.h"
|
||||
|
||||
class History;
|
||||
@@ -175,7 +176,9 @@ struct ParticipantVideoParams;
|
||||
[[nodiscard]] uint32 GetAdditionalAudioSsrc(
|
||||
const std::shared_ptr<ParticipantVideoParams> ¶ms);
|
||||
|
||||
class GroupCall final : public base::has_weak_ptr {
|
||||
class GroupCall final
|
||||
: public base::has_weak_ptr
|
||||
, private Webrtc::CaptureMuteTracker {
|
||||
public:
|
||||
class Delegate {
|
||||
public:
|
||||
@@ -550,6 +553,9 @@ private:
|
||||
void applySelfUpdate(const MTPDgroupCallParticipant &data);
|
||||
void applyOtherParticipantUpdate(const MTPDgroupCallParticipant &data);
|
||||
|
||||
void captureMuteChanged(bool mute) override;
|
||||
rpl::producer<Webrtc::DeviceResolvedId> captureMuteDeviceId() override;
|
||||
|
||||
void setupMediaDevices();
|
||||
void setupOutgoingVideo();
|
||||
void setScreenEndpoint(std::string endpoint);
|
||||
|
Submodule Telegram/lib_webrtc updated: 5493af61df...1cbf5fa7d8
Reference in New Issue
Block a user