mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 15:15:13 +00:00
Use audio device enumeration from lib_webrtc.
This commit is contained in:
@@ -24,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "calls/calls_panel.h"
|
||||
#include "webrtc/webrtc_video_track.h"
|
||||
#include "webrtc/webrtc_camera_utilities.h"
|
||||
#include "webrtc/webrtc_media_devices.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "facades.h"
|
||||
@@ -350,7 +350,7 @@ void Call::setupOutgoingVideo() {
|
||||
_videoOutgoing->stateValue(
|
||||
) | rpl::start_with_next([=](Webrtc::VideoState state) {
|
||||
if (state != Webrtc::VideoState::Inactive
|
||||
&& Webrtc::GetCamerasList().empty()) {
|
||||
&& Webrtc::GetVideoInputList().empty()) {
|
||||
_videoOutgoing->setState(Webrtc::VideoState::Inactive);
|
||||
} else if (_state.current() != State::Established
|
||||
&& state != started
|
||||
@@ -710,6 +710,8 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
auto encryptionKeyValue = std::make_shared<std::array<uint8_t, 256>>();
|
||||
memcpy(encryptionKeyValue->data(), _authKey.data(), 256);
|
||||
|
||||
const auto &settings = Core::App().settings();
|
||||
|
||||
const auto weak = base::make_weak(this);
|
||||
tgcalls::Descriptor descriptor = {
|
||||
.config = tgcalls::Config{
|
||||
@@ -726,6 +728,12 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
.encryptionKey = tgcalls::EncryptionKey(
|
||||
std::move(encryptionKeyValue),
|
||||
(_type == Type::Outgoing)),
|
||||
.mediaDevicesConfig = tgcalls::MediaDevicesConfig{
|
||||
.audioInputId = settings.callInputDeviceID().toStdString(),
|
||||
.audioOutputId = settings.callOutputDeviceID().toStdString(),
|
||||
.inputVolume = settings.callInputVolume() / 100.f,
|
||||
.outputVolume = settings.callOutputVolume() / 100.f,
|
||||
},
|
||||
.videoCapture = _videoCapture,
|
||||
.stateUpdated = [=](tgcalls::State state) {
|
||||
crl::on_main(weak, [=] {
|
||||
@@ -810,14 +818,6 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
|
||||
}
|
||||
|
||||
raw->setIncomingVideoOutput(_videoIncoming->sink());
|
||||
|
||||
const auto &settings = Core::App().settings();
|
||||
raw->setAudioOutputDevice(
|
||||
settings.callOutputDeviceID().toStdString());
|
||||
raw->setAudioInputDevice(
|
||||
settings.callInputDeviceID().toStdString());
|
||||
raw->setOutputVolume(settings.callOutputVolume() / 100.0f);
|
||||
raw->setInputVolume(settings.callInputVolume() / 100.0f);
|
||||
raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
|
||||
}
|
||||
|
||||
|
@@ -176,13 +176,17 @@ public:
|
||||
_autoLock = value;
|
||||
}
|
||||
[[nodiscard]] QString callOutputDeviceID() const {
|
||||
return _callOutputDeviceID;
|
||||
return _callOutputDeviceID.isEmpty()
|
||||
? u"default"_q
|
||||
: _callOutputDeviceID;
|
||||
}
|
||||
void setCallOutputDeviceID(const QString &value) {
|
||||
_callOutputDeviceID = value;
|
||||
}
|
||||
[[nodiscard]] QString callInputDeviceID() const {
|
||||
return _callInputDeviceID;
|
||||
return _callInputDeviceID.isEmpty()
|
||||
? u"default"_q
|
||||
: _callInputDeviceID;
|
||||
}
|
||||
void setCallInputDeviceID(const QString &value) {
|
||||
_callInputDeviceID = value;
|
||||
|
@@ -593,6 +593,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
||||
if (type == SystemSettingsType::Audio) {
|
||||
crl::on_main([] {
|
||||
WinExec("control.exe mmsys.cpl", SW_SHOW);
|
||||
//QDesktopServices::openUrl(QUrl("ms-settings:sound"));
|
||||
});
|
||||
}
|
||||
return true;
|
||||
|
@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "webrtc/webrtc_media_devices.h"
|
||||
#include "facades.h"
|
||||
|
||||
#ifdef slots
|
||||
@@ -68,10 +69,10 @@ void Calls::setupContent() {
|
||||
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
const auto getId = [](const auto &device) {
|
||||
return QString::fromStdString(device.id);
|
||||
return device.id;
|
||||
};
|
||||
const auto getName = [](const auto &device) {
|
||||
return QString::fromStdString(device.displayName);
|
||||
return device.name;
|
||||
};
|
||||
|
||||
const auto &settings = Core::App().settings();
|
||||
@@ -79,7 +80,7 @@ void Calls::setupContent() {
|
||||
if (settings.callOutputDeviceID() == qsl("default")) {
|
||||
return tr::lng_settings_call_device_default(tr::now);
|
||||
}
|
||||
const auto &list = VoIP::EnumerateAudioOutputs();
|
||||
const auto list = Webrtc::GetAudioOutputList();
|
||||
const auto i = ranges::find(
|
||||
list,
|
||||
settings.callOutputDeviceID(),
|
||||
@@ -93,7 +94,7 @@ void Calls::setupContent() {
|
||||
if (settings.callInputDeviceID() == qsl("default")) {
|
||||
return tr::lng_settings_call_device_default(tr::now);
|
||||
}
|
||||
const auto &list = VoIP::EnumerateAudioInputs();
|
||||
const auto list = Webrtc::GetAudioInputList();
|
||||
const auto i = ranges::find(
|
||||
list,
|
||||
settings.callInputDeviceID(),
|
||||
@@ -115,7 +116,7 @@ void Calls::setupContent() {
|
||||
),
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
const auto &devices = VoIP::EnumerateAudioOutputs();
|
||||
const auto &devices = Webrtc::GetAudioOutputList();
|
||||
const auto options = ranges::view::concat(
|
||||
ranges::view::single(tr::lng_settings_call_device_default(tr::now)),
|
||||
devices | ranges::view::transform(getName)
|
||||
@@ -132,11 +133,10 @@ void Calls::setupContent() {
|
||||
const auto deviceId = option
|
||||
? devices[option - 1].id
|
||||
: "default";
|
||||
Core::App().settings().setCallOutputDeviceID(
|
||||
QString::fromStdString(deviceId));
|
||||
Core::App().settings().setCallOutputDeviceID(deviceId);
|
||||
Core::App().saveSettingsDelayed();
|
||||
if (const auto call = Core::App().calls().currentCall()) {
|
||||
call->setCurrentAudioDevice(false, deviceId);
|
||||
call->setCurrentAudioDevice(false, deviceId.toStdString());
|
||||
}
|
||||
});
|
||||
Ui::show(Box<SingleChoiceBox>(
|
||||
@@ -171,7 +171,7 @@ void Calls::setupContent() {
|
||||
};
|
||||
outputSlider->resize(st::settingsAudioVolumeSlider.seekSize);
|
||||
outputSlider->setPseudoDiscrete(
|
||||
201,
|
||||
101,
|
||||
[](int val) { return val; },
|
||||
settings.callOutputVolume(),
|
||||
updateOutputVolume);
|
||||
@@ -191,7 +191,7 @@ void Calls::setupContent() {
|
||||
),
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
const auto &devices = VoIP::EnumerateAudioInputs();
|
||||
const auto devices = Webrtc::GetAudioInputList();
|
||||
const auto options = ranges::view::concat(
|
||||
ranges::view::single(tr::lng_settings_call_device_default(tr::now)),
|
||||
devices | ranges::view::transform(getName)
|
||||
@@ -208,14 +208,13 @@ void Calls::setupContent() {
|
||||
const auto deviceId = option
|
||||
? devices[option - 1].id
|
||||
: "default";
|
||||
Core::App().settings().setCallInputDeviceID(
|
||||
QString::fromStdString(deviceId));
|
||||
Core::App().settings().setCallInputDeviceID(deviceId);
|
||||
Core::App().saveSettingsDelayed();
|
||||
if (_micTester) {
|
||||
stopTestingMicrophone();
|
||||
}
|
||||
if (const auto call = Core::App().calls().currentCall()) {
|
||||
call->setCurrentAudioDevice(true, deviceId);
|
||||
call->setCurrentAudioDevice(true, deviceId.toStdString());
|
||||
}
|
||||
});
|
||||
Ui::show(Box<SingleChoiceBox>(
|
||||
|
2
Telegram/ThirdParty/libtgvoip
vendored
2
Telegram/ThirdParty/libtgvoip
vendored
Submodule Telegram/ThirdParty/libtgvoip updated: 6e82b6e456...7563a96b8f
2
Telegram/ThirdParty/tgcalls
vendored
2
Telegram/ThirdParty/tgcalls
vendored
Submodule Telegram/ThirdParty/tgcalls updated: 3e4c5e2c23...c6c78d6872
@@ -170,6 +170,8 @@ remove_target_sources(lib_tgcalls ${tgcalls_loc}
|
||||
platform/android/VideoCameraCapturer.h
|
||||
platform/android/VideoCapturerInterfaceImpl.cpp
|
||||
platform/android/VideoCapturerInterfaceImpl.h
|
||||
reference/InstanceImplReference.cpp
|
||||
reference/InstanceImplReference.h
|
||||
)
|
||||
|
||||
target_include_directories(lib_tgcalls
|
||||
|
Submodule Telegram/lib_webrtc updated: 4d0f0b8ef4...32957e8559
Reference in New Issue
Block a user