summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sydra.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/sydra.c b/src/sydra.c
index dd85038..1c9e605 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -480,30 +480,48 @@ static GstElement* create_pipeline(options_t* opt, struct udp_elements *udp)
}
+struct addr_port{
+ enum { IPv4, IPv6 } type_;
+ gchar addr_[INET6_ADDRSTRLEN + 1];
+ guint16 port_;
+};
+
+int cmp_addr_port(struct addr_port *a, struct addr_port *b)
+{
+ if(a->type_ != b->type_ || a->port_ != b->port_)
+ return -1;
+ return strncmp(a->addr_, b->addr_, sizeof(a->addr_));
+}
+
static void udp_add_client(struct sockaddr_storage *addr, socklen_t addrlen, GstElement* udp)
{
- char addrstr[INET6_ADDRSTRLEN + 1];
- u_short port;
- char addrport_sep = ':';
+ struct addr_port* client = g_new(struct addr_port, 1);
+ if(!client) return;
switch(addr->ss_family)
{
- case AF_INET: addrport_sep = ':'; port = ntohs(((struct sockaddr_in*)addr)->sin_port); break;
- case AF_INET6: addrport_sep = '.'; port = ntohs(((struct sockaddr_in6*)addr)->sin6_port); break;
+ case AF_INET: client->type_ = IPv4; client->port_ = ntohs(((struct sockaddr_in*)addr)->sin_port); break;
+ case AF_INET6: client->type_ = IPv6; client->port_ = ntohs(((struct sockaddr_in6*)addr)->sin6_port); break;
default: return;
}
- int errcode = getnameinfo((struct sockaddr *)addr, addrlen, addrstr, sizeof(addrstr), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
+ int errcode = getnameinfo((struct sockaddr *)addr, addrlen, client->addr_, sizeof(client->addr_), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
if (errcode != 0) {
log_printf(WARNING, "getnameinfo() error: %s", gai_strerror(errcode));
return;
}
gchar* name = gst_element_get_name(udp);
- log_printf(DEBUG, "adding host %s%c%d to list of receivers to element %s", addrstr, addrport_sep, port, name);
+ log_printf(DEBUG, "adding host %s%c%d to list of receivers to element %s", client->addr_, client->type_ == IPv4 ? ':' : '.', client->port_, name);
g_free(name);
- g_signal_emit_by_name(G_OBJECT(udp), "add", addrstr, port, NULL);
+ g_signal_emit_by_name(G_OBJECT(udp), "add", client->addr_, client->port_, NULL);
+ g_free(client);
}
+struct on_udp_desc_read_param {
+ GstElement* udp_;
+ GList* clients_;
+};
+
static gboolean on_udp_desc_ready(gint fd, GIOCondition cond, gpointer user_data)
{
GstElement* udp = (GstElement*)user_data;
@@ -560,6 +578,7 @@ static gboolean attach_udp_descriptors(struct udp_elements *udp)
}
+
int main_loop(options_t* opt)
{
log_printf(INFO, "entering main loop");