Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

10 miesięcy temu
1234567891011121314151617181920212223242526272829
  1. // RFC7587 RTP Payload Format for the Opus Speech and Audio Codec
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <assert.h>
  7. #include "sdp-payload.h"
  8. int sdp_opus(uint8_t *data, int bytes, const char* proto, unsigned short port, int payload, int sample_rate, int channel_count, const void* extra, int extra_size)
  9. {
  10. /* The opus RTP draft says that all opus streams MUST be declared
  11. as stereo, to avoid negotiation failures. The actual number of
  12. channels can change on a packet-by-packet basis. The number of
  13. channels a receiver prefers to receive or a sender plans to send
  14. can be declared via fmtp parameters (both default to mono), but
  15. receivers MUST be able to receive and process stereo packets. */
  16. static const char* pattern =
  17. "m=audio %hu %s %d\n"
  18. "a=rtpmap:%d opus/%d/2\n";
  19. int n;
  20. sample_rate = sample_rate ? sample_rate : 48000;
  21. n = snprintf((char*)data, bytes, pattern, port, proto && *proto ? proto : "RTP/AVP", payload, payload, sample_rate);
  22. if (2 == channel_count)
  23. n += snprintf((char*)data + n, bytes - n, "a=fmtp:%d sprop-stereo=1\n", payload);
  24. return n;
  25. }