diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/main.c | 18 |
2 files changed, 16 insertions, 4 deletions
@@ -2,7 +2,7 @@ DEBUG_CFLAGS := -O0 -ggdb -Wall -fsanitize=address -fno-omit-frame-pointer -DENC CFLAGS := -O0 -ggdb -Wall -fno-omit-frame-pointer -DENCODE_DEBUG #CFLAGS := -O3 -march=native -Wall PKGCONFIG := pkg-config -LIBS := $(shell $(PKGCONFIG) --libs --cflags glib-2.0 gio-unix-2.0 libsoup-2.4 gstreamer-pbutils-1.0) -lrt +LIBS := $(shell $(PKGCONFIG) --libs --cflags glib-2.0 gio-unix-2.0 libsoup-2.4 gstreamer-pbutils-1.0 gstreamer-video-1.0) -lrt SERVER_NAME := stp-server SRC_OBJS := $(addprefix src/,debug/local-play.o lib.o encode.o) @@ -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", |