diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-09-27 18:35:34 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-09-27 18:35:34 +0200 |
commit | 15b4ff94088747cb6a29f05a48d2dd55f51acb81 (patch) | |
tree | b34e39caba27da9d6a19a26d5c4a2a86cfcef716 | |
parent | added option for mode (diff) |
prepared main loop for receiver mode
-rw-r--r-- | src/datatypes.h | 7 | ||||
-rw-r--r-- | src/options.c | 10 | ||||
-rw-r--r-- | src/options.h | 1 | ||||
-rw-r--r-- | src/pipelines.c | 6 | ||||
-rw-r--r-- | src/pipelines.h | 1 | ||||
-rw-r--r-- | src/sydra.c | 9 | ||||
-rw-r--r-- | src/udp.c | 11 | ||||
-rw-r--r-- | src/udp.h | 1 |
8 files changed, 42 insertions, 4 deletions
diff --git a/src/datatypes.h b/src/datatypes.h index 44912f8..f60d97f 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -69,5 +69,12 @@ struct udp_sinks { int client_timeout_; }; +struct udp_sources { + GstElement* rtp_video_; + GstElement* rtcp_video_; + GstElement* rtp_audio_; + GstElement* rtcp_audio_; + int keepalive_interval_; +}; #endif diff --git a/src/options.c b/src/options.c index 18fe1e1..48a0f20 100644 --- a/src/options.c +++ b/src/options.c @@ -74,6 +74,7 @@ static void options_defaults(options_t* opt) opt->rtp_addr_local_ = NULL; opt->rtp_port_base_local_ = 5000; opt->timeout_ = 30; + opt->keepalive_int_ = 10; opt->preview_videosink_ = NULL; @@ -129,7 +130,9 @@ static GOptionGroup* options_get_rtp_group(options_t* opt) { "rtp-port-base-local", 'O', 0, G_OPTION_ARG_INT, &opt->rtp_port_base_local_, "base number for local ports to bind to", "PORT" }, { "timeout", 't', 0, G_OPTION_ARG_INT, &opt->timeout_, - "client timeout in seconds (0 means no timeout)", "VALUE" }, + "client timeout in seconds (0 means no timeout) - sender mode only!", "VALUE" }, + { "keepalive-interval", 'k', 0, G_OPTION_ARG_INT, &opt->keepalive_int_, + "interval in seconds for sending out keep alive messages (0 means no keep alives) - receiver mode only!", "VALUE" }, { NULL } }; GOptionGroup* rtp_group = g_option_group_new ("rtp", "RTP Options", @@ -262,6 +265,10 @@ static int options_parse_post(options_t* opt) printf("Failed to initialize: timeout is invalid\n"); return -3; } + if(opt->keepalive_int_ < 0) { + printf("Failed to initialize: keep alive interval is invalid\n"); + return -3; + } if(opt->debug_) { opt->daemonize_ = 0; @@ -364,6 +371,7 @@ void options_print(options_t* opt) printf(" rtp_addr_local: >>%s<<\n", opt->rtp_addr_local_); printf(" rtp_port_base_local: %d\n", opt->rtp_port_base_local_); printf(" timeout: %d\n", opt->timeout_); + printf(" keepalive_int: %d\n", opt->keepalive_int_); printf(" preview_video_sink: >>%s<<\n", opt->preview_videosink_); printf(" video_enc_rec: >>%s<<\n", opt->video_enc_rec_); printf(" audio_enc_rec: >>%s<<\n", opt->audio_enc_rec_); diff --git a/src/options.h b/src/options.h index a4e0bc7..983964e 100644 --- a/src/options.h +++ b/src/options.h @@ -64,6 +64,7 @@ struct options_struct { gchar* rtp_addr_local_; gint rtp_port_base_local_; gint timeout_; + gint keepalive_int_; gchar* preview_videosink_; diff --git a/src/pipelines.c b/src/pipelines.c index 3d32237..b241cde 100644 --- a/src/pipelines.c +++ b/src/pipelines.c @@ -266,3 +266,9 @@ GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp) log_printf(DEBUG, "pipeline created successfully!"); return pipeline; } + +GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp) +{ + log_printf(ERROR, "Receiver Mode is not yet implemented!"); + return NULL; +} diff --git a/src/pipelines.h b/src/pipelines.h index effd590..0d09e3a 100644 --- a/src/pipelines.h +++ b/src/pipelines.h @@ -41,5 +41,6 @@ #include "options.h" GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp); +GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp); #endif diff --git a/src/sydra.c b/src/sydra.c index a7a73f4..ca48724 100644 --- a/src/sydra.c +++ b/src/sydra.c @@ -167,9 +167,11 @@ int main_loop(options_t* opt) { log_printf(INFO, "entering main loop"); - struct udp_sinks udp = { { NULL, NULL }, { NULL, NULL }, + struct udp_sinks sinks = { { NULL, NULL }, { NULL, NULL }, { NULL, NULL }, { NULL, NULL }, opt->timeout_ }; - GstElement *pipeline = create_sender_pipeline(opt, &udp); + struct udp_sources sources = { NULL, NULL, NULL, NULL, opt->keepalive_int_ }; + GstElement *pipeline = opt->mode_ == SENDER ? create_sender_pipeline(opt, &sinks) : + create_receiver_pipeline(opt, &sources); if(!pipeline) { log_printf(ERROR, "creating pipeline failed"); return -1; @@ -190,7 +192,8 @@ int main_loop(options_t* opt) log_printf(INFO, "Set State: Paused"); gst_element_set_state(pipeline, GST_STATE_PAUSED); - if(!attach_udpsinks(&udp)) + if((opt->mode_ == SENDER && !attach_udpsinks(&sinks)) || + (opt->mode_ == RECEIVER && !attach_udpsources(&sources))) return -1; log_printf(INFO, "Set State: Playing"); @@ -229,3 +229,14 @@ gboolean attach_udpsinks(struct udp_sinks *sinks) return TRUE; } + + +gboolean attach_udpsources(struct udp_sources *sources) +{ + if(!sources) + return FALSE; + + log_printf(ERROR, "Receiver Mode is not yet implemented!"); + + return FALSE; +} @@ -39,5 +39,6 @@ #include "datatypes.h" gboolean attach_udpsinks(struct udp_sinks *sinks); +gboolean attach_udpsources(struct udp_sources *sources); #endif |