Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

rtp-ext-toffset.c 1.0KB

il y a 10 mois
1234567891011121314151617181920212223242526272829303132333435
  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. }