summaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-24 23:52:13 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-24 23:52:13 +0200
commit812b94d7f880d8844da3533df083899eafe1d676 (patch)
tree3f36b14207282804818b089e0488e3530f6fdb53 /src/udp.c
parentadded udp socket handling to own file (diff)
some name refactoring
Diffstat (limited to 'src/udp.c')
-rw-r--r--src/udp.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/udp.c b/src/udp.c
index bce74d7..3c51511 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -45,7 +45,15 @@
#include "log.h"
-static void udp_add_client(struct sockaddr_storage *addr, socklen_t addrlen, struct udp_sink* sink)
+#define UDP_PROTO_MAGIC "SYDRA:"
+#define UDP_PROTO_MAGIC_LEN (sizeof(UDP_PROTO_MAGIC)-1)
+#define UDP_PROTO_CMD_ADD_CLIENT "add_client\n"
+#define UDP_PROTO_CMD_ADD_CLIENT_LEN (sizeof(UDP_PROTO_CMD_ADD_CLIENT)-1)
+#define UDP_PROTO_CMD_RM_CLIENT "remove_client\n"
+#define UDP_PROTO_CMD_RM_CLIENT_LEN (sizeof(UDP_PROTO_CMD_RM_CLIENT)-1)
+
+
+static void udpsink_add_client(struct sockaddr_storage *addr, socklen_t addrlen, struct udp_sink* sink)
{
struct addr_port* client = g_new(struct addr_port, 1);
if(!client) return;
@@ -74,7 +82,7 @@ static void udp_add_client(struct sockaddr_storage *addr, socklen_t addrlen, str
g_free(name);
}
-static void udp_remove_client(struct sockaddr_storage *addr, socklen_t addrlen, struct udp_sink* sink)
+static void udpsink_remove_client(struct sockaddr_storage *addr, socklen_t addrlen, struct udp_sink* sink)
{
// TODO: implement this!
gchar* name = gst_element_get_name(sink->udp_);
@@ -82,13 +90,6 @@ static void udp_remove_client(struct sockaddr_storage *addr, socklen_t addrlen,
g_free(name);
}
-#define UDP_PROTO_MAGIC "SYDRA:"
-#define UDP_PROTO_MAGIC_LEN (sizeof(UDP_PROTO_MAGIC)-1)
-#define UDP_PROTO_CMD_ADD_CLIENT "add_client\n"
-#define UDP_PROTO_CMD_ADD_CLIENT_LEN (sizeof(UDP_PROTO_CMD_ADD_CLIENT)-1)
-#define UDP_PROTO_CMD_RM_CLIENT "remove_client\n"
-#define UDP_PROTO_CMD_RM_CLIENT_LEN (sizeof(UDP_PROTO_CMD_RM_CLIENT)-1)
-
static gboolean on_udp_desc_ready(gint fd, GIOCondition cond, gpointer user_data)
{
struct udp_sink* sink = (struct udp_sink*)user_data;
@@ -117,17 +118,17 @@ static gboolean on_udp_desc_ready(gint fd, GIOCondition cond, gpointer user_data
u_int8_t* cmd = &(buf[UDP_PROTO_MAGIC_LEN]);
if(bytes == (UDP_PROTO_MAGIC_LEN+UDP_PROTO_CMD_ADD_CLIENT_LEN) &&
!memcmp(UDP_PROTO_CMD_ADD_CLIENT, cmd, UDP_PROTO_CMD_ADD_CLIENT_LEN)) {
- udp_add_client(&addr, addrlen, sink);
+ udpsink_add_client(&addr, addrlen, sink);
} else if(bytes == (UDP_PROTO_MAGIC_LEN+UDP_PROTO_CMD_RM_CLIENT_LEN) &&
!memcmp(UDP_PROTO_CMD_RM_CLIENT, cmd, UDP_PROTO_CMD_RM_CLIENT_LEN)) {
- udp_remove_client(&addr, addrlen, sink);
+ udpsink_remove_client(&addr, addrlen, sink);
} else {
log_printf(DEBUG, "client discovery: ignoring invalid command");
}
return TRUE;
}
-static gboolean attach_udp_descriptor(struct udp_sink* sink, const char* name, const char* prop)
+static gboolean attach_udpsink(struct udp_sink* sink, const char* name, const char* prop)
{
GSocket *sock;
g_object_get(G_OBJECT(sink->udp_), prop, &sock, NULL);
@@ -142,16 +143,16 @@ static gboolean attach_udp_descriptor(struct udp_sink* sink, const char* name, c
return TRUE;
}
-gboolean attach_udp_descriptors(struct udp_sinks *sinks)
+gboolean attach_udpsinks(struct udp_sinks *sinks)
{
- if(!attach_udp_descriptor(&(sinks->rtp_video_), "RTP(video) IPv4", "used-socket") ||
- !attach_udp_descriptor(&(sinks->rtp_video_), "RTP(video) IPv6", "used-socket-v6") ||
- !attach_udp_descriptor(&(sinks->rtcp_video_), "RTCP(video) IPv4", "used-socket") ||
- !attach_udp_descriptor(&(sinks->rtcp_video_), "RTCP(video) IPv6", "used-socket-v6") ||
- !attach_udp_descriptor(&(sinks->rtp_audio_), "RTP(audio) IPv4", "used-socket") ||
- !attach_udp_descriptor(&(sinks->rtp_audio_), "RTP(audio) IPv6", "used-socket-v6") ||
- !attach_udp_descriptor(&(sinks->rtcp_audio_), "RTCP(audio) IPv4", "used-socket") ||
- !attach_udp_descriptor(&(sinks->rtcp_audio_), "RTCP(audio) IPv6", "used-socket-v6")) {
+ if(!attach_udpsink(&(sinks->rtp_video_), "RTP(video) IPv4", "used-socket") ||
+ !attach_udpsink(&(sinks->rtp_video_), "RTP(video) IPv6", "used-socket-v6") ||
+ !attach_udpsink(&(sinks->rtcp_video_), "RTCP(video) IPv4", "used-socket") ||
+ !attach_udpsink(&(sinks->rtcp_video_), "RTCP(video) IPv6", "used-socket-v6") ||
+ !attach_udpsink(&(sinks->rtp_audio_), "RTP(audio) IPv4", "used-socket") ||
+ !attach_udpsink(&(sinks->rtp_audio_), "RTP(audio) IPv6", "used-socket-v6") ||
+ !attach_udpsink(&(sinks->rtcp_audio_), "RTCP(audio) IPv4", "used-socket") ||
+ !attach_udpsink(&(sinks->rtcp_audio_), "RTCP(audio) IPv6", "used-socket-v6")) {
return FALSE;
}
return TRUE;