global.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright (c) 2020-2021 Paul-Louis Ageneau
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef RTC_GLOBAL_H
  19. #define RTC_GLOBAL_H
  20. #include "common.hpp"
  21. #include <chrono>
  22. #include <iostream>
  23. #include <future>
  24. namespace rtc {
  25. enum class LogLevel { // Don't change, it must match plog severity
  26. None = 0,
  27. Fatal = 1,
  28. Error = 2,
  29. Warning = 3,
  30. Info = 4,
  31. Debug = 5,
  32. Verbose = 6
  33. };
  34. typedef std::function<void(LogLevel level, string message)> LogCallback;
  35. RTC_CPP_EXPORT void InitLogger(LogLevel level, LogCallback callback = nullptr);
  36. #ifdef PLOG_DEFAULT_INSTANCE_ID
  37. // Deprecated, kept for retro-compatibility
  38. [[deprecated]]
  39. RTC_CPP_EXPORT void InitLogger(plog::Severity severity, plog::IAppender *appender = nullptr);
  40. #endif
  41. RTC_CPP_EXPORT void Preload();
  42. RTC_CPP_EXPORT std::shared_future<void> Cleanup();
  43. struct SctpSettings {
  44. // For the following settings, not set means optimized default
  45. optional<size_t> recvBufferSize; // in bytes
  46. optional<size_t> sendBufferSize; // in bytes
  47. optional<size_t> maxChunksOnQueue; // in chunks
  48. optional<size_t> initialCongestionWindow; // in MTUs
  49. optional<size_t> maxBurst; // in MTUs
  50. optional<unsigned int> congestionControlModule; // 0: RFC2581, 1: HSTCP, 2: H-TCP, 3: RTCC
  51. optional<std::chrono::milliseconds> delayedSackTime;
  52. optional<std::chrono::milliseconds> minRetransmitTimeout;
  53. optional<std::chrono::milliseconds> maxRetransmitTimeout;
  54. optional<std::chrono::milliseconds> initialRetransmitTimeout;
  55. optional<unsigned int> maxRetransmitAttempts;
  56. optional<std::chrono::milliseconds> heartbeatInterval;
  57. };
  58. RTC_CPP_EXPORT void SetSctpSettings(SctpSettings s);
  59. } // namespace rtc
  60. RTC_CPP_EXPORT std::ostream &operator<<(std::ostream &out, rtc::LogLevel level);
  61. #endif