settings_calls.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "settings/settings_common_session.h"
  9. #include "ui/effects/animations.h"
  10. #include "base/timer.h"
  11. namespace style {
  12. struct Checkbox;
  13. struct Radio;
  14. } // namespace style
  15. namespace Calls {
  16. class Call;
  17. } // namespace Calls
  18. namespace Ui {
  19. class LevelMeter;
  20. class GenericBox;
  21. class Show;
  22. } // namespace Ui
  23. namespace Webrtc {
  24. class AudioInputTester;
  25. class VideoTrack;
  26. } // namespace Webrtc
  27. namespace Settings {
  28. class Calls : public Section<Calls> {
  29. public:
  30. Calls(QWidget *parent, not_null<Window::SessionController*> controller);
  31. ~Calls();
  32. [[nodiscard]] rpl::producer<QString> title() override;
  33. void sectionSaveChanges(FnMut<void()> done) override;
  34. static Webrtc::VideoTrack *AddCameraSubsection(
  35. std::shared_ptr<Ui::Show> show,
  36. not_null<Ui::VerticalLayout*> content,
  37. bool saveToSettings);
  38. private:
  39. void setupContent();
  40. void requestPermissionAndStartTestingMicrophone();
  41. void initPlaybackButton(
  42. not_null<Ui::VerticalLayout*> container,
  43. rpl::producer<QString> text,
  44. rpl::producer<QString> resolvedId,
  45. Fn<void(QString)> set);
  46. void initCaptureButton(
  47. not_null<Ui::VerticalLayout*> container,
  48. rpl::producer<QString> text,
  49. rpl::producer<QString> resolvedId,
  50. Fn<void(QString)> set);
  51. const not_null<Window::SessionController*> _controller;
  52. rpl::event_stream<QString> _cameraNameStream;
  53. rpl::variable<bool> _testingMicrophone;
  54. };
  55. inline constexpr auto kMicTestUpdateInterval = crl::time(100);
  56. inline constexpr auto kMicTestAnimationDuration = crl::time(200);
  57. [[nodiscard]] rpl::producer<QString> PlaybackDeviceNameValue(
  58. rpl::producer<QString> id);
  59. [[nodiscard]] rpl::producer<QString> CaptureDeviceNameValue(
  60. rpl::producer<QString> id);
  61. [[nodiscard]] rpl::producer<QString> CameraDeviceNameValue(
  62. rpl::producer<QString> id);
  63. [[nodiscard]] object_ptr<Ui::GenericBox> ChoosePlaybackDeviceBox(
  64. rpl::producer<QString> currentId,
  65. Fn<void(QString id)> chosen,
  66. const style::Checkbox *st = nullptr,
  67. const style::Radio *radioSt = nullptr);
  68. [[nodiscard]] object_ptr<Ui::GenericBox> ChooseCaptureDeviceBox(
  69. rpl::producer<QString> currentId,
  70. Fn<void(QString id)> chosen,
  71. const style::Checkbox *st = nullptr,
  72. const style::Radio *radioSt = nullptr);
  73. [[nodiscard]] object_ptr<Ui::GenericBox> ChooseCameraDeviceBox(
  74. rpl::producer<QString> currentId,
  75. Fn<void(QString id)> chosen,
  76. const style::Checkbox *st = nullptr,
  77. const style::Radio *radioSt = nullptr);
  78. } // namespace Settings