[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-65-g93db3cb
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Apr 29 16:36:07 PDT 2009
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from c95cc9e55f02ea7cf4e86e40c6d9ee390c112d9f (commit)
- Log -----------------------------------------------------------------
93db3cb rygel: instead of always handing out wildcard address find out the actual address we are listening on
8dfdfd4 http: export information about currently active server strings
23a798c strlist: add new calls pa_strlist_{next|data}()
9208b86 parseaddr: add new call pa_is_ip_address()
d5f9057 rygel: make server name configurable
-----------------------------------------------------------------------
Summary of changes:
src/modules/module-protocol-stub.c | 38 ++++++++++++++++-
src/modules/module-rygel-media-server.c | 72 +++++++++++++++++++++++++++++-
src/pulsecore/parseaddr.c | 15 ++++++
src/pulsecore/parseaddr.h | 2 +
src/pulsecore/protocol-http.c | 29 ++++++++++++-
src/pulsecore/protocol-http.h | 6 ++-
src/pulsecore/strlist.c | 12 +++++
src/pulsecore/strlist.h | 6 +++
8 files changed, 174 insertions(+), 6 deletions(-)
-----------------------------------------------------------------------
commit d5f90575581b90417082d44968f579ea02d3c662
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Apr 29 23:48:40 2009 +0200
rygel: make server name configurable
diff --git a/src/modules/module-rygel-media-server.c b/src/modules/module-rygel-media-server.c
index b851612..7136cbe 100644
--- a/src/modules/module-rygel-media-server.c
+++ b/src/modules/module-rygel-media-server.c
@@ -35,6 +35,7 @@
#include <pulse/xmalloc.h>
#include <pulse/util.h>
#include <pulse/i18n.h>
+#include <pulse/utf8.h>
#include <pulsecore/sink.h>
#include <pulsecore/source.h>
@@ -53,6 +54,8 @@ PA_MODULE_AUTHOR("Lennart Poettering");
PA_MODULE_DESCRIPTION("UPnP MediaServer Plugin for Rygel");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_USAGE(
+ "display_name=<UPnP Media Server name>");
/* This implements http://live.gnome.org/action/edit/Rygel/MediaProviderSpec */
@@ -141,6 +144,7 @@ PA_MODULE_LOAD_ONCE(TRUE);
static const char* const valid_modargs[] = {
+ "display_name",
NULL
};
@@ -151,6 +155,8 @@ struct userdata {
pa_dbus_connection *bus;
pa_bool_t got_name:1;
+ char *display_name;
+
pa_hook_slot *source_new_slot, *source_unlink_slot;
};
@@ -260,7 +266,7 @@ static DBusHandlerResult root_handler(DBusConnection *c, DBusMessage *m, void *u
} else if (message_is_property_get(m, "org.Rygel.MediaObject1", "display-name")) {
pa_assert_se(r = dbus_message_new_method_return(m));
- append_variant_string(r, "PulseAudio");
+ append_variant_string(r, u->display_name);
} else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
const char *xml = ROOT_INTROSPECT_XML;
@@ -462,6 +468,8 @@ int pa__init(pa_module *m) {
struct userdata *u;
pa_modargs *ma = NULL;
DBusError error;
+ const char *t;
+
static const DBusObjectPathVTable vtable_root = {
.message_function = root_handler,
};
@@ -480,6 +488,16 @@ int pa__init(pa_module *m) {
u->core = m->core;
u->module = m;
+ if ((t = pa_modargs_get_value(ma, "display_name", NULL)))
+ u->display_name = pa_utf8_filter(t);
+ else {
+ char *h;
+
+ h = pa_get_host_name_malloc();
+ u->display_name = pa_sprintf_malloc(_("Audio on %s"), h);
+ pa_xfree(h);
+ }
+
u->source_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_new_cb, u);
u->source_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) source_unlink_cb, u);
@@ -545,5 +563,7 @@ void pa__done(pa_module*m) {
pa_dbus_connection_unref(u->bus);
}
+ pa_xfree(u->display_name);
+
pa_xfree(u);
}
commit 9208b86b5ecf72b69743a09cd0c8a99078c0fc0f
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 30 01:33:21 2009 +0200
parseaddr: add new call pa_is_ip_address()
diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c
index 5b53122..1cd010b 100644
--- a/src/pulsecore/parseaddr.c
+++ b/src/pulsecore/parseaddr.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <stdlib.h>
+#include <arpa/inet.h>
#include <pulse/xmalloc.h>
#include <pulse/util.h>
@@ -131,3 +132,17 @@ int pa_parse_address(const char *name, pa_parsed_address *ret_p) {
return 0;
}
+
+pa_bool_t pa_is_ip_address(const char *a) {
+ char buf[INET6_ADDRSTRLEN];
+
+ pa_assert(a);
+
+ if (inet_pton(AF_INET6, a, buf) >= 1)
+ return TRUE;
+
+ if (inet_pton(AF_INET, a, buf) >= 1)
+ return TRUE;
+
+ return FALSE;
+}
diff --git a/src/pulsecore/parseaddr.h b/src/pulsecore/parseaddr.h
index 5fbcb9a..0728b5e 100644
--- a/src/pulsecore/parseaddr.h
+++ b/src/pulsecore/parseaddr.h
@@ -39,4 +39,6 @@ typedef struct pa_parsed_address {
int pa_parse_address(const char *a, pa_parsed_address *ret_p);
+pa_bool_t pa_is_ip_address(const char *a);
+
#endif
commit 23a798caf6aa70bbff3fcbe9bbdb50d602bd1bb3
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 30 01:33:56 2009 +0200
strlist: add new calls pa_strlist_{next|data}()
diff --git a/src/pulsecore/strlist.c b/src/pulsecore/strlist.c
index cbafbba..0f4ca86 100644
--- a/src/pulsecore/strlist.c
+++ b/src/pulsecore/strlist.c
@@ -159,3 +159,15 @@ pa_strlist *pa_strlist_reverse(pa_strlist *l) {
return r;
}
+
+pa_strlist *pa_strlist_next(pa_strlist *s) {
+ pa_assert(s);
+
+ return s->next;
+}
+
+const char *pa_strlist_data(pa_strlist *s) {
+ pa_assert(s);
+
+ return ITEM_TO_TEXT(s);
+}
diff --git a/src/pulsecore/strlist.h b/src/pulsecore/strlist.h
index 2584e86..e57203c 100644
--- a/src/pulsecore/strlist.h
+++ b/src/pulsecore/strlist.h
@@ -47,4 +47,10 @@ pa_strlist* pa_strlist_parse(const char *s);
/* Reverse string list */
pa_strlist *pa_strlist_reverse(pa_strlist *l);
+/* Return the next item in the list */
+pa_strlist *pa_strlist_next(pa_strlist *s);
+
+/* Return the string associated to the current item */
+const char *pa_strlist_data(pa_strlist *s);
+
#endif
commit 8dfdfd4e1be6359dc49a44539699c1383ff2b46a
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 30 01:35:18 2009 +0200
http: export information about currently active server strings
diff --git a/src/modules/module-protocol-stub.c b/src/modules/module-protocol-stub.c
index ce3dcd0..5b351d1 100644
--- a/src/modules/module-protocol-stub.c
+++ b/src/modules/module-protocol-stub.c
@@ -251,7 +251,7 @@ int pa__init(pa_module*m) {
int r;
#endif
-#if defined(USE_PROTOCOL_NATIVE)
+#if defined(USE_PROTOCOL_NATIVE) || defined(USE_PROTOCOL_HTTP)
char t[256];
#endif
@@ -382,6 +382,24 @@ int pa__init(pa_module*m) {
# endif
#endif
+#if defined(USE_PROTOCOL_HTTP)
+#if defined(USE_TCP_SOCKETS)
+ if (u->socket_server_ipv4)
+ if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t)))
+ pa_http_protocol_add_server_string(u->http_protocol, t);
+
+#ifdef HAVE_IPV6
+ if (u->socket_server_ipv6)
+ if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t)))
+ pa_http_protocol_add_server_string(u->http_protocol, t);
+#endif /* HAVE_IPV6 */
+#else /* USE_TCP_SOCKETS */
+ if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t)))
+ pa_http_protocol_add_server_string(u->http_protocol, t);
+
+#endif /* USE_TCP_SOCKETS */
+#endif /* USE_PROTOCOL_HTTP */
+
if (ma)
pa_modargs_free(ma);
@@ -419,6 +437,24 @@ void pa__done(pa_module*m) {
}
#elif defined(USE_PROTOCOL_HTTP)
if (u->http_protocol) {
+ char t[256];
+
+#if defined(USE_TCP_SOCKETS)
+ if (u->socket_server_ipv4)
+ if (pa_socket_server_get_address(u->socket_server_ipv4, t, sizeof(t)))
+ pa_http_protocol_remove_server_string(u->http_protocol, t);
+
+#ifdef HAVE_IPV6
+ if (u->socket_server_ipv6)
+ if (pa_socket_server_get_address(u->socket_server_ipv6, t, sizeof(t)))
+ pa_http_protocol_remove_server_string(u->http_protocol, t);
+#endif /* HAVE_IPV6 */
+#else /* USE_TCP_SOCKETS */
+ if (u->socket_server_unix)
+ if (pa_socket_server_get_address(u->socket_server_unix, t, sizeof(t)))
+ pa_http_protocol_remove_server_string(u->http_protocol, t);
+#endif /* USE_PROTOCOL_HTTP */
+
pa_http_protocol_disconnect(u->http_protocol, u->module);
pa_http_protocol_unref(u->http_protocol);
}
diff --git a/src/pulsecore/protocol-http.c b/src/pulsecore/protocol-http.c
index 46850b2..b5d7530 100644
--- a/src/pulsecore/protocol-http.c
+++ b/src/pulsecore/protocol-http.c
@@ -97,6 +97,8 @@ struct pa_http_protocol {
pa_core *core;
pa_idxset *connections;
+
+ pa_strlist *servers;
};
enum {
@@ -698,7 +700,7 @@ static pa_http_protocol* http_protocol_new(pa_core *c) {
pa_assert(c);
- p = pa_xnew(pa_http_protocol, 1);
+ p = pa_xnew0(pa_http_protocol, 1);
PA_REFCNT_INIT(p);
p->core = c;
p->connections = pa_idxset_new(NULL, NULL);
@@ -740,7 +742,32 @@ void pa_http_protocol_unref(pa_http_protocol *p) {
pa_idxset_free(p->connections, NULL, NULL);
+ pa_strlist_free(p->servers);
+
pa_assert_se(pa_shared_remove(p->core, "http-protocol") >= 0);
pa_xfree(p);
}
+
+void pa_http_protocol_add_server_string(pa_http_protocol *p, const char *name) {
+ pa_assert(p);
+ pa_assert(PA_REFCNT_VALUE(p) >= 1);
+ pa_assert(name);
+
+ p->servers = pa_strlist_prepend(p->servers, name);
+}
+
+void pa_http_protocol_remove_server_string(pa_http_protocol *p, const char *name) {
+ pa_assert(p);
+ pa_assert(PA_REFCNT_VALUE(p) >= 1);
+ pa_assert(name);
+
+ p->servers = pa_strlist_remove(p->servers, name);
+}
+
+pa_strlist *pa_http_protocol_servers(pa_http_protocol *p) {
+ pa_assert(p);
+ pa_assert(PA_REFCNT_VALUE(p) >= 1);
+
+ return p->servers;
+}
diff --git a/src/pulsecore/protocol-http.h b/src/pulsecore/protocol-http.h
index 40b3d82..f7517e8 100644
--- a/src/pulsecore/protocol-http.h
+++ b/src/pulsecore/protocol-http.h
@@ -26,7 +26,7 @@
#include <pulsecore/module.h>
#include <pulsecore/modargs.h>
#include <pulsecore/iochannel.h>
-
+#include <pulsecore/strlist.h>
typedef struct pa_http_protocol pa_http_protocol;
@@ -36,4 +36,8 @@ void pa_http_protocol_unref(pa_http_protocol *p);
void pa_http_protocol_connect(pa_http_protocol *p, pa_iochannel *io, pa_module *m);
void pa_http_protocol_disconnect(pa_http_protocol *p, pa_module *m);
+void pa_http_protocol_add_server_string(pa_http_protocol *p, const char *name);
+void pa_http_protocol_remove_server_string(pa_http_protocol *p, const char *name);
+pa_strlist *pa_http_protocol_servers(pa_http_protocol *p);
+
#endif
commit 93db3cba60f437fc97abcceceadcc2d7f4ce8479
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Apr 30 01:36:05 2009 +0200
rygel: instead of always handing out wildcard address find out the actual address we are listening on
diff --git a/src/modules/module-rygel-media-server.c b/src/modules/module-rygel-media-server.c
index 7136cbe..da6bc7a 100644
--- a/src/modules/module-rygel-media-server.c
+++ b/src/modules/module-rygel-media-server.c
@@ -47,6 +47,8 @@
#include <pulsecore/namereg.h>
#include <pulsecore/mime-type.h>
#include <pulsecore/strbuf.h>
+#include <pulsecore/protocol-http.h>
+#include <pulsecore/parseaddr.h>
#include "module-rygel-media-server-symdef.h"
@@ -158,6 +160,8 @@ struct userdata {
char *display_name;
pa_hook_slot *source_new_slot, *source_unlink_slot;
+
+ pa_http_protocol *http;
};
static void send_signal(struct userdata *u, pa_source *s, const char *name) {
@@ -287,6 +291,45 @@ static DBusHandlerResult root_handler(DBusConnection *c, DBusMessage *m, void *u
return DBUS_HANDLER_RESULT_HANDLED;
}
+static char *compute_url(struct userdata *u, const char *name) {
+ pa_strlist *i;
+
+ pa_assert(u);
+ pa_assert(name);
+
+ for (i = pa_http_protocol_servers(u->http); i; i = pa_strlist_next(i)) {
+ pa_parsed_address a;
+
+ PA_DEBUG_TRAP;
+
+ if (pa_parse_address(pa_strlist_data(i), &a) >= 0 &&
+ (a.type == PA_PARSED_ADDRESS_TCP4 ||
+ a.type == PA_PARSED_ADDRESS_TCP6 ||
+ a.type == PA_PARSED_ADDRESS_TCP_AUTO)) {
+
+ const char *address;
+ char *s;
+
+ if (pa_is_ip_address(a.path_or_host))
+ address = a.path_or_host;
+ else
+ address = "@ADDRESS@";
+
+ if (a.port <= 0)
+ a.port = 4714;
+
+ s = pa_sprintf_malloc("http://%s:%u/listen/source/%s", address, a.port, name);
+
+ pa_xfree(a.path_or_host);
+ return s;
+ }
+
+ pa_xfree(a.path_or_host);
+ }
+
+ return pa_sprintf_malloc("http://@ADDRESS@:4714/listen/source/%s", name);
+}
+
static DBusHandlerResult sinks_and_sources_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
struct userdata *u = userdata;
DBusMessage *r = NULL;
@@ -431,8 +474,7 @@ static DBusHandlerResult sinks_and_sources_handler(DBusConnection *c, DBusMessag
pa_assert_se(r = dbus_message_new_method_return(m));
- array[0] = pa_sprintf_malloc("http://@ADDRESS@:4714/listen/source/%s",
- sink ? sink->monitor_source->name : source->name);
+ array[0] = compute_url(u, sink ? sink->monitor_source->name : source->name);
pa_assert_se(dbus_message_append_args(
r,
@@ -487,6 +529,7 @@ int pa__init(pa_module *m) {
m->userdata = u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->module = m;
+ u->http = pa_http_protocol_get(u->core);
if ((t = pa_modargs_get_value(ma, "display_name", NULL)))
u->display_name = pa_utf8_filter(t);
@@ -565,5 +608,8 @@ void pa__done(pa_module*m) {
pa_xfree(u->display_name);
+ if (u->http)
+ pa_http_protocol_unref(u->http);
+
pa_xfree(u);
}
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list