mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +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);
|
GstRTMPSink *rtmpsink = GST_RTMP_SINK (sink);
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const GValue *sh;
|
const GValue *sh;
|
||||||
GArray *buffers;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "caps set to %" GST_PTR_FORMAT, caps);
|
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 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtmpsink->header = gst_buffer_new ();
|
|
||||||
|
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
sh = gst_structure_get_value (s, "streamheader");
|
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 */
|
if (GST_VALUE_HOLDS_BUFFER (sh)) {
|
||||||
for (i = 0; i < buffers->len; ++i) {
|
rtmpsink->header = gst_buffer_ref (gst_value_get_buffer (sh));
|
||||||
GValue *val;
|
} else if (GST_VALUE_HOLDS_ARRAY (sh)) {
|
||||||
GstBuffer *buf;
|
GArray *buffers;
|
||||||
|
gint i;
|
||||||
|
|
||||||
val = &g_array_index (buffers, GValue, i);
|
buffers = g_value_peek_pointer (sh);
|
||||||
buf = g_value_peek_pointer (val);
|
|
||||||
|
|
||||||
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_DEBUG_OBJECT (rtmpsink, "have %" G_GSIZE_FORMAT " bytes of header data",
|
||||||
gst_buffer_get_size (rtmpsink->header));
|
gst_buffer_get_size (rtmpsink->header));
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue