25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

41 satır
1.5KB

  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://webrtc.googlesource.com/src/+/refs/heads/main/docs/native-code/rtp-hdrext/abs-send-time
  9. /*
  10. Wire format: 1-byte extension, 3 bytes of data. total 4 bytes extra per packet (plus shared 4 bytes for all extensions present: 2 byte magic word 0xBEDE, 2 byte # of extensions). Will in practice replace the ¡°toffset¡± extension so we should see no long term increase in traffic as a result.
  11. Encoding: Timestamp is in seconds, 24 bit 6.18 fixed point, yielding 64s wraparound and 3.8us resolution (one increment for each 477 bytes going out on a 1Gbps interface).
  12. Relation to NTP timestamps: abs_send_time_24 = (ntp_timestamp_64 >> 14) & 0x00ffffff ; NTP timestamp is 32 bits for whole seconds, 32 bits fraction of second.
  13. SDP "a= name": "abs-send-time" ; this is also used in client/cloud signaling.
  14. */
  15. int rtp_ext_abs_send_time_parse(const uint8_t* data, int bytes, uint64_t *timestamp)
  16. {
  17. if (bytes < 3)
  18. return -1;
  19. *timestamp = ((uint64_t)data[0] << 16) | ((uint64_t)data[1] << 8) | data[2];
  20. *timestamp = (*timestamp * 1000000) >> 18;
  21. return 0;
  22. }
  23. int rtp_ext_abs_send_time_write(uint8_t* data, int bytes, uint64_t timestamp)
  24. {
  25. if (bytes < 3)
  26. return -1;
  27. timestamp = (timestamp << 18) / 1000000;
  28. data[0] = (uint8_t)(timestamp >> 16);
  29. data[1] = (uint8_t)(timestamp >> 8);
  30. data[2] = (uint8_t)(timestamp >> 0);
  31. return 3;
  32. }