From f23736d52f66ae951c85ad4d7f2d0bd1cc672447 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Fri, 27 Mar 2015 20:16:28 +0100 Subject: [PATCH] appsrc: handle a sample not having caps or a buffer more gracefully https://bugzilla.gnome.org/show_bug.cgi?id=746908 --- gst-libs/gst/app/gstappsrc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index f3a56b3560..c47cace97f 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -1666,10 +1666,22 @@ gst_app_src_push_sample_internal (GstAppSrc * appsrc, GstSample * sample) { GstBuffer *buffer; GstCaps *caps; + g_return_val_if_fail (GST_IS_SAMPLE (sample), GST_FLOW_ERROR); + caps = gst_sample_get_caps (sample); - gst_app_src_set_caps (appsrc, caps); + if (caps != NULL) { + gst_app_src_set_caps (appsrc, caps); + } else { + GST_WARNING_OBJECT (appsrc, "received sample without caps"); + } + buffer = gst_sample_get_buffer (sample); + if (buffer == NULL) { + GST_WARNING_OBJECT (appsrc, "received sample without buffer"); + return GST_FLOW_OK; + } + return gst_app_src_push_buffer_full (appsrc, buffer, FALSE); }