diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-17 12:01:21 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-17 12:01:23 (GMT) |
commit | ba9064de9af710f1215cf8ad0c7094d190dbfade (patch) | |
tree | 4460400edae5e6b3d425a664b1dd2dae5278ef29 /src | |
parent | e9e577c4aba08656a6cc3afe0c51d101ce01b730 (diff) | |
download | soup-transcoding-proxy-ba9064de9af710f1215cf8ad0c7094d190dbfade.zip soup-transcoding-proxy-ba9064de9af710f1215cf8ad0c7094d190dbfade.tar.gz |
appsink: Force encodebin to create a keyframe when a client connects
This avoids long waits when, for instance, the fps is 3, since the
keyframe-max-dist is 128
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -21,6 +21,7 @@ */ #include <glib-unix.h> +#include <gst/video/video.h> #include "lib.h" #include "encode.h" @@ -240,10 +241,11 @@ GET: /* A GET request was received. We connect from the pipeline to the * client requesting the stream and start writing the response. */ GstCaps *caps = NULL; + GstEvent *event; GstBuffer *buffer; GstFlowReturn ret; GstStateChangeReturn state_change; - GstElement *bin, *tee, *q2, *appsink; + GstElement *encodebin, *bin, *tee, *q2, *appsink; GstPadTemplate *template; GstPad *srcpad, *sinkpadq2; TranscodeClientCtx *client_ctx; @@ -322,7 +324,7 @@ GET: buffer = stp_get_streamheader_from_caps (caps); if (!buffer) { g_critical ("Unable to get streamheader from caps"); - goto nostreamheader; + goto force_key_unit; } ret = gst_pad_push (srcpad, buffer); @@ -332,7 +334,17 @@ GET: goto err; } -nostreamheader: +force_key_unit: + encodebin = gst_bin_get_by_name (GST_BIN (server_ctx->pipeline), + "encodebin"); + event = gst_video_event_new_downstream_force_key_unit (GST_CLOCK_TIME_NONE, + GST_CLOCK_TIME_NONE, + GST_CLOCK_TIME_NONE, + FALSE, 1); + if (!gst_element_send_event (encodebin, event)) + g_critical ("Couldn't send upstream key unit event!"); + gst_object_unref (encodebin); + client_ctx->appsink = appsink; g_signal_connect (appsink, "new-sample", |