summaryrefslogtreecommitdiff
path: root/src
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
parentadded udp socket handling to own file (diff)
some name refactoring
Diffstat (limited to 'src')
-rw-r--r--src/pipelines.c2
-rw-r--r--src/pipelines.h2
-rw-r--r--src/sydra.c4
-rw-r--r--src/udp.c43
-rw-r--r--src/udp.h2
5 files changed, 27 insertions, 26 deletions
diff --git a/src/pipelines.c b/src/pipelines.c
index 5c687fb..dc75499 100644
--- a/src/pipelines.c
+++ b/src/pipelines.c
@@ -233,7 +233,7 @@ static gboolean create_recorder_elements(options_t* opt, GstElement* pipeline, s
return TRUE;
}
-GstElement* create_pipeline(options_t* opt, struct udp_sinks *udp)
+GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp)
{
GstElement *pipeline = gst_pipeline_new ("sydra");
if(!pipeline) {
diff --git a/src/pipelines.h b/src/pipelines.h
index 3c68365..effd590 100644
--- a/src/pipelines.h
+++ b/src/pipelines.h
@@ -40,6 +40,6 @@
#include <gst/gst.h>
#include "options.h"
-GstElement* create_pipeline(options_t* opt, struct udp_sinks *udp);
+GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp);
#endif
diff --git a/src/sydra.c b/src/sydra.c
index 44abc38..d246b5d 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -171,7 +171,7 @@ int main_loop(options_t* opt)
struct udp_sinks udp = { { NULL, NULL }, { NULL, NULL },
{ NULL, NULL }, { NULL, NULL } };
- GstElement *pipeline = create_pipeline(opt, &udp);
+ GstElement *pipeline = create_sender_pipeline(opt, &udp);
if(!pipeline) {
log_printf(ERROR, "creating pipeline failed");
return -1;
@@ -192,7 +192,7 @@ int main_loop(options_t* opt)
log_printf(INFO, "Set State: Paused");
gst_element_set_state(pipeline, GST_STATE_PAUSED);
- if(!attach_udp_descriptors(&udp))
+ if(!attach_udpsinks(&udp))
return -1;
log_printf(INFO, "Set State: Playing");
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;
diff --git a/src/udp.h b/src/udp.h
index dcdc5ca..b7c2101 100644
--- a/src/udp.h
+++ b/src/udp.h
@@ -38,6 +38,6 @@
#include "datatypes.h"
-gboolean attach_udp_descriptors(struct udp_sinks *sinks);
+gboolean attach_udpsinks(struct udp_sinks *sinks);
#endif