track.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Copyright (c) 2020-2021 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. #include "track.hpp"
  19. #include "impl/internals.hpp"
  20. #include "impl/track.hpp"
  21. namespace rtc {
  22. Track::Track(impl_ptr<impl::Track> impl)
  23. : CheshireCat<impl::Track>(impl), Channel(std::dynamic_pointer_cast<impl::Channel>(impl)) {}
  24. string Track::mid() const { return impl()->mid(); }
  25. Description::Direction Track::direction() const { return impl()->direction(); }
  26. Description::Media Track::description() const { return impl()->description(); }
  27. void Track::setDescription(Description::Media description) {
  28. impl()->setDescription(std::move(description));
  29. }
  30. void Track::close() { impl()->close(); }
  31. bool Track::send(message_variant data) { return impl()->outgoing(make_message(std::move(data))); }
  32. bool Track::send(const byte *data, size_t size) { return send(binary(data, data + size)); }
  33. bool Track::isOpen(void) const { return impl()->isOpen(); }
  34. bool Track::isClosed(void) const { return impl()->isClosed(); }
  35. size_t Track::maxMessageSize() const { return impl()->maxMessageSize(); }
  36. void Track::setMediaHandler(shared_ptr<MediaHandler> handler) {
  37. impl()->setMediaHandler(std::move(handler));
  38. }
  39. bool Track::requestKeyframe() {
  40. if (auto handler = impl()->getMediaHandler())
  41. return handler->requestKeyframe();
  42. return false;
  43. }
  44. shared_ptr<MediaHandler> Track::getMediaHandler() { return impl()->getMediaHandler(); }
  45. } // namespace rtc