summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-10-01 01:00:52 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-10-01 01:00:52 +0200
commitcbdf9a12a01e7c17b846a76ea432aa6be4cc3baf (patch)
treedfe97ab75b70c573cae37b7a6f4e96104f4002f7 /src
parentsome cleanup (diff)
resolving remote rtp works now
Diffstat (limited to 'src')
-rw-r--r--src/sydra.c12
-rw-r--r--src/udp.c64
-rw-r--r--src/udp.h2
3 files changed, 65 insertions, 13 deletions
diff --git a/src/sydra.c b/src/sydra.c
index 22f0157..f94610c 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -108,7 +108,7 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
{
GstClock *clock;
gst_message_parse_new_clock(msg, &clock);
- log_printf(INFO, "New clock: %s", (clock ? GST_OBJECT_NAME (clock) : "NULL"));
+ log_printf(NOTICE, "New clock: %s", (clock ? GST_OBJECT_NAME (clock) : "NULL"));
break;
}
case GST_MESSAGE_QOS: {
@@ -165,11 +165,11 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
int main_loop(options_t* opt)
{
- log_printf(INFO, "entering main loop");
+ log_printf(NOTICE, "entering main loop");
struct udp_sinks sinks = { { NULL, NULL }, { NULL, NULL },
{ NULL, NULL }, { NULL, NULL }, opt->timeout_ };
- struct udp_sources sources = { NULL, NULL, NULL, NULL, opt->keepalive_int_ };
+ struct udp_sources sources = { NULL, NULL, NULL, NULL, opt->keepalive_int_, NULL };
GstElement *pipeline = opt->mode_ == SENDER ? create_sender_pipeline(opt, &sinks) :
create_receiver_pipeline(opt, &sources);
if(!pipeline) {
@@ -189,14 +189,14 @@ int main_loop(options_t* opt)
G_CALLBACK(gst_object_default_deep_notify), NULL);
}
- log_printf(INFO, "Set State: Paused");
+ log_printf(NOTICE, "Set State: Paused");
gst_element_set_state(pipeline, GST_STATE_PAUSED);
if((opt->mode_ == SENDER && !attach_udpsinks(&sinks)) ||
- (opt->mode_ == RECEIVER && !attach_udpsources(&sources)))
+ (opt->mode_ == RECEIVER && !attach_udpsources(&sources, opt->rtp_host_)))
return -1;
- log_printf(INFO, "Set State: Playing");
+ log_printf(NOTICE, "Set State: Playing");
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_unix_signal_add(SIGHUP, sig_handler_terminate, loop);
diff --git a/src/udp.c b/src/udp.c
index 78b09aa..ee6170c 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -230,21 +230,73 @@ gboolean attach_udpsinks(struct udp_sinks *sinks)
return TRUE;
}
+static gboolean send_keepalive(GstElement* source, const char* name, GInetAddress* remote)
+{
+ 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);
+
+ log_printf(WARNING, "if implemented keep alives would be sent out to fd: %d", fd);
+ return TRUE;
+}
+
static gboolean send_keepalives(gpointer user_data)
{
- log_printf(WARNING, "sending keep alives is not yet supporet!");
+ struct udp_sources* sources = (struct udp_sources*)user_data;
+ if(!send_keepalive(sources->rtp_video_, "RTP(video)", sources->remote_addr_) ||
+ !send_keepalive(sources->rtcp_video_, "RTCP(video)", sources->remote_addr_) ||
+ !send_keepalive(sources->rtp_audio_, "RTP(audio)", sources->remote_addr_) ||
+ !send_keepalive(sources->rtcp_audio_, "RTCP(audio)", sources->remote_addr_)) {
+ return FALSE;
+ }
+
return TRUE;
}
-gboolean attach_udpsources(struct udp_sources *sources)
+void on_rtphost_resolved(GObject* resolver, GAsyncResult *res, gpointer user_data)
+{
+ struct udp_sources* sources = (struct udp_sources*)user_data;
+ GError *error = NULL;
+ GList* addrs = g_resolver_lookup_by_name_finish ((GResolver *)resolver, res, &error);
+ if(!addrs) {
+ log_printf(ERROR, "Resolving of remote RTP host failed: %s", error ? error->message : "unknown error");
+ g_error_free(error);
+ return;
+ }
+
+ GList *entry;
+ guint idx;
+ log_printf(DEBUG, "Resolving of remote RTP host succeded:");
+ for (entry = addrs, idx = 1; entry != NULL; entry = entry->next, ++idx) {
+ GInetAddress* addr = (GInetAddress*)entry->data;
+ if(!sources->remote_addr_) {
+ sources->remote_addr_ = g_inet_address_new_from_bytes(g_inet_address_to_bytes(addr),
+ g_inet_address_get_family(addr));
+ log_printf(DEBUG, " result %d: %s (selected)", idx, g_inet_address_to_string(addr));
+ } else {
+ log_printf(DEBUG, " result %d: %s", idx, g_inet_address_to_string(addr));
+ }
+ }
+ g_resolver_free_addresses(addrs);
+ log_printf(INFO, "Set address for remote RTP host: %s", g_inet_address_to_string(sources->remote_addr_));
+
+ if(send_keepalives(sources))
+ g_timeout_add_seconds(sources->keepalive_interval_, send_keepalives, sources);
+}
+
+gboolean attach_udpsources(struct udp_sources *sources, gchar* rtphost)
{
if(!sources)
return FALSE;
- if(sources->keepalive_interval_ > 0) {
- send_keepalives(sources);
- if(!g_timeout_add_seconds(sources->keepalive_interval_, send_keepalives, sources))
- return FALSE;
+ if(sources->keepalive_interval_ > 0 && rtphost) {
+ GResolver* resolver = g_resolver_get_default();
+ g_resolver_lookup_by_name_async(resolver, rtphost, NULL, on_rtphost_resolved, sources);
}
return TRUE;
diff --git a/src/udp.h b/src/udp.h
index ed3c7e7..c9606c4 100644
--- a/src/udp.h
+++ b/src/udp.h
@@ -39,6 +39,6 @@
#include "datatypes.h"
gboolean attach_udpsinks(struct udp_sinks *sinks);
-gboolean attach_udpsources(struct udp_sources *sources);
+gboolean attach_udpsources(struct udp_sources *sources, gchar* rtphost);
#endif