calls_controller_tgvoip.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 "calls/calls_controller.h"
  9. namespace Calls {
  10. class TgVoipController final : public Controller {
  11. public:
  12. TgVoipController(
  13. const TgVoipConfig &config,
  14. const TgVoipPersistentState &persistentState,
  15. const std::vector<TgVoipEndpoint> &endpoints,
  16. const TgVoipProxy *proxy,
  17. TgVoipNetworkType initialNetworkType,
  18. const TgVoipEncryptionKey &encryptionKey)
  19. : _impl(TgVoip::makeInstance(
  20. config,
  21. persistentState,
  22. endpoints,
  23. proxy,
  24. initialNetworkType,
  25. encryptionKey)) {
  26. }
  27. [[nodiscard]] static std::string Version() {
  28. return TgVoip::getVersion();
  29. }
  30. std::string version() override {
  31. return Version();
  32. }
  33. void setNetworkType(TgVoipNetworkType networkType) override {
  34. _impl->setNetworkType(networkType);
  35. }
  36. void setMuteMicrophone(bool muteMicrophone) override {
  37. _impl->setMuteMicrophone(muteMicrophone);
  38. }
  39. void setAudioOutputGainControlEnabled(bool enabled) override {
  40. _impl->setAudioOutputGainControlEnabled(enabled);
  41. }
  42. void setEchoCancellationStrength(int strength) override {
  43. _impl->setEchoCancellationStrength(strength);
  44. }
  45. void setAudioInputDevice(std::string id) override {
  46. _impl->setAudioInputDevice(id);
  47. }
  48. void setAudioOutputDevice(std::string id) override {
  49. _impl->setAudioOutputDevice(id);
  50. }
  51. void setInputVolume(float level) override {
  52. _impl->setInputVolume(level);
  53. }
  54. void setOutputVolume(float level) override {
  55. _impl->setOutputVolume(level);
  56. }
  57. void setAudioOutputDuckingEnabled(bool enabled) override {
  58. _impl->setAudioOutputDuckingEnabled(enabled);
  59. }
  60. bool receiveSignalingData(const QByteArray &data) override {
  61. return false;
  62. }
  63. std::string getLastError() override {
  64. return _impl->getLastError();
  65. }
  66. std::string getDebugInfo() override {
  67. return _impl->getDebugInfo();
  68. }
  69. int64_t getPreferredRelayId() override {
  70. return _impl->getPreferredRelayId();
  71. }
  72. TgVoipTrafficStats getTrafficStats() override {
  73. return _impl->getTrafficStats();
  74. }
  75. TgVoipPersistentState getPersistentState() override {
  76. return _impl->getPersistentState();
  77. }
  78. void setOnStateUpdated(Fn<void(TgVoipState)> onStateUpdated) override {
  79. _impl->setOnStateUpdated(std::move(onStateUpdated));
  80. }
  81. void setOnSignalBarsUpdated(Fn<void(int)> onSignalBarsUpdated) override {
  82. _impl->setOnSignalBarsUpdated(std::move(onSignalBarsUpdated));
  83. }
  84. TgVoipFinalState stop() override {
  85. return _impl->stop();
  86. }
  87. private:
  88. const std::unique_ptr<TgVoip> _impl;
  89. };
  90. } // namespace Calls