matroskamux: store caps and set on buffers rather than using pad caps

This commit is contained in:
Zaheer Abbas Merali 2010-05-21 13:38:11 +01:00
parent b4e6fcd051
commit d3daa12473
3 changed files with 22 additions and 14 deletions

View file

@ -65,6 +65,8 @@ gst_ebml_write_init (GstEbmlWrite * ebml, GstEbmlWriteClass * klass)
ebml->streamheader = NULL;
ebml->streamheader_pos = 0;
ebml->writing_streamheader = FALSE;
ebml->caps = NULL;
}
static void
@ -84,6 +86,10 @@ gst_ebml_write_finalize (GObject * object)
ebml->streamheader = NULL;
}
if (ebml->caps) {
gst_caps_unref (ebml->caps);
ebml->caps = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
@ -216,7 +222,7 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
buffer = gst_byte_writer_free_and_get_buffer (ebml->cache);
ebml->cache = NULL;
GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
gst_buffer_set_caps (buffer, ebml->caps);
if (ebml->last_write_result == GST_FLOW_OK) {
if (ebml->need_newsegment) {
GstEvent *ev;
@ -225,6 +231,9 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml)
if (gst_pad_push_event (ebml->srcpad, ev))
ebml->need_newsegment = FALSE;
}
if (ebml->writing_streamheader) {
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
}
ebml->last_write_result = gst_pad_push (ebml->srcpad, buffer);
} else {
gst_buffer_unref (buffer);
@ -390,7 +399,10 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf)
ebml->need_newsegment = FALSE;
}
buf = gst_buffer_make_metadata_writable (buf);
gst_buffer_set_caps (buf, GST_PAD_CAPS (ebml->srcpad));
gst_buffer_set_caps (buf, ebml->caps);
if (ebml->writing_streamheader) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
}
ebml->last_write_result = gst_pad_push (ebml->srcpad, buf);
} else {
gst_buffer_unref (buf);

View file

@ -59,6 +59,8 @@ typedef struct _GstEbmlWrite {
gboolean writing_streamheader;
GstByteWriter *streamheader;
guint64 streamheader_pos;
GstCaps *caps;
} GstEbmlWrite;
typedef struct _GstEbmlWriteClass {

View file

@ -2007,16 +2007,10 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
GTimeVal time = { 0, 0 };
GstBuffer *streamheader_buffer;
/* set initial pad caps */
{
GstCaps *caps;
if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
caps = gst_caps_from_string ("video/webm");
} else {
caps = gst_caps_from_string ("video/x-matroska");
}
gst_pad_set_caps (mux->srcpad, caps);
gst_caps_unref (caps);
if (!strcmp (mux->doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
ebml->caps = gst_caps_from_string ("video/webm");
} else {
ebml->caps = gst_caps_from_string ("video/x-matroska");
}
/* we start with a EBML header */
doctype = mux->doctype;
@ -2135,8 +2129,8 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
g_value_unset (&bufval);
gst_structure_set_value (s, "streamheader", &streamheader);
g_value_unset (&streamheader);
gst_pad_set_caps (mux->srcpad, caps);
gst_caps_unref (caps);
gst_caps_unref (ebml->caps);
ebml->caps = caps;
}
}