summaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-10-01 02:02:51 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-10-01 02:02:51 +0200
commit4a1a07b2fe9dcd3327312aa092fe60d315f9ea37 (patch)
tree8baea457f7b6f336e9df481844a74fbc30999235 /src/udp.c
parentsending keep alives works now (diff)
sending remove client command when closed
Diffstat (limited to 'src/udp.c')
-rw-r--r--src/udp.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/udp.c b/src/udp.c
index 9de5d7a..d9133aa 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -230,13 +230,8 @@ gboolean attach_udpsinks(struct udp_sinks *sinks)
return TRUE;
}
-static gboolean send_keepalive(GstElement* source, const char* name, GInetAddress* remote, guint port)
+static gboolean send_udpsrc_buf(GstElement* source, const char* name, GInetAddress* remote, guint port, u_int8_t* buf, size_t buflen)
{
- if(!remote) {
- log_printf(WARNING, "keepalives are enabled but no remote address is set... disabling keep alives");
- return FALSE;
- }
-
GSocket *sock;
g_object_get(G_OBJECT(source), "used-socket", &sock, NULL);
int fd = g_socket_get_fd(sock);
@@ -264,13 +259,34 @@ static gboolean send_keepalive(GstElement* source, const char* name, GInetAddres
default: log_printf(ERROR, "remote address has unsupported protocol family - disabling keep alives"); return FALSE;
}
- log_printf(DEBUG, "sending keep-alive out on to %s %d - %s (fd=%d)", g_inet_address_to_string(remote), port, name, fd);
- gchar buf[] = UDP_PROTO_MAGIC UDP_PROTO_CMD_ADD_CLIENT;
- sendto(fd, buf, UDP_PROTO_MAGIC_LEN+UDP_PROTO_CMD_ADD_CLIENT_LEN, 0, (struct sockaddr *)&(addr), addrlen);
+ log_printf(DEBUG, "sending cmd out on to %s %d - %s (fd=%d)", g_inet_address_to_string(remote), port, name, fd);
+ sendto(fd, buf, buflen, 0, (struct sockaddr *)&(addr), addrlen);
return TRUE;
}
+static void send_remove(GstElement* source, const char* name, GInetAddress* remote, guint port)
+{
+ if(!remote)
+ return;
+
+ u_int8_t buf[] = UDP_PROTO_MAGIC UDP_PROTO_CMD_RM_CLIENT;
+ size_t buflen = UDP_PROTO_MAGIC_LEN+UDP_PROTO_CMD_RM_CLIENT_LEN;
+ send_udpsrc_buf(source, name, remote, port, buf, buflen);
+}
+
+static gboolean send_keepalive(GstElement* source, const char* name, GInetAddress* remote, guint port)
+{
+ if(!remote) {
+ log_printf(WARNING, "keepalives are enabled but no remote address is set... disabling keep alives");
+ return FALSE;
+ }
+
+ u_int8_t buf[] = UDP_PROTO_MAGIC UDP_PROTO_CMD_ADD_CLIENT;
+ size_t buflen = UDP_PROTO_MAGIC_LEN+UDP_PROTO_CMD_ADD_CLIENT_LEN;
+ return send_udpsrc_buf(source, name, remote, port, buf, buflen);
+}
+
static gboolean send_keepalives(gpointer user_data)
{
struct udp_sources* sources = (struct udp_sources*)user_data;
@@ -328,3 +344,12 @@ gboolean attach_udpsources(struct udp_sources *sources, gchar* rtphost)
return TRUE;
}
+
+void detach_udpsources(struct udp_sources *sources)
+{
+ guint port = sources->port_base_;
+ send_remove(sources->rtp_video_, "RTP(video)", sources->remote_addr_, port++);
+ send_remove(sources->rtcp_video_, "RTCP(video)", sources->remote_addr_, port++);
+ send_remove(sources->rtp_audio_, "RTP(audio)", sources->remote_addr_, port++);
+ send_remove(sources->rtcp_audio_, "RTCP(audio)", sources->remote_addr_, port++);
+}