rtppacketizationconfig.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * Copyright (c) 2020 Filip Klembara (in2core)
  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_RTP_PACKETIZATION_CONFIG_H
  9. #define RTC_RTP_PACKETIZATION_CONFIG_H
  10. #if RTC_ENABLE_MEDIA
  11. #include "dependencydescriptor.hpp"
  12. #include "rtp.hpp"
  13. namespace rtc {
  14. // RTP configuration used in packetization process
  15. class RTC_CPP_EXPORT RtpPacketizationConfig {
  16. public:
  17. SSRC ssrc;
  18. std::string cname;
  19. uint8_t payloadType;
  20. uint32_t clockRate;
  21. uint8_t videoOrientationId;
  22. // current sequence number
  23. uint16_t sequenceNumber;
  24. // current timestamp
  25. uint32_t timestamp;
  26. // start timestamp
  27. uint32_t startTimestamp;
  28. /// Current video orientation
  29. ///
  30. /// Bit# 7 6 5 4 3 2 1 0
  31. /// Definition 0 0 0 0 C F R1 R0
  32. ///
  33. /// C
  34. /// 0 - Front-facing camera (use this if unsure)
  35. /// 1 - Back-facing camera
  36. ///
  37. /// F
  38. /// 0 - No Flip
  39. /// 1 - Horizontal flip
  40. ///
  41. /// R1 R0 - CW rotation that receiver must apply
  42. /// 0 - 0 degrees
  43. /// 1 - 90 degrees
  44. /// 2 - 180 degrees
  45. /// 3 - 270 degrees
  46. uint8_t videoOrientation = 0;
  47. // MID Extension Header
  48. uint8_t midId = 0;
  49. optional<std::string> mid;
  50. // RID Extension Header
  51. uint8_t ridId = 0;
  52. optional<std::string> rid;
  53. // Dependency Descriptor Extension Header
  54. uint8_t dependencyDescriptorId = 0;
  55. optional<DependencyDescriptorContext> dependencyDescriptorContext;
  56. // the negotiated ID of the playout delay header extension
  57. // https://webrtc.googlesource.com/src/+/main/docs/native-code/rtp-hdrext/playout-delay/README.md
  58. uint8_t playoutDelayId = 0;
  59. // Minimum/maxiumum playout delay, in 10ms intervals. A value of 10 would equal a 100ms delay
  60. uint16_t playoutDelayMin = 0;
  61. uint16_t playoutDelayMax = 0;
  62. /// Construct RTP configuration used in packetization process
  63. /// @param ssrc SSRC of source
  64. /// @param cname CNAME of source
  65. /// @param payloadType Payload type of source
  66. /// @param clockRate Clock rate of source used in timestamps
  67. /// nullopt)
  68. /// @param videoOrientationId Video orientation (see above)
  69. RtpPacketizationConfig(SSRC ssrc, std::string cname, uint8_t payloadType, uint32_t clockRate,
  70. uint8_t videoOrientationId = 0);
  71. RtpPacketizationConfig(const RtpPacketizationConfig &) = delete;
  72. /// Convert timestamp to seconds
  73. /// @param timestamp Timestamp
  74. /// @param clockRate Clock rate for timestamp calculation
  75. static double getSecondsFromTimestamp(uint32_t timestamp, uint32_t clockRate);
  76. /// Convert timestamp to seconds
  77. /// @param timestamp Timestamp
  78. double timestampToSeconds(uint32_t timestamp);
  79. /// Convert seconds to timestamp
  80. /// @param seconds Number of seconds
  81. /// @param clockRate Clock rate for timestamp calculation
  82. static uint32_t getTimestampFromSeconds(double seconds, uint32_t clockRate);
  83. /// Convert seconds to timestamp
  84. /// @param seconds Number of seconds
  85. uint32_t secondsToTimestamp(double seconds);
  86. };
  87. } // namespace rtc
  88. #endif /* RTC_ENABLE_MEDIA */
  89. #endif /* RTC_RTP_PACKETIZATION_CONFIG_H */