track.hpp 2.0 KB

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