From 933743581bd9b93ae7059f5fb391f47ae9d7b43d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 2 Mar 2023 20:04:24 +0100 Subject: [PATCH] module-rtp: fix rtp.media property Use sess.media for the media type (audio/midi) because rtp.media is used in the SDP to describe the media (midi and audio are both are audio). --- src/modules/module-rtp-sap.c | 4 ++-- src/modules/module-rtp-sink.c | 8 ++++---- src/modules/module-rtp-source.c | 12 +++++------ src/modules/module-rtp/stream.c | 35 ++++++++++++++++----------------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/modules/module-rtp-sap.c b/src/modules/module-rtp-sap.c index f36891bee..1e4eb18d8 100644 --- a/src/modules/module-rtp-sap.c +++ b/src/modules/module-rtp-sap.c @@ -734,7 +734,7 @@ static int session_load_source(struct session *session, struct pw_properties *pr if ((str = pw_properties_get(props, "rtp.session")) != NULL) fprintf(f, "\"sess.name\" = \"%s\", ", str); - if ((media = pw_properties_get(props, "rtp.media")) == NULL) + if ((media = pw_properties_get(props, "sess.media")) == NULL) media = "audio"; if (spa_streq(media, "audio")) { @@ -750,7 +750,7 @@ static int session_load_source(struct session *session, struct pw_properties *pr pw_log_error("unknown rtp.mime type %s", mime); return -EINVAL; } - fprintf(f, "\"rtp.media\" = \"%s\", ", format_info->media_type); + fprintf(f, "\"sess.media\" = \"%s\", ", format_info->media_type); if (format_info->format_str != NULL) { pw_properties_set(props, "audio.format", format_info->format_str); if ((str = pw_properties_get(props, "rtp.rate")) != NULL) diff --git a/src/modules/module-rtp-sink.c b/src/modules/module-rtp-sink.c index fce7e3cc5..a2929d008 100644 --- a/src/modules/module-rtp-sink.c +++ b/src/modules/module-rtp-sink.c @@ -48,7 +48,7 @@ * - `sess.name = `: a session name * - `sess.ts-offset = `: an offset to apply to the timestamp, default -1 = random offset * - `sess.ts-refclk = `: the name of a reference clock - * - `sess.media = `: the session media type audio|midi, default audio + * - `sess.media = `: the media type audio|midi, default audio * - `stream.props = {}`: properties to be passed to the stream * * ## General options @@ -83,7 +83,7 @@ * #sess.min-ptime = 2 * #sess.max-ptime = 20 * #sess.name = "PipeWire RTP stream" - * #sess.media = audio + * #sess.media = "audio" * #audio.format = "S16BE" * #audio.rate = 48000 * #audio.channels = 2 @@ -122,7 +122,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); "sess.name= " \ "sess.min-ptime= " \ "sess.max-ptime= " \ - "sess.media= " \ + "sess.media= " \ "audio.format= " \ "audio.rate= " \ "audio.channels= "\ @@ -455,7 +455,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) copy_props(impl, props, PW_KEY_MEDIA_NAME); copy_props(impl, props, PW_KEY_MEDIA_CLASS); copy_props(impl, props, "net.mtu"); - copy_props(impl, props, "rtp.media"); + copy_props(impl, props, "sess.media"); copy_props(impl, props, "sess.name"); copy_props(impl, props, "sess.min-ptime"); copy_props(impl, props, "sess.max-ptime"); diff --git a/src/modules/module-rtp-source.c b/src/modules/module-rtp-source.c index b0b7f682f..c9399efea 100644 --- a/src/modules/module-rtp-source.c +++ b/src/modules/module-rtp-source.c @@ -46,7 +46,7 @@ * - `local.ifname = `: interface name to use * - `node.always-process = `: true to receive even when not running * - `sess.latency.msec = `: target network latency in milliseconds, default 100 - * - `rtp.media = `: the media type audio|midi, default audio + * - `sess.media = `: the media type audio|midi, default audio * - `stream.props = {}`: properties to be passed to the stream * * ## General options @@ -74,7 +74,7 @@ * #local.ifname = eth0 * sess.latency.msec = 100 * #node.always-process = false - * #rtp.media = "audio" + * #sess.media = "audio" * #audio.format = "S16BE" * #audio.rate = 48000 * #audio.channels = 2 @@ -103,7 +103,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); "source.ip= " \ "source.port= " \ "sess.latency.msec= " \ - "rtp.media= " \ + "sess.media= " \ "audio.format= " \ "audio.rate= " \ "audio.channels= "\ @@ -478,7 +478,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) copy_props(impl, props, PW_KEY_MEDIA_NAME); copy_props(impl, props, PW_KEY_MEDIA_CLASS); copy_props(impl, props, "net.mtu"); - copy_props(impl, props, "rtp.media"); + copy_props(impl, props, "sess.media"); copy_props(impl, props, "sess.name"); copy_props(impl, props, "sess.min-ptime"); copy_props(impl, props, "sess.max-ptime"); @@ -487,12 +487,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) str = pw_properties_get(props, "local.ifname"); impl->ifname = str ? strdup(str) : NULL; - impl->src_port = pw_properties_get_uint32(stream_props, "source.port", 0); + impl->src_port = pw_properties_get_uint32(props, "source.port", 0); if (impl->src_port == 0) { pw_log_error("invalid source.port"); goto out; } - if ((str = pw_properties_get(stream_props, "source.ip")) == NULL || + if ((str = pw_properties_get(props, "source.ip")) == NULL || (res = parse_address(str, impl->src_port, &impl->src_addr, &impl->src_len)) < 0) { pw_log_error("invalid source.ip %s: %s", str, spa_strerror(res)); goto out; diff --git a/src/modules/module-rtp/stream.c b/src/modules/module-rtp/stream.c index ffa388bc3..b26b73ac5 100644 --- a/src/modules/module-rtp/stream.c +++ b/src/modules/module-rtp/stream.c @@ -270,24 +270,23 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core, spa_hook_list_init(&impl->listener_list); impl->stream_events = stream_events; - impl->info.media_type = SPA_MEDIA_TYPE_audio; - impl->info.media_subtype = SPA_MEDIA_SUBTYPE_raw; - if ((str = pw_properties_get(props, "rtp.media")) != NULL) { - if (spa_streq(str, "audio")) { - impl->info.media_type = SPA_MEDIA_TYPE_audio; - impl->info.media_subtype = SPA_MEDIA_SUBTYPE_raw; - impl->payload = 127; - } - else if (spa_streq(str, "midi")) { - impl->info.media_type = SPA_MEDIA_TYPE_application; - impl->info.media_subtype = SPA_MEDIA_SUBTYPE_control; - impl->payload = 0x61; - } - else { - pw_log_error("unsupported media type:%s", str); - res = -EINVAL; - goto out; - } + if ((str = pw_properties_get(props, "sess.media")) == NULL) + str = "audio"; + + if (spa_streq(str, "audio")) { + impl->info.media_type = SPA_MEDIA_TYPE_audio; + impl->info.media_subtype = SPA_MEDIA_SUBTYPE_raw; + impl->payload = 127; + } + else if (spa_streq(str, "midi")) { + impl->info.media_type = SPA_MEDIA_TYPE_application; + impl->info.media_subtype = SPA_MEDIA_SUBTYPE_control; + impl->payload = 0x61; + } + else { + pw_log_error("unsupported media type:%s", str); + res = -EINVAL; + goto out; } switch (impl->info.media_type) {