rtp_header_extension_map.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_EXTENSION_MAP_H_
  2. #define MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_EXTENSION_MAP_H_
  3. #include <stdint.h>
  4. #include <string>
  5. #include "../rtp_header_extension/rtp_header_extension_defines.h"
  6. class RtpHeaderExtensionMap {
  7. public:
  8. static const RTPExtensionType kInvalidType = kRtpExtensionNone;
  9. static const int kInvalidId = 0;
  10. RtpHeaderExtensionMap();
  11. explicit RtpHeaderExtensionMap(bool extmap_allow_mixed);
  12. template <typename Extension>
  13. bool Register(int id) {
  14. return Register(id, Extension::kId, Extension::kUri);
  15. }
  16. bool RegisterByType(int id, RTPExtensionType type);
  17. bool RegisterByUri(int id, const std::string& uri);
  18. bool IsRegistered(RTPExtensionType type) const {
  19. return GetId(type) != kInvalidId;
  20. }
  21. // Return kInvalidType if not found.
  22. RTPExtensionType GetType(int id) const;
  23. // Return kInvalidId if not found.
  24. uint8_t GetId(RTPExtensionType type) const {
  25. return ids_[type];
  26. }
  27. // TODO(danilchap): Remove use of the functions below.
  28. int32_t Register(RTPExtensionType type, int id) {
  29. return RegisterByType(id, type) ? 0 : -1;
  30. }
  31. int32_t Deregister(RTPExtensionType type);
  32. // Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
  33. // Set to true if it's allowed to mix one- and two-byte RTP header extensions
  34. // in the same stream.
  35. bool ExtmapAllowMixed() const { return extmap_allow_mixed_; }
  36. void SetExtmapAllowMixed(bool extmap_allow_mixed) {
  37. extmap_allow_mixed_ = extmap_allow_mixed;
  38. }
  39. private:
  40. bool Register(int id, RTPExtensionType type, const char* uri);
  41. uint8_t ids_[kRtpExtensionNumberOfExtensions];
  42. bool extmap_allow_mixed_;
  43. };
  44. #endif // MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_EXTENSION_MAP_H_