diff options
Diffstat (limited to 'src/modules/rtp/module-rtp-send.c')
-rw-r--r-- | src/modules/rtp/module-rtp-send.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index 5a4c6fc06..fd5b63abe 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -67,6 +67,7 @@ PA_MODULE_USAGE( "ttl=<ttl value> " "inhibit_auto_suspend=<always|never|only_with_non_monitor_sources>" "stream_name=<name of the stream>" + "enable_opus=<enable OPUS codec>" ); #define DEFAULT_PORT 46000 @@ -92,6 +93,7 @@ static const char* const valid_modargs[] = { "ttl", "inhibit_auto_suspend", "stream_name", + "enable_opus", NULL }; @@ -228,6 +230,7 @@ int pa__init(pa_module*m) { socklen_t k; char hn[128], *n; bool loop = false; + bool enable_opus = false; enum inhibit_auto_suspend inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES; const char *inhibit_auto_suspend_str; pa_source_output_new_data data; @@ -249,6 +252,11 @@ int pa__init(pa_module*m) { goto fail; } + if (pa_modargs_get_value_boolean(ma, "enable_opus", &enable_opus) < 0) { + pa_log("Failed to parse \"use_opus\" parameter."); + goto fail; + } + if ((inhibit_auto_suspend_str = pa_modargs_get_value(ma, "inhibit_auto_suspend", NULL))) { if (pa_streq(inhibit_auto_suspend_str, "always")) inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ALWAYS; @@ -263,7 +271,7 @@ int pa__init(pa_module*m) { } ss = s->sample_spec; - pa_rtp_sample_spec_fixup(&ss); + pa_rtp_sample_spec_fixup(&ss, enable_opus); cm = s->channel_map; if (pa_modargs_get_sample_spec(ma, &ss) < 0) { pa_log("Failed to parse sample specification"); @@ -275,6 +283,11 @@ int pa__init(pa_module*m) { goto fail; } + if (enable_opus && ss.rate != 48000) { + pa_log_warn("OPUS requires sample rate as 48 KHz. Setting rate=48000."); + ss.rate = 48000; + } + if (ss.channels != cm.channels) pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_AIFF); @@ -476,19 +489,19 @@ int pa__init(pa_module*m) { p = pa_sdp_build(af, (void*) &((struct sockaddr_in*) &sa_dst)->sin_addr, (void*) &dst_sa4.sin_addr, - n, (uint16_t) port, payload, &ss); + n, (uint16_t) port, payload, &ss, enable_opus); #ifdef HAVE_IPV6 } else { p = pa_sdp_build(af, (void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr, (void*) &dst_sa6.sin6_addr, - n, (uint16_t) port, payload, &ss); + n, (uint16_t) port, payload, &ss, enable_opus); #endif } pa_xfree(n); - if (!(u->rtp_context = pa_rtp_context_new_send(fd, payload, mtu, &ss))) + if (!(u->rtp_context = pa_rtp_context_new_send(fd, payload, mtu, &ss, enable_opus))) goto fail; pa_sap_context_init_send(&u->sap_context, sap_fd, p); |