mediahandler.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // Called when there is traffic coming from the peer
  20. virtual message_ptr incoming(message_ptr ptr) = 0;
  21. // Called when there is traffic that needs to be sent to the peer
  22. virtual message_ptr outgoing(message_ptr ptr) = 0;
  23. // This callback is used to send traffic back to the peer.
  24. void onOutgoing(const std::function<void(message_ptr)> &cb) {
  25. this->outgoingCallback = synchronized_callback<message_ptr>(cb);
  26. }
  27. virtual bool requestKeyframe() { return false; }
  28. };
  29. } // namespace rtc
  30. #endif // RTC_MEDIA_HANDLER_H