summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-25 01:26:39 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-25 01:26:39 +0200
commitd0dd288687557c4dc4d4ade3caf22eccf0e74ffa (patch)
treeef21a035f686ee35f00226e8caf32683c4babd3b /src
parentadded timeout option (diff)
add callback for client timeout check
Diffstat (limited to 'src')
-rw-r--r--src/datatypes.h1
-rw-r--r--src/options.c2
-rw-r--r--src/sydra.c2
-rw-r--r--src/udp.c15
4 files changed, 18 insertions, 2 deletions
diff --git a/src/datatypes.h b/src/datatypes.h
index cc8179c..c5b5168 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -64,6 +64,7 @@ struct udp_sinks {
struct udp_sink rtcp_video_;
struct udp_sink rtp_audio_;
struct udp_sink rtcp_audio_;
+ int client_timeout_;
};
diff --git a/src/options.c b/src/options.c
index 737bd7d..f0daca6 100644
--- a/src/options.c
+++ b/src/options.c
@@ -230,7 +230,7 @@ void options_default(options_t* opt)
opt->rtp_port_base_ = 5000;
opt->rtp_addr_local_ = NULL;
opt->rtp_port_base_local_ = 5000;
- opt->timeout_ = 0;
+ opt->timeout_ = 30;
opt->preview_videosink_ = NULL;
diff --git a/src/sydra.c b/src/sydra.c
index a3772cd..877172a 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -169,7 +169,7 @@ int main_loop(options_t* opt)
log_printf(INFO, "entering main loop");
struct udp_sinks udp = { { NULL, NULL }, { NULL, NULL },
- { NULL, NULL }, { NULL, NULL } };
+ { NULL, NULL }, { NULL, NULL }, opt->timeout_ };
GstElement *pipeline = create_sender_pipeline(opt, &udp);
if(!pipeline) {
log_printf(ERROR, "creating pipeline failed");
diff --git a/src/udp.c b/src/udp.c
index c4da533..2064e4f 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -155,6 +155,13 @@ static gboolean on_udp_desc_ready(gint fd, GIOCondition cond, gpointer user_data
return TRUE;
}
+gboolean check_client_timeout(gpointer user_data)
+{
+ struct udp_sinks* sinks = (struct udp_sinks*)user_data;
+ log_printf(DEBUG, "******************* checking timeout *******************: %d sec.", sinks->client_timeout_);
+ return TRUE;
+}
+
static gboolean attach_udpsink(struct udp_sink* sink, const char* name, const char* prop)
{
GSocket *sock;
@@ -172,6 +179,9 @@ static gboolean attach_udpsink(struct udp_sink* sink, const char* name, const ch
gboolean attach_udpsinks(struct udp_sinks *sinks)
{
+ if(!sinks)
+ return FALSE;
+
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") ||
@@ -182,5 +192,10 @@ gboolean attach_udpsinks(struct udp_sinks *sinks)
!attach_udpsink(&(sinks->rtcp_audio_), "RTCP(audio) IPv6", "used-socket-v6")) {
return FALSE;
}
+ if(sinks->client_timeout_ > 0) {
+ if(!g_timeout_add_seconds(1, check_client_timeout, sinks))
+ return FALSE;
+ }
+
return TRUE;
}