mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
rtp: Enable support for OPUS
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/510>
This commit is contained in:
parent
0b9ef4cd0a
commit
86d1dd0d70
8 changed files with 174 additions and 47 deletions
|
|
@ -39,8 +39,9 @@
|
|||
#include "sdp.h"
|
||||
#include "rtp.h"
|
||||
|
||||
char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, uint16_t port, uint8_t payload, const pa_sample_spec *ss) {
|
||||
char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, uint16_t port, uint8_t payload, const pa_sample_spec *ss, bool enable_opus) {
|
||||
uint32_t ntp;
|
||||
uint32_t rate, channels;
|
||||
char buf_src[64], buf_dst[64], un[64];
|
||||
const char *u, *f;
|
||||
|
||||
|
|
@ -53,7 +54,15 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
|
|||
pa_assert(af == AF_INET);
|
||||
#endif
|
||||
|
||||
pa_assert_se(f = pa_rtp_format_to_string(ss->format));
|
||||
if (enable_opus) {
|
||||
f = "OPUS";
|
||||
rate = 48000;
|
||||
channels = 2;
|
||||
} else {
|
||||
pa_assert_se(f = pa_rtp_format_to_string(ss->format));
|
||||
rate = ss->rate;
|
||||
channels = ss->channels;
|
||||
}
|
||||
|
||||
if (!(u = pa_get_user_name(un, sizeof(un))))
|
||||
u = "-";
|
||||
|
|
@ -78,7 +87,7 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
|
|||
af == AF_INET ? "IP4" : "IP6", buf_dst,
|
||||
(unsigned long) ntp,
|
||||
port, payload,
|
||||
payload, f, ss->rate, ss->channels);
|
||||
payload, f, rate, channels);
|
||||
}
|
||||
|
||||
static pa_sample_spec *parse_sdp_sample_spec(pa_sample_spec *ss, char *c) {
|
||||
|
|
@ -89,6 +98,9 @@ static pa_sample_spec *parse_sdp_sample_spec(pa_sample_spec *ss, char *c) {
|
|||
if (pa_startswith(c, "L16/")) {
|
||||
ss->format = PA_SAMPLE_S16BE;
|
||||
c += 4;
|
||||
} else if (pa_startswith(c, "OPUS/")) {
|
||||
ss->format = PA_SAMPLE_S16LE;
|
||||
c += 5;
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
|
|
@ -218,6 +230,9 @@ pa_sdp_info *pa_sdp_parse(const char *t, pa_sdp_info *i, int is_goodbye) {
|
|||
|
||||
if (parse_sdp_sample_spec(&i->sample_spec, c))
|
||||
ss_valid = true;
|
||||
|
||||
if (pa_startswith(c, "OPUS/"))
|
||||
i->enable_opus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue