summaryrefslogtreecommitdiff
path: root/src/sydra.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-22 05:17:42 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-22 05:17:42 +0200
commit00902a0ef808048f6d839723090e477b15a2d9e9 (patch)
tree997a6f049d67cda6dc52b5fbe81bfc5c206d8872 /src/sydra.c
parentfixed wrong type for textoverlay parameters (diff)
recording with different codecs works now
Signed-off-by: Christian Pointner <equinox@spreadspace.org>
Diffstat (limited to 'src/sydra.c')
-rw-r--r--src/sydra.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/sydra.c b/src/sydra.c
index 5dc7ba4..8d637f2 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -227,7 +227,7 @@ static gboolean sydra_link_static_compatible(GstElement* src, const char* src_pa
if(!src_pad) return FALSE;
GstPad *sink_pad = gst_element_get_compatible_pad(sink, src_pad, NULL);
- if(!src_pad) return FALSE;
+ if(!sink_pad) return FALSE;
gchar* sink_pad_name = gst_pad_get_name(sink_pad);
gboolean res = sydra_link_pads(src, src_pad, src_pad_name, sink, sink_pad, sink_pad_name);
@@ -353,17 +353,30 @@ static gboolean create_preview_elements(const char* preview_bin_desc, GstElement
return TRUE;
}
-static gboolean create_recorder_elements(const char* mux_str, const char* name_format, GstElement* pipeline, GstElement* tv, GstElement* ta)
+static gboolean create_recorder_elements(options_t* opt, GstElement* pipeline, struct media_elements *mv, struct media_elements *ma)
{
GstElement *qv = sydra_create_element("queue", NULL);
GstElement *qa = sydra_create_element("queue", NULL);
- GstElement *mux = sydra_create_element(mux_str, NULL);
+ GstElement *mux = sydra_create_element(opt->rec_mux_, NULL);
GstElement *sink = sydra_create_element("filesink", NULL);
if(!qv || !qa || !mux || !sink) {
return FALSE;
}
+ GstElement *ev = NULL, *tv = mv->tee_enc_;
+ if(opt->video_enc_rec_) {
+ ev = sydra_create_bin_from_desc("record video encoder", opt->video_enc_rec_);
+ if(!ev) return FALSE;
+ tv = mv->tee_raw_;
+ }
+ GstElement *ea = NULL, *ta = ma->tee_enc_;
+ if(opt->audio_enc_rec_) {
+ ea = sydra_create_bin_from_desc("record audio encoder", opt->audio_enc_rec_);
+ if(!ea) return FALSE;
+ ta = ma->tee_raw_;
+ }
+
log_printf(DEBUG, "recorder path created successfully!");
struct timespec now;
@@ -371,20 +384,29 @@ static gboolean create_recorder_elements(const char* mux_str, const char* name_f
struct tm bd_time;
localtime_r(&(now.tv_sec), &bd_time);
char recfile[1024]; //TODO: fix this hardcoded length
- strftime(recfile, sizeof(recfile), name_format, &bd_time);
+ recfile[0] = 0;
+ strftime(recfile, sizeof(recfile), opt->rec_name_format_, &bd_time);
g_object_set(G_OBJECT(sink), "location", recfile, NULL);
- gst_bin_add_many (GST_BIN(pipeline), qv, qa, mux, sink, NULL);
+ gst_bin_add_many(GST_BIN(pipeline), qv, qa, mux, sink, NULL);
gst_element_link(mux, sink);
+ GstElement* sv = qv;
+ if(ev) {
+ gst_bin_add(GST_BIN(pipeline), ev);
+ gst_element_link(qv, ev);
+ sv = ev;
+ }
+ GstElement* sa = qa;
+ if(ev) {
+ gst_bin_add(GST_BIN(pipeline), ea);
+ gst_element_link(qa, ea);
+ sa = ea;
+ }
- /* if(!sydra_link_request_static(tv, "src_%u", qv, "sink") || */
- /* !sydra_link_static_compatible(qv, "src", mux) || */
- /* !sydra_link_request_static(ta, "src_%u", qa, "sink") || */
- /* !sydra_link_static_compatible(qa, "src", mux)) { */
- /* return FALSE; */
- /* } */
if(!sydra_link_request_static(tv, "src_%u", qv, "sink") ||
- !sydra_link_static_compatible(qv, "src", mux)) {
+ !sydra_link_static_compatible(sv, "src", mux) ||
+ !sydra_link_request_static(ta, "src_%u", qa, "sink") ||
+ !sydra_link_static_compatible(sa, "src", mux)) {
return FALSE;
}
@@ -423,7 +445,7 @@ static GstElement* create_pipeline(options_t* opt)
}
if(opt->rec_mux_) {
- if(!create_recorder_elements(opt->rec_mux_, opt->rec_name_format_, pipeline, video.tee_enc_, audio.tee_enc_))
+ if(!create_recorder_elements(opt, pipeline, &video, &audio))
return NULL;
}