rtppacketizationconfig.hpp 2.9 KB

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