track.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright (c) 2020 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_TRACK_H
  19. #define RTC_TRACK_H
  20. #include "channel.hpp"
  21. #include "description.hpp"
  22. #include "common.hpp"
  23. #include "mediahandler.hpp"
  24. #include "message.hpp"
  25. #include <atomic>
  26. #include <shared_mutex>
  27. #include <variant>
  28. namespace rtc {
  29. namespace impl {
  30. class Track;
  31. } // namespace impl
  32. class RTC_CPP_EXPORT Track final : private CheshireCat<impl::Track>, public Channel {
  33. public:
  34. Track(impl_ptr<impl::Track> impl);
  35. ~Track() = default;
  36. string mid() const;
  37. Description::Direction direction() const;
  38. Description::Media description() const;
  39. void setDescription(Description::Media description);
  40. void close(void) override;
  41. bool send(message_variant data) override;
  42. bool send(const byte *data, size_t size) override;
  43. bool isOpen(void) const override;
  44. bool isClosed(void) const override;
  45. size_t maxMessageSize() const override;
  46. bool requestKeyframe();
  47. // RTCP handler
  48. void setRtcpHandler(std::shared_ptr<MediaHandler> handler);
  49. std::shared_ptr<MediaHandler> getRtcpHandler();
  50. private:
  51. using CheshireCat<impl::Track>::impl;
  52. };
  53. } // namespace rtc
  54. #endif