mediahandler.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  3. * Copyright (c) 2020 Paul-Louis Ageneau
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  8. */
  9. #ifndef RTC_MEDIA_HANDLER_H
  10. #define RTC_MEDIA_HANDLER_H
  11. #include "common.hpp"
  12. #include "message.hpp"
  13. namespace rtc {
  14. class RTC_CPP_EXPORT MediaHandler {
  15. protected:
  16. // Use this callback when trying to send custom data (such as RTCP) to the client.
  17. synchronized_callback<message_ptr> outgoingCallback;
  18. public:
  19. virtual ~MediaHandler() = default;
  20. // Called when there is traffic coming from the peer
  21. virtual message_ptr incoming(message_ptr ptr) = 0;
  22. // Called when there is traffic that needs to be sent to the peer
  23. virtual message_ptr outgoing(message_ptr ptr) = 0;
  24. // This callback is used to send traffic back to the peer.
  25. void onOutgoing(const std::function<void(message_ptr)> &cb) {
  26. this->outgoingCallback = synchronized_callback<message_ptr>(cb);
  27. }
  28. virtual bool requestKeyframe() { return false; }
  29. };
  30. } // namespace rtc
  31. #endif // RTC_MEDIA_HANDLER_H