+2005-07-11 daniel fischer <dan@f3c.com>
+
+ Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+
+ * ext/ffmpeg/gstffmpeg.h:
+ * ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_loop):
+ * ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
+ (gst_ffmpegdata_write):
+ Add a stream-header flag to set stream-header caps on some streams,
+ such as (in this case) flv (fixes #309051).
+
2005-06-27 Luca Ognibene <luogni@tin.it>
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_loop):
-Subproject commit d6e46b214fac0ecb46010ff522af2f7653e1c18e
+Subproject commit ac7272b7af934c2294a44ac1c0f3fac3f8d17ec6
extern URLProtocol gstreamer_protocol;
+/* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
+ * buffer should be used as streamheader property on the pad's caps. */
+#define GST_FFMPEG_URL_STREAMHEADER 16
+
#endif /* __GST_FFMPEG_H__ */
/* open "file" (gstreamer protocol to next element) */
if (!ffmpegmux->opened) {
const GstTagList *iface_tags;
+ int open_flags = URL_WRONLY;
/* we do need all streams to have started capsnego,
* or things will go horribly wrong */
gst_tag_list_free (tags);
}
+ /* set the streamheader flag for gstffmpegprotocol if codec supports it */
+ if (!strcmp (ffmpegmux->context->oformat->name, "flv") ) {
+ open_flags |= GST_FFMPEG_URL_STREAMHEADER;
+ }
+
if (url_fopen (&ffmpegmux->context->pb,
- ffmpegmux->context->filename, URL_WRONLY) < 0) {
+ ffmpegmux->context->filename, open_flags) < 0) {
GST_ELEMENT_ERROR (element, LIBRARY, TOO_LAZY, (NULL),
("Failed to open stream context in ffmux"));
return;
("Failed to write file header - check codec settings"));
return;
}
+
+ /* flush the header so it will be used as streamheader */
+ put_flush_packet (&ffmpegmux->context->pb);
}
/* take the one with earliest timestamp,
GstByteStream *bs;
gboolean eos;
+ gboolean set_streamheader;
};
static int
info = g_new0 (GstProtocolInfo, 1);
+ info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
+ flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+
/* we don't support R/W together */
if (flags != URL_RDONLY && flags != URL_WRONLY) {
g_warning ("Only read-only or write-only are supported");
GstBuffer *outbuf;
GST_DEBUG ("Writing %d bytes", size);
-
info = (GstProtocolInfo *) h->priv_data;
- g_return_val_if_fail (h->flags == URL_WRONLY, -EIO);
+ g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
/* create buffer and push data further */
outbuf = gst_buffer_new_and_alloc (size);
GST_BUFFER_SIZE (outbuf) = size;
memcpy (GST_BUFFER_DATA (outbuf), buf, size);
+ if (info->set_streamheader) {
+ GstCaps *caps = gst_pad_get_caps (info->pad);
+ GList *bufs = NULL;
+ GstStructure *structure = gst_caps_get_structure (caps, 0);
+ GValue list = { 0 }, value = { 0 };
+
+ GST_DEBUG ("Using buffer (size %i) as streamheader", size);
+
+ g_value_init (&list, GST_TYPE_FIXED_LIST);
+
+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_IN_CAPS);
+
+ g_value_init (&value, GST_TYPE_BUFFER);
+ g_value_set_boxed (&value, outbuf);
+ gst_value_list_append_value (&list, &value);
+ g_value_unset (&value);
+
+ gst_structure_set_value (structure, "streamheader", &list);
+ g_value_unset (&list);
+
+ gst_pad_try_set_caps (info->pad, caps);
+
+ /* only set the first buffer */
+ info->set_streamheader = FALSE;
+ }
+
gst_pad_push (info->pad, GST_DATA (outbuf));
return size;