Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

36 řádky
1.0KB

  1. #include "rtp-ext.h"
  2. #include <inttypes.h>
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <assert.h>
  7. #include <stdio.h>
  8. // https://datatracker.ietf.org/doc/html/rfc5450
  9. /*
  10. 0 1 2 3
  11. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  12. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  13. | ID | len=2 | transmission offset |
  14. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  15. */
  16. int rtp_ext_toffset_parse(const uint8_t* data, int bytes, uint32_t* timestamp)
  17. {
  18. if (bytes < 3)
  19. return -1;
  20. *timestamp = ((uint32_t)data[0] << 16) | ((uint32_t)data[1] << 8) | data[2];
  21. return 0;
  22. }
  23. int rtp_ext_toffset_write(uint8_t* data, int bytes, uint32_t timestamp)
  24. {
  25. if (bytes < 3)
  26. return -1;
  27. data[0] = (uint8_t)(timestamp >> 16);
  28. data[1] = (uint8_t)(timestamp >> 8);
  29. data[2] = (uint8_t)(timestamp >> 0);
  30. return 3;
  31. }