From 34dd4a20f2e976b260e8aa3f3128e55ec80bb85b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Aug 2008 23:56:25 +0200 Subject: fix shutdown when --disallow-module-loading=1 is passed --- src/modules/rtp/module-rtp-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/rtp/module-rtp-send.c') diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index d0d06c4d..5e542253 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -139,7 +139,7 @@ static void source_output_kill(pa_source_output* o) { pa_source_output_assert_ref(o); pa_assert_se(u = o->userdata); - pa_module_unload_request(u->module); + pa_module_unload_request(u->module, TRUE); pa_source_output_unlink(u->source_output); pa_source_output_unref(u->source_output); -- cgit From 8d596a9bc560eb6740e2f303cda712eb7169c3ce Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 15 Aug 2008 14:40:08 +0200 Subject: Make Multicast TTL for RTP configurable, patch from 'dfort' Signed-off-by: Lennart Poettering --- src/modules/rtp/module-rtp-send.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/modules/rtp/module-rtp-send.c') diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index 5e542253..aad21265 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -67,10 +67,12 @@ PA_MODULE_USAGE( "destination= " "port= " "mtu= " - "loop=" + "loop= " + "ttl=" ); #define DEFAULT_PORT 46000 +#define DEFAULT_TTL 1 #define SAP_PORT 9875 #define DEFAULT_DESTINATION "224.0.0.56" #define MEMBLOCKQ_MAXLENGTH (1024*170) @@ -86,6 +88,7 @@ static const char* const valid_modargs[] = { "port", "mtu" , "loop", + "ttl", NULL }; @@ -167,6 +170,7 @@ int pa__init(pa_module*m) { pa_modargs *ma = NULL; const char *dest; uint32_t port = DEFAULT_PORT, mtu; + unsigned char ttl = DEFAULT_TTL; int af, fd = -1, sap_fd = -1; pa_source *s; pa_sample_spec ss; @@ -235,6 +239,11 @@ int pa__init(pa_module*m) { if (port & 1) pa_log_warn("Port number not even as suggested in RFC3550!"); + if (pa_modargs_get_value_u32(ma, "ttl", &ttl) < 0 || ttl < 1 || ttl > 0xFF) { + pa_log("ttl= expects a numerical argument between 1 and 255."); + goto fail; + } + dest = pa_modargs_get_value(ma, "destination", DEFAULT_DESTINATION); if (inet_pton(AF_INET6, dest, &sa6.sin6_addr) > 0) { @@ -279,6 +288,11 @@ int pa__init(pa_module*m) { goto fail; } + if (ttl != DEFAULT_TTL && setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) { + pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno)); + goto fail; + } + /* If the socket queue is full, let's drop packets */ pa_make_fd_nonblock(fd); pa_make_udp_socket_low_delay(fd); @@ -290,6 +304,7 @@ int pa__init(pa_module*m) { pa_proplist_sets(data.proplist, "rtp.destination", dest); pa_proplist_setf(data.proplist, "rtp.mtu", "%lu", (unsigned long) mtu); pa_proplist_setf(data.proplist, "rtp.port", "%lu", (unsigned long) port); + pa_proplist_setf(data.proplist, "rtp.ttl", "%lu", (unsigned long) ttl); data.driver = __FILE__; data.module = m; data.source = s; @@ -342,7 +357,7 @@ int pa__init(pa_module*m) { pa_rtp_context_init_send(&u->rtp_context, fd, m->core->cookie, payload, pa_frame_size(&ss)); pa_sap_context_init_send(&u->sap_context, sap_fd, p); - pa_log_info("RTP stream initialized with mtu %u on %s:%u, SSRC=0x%08x, payload=%u, initial sequence #%u", mtu, dest, port, u->rtp_context.ssrc, payload, u->rtp_context.sequence); + pa_log_info("RTP stream initialized with mtu %u on %s:%u ttl=%u, SSRC=0x%08x, payload=%u, initial sequence #%u", mtu, dest, port, ttl, u->rtp_context.ssrc, payload, u->rtp_context.sequence); pa_log_info("SDP-Data:\n%s\nEOF", p); pa_sap_send(&u->sap_context, 0); -- cgit From 67858c6e46b6795893ef1337bef1d86c018cdd9e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 18 Aug 2008 17:36:59 +0200 Subject: fix type error --- src/modules/rtp/module-rtp-send.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/modules/rtp/module-rtp-send.c') diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index aad21265..1423cbc1 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -170,7 +170,7 @@ int pa__init(pa_module*m) { pa_modargs *ma = NULL; const char *dest; uint32_t port = DEFAULT_PORT, mtu; - unsigned char ttl = DEFAULT_TTL; + uint32_t ttl = DEFAULT_TTL; int af, fd = -1, sap_fd = -1; pa_source *s; pa_sample_spec ss; @@ -288,9 +288,13 @@ int pa__init(pa_module*m) { goto fail; } - if (ttl != DEFAULT_TTL && setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) { - pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno)); - goto fail; + if (ttl != DEFAULT_TTL) { + int _ttl = (int) ttl; + + if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &_ttl, sizeof(_ttl)) < 0) { + pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno)); + goto fail; + } } /* If the socket queue is full, let's drop packets */ -- cgit From b7026bf248948a6a30386ddbcc137f48f369a51e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Aug 2008 22:39:54 +0200 Subject: add a few more gcc warning flags and fix quite a few problems found by doing so --- src/modules/rtp/module-rtp-send.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/modules/rtp/module-rtp-send.c') diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index 1423cbc1..280067a5 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -171,7 +171,8 @@ int pa__init(pa_module*m) { const char *dest; uint32_t port = DEFAULT_PORT, mtu; uint32_t ttl = DEFAULT_TTL; - int af, fd = -1, sap_fd = -1; + sa_family_t af; + int fd = -1, sap_fd = -1; pa_source *s; pa_sample_spec ss; pa_channel_map cm; @@ -223,14 +224,14 @@ int pa__init(pa_module*m) { payload = pa_rtp_payload_from_sample_spec(&ss); - mtu = pa_frame_align(DEFAULT_MTU, &ss); + mtu = (uint32_t) pa_frame_align(DEFAULT_MTU, &ss); if (pa_modargs_get_value_u32(ma, "mtu", &mtu) < 0 || mtu < 1 || mtu % pa_frame_size(&ss) != 0) { pa_log("Invalid MTU."); goto fail; } - port = DEFAULT_PORT + ((rand() % 512) << 1); + port = DEFAULT_PORT + ((uint32_t) (rand() % 512) << 1); if (pa_modargs_get_value_u32(ma, "port", &port) < 0 || port < 1 || port > 0xFFFF) { pa_log("port= expects a numerical argument between 1 and 65535."); goto fail; @@ -248,12 +249,12 @@ int pa__init(pa_module*m) { if (inet_pton(AF_INET6, dest, &sa6.sin6_addr) > 0) { sa6.sin6_family = af = AF_INET6; - sa6.sin6_port = htons(port); + sa6.sin6_port = htons((uint16_t) port); sap_sa6 = sa6; sap_sa6.sin6_port = htons(SAP_PORT); } else if (inet_pton(AF_INET, dest, &sa4.sin_addr) > 0) { sa4.sin_family = af = AF_INET; - sa4.sin_port = htons(port); + sa4.sin_port = htons((uint16_t) port); sap_sa4 = sa4; sap_sa4.sin_port = htons(SAP_PORT); } else { @@ -266,7 +267,7 @@ int pa__init(pa_module*m) { goto fail; } - if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, af == AF_INET ? sizeof(sa4) : sizeof(sa6)) < 0) { + if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, (socklen_t) (af == AF_INET ? sizeof(sa4) : sizeof(sa6))) < 0) { pa_log("connect() failed: %s", pa_cstrerror(errno)); goto fail; } @@ -276,7 +277,7 @@ int pa__init(pa_module*m) { goto fail; } - if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6)) < 0) { + if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, (socklen_t) (af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6))) < 0) { pa_log("connect() failed: %s", pa_cstrerror(errno)); goto fail; } @@ -354,7 +355,7 @@ int pa__init(pa_module*m) { p = pa_sdp_build(af, af == AF_INET ? (void*) &((struct sockaddr_in*) &sa_dst)->sin_addr : (void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr, af == AF_INET ? (void*) &sa4.sin_addr : (void*) &sa6.sin6_addr, - n, port, payload, &ss); + n, (uint16_t) port, payload, &ss); pa_xfree(n); -- cgit