mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
rtmpsink: don't crash if there's streamheader field in the caps
Fix regression when used in combination with new flvmux which was ported to GstAggregator, and which sends plain video/x-flv caps before sending full caps that include streamheaders.
This commit is contained in:
parent
297f7e4f04
commit
49d30c901d
1 changed files with 25 additions and 13 deletions
|
@ -398,8 +398,6 @@ gst_rtmp_sink_setcaps (GstBaseSink * sink, GstCaps * caps)
|
|||
GstRTMPSink *rtmpsink = GST_RTMP_SINK (sink);
|
||||
GstStructure *s;
|
||||
const GValue *sh;
|
||||
GArray *buffers;
|
||||
gint i;
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "caps set to %" GST_PTR_FORMAT, caps);
|
||||
|
||||
|
@ -409,29 +407,43 @@ gst_rtmp_sink_setcaps (GstBaseSink * sink, GstCaps * caps)
|
|||
rtmpsink->header = NULL;
|
||||
}
|
||||
|
||||
rtmpsink->header = gst_buffer_new ();
|
||||
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
|
||||
sh = gst_structure_get_value (s, "streamheader");
|
||||
buffers = g_value_peek_pointer (sh);
|
||||
if (sh == NULL)
|
||||
goto out;
|
||||
|
||||
/* Concatenate all buffers in streamheader into one */
|
||||
for (i = 0; i < buffers->len; ++i) {
|
||||
GValue *val;
|
||||
GstBuffer *buf;
|
||||
if (GST_VALUE_HOLDS_BUFFER (sh)) {
|
||||
rtmpsink->header = gst_buffer_ref (gst_value_get_buffer (sh));
|
||||
} else if (GST_VALUE_HOLDS_ARRAY (sh)) {
|
||||
GArray *buffers;
|
||||
gint i;
|
||||
|
||||
val = &g_array_index (buffers, GValue, i);
|
||||
buf = g_value_peek_pointer (val);
|
||||
buffers = g_value_peek_pointer (sh);
|
||||
|
||||
gst_buffer_ref (buf);
|
||||
/* Concatenate all buffers in streamheader into one */
|
||||
rtmpsink->header = gst_buffer_new ();
|
||||
for (i = 0; i < buffers->len; ++i) {
|
||||
GValue *val;
|
||||
GstBuffer *buf;
|
||||
|
||||
rtmpsink->header = gst_buffer_append (rtmpsink->header, buf);
|
||||
val = &g_array_index (buffers, GValue, i);
|
||||
buf = g_value_peek_pointer (val);
|
||||
|
||||
gst_buffer_ref (buf);
|
||||
|
||||
rtmpsink->header = gst_buffer_append (rtmpsink->header, buf);
|
||||
}
|
||||
} else {
|
||||
GST_ERROR_OBJECT (rtmpsink, "streamheader field has unexpected type %s",
|
||||
G_VALUE_TYPE_NAME (sh));
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (rtmpsink, "have %" G_GSIZE_FORMAT " bytes of header data",
|
||||
gst_buffer_get_size (rtmpsink->header));
|
||||
|
||||
out:
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue