rtppacketizationconfig.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. const SSRC ssrc;
  17. const std::string cname;
  18. const uint8_t payloadType;
  19. const uint32_t clockRate;
  20. const 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. /// Construct RTP configuration used in packetization process
  47. /// @param ssrc SSRC of source
  48. /// @param cname CNAME of source
  49. /// @param payloadType Payload type of source
  50. /// @param clockRate Clock rate of source used in timestamps
  51. /// nullopt)
  52. /// @param videoOrientationId Video orientation (see above)
  53. RtpPacketizationConfig(SSRC ssrc, std::string cname, uint8_t payloadType, uint32_t clockRate,
  54. uint8_t videoOrientationId = 0);
  55. RtpPacketizationConfig(const RtpPacketizationConfig &) = delete;
  56. /// Convert timestamp to seconds
  57. /// @param timestamp Timestamp
  58. /// @param clockRate Clock rate for timestamp calculation
  59. static double getSecondsFromTimestamp(uint32_t timestamp, uint32_t clockRate);
  60. /// Convert timestamp to seconds
  61. /// @param timestamp Timestamp
  62. double timestampToSeconds(uint32_t timestamp);
  63. /// Convert seconds to timestamp
  64. /// @param seconds Number of seconds
  65. /// @param clockRate Clock rate for timestamp calculation
  66. static uint32_t getTimestampFromSeconds(double seconds, uint32_t clockRate);
  67. /// Convert seconds to timestamp
  68. /// @param seconds Number of seconds
  69. uint32_t secondsToTimestamp(double seconds);
  70. };
  71. } // namespace rtc
  72. #endif /* RTC_ENABLE_MEDIA */
  73. #endif /* RTC_RTP_PACKETIZATION_CONFIG_H */