calls_controller.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include "calls/calls_controller.h"
  8. #include "calls/calls_controller_tgvoip.h"
  9. #include "calls/calls_controller_webrtc.h"
  10. namespace Calls {
  11. [[nodiscard]] std::unique_ptr<Controller> MakeController(
  12. const std::string &version,
  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. Fn<void(QByteArray)> sendSignalingData,
  20. Fn<void(QImage)> displayNextFrame) {
  21. if (version == WebrtcController::Version()) {
  22. return std::make_unique<WebrtcController>(
  23. config,
  24. persistentState,
  25. endpoints,
  26. proxy,
  27. initialNetworkType,
  28. encryptionKey,
  29. std::move(sendSignalingData),
  30. std::move(displayNextFrame));
  31. }
  32. return std::make_unique<TgVoipController>(
  33. config,
  34. persistentState,
  35. endpoints,
  36. proxy,
  37. initialNetworkType,
  38. encryptionKey);
  39. }
  40. std::vector<std::string> CollectControllerVersions() {
  41. return { WebrtcController::Version(), TgVoipController::Version() };
  42. }
  43. int ControllerMaxLayer() {
  44. return TgVoip::getConnectionMaxLayer();
  45. }
  46. } // namespace Calls