mediahandler.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  3. * Copyright (c) 2020 Paul-Louis Ageneau
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef RTC_MEDIA_HANDLER_H
  20. #define RTC_MEDIA_HANDLER_H
  21. #include "common.hpp"
  22. #include "message.hpp"
  23. namespace rtc {
  24. class RTC_CPP_EXPORT MediaHandler {
  25. protected:
  26. // Use this callback when trying to send custom data (such as RTCP) to the client.
  27. synchronized_callback<message_ptr> outgoingCallback;
  28. public:
  29. // Called when there is traffic coming from the peer
  30. virtual message_ptr incoming(message_ptr ptr) = 0;
  31. // Called when there is traffic that needs to be sent to the peer
  32. virtual message_ptr outgoing(message_ptr ptr) = 0;
  33. // This callback is used to send traffic back to the peer.
  34. void onOutgoing(const std::function<void(message_ptr)> &cb) {
  35. this->outgoingCallback = synchronized_callback<message_ptr>(cb);
  36. }
  37. virtual bool requestKeyframe() { return false; }
  38. };
  39. } // namespace rtc
  40. #endif // RTC_MEDIA_HANDLER_H