track.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright (c) 2020 Paul-Louis Ageneau
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. #ifndef RTC_TRACK_H
  9. #define RTC_TRACK_H
  10. #include "channel.hpp"
  11. #include "common.hpp"
  12. #include "description.hpp"
  13. #include "mediahandler.hpp"
  14. namespace rtc {
  15. namespace impl {
  16. class Track;
  17. } // namespace impl
  18. class RTC_CPP_EXPORT Track final : private CheshireCat<impl::Track>, public Channel {
  19. public:
  20. Track(impl_ptr<impl::Track> impl);
  21. ~Track() override;
  22. string mid() const;
  23. Description::Direction direction() const;
  24. Description::Media description() const;
  25. void setDescription(Description::Media description);
  26. void close(void) override;
  27. bool send(message_variant data) override;
  28. bool send(const byte *data, size_t size) override;
  29. bool isOpen(void) const override;
  30. bool isClosed(void) const override;
  31. size_t maxMessageSize() const override;
  32. void sendFrame(binary data, FrameInfo info);
  33. void sendFrame(const byte *data, size_t size, FrameInfo info);
  34. void onFrame(std::function<void(binary data, FrameInfo info)> callback);
  35. bool requestKeyframe();
  36. bool requestBitrate(unsigned int bitrate);
  37. void setMediaHandler(shared_ptr<MediaHandler> handler);
  38. void chainMediaHandler(shared_ptr<MediaHandler> handler);
  39. shared_ptr<MediaHandler> getMediaHandler();
  40. // Deprecated, use setMediaHandler() and getMediaHandler()
  41. inline void setRtcpHandler(shared_ptr<MediaHandler> handler) { setMediaHandler(handler); }
  42. inline shared_ptr<MediaHandler> getRtcpHandler() { return getMediaHandler(); }
  43. private:
  44. using CheshireCat<impl::Track>::impl;
  45. };
  46. } // namespace rtc
  47. #endif