diff options
Diffstat (limited to 'src/modules/rtp/sdp.c')
-rw-r--r-- | src/modules/rtp/sdp.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/modules/rtp/sdp.c b/src/modules/rtp/sdp.c index 6a2e0c964..e130509df 100644 --- a/src/modules/rtp/sdp.c +++ b/src/modules/rtp/sdp.c @@ -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; } } } |