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