Start using media device manager from lib_webrtc.
This commit is contained in:
parent
c5ad7c7c89
commit
e73b522411
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_group_call.h"
|
#include "data/data_group_call.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "base/global_shortcuts.h"
|
#include "base/global_shortcuts.h"
|
||||||
|
#include "webrtc/webrtc_media_devices.h"
|
||||||
|
|
||||||
#include <tgcalls/group/GroupInstanceImpl.h>
|
#include <tgcalls/group/GroupInstanceImpl.h>
|
||||||
|
|
||||||
|
@ -44,6 +45,14 @@ constexpr auto kCheckJoinedTimeout = 4 * crl::time(1000);
|
||||||
constexpr auto kUpdateSendActionEach = crl::time(500);
|
constexpr auto kUpdateSendActionEach = crl::time(500);
|
||||||
constexpr auto kPlayConnectingEach = crl::time(1056) + 2 * crl::time(1000);
|
constexpr auto kPlayConnectingEach = crl::time(1056) + 2 * crl::time(1000);
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<Webrtc::MediaDevices> CreateMediaDevices() {
|
||||||
|
const auto &settings = Core::App().settings();
|
||||||
|
return Webrtc::CreateMediaDevices(
|
||||||
|
settings.callInputDeviceId(),
|
||||||
|
settings.callOutputDeviceId(),
|
||||||
|
settings.callVideoInputDeviceId());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
GroupCall::GroupCall(
|
GroupCall::GroupCall(
|
||||||
|
@ -57,7 +66,8 @@ GroupCall::GroupCall(
|
||||||
, _lastSpokeCheckTimer([=] { checkLastSpoke(); })
|
, _lastSpokeCheckTimer([=] { checkLastSpoke(); })
|
||||||
, _checkJoinedTimer([=] { checkJoined(); })
|
, _checkJoinedTimer([=] { checkJoined(); })
|
||||||
, _pushToTalkCancelTimer([=] { pushToTalkCancel(); })
|
, _pushToTalkCancelTimer([=] { pushToTalkCancel(); })
|
||||||
, _connectingSoundTimer([=] { playConnectingSoundOnce(); }) {
|
, _connectingSoundTimer([=] { playConnectingSoundOnce(); })
|
||||||
|
, _mediaDevices(CreateMediaDevices()) {
|
||||||
_muted.value(
|
_muted.value(
|
||||||
) | rpl::combine_previous(
|
) | rpl::combine_previous(
|
||||||
) | rpl::start_with_next([=](MuteState previous, MuteState state) {
|
) | rpl::start_with_next([=](MuteState previous, MuteState state) {
|
||||||
|
@ -83,6 +93,22 @@ GroupCall::GroupCall(
|
||||||
} else {
|
} else {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_mediaDevices->audioInputId(
|
||||||
|
) | rpl::start_with_next([=](QString id) {
|
||||||
|
_audioInputId = id;
|
||||||
|
if (_instance) {
|
||||||
|
_instance->setAudioInputDevice(id.toStdString());
|
||||||
|
}
|
||||||
|
}, _lifetime);
|
||||||
|
|
||||||
|
_mediaDevices->audioOutputId(
|
||||||
|
) | rpl::start_with_next([=](QString id) {
|
||||||
|
_audioOutputId = id;
|
||||||
|
if (_instance) {
|
||||||
|
_instance->setAudioOutputDevice(id.toStdString());
|
||||||
|
}
|
||||||
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupCall::~GroupCall() {
|
GroupCall::~GroupCall() {
|
||||||
|
@ -553,8 +579,8 @@ void GroupCall::createAndStartController() {
|
||||||
}
|
}
|
||||||
crl::on_main(weak, [=] { audioLevelsUpdated(data); });
|
crl::on_main(weak, [=] { audioLevelsUpdated(data); });
|
||||||
},
|
},
|
||||||
.initialInputDeviceId = settings.callInputDeviceId().toStdString(),
|
.initialInputDeviceId = _audioInputId.toStdString(),
|
||||||
.initialOutputDeviceId = settings.callOutputDeviceId().toStdString(),
|
.initialOutputDeviceId = _audioOutputId.toStdString(),
|
||||||
};
|
};
|
||||||
if (Logs::DebugEnabled()) {
|
if (Logs::DebugEnabled()) {
|
||||||
auto callLogFolder = cWorkingDir() + qsl("DebugLogs");
|
auto callLogFolder = cWorkingDir() + qsl("DebugLogs");
|
||||||
|
@ -574,6 +600,7 @@ void GroupCall::createAndStartController() {
|
||||||
LOG(("Call Info: Creating group instance"));
|
LOG(("Call Info: Creating group instance"));
|
||||||
_instance = std::make_unique<tgcalls::GroupInstanceImpl>(
|
_instance = std::make_unique<tgcalls::GroupInstanceImpl>(
|
||||||
std::move(descriptor));
|
std::move(descriptor));
|
||||||
|
|
||||||
updateInstanceMuteState();
|
updateInstanceMuteState();
|
||||||
|
|
||||||
//raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
|
//raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
|
||||||
|
@ -740,13 +767,10 @@ void GroupCall::sendMutedUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::setCurrentAudioDevice(bool input, const QString &deviceId) {
|
void GroupCall::setCurrentAudioDevice(bool input, const QString &deviceId) {
|
||||||
if (_instance) {
|
if (input) {
|
||||||
const auto id = deviceId.toStdString();
|
_mediaDevices->switchToAudioInput(deviceId);
|
||||||
if (input) {
|
} else {
|
||||||
_instance->setAudioInputDevice(id);
|
_mediaDevices->switchToAudioOutput(deviceId);
|
||||||
} else {
|
|
||||||
_instance->setAudioOutputDevice(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@ class GlobalShortcutManager;
|
||||||
class GlobalShortcutValue;
|
class GlobalShortcutValue;
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
namespace Webrtc {
|
||||||
|
class MediaDevices;
|
||||||
|
} // namespace Webrtc
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct LastSpokeTimes;
|
struct LastSpokeTimes;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
@ -205,6 +209,10 @@ private:
|
||||||
base::Timer _connectingSoundTimer;
|
base::Timer _connectingSoundTimer;
|
||||||
bool _hadJoinedState = false;
|
bool _hadJoinedState = false;
|
||||||
|
|
||||||
|
std::unique_ptr<Webrtc::MediaDevices> _mediaDevices;
|
||||||
|
QString _audioInputId;
|
||||||
|
QString _audioOutputId;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0ed2a6cc048e30ee8bacf7212f3f12f4f7ae2b5a
|
Subproject commit beb63dd9a68662cf96c4b3b165bad3907323ea89
|
Loading…
Reference in New Issue