From: <ra...@fr...> - 2004-08-25 03:07:07
|
CVS Root: /cvs/gstreamer Module: gst-sandbox Changes by: ramon Date: Tue Aug 24 2004 20:07:03 PDT Log message: address.c: Now compiles gstrtpdec.c: Fixes in param specs. Modified files: rtpdec : Makefile address.c gstrtpdec.c gstrtpdec.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/Makefile.diff?r1=1.7&r2=1.8 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/address.c.diff?r1=1.6&r2=1.7 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/gstrtpdec.c.diff?r1=1.15&r2=1.16 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/gstrtpdec.h.diff?r1=1.12&r2=1.13 ====Begin Diffs==== Index: Makefile =================================================================== RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile 25 Aug 2004 01:20:38 -0000 1.7 +++ Makefile 25 Aug 2004 03:06:51 -0000 1.8 @@ -1,22 +1,31 @@ CFLAGS=$(shell pkg-config --cflags gstreamer-0.8) -DGST_PACKAGE='"GStreamer"' -DGST_ORIGIN='"http://gstreamer.net"' -DVERSION='"0.0"' -DHAVE_USER_MTU -Wall -Werror -rtpdec.so: gstrtpdec.o rtpdec.o rtp_report.o socket_fns.o address.o - libtool --mode=link gcc -module -export-symbols-regex gst_plugin_desc \ - -o rtpdec.so \ - gstrtpdec.o rtpdec.o rtp_report.o socket_fns.o address.o \ + +rtpdec.la: gstrtpdec.lo rtpdec.lo rtp_report.lo socket_fns.lo address.lo + libtool --mode=link gcc -module \ + -rpath /home/ramon/projects/internet-radio/gstreamer/gst-sandbox/rtpdec \ + -export-symbols-regex gst_plugin_desc \ + -o rtpdec.la \ + gstrtpdec.lo rtpdec.lo rtp_report.lo socket_fns.lo address.lo \ $$(pkg-config --libs gstreamer-0.8) -gstrtpdec.o: gstrtpdec.c - libtool --mode=compile gcc $(CFLAGS) -c gstrtpdec.c +gstrtpdec.lo: gstrtpdec.c + libtool --mode=compile gcc $(CFLAGS) -o gstrtpdec.lo -c gstrtpdec.c -rtpdec.o: rtpdec.c - libtool --mode=compile gcc $(CFLAGS) -c rtpdec.c +rtpdec.lo: rtpdec.c + libtool --mode=compile gcc $(CFLAGS) -o rtpdec.lo -c rtpdec.c -rtp_report.o: rtp_report.c - libtool --mode=compile gcc $(CFLAGS) -c rtp_report.c +rtp_report.lo: rtp_report.c + libtool --mode=compile gcc $(CFLAGS) -o rtp_report.lo -c rtp_report.c -socket_fns.o: socket_fns.c - libtool --mode=compile gcc $(CFLAGS) -c socket_fns.c +socket_fns.lo: socket_fns.c + libtool --mode=compile gcc $(CFLAGS) -o socket_fns.lo -c socket_fns.c -address.o: address.c - libtool --mode=compile gcc $(CFLAGS) -c address.c +address.lo: address.c + libtool --mode=compile gcc $(CFLAGS) -o address.o -c address.c +.PHONY: install +install: rtpdec.la + libtool --mode=install install rtpdec.la /home/ramon/projects/internet-radio/gstreamer-build/lib/gstreamer-0.8/ Index: address.c RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/address.c,v retrieving revision 1.6 diff -u -d -r1.6 -r1.7 --- address.c 25 Aug 2004 01:20:38 -0000 1.6 +++ address.c 25 Aug 2004 03:06:51 -0000 1.7 @@ -1,5 +1,6 @@ #include "address.h" #include <netdb.h> +#include <string.h> static gpointer gst_address_copy (gpointer); @@ -7,6 +8,8 @@ static void resolve_name (const gchar * name, GstNumAddress * result); +static void map_ipv4_to_ipv6(const struct in_addr* ipv4_addr, const struct in6_addr* ipv6_addr); GType gst_address_get_type (void) { @@ -55,26 +58,20 @@ void gst_addr_resolve_address (const GstAddress * address, GstNumAddress * result) - if (result->alternatives != NULL) { - g_free (result->alternatives); - } - result->num_alternatives = 0; - result->alternatives = NULL; + struct in6_addr addr6; + g_assert(result->alternatives == NULL); + // result->alternatives = g_array_new(FALSE, TRUE, sizeof(struct in6_addr)); switch (address->type) { case ADDR_IPV4: - result->num_alternatives = 1; - result->alternatives = g_new (struct in6_addr, 1); - - map_ipv4_to_ipv6 (address->addr.ipv4_address, result->alternatives[0]); + map_ipv4_to_ipv6 (&address->addr.ipv4_address, &addr6); + result->alternatives = g_array_sized_new(FALSE, TRUE, sizeof(struct in6_addr), 1); + g_array_append_vals(result->alternatives, (gpointer) &addr6, 1); break; case ADDR_IPV6: - result->alternatives[0] = address->addr.ipv6_address; + g_array_append_vals(result->alternatives, (gpointer) &address->addr.ipv6_address , 1); case ADDR_NAME: resolve_name (address->addr.name, result); } } @@ -82,32 +79,32 @@ resolve_name (const gchar * name, GstNumAddress * result) int error; - struct addrinfo *result; + struct addrinfo *result_ai; struct addrinfo *link; - error = getaddrinfo (name, NULL, NULL, &result); + guint num_alternatives, alternative; + error = getaddrinfo (name, NULL, NULL, &result_ai); if (error != 0) return; - link = result; + link = result_ai; while (link != NULL) { if (link->ai_family == AF_INET || link->ai_family == AF_INET6) { - result->num_alternatives++; + num_alternatives++; } link = link->ai_next; - result->alternatives = g_new0 (struct in6_addr, result->num_alternatives); + result->alternatives = g_array_sized_new(FALSE, FALSE, sizeof(struct in6_addr), num_alternatives); - alternative = result->alternatives; + alternative = 0; if (link->ai_protocol == AF_INET || link->ai_family == AF_INET6) { - *alternative = ((struct sockaddr_in6 *) link->ai_addr)->sin6_addr; + g_array_index(result->alternatives, struct in6_addr, alternative) = ((struct sockaddr_in6 *) link->ai_addr)->sin6_addr; alternative++; - freeaddrinfo (result); + freeaddrinfo (result_ai); gboolean @@ -115,14 +112,16 @@ int i; - struct in6_addr addr; - g_assert (address->len > 0); - for (i = 0; i < address->len; i++) { - addr = g_array_index (address, struct in6_addr, i); + struct sockaddr_in6 addr; + g_assert (address->alternatives->len > 0); + for (i = 0; i < address->alternatives->len; i++) { + addr.sin6_family = AF_INET6; + addr.sin6_flowinfo = 0; + addr.sin6_scope_id = 0; + addr.sin6_addr = g_array_index (address->alternatives, struct in6_addr, i); addr.sin6_port = port; - error = bind (socket, &addr, sizeof (struct in6_addr)); + error = bind (socket, (struct sockaddr*) &addr, sizeof (struct sockaddr_in6)); if (error == 0) { @@ -135,14 +134,16 @@ - struct in6_adr addr; - g_assert (addess->len > 0); - error = connect (socket, &addr, sizeof (struct in6_addr)); + error = connect (socket, (struct sockaddr*) &addr, sizeof (struct sockaddr_in6)); @@ -152,18 +153,19 @@ -try_send (int socket, GstNumAddressPort * remote, const char *data, guint size) +gst_addr_try_send (int socket, const GstNumAddress * remote, in_port_t port, const char *data, guint size) struct sockaddr_in6 peer; guint i; gboolean sucess; + int error; - peer.sin6_port = remote->port; + peer.sin6_port = htons(port); peer.sin6_flowinfo = 0; peer.sin6_scope_id = 0; - for (i = 0; i < remote->address.num_alternatives; i++) { - peer.sin6_addr = remote->address.alternatives[i]; - error = sendto (socket, data, size, 0, &peer, sizeof (sockaddr_in6)); + for (i = 0; i < remote->alternatives->len; i++) { + peer.sin6_addr = g_array_index(remote->alternatives, struct in6_addr, i); + error = sendto (socket, data, size, 0, (struct sockaddr*) &peer, sizeof (struct sockaddr_in6)); sucess = error >= 0; if (sucess) @@ -174,23 +176,29 @@ gst_addr_allowed (const GstAuthorizedAddrs * acls, struct sockaddr_in6 *peer) - GstAuthorizedAddr *acl_entry; - GstNumAddr *addr; - struct in6_addr *addr_alt; + const GstAuthorizedAddr *acl_entry; + const GstNumAddress *addr; + const struct in6_addr *addr_alt; unsigned int i, j; for (i = 0; i < acls->authorized_addrs->len; i++) { - acl_entry = g_array_index (acls->authorized_addrs, GstAuthorizedAddr, i); + acl_entry = & g_array_index (acls->authorized_addrs, const GstAuthorizedAddr, i); if (peer->sin6_port < acl_entry->low || peer->sin6_port > acl_entry->high) continue; addr = &acl_entry->addr; for (j = 0; j < addr->alternatives->len; j++) { - addr_alt = ((struct in6_addr *) + addr_alt = &((const struct in6_addr *) addr->alternatives->data)[j]; - if (memcpy (addr_alt, peer->sin6_addr, sizeof (struct sockaddr_in6))) { + if (memcmp (addr_alt, &peer->sin6_addr, sizeof (struct sockaddr_in6))) { return TRUE; } return FALSE; +static void map_ipv4_to_ipv6(const struct in_addr* ipv4_addr, const struct in6_addr* ipv6_addr) +{ + /* FIXME: implement */ +} Index: gstrtpdec.c RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/gstrtpdec.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- gstrtpdec.c 25 Aug 2004 01:20:38 -0000 1.15 +++ gstrtpdec.c 25 Aug 2004 03:06:51 -0000 1.16 @@ -145,10 +145,10 @@ GST_TYPE_ADDRESS, G_PARAM_WRITABLE)); g_object_class_install_property (gobject_class, ARG_REMOTE_DATA_PORT, g_param_spec_int ("remote_data_port", "remote_data_port", "the port in machine we will connect, from where data will be delivered", - 0, 32767, -1, G_PARAM_READWRITE)); + 0, 32767, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_REMOTE_CONTROL_PORT, - g_param_spec_int ("remote_data_port", "remote_data_port", "the port in machine we will connect, from where data will be delivered", + g_param_spec_int ("remote_control_port", "remote_control_port", "the port in machine we will connect, from where data will be delivered", g_object_class_install_property (gobject_class, ARG_REMOTE_HOST, g_param_spec_boxed("remote_addr", "remote_addr", "the address of the remote machine that we will talk to", Index: gstrtpdec.h RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/gstrtpdec.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- gstrtpdec.h 13 Aug 2004 10:30:53 -0000 1.12 +++ gstrtpdec.h 25 Aug 2004 03:06:51 -0000 1.13 @@ -28,8 +28,8 @@ typedef struct _GstRtpdec GstRtpdec; typedef struct _GstRtpdecClass GstRtpdecClass; -const guint32 sender_magic = 0x0c0deb12; -const guint32 recv_magic = 0x0badbeef; +static const guint32 sender_magic = 0x0c0deb12; +static const guint32 recv_magic = 0x0badbeef; struct _GstRtpdecHandler; |