From 245fb79909672f9e5f9163161e75c1b42c77e723 Mon Sep 17 00:00:00 2001 From: Zaheer Abbas Merali Date: Wed, 22 Sep 2004 14:35:13 +0000 Subject: ext/: remove explicit newmedia support from oggmux and vorbisenc add debug category to vorbisenc Original commit message from CVS: 2004-09-22 Zaheer Abbas Merali * ext/ogg/gstoggmux.c: (gst_ogg_mux_init), (gst_ogg_mux_next_buffer), (gst_ogg_mux_loop): * ext/vorbis/vorbis.c: (plugin_init): * ext/vorbis/vorbisenc.c: (gst_vorbisenc_init), (gst_vorbisenc_chain): * ext/vorbis/vorbisenc.h: remove explicit newmedia support from oggmux and vorbisenc add debug category to vorbisenc * gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_class_init), (gst_multifilesink_init), (gst_multifilesink_dispose), (gst_multifilesink_set_location), (gst_multifilesink_set_property), (gst_multifilesink_next_file), (gst_multifilesink_handle_event), (gst_multifilesink_chain), (plugin_init): * gst/multifilesink/gstmultifilesink.h: add support for streamheader in multifilesink --- gst/multifilesink/gstmultifilesink.c | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'gst/multifilesink/gstmultifilesink.c') diff --git a/gst/multifilesink/gstmultifilesink.c b/gst/multifilesink/gstmultifilesink.c index 70c4612e..4bde51b0 100644 --- a/gst/multifilesink/gstmultifilesink.c +++ b/gst/multifilesink/gstmultifilesink.c @@ -180,6 +180,8 @@ gst_multifilesink_init (GstMultiFileSink * filesink) filesink->curfilename = NULL; filesink->curfileindex = 0; filesink->numfiles = 0; + + filesink->streamheader = NULL; } static void gst_multifilesink_dispose (GObject * object) @@ -349,8 +351,35 @@ gst_multifilesink_next_file (GstMultiFileSink * sink) } GST_FLAG_SET (sink, GST_MULTIFILESINK_OPEN); - sink->data_written = 0; + if (sink->streamheader) { + GSList *l; + + for (l = sink->streamheader; l; l = l->next) { + /* queue stream headers for sending */ + guint bytes_written = 0, back_pending = 0; + GstBuffer *buf = GST_BUFFER (l->data); + + if (ftell (sink->file) < sink->data_written) + back_pending = sink->data_written - ftell (sink->file); + while (bytes_written < GST_BUFFER_SIZE (buf)) { + size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, + GST_BUFFER_SIZE (buf) - bytes_written, + sink->file); + + if (wrote <= 0) { + GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), sink->filename), + ("Only %d of %d bytes written: %s", + bytes_written, GST_BUFFER_SIZE (buf), strerror (errno))); + break; + } + bytes_written += wrote; + } + + sink->data_written += bytes_written - back_pending; + } + } sink->curfileindex++; return TRUE; @@ -516,7 +545,21 @@ gst_multifilesink_chain (GstPad * pad, GstData * _data) return; } + /* if the incoming buffer is marked as IN CAPS, then we assume for now + * it's a streamheader that needs to be sent to each new client, so we + * put it on our internal list of streamheader buffers. + * After that we return, since we only send these out when we get + * non IN_CAPS buffers so we properly keep track of clients that got + * streamheaders. */ + if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_IN_CAPS)) { + GST_DEBUG_OBJECT (filesink, + "appending IN_CAPS buffer with length %d to streamheader", + GST_BUFFER_SIZE (buf)); + gst_buffer_ref (buf); + filesink->streamheader = g_slist_append (filesink->streamheader, buf); + } if (GST_FLAG_IS_SET (filesink, GST_MULTIFILESINK_OPEN)) { + guint bytes_written = 0, back_pending = 0; if (ftell (filesink->file) < filesink->data_written) -- cgit v1.2.1