diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-07-19 22:29:19 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-07-19 22:29:19 +0100 |
commit | 71efbb1e73a557d50093ccaf2ecc47009b7edd95 (patch) | |
tree | 700a8e27f5a685f160d24b34e74dc2a767ca2e76 | |
parent | 71e6bbd19fa1845dc07abc561b1ca5a71ae59d60 (diff) | |
download | gstreamer-plugins-bad-71efbb1e73a557d50093ccaf2ecc47009b7edd95.tar.gz |
kate: fix up for additional subtitle/x-kate media type
-rw-r--r-- | ext/kate/gstkate.h | 2 | ||||
-rw-r--r-- | ext/kate/gstkatedec.c | 2 | ||||
-rw-r--r-- | ext/kate/gstkateenc.c | 12 | ||||
-rw-r--r-- | ext/kate/gstkateparse.c | 14 | ||||
-rw-r--r-- | ext/kate/gstkatetiger.c | 12 | ||||
-rw-r--r-- | ext/kate/gstkateutil.c | 2 | ||||
-rw-r--r-- | tests/check/elements/kate.c | 14 |
7 files changed, 40 insertions, 18 deletions
diff --git a/ext/kate/gstkate.h b/ext/kate/gstkate.h index fbccfea1b..f19688136 100644 --- a/ext/kate/gstkate.h +++ b/ext/kate/gstkate.h @@ -48,7 +48,7 @@ G_BEGIN_DECLS -#define GST_KATE_MEDIA_TYPE "subtitle/x-kate" +/* nothing here any more */ G_END_DECLS diff --git a/ext/kate/gstkatedec.c b/ext/kate/gstkatedec.c index 8becb27ef..30ab8c166 100644 --- a/ext/kate/gstkatedec.c +++ b/ext/kate/gstkatedec.c @@ -103,7 +103,7 @@ enum static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE) + GST_STATIC_CAPS ("subtitle/x-kate") ); static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 8e1b2ec13..ccf013965 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -133,7 +133,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE) + GST_STATIC_CAPS ("subtitle/x-kate; application/x-kate") ); static void gst_kate_enc_set_property (GObject * object, guint prop_id, @@ -554,9 +554,13 @@ gst_kate_enc_send_headers (GstKateEnc * ke) } if (rflow == GST_FLOW_OK) { - caps = - gst_kate_util_set_header_on_caps (&ke->element, - gst_pad_get_caps (ke->srcpad), headers); + if (ke->category != NULL && strstr (ke->category, "subtitle")) { + caps = gst_kate_util_set_header_on_caps (&ke->element, + gst_caps_from_string ("subtitle/x-kate"), headers); + } else { + caps = gst_kate_util_set_header_on_caps (&ke->element, + gst_caps_from_string ("application/x-kate"), headers); + } if (caps) { GST_DEBUG_OBJECT (ke, "here are the caps: %" GST_PTR_FORMAT, caps); gst_pad_set_caps (ke->srcpad, caps); diff --git a/ext/kate/gstkateparse.c b/ext/kate/gstkateparse.c index b44eea91d..5cf8ec48f 100644 --- a/ext/kate/gstkateparse.c +++ b/ext/kate/gstkateparse.c @@ -76,17 +76,17 @@ GST_ELEMENT_DETAILS ("Kate stream parser", "Vincent Penquerc'h <ogg.k.ogg.k at googlemail dot com>"); static GstStaticPadTemplate gst_kate_parse_sink_factory = -GST_STATIC_PAD_TEMPLATE ("sink", + GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE) + GST_STATIC_CAPS ("subtitle/x-kate; application/x-kate") ); static GstStaticPadTemplate gst_kate_parse_src_factory = -GST_STATIC_PAD_TEMPLATE ("src", + GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE) + GST_STATIC_CAPS ("subtitle/x-kate; application/x-kate") ); GST_BOILERPLATE (GstKateParse, gst_kate_parse, GstElement, GST_TYPE_ELEMENT); @@ -169,7 +169,8 @@ gst_kate_parse_push_headers (GstKateParse * parse) /* get the headers into the caps, passing them to kate as we go */ caps = gst_kate_util_set_header_on_caps (&parse->element, - gst_pad_get_caps (parse->srcpad), parse->streamheader); + gst_pad_get_negotiated_caps (parse->sinkpad), parse->streamheader); + if (G_UNLIKELY (!caps)) { GST_ERROR_OBJECT (parse, "Failed to set headers on caps"); return GST_FLOW_ERROR; @@ -389,6 +390,9 @@ gst_kate_parse_chain (GstPad * pad, GstBuffer * buffer) g_assert (klass->parse_packet != NULL); + if (G_UNLIKELY (GST_PAD_CAPS (pad) == NULL)) + return GST_FLOW_NOT_NEGOTIATED; + return klass->parse_packet (parse, buffer); } diff --git a/ext/kate/gstkatetiger.c b/ext/kate/gstkatetiger.c index 20df04812..433a31068 100644 --- a/ext/kate/gstkatetiger.c +++ b/ext/kate/gstkatetiger.c @@ -108,14 +108,14 @@ enum ARG_DEFAULT_BACKGROUND_RED, ARG_DEFAULT_BACKGROUND_GREEN, ARG_DEFAULT_BACKGROUND_BLUE, - ARG_DEFAULT_BACKGROUND_ALPHA, + ARG_DEFAULT_BACKGROUND_ALPHA }; static GstStaticPadTemplate kate_sink_factory = -GST_STATIC_PAD_TEMPLATE ("kate_sink", + GST_STATIC_PAD_TEMPLATE ("kate_sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE) + GST_STATIC_CAPS ("subtitle/x-kate; application/x-kate") ); static GstStaticPadTemplate video_sink_factory = @@ -294,10 +294,8 @@ gst_kate_tiger_init (GstKateTiger * tiger, GstKateTigerClass * gclass) GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_chain)); gst_pad_set_query_function (tiger->katesinkpad, GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_sink_query)); - gst_pad_use_fixed_caps (tiger->katesinkpad); - gst_pad_set_caps (tiger->katesinkpad, - gst_static_pad_template_get_caps (&kate_sink_factory)); - gst_pad_set_event_function (tiger->katesinkpad, gst_kate_tiger_kate_event); + gst_pad_set_event_function (tiger->katesinkpad, + GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_event)); gst_element_add_pad (GST_ELEMENT (tiger), tiger->katesinkpad); tiger->videosinkpad = diff --git a/ext/kate/gstkateutil.c b/ext/kate/gstkateutil.c index 2928771d6..f47ba575d 100644 --- a/ext/kate/gstkateutil.c +++ b/ext/kate/gstkateutil.c @@ -33,6 +33,8 @@ gst_kate_util_set_header_on_caps (GstElement * element, GstCaps * caps, GstStructure *structure; GValue array = { 0 }; + GST_LOG_OBJECT (element, "caps: %" GST_PTR_FORMAT, caps); + if (G_UNLIKELY (!caps)) return NULL; if (G_UNLIKELY (!headers)) diff --git a/tests/check/elements/kate.c b/tests/check/elements/kate.c index f7ac3ed4a..80ea68820 100644 --- a/tests/check/elements/kate.c +++ b/tests/check/elements/kate.c @@ -40,20 +40,25 @@ static const guint8 kate_header_0x81[53] = { 0x72, 0x29, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x54, 0x49, 0x54, 0x4c, 0x45, 0x3d, /* r)........TITLE= */ 0x54, 0x69, 0x67, 0x65, 0x72, /* Tiger */ }; + static const guint8 kate_header_0x8x[10] = { 0x80, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00 }; + static const guint8 kate_header_0x88[11] = { 0x88, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const guint8 kate_header_0x00[45] = { 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* ................ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x70, 0x6c, 0x61, /* .............pla */ 0x69, 0x6e, 0x20, 0x6f, 0x6c, 0x64, 0x20, 0x74, 0x65, 0x78, 0x74, 0x08, 0x00 /* in old text.. */ }; + static const guint8 kate_header_0x01[1] = { 0x01 }; + static const guint8 kate_header_0x7f[1] = { 0x7f }; @@ -600,16 +605,21 @@ static void test_kate_send_headers (GstPad * pad) { GstBuffer *inbuffer; + GstCaps *caps; int i; + caps = gst_caps_new_simple ("subtitle/x-kate", NULL); + /* push headers */ inbuffer = gst_buffer_new (); + gst_buffer_set_caps (inbuffer, caps); GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x80; GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x80); GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0; fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK); inbuffer = gst_buffer_new (); + gst_buffer_set_caps (inbuffer, caps); GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x81; GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x81); GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0; @@ -617,6 +627,7 @@ test_kate_send_headers (GstPad * pad) for (i = 2; i < 8; ++i) { inbuffer = gst_buffer_new_and_alloc (sizeof (kate_header_0x8x)); + gst_buffer_set_caps (inbuffer, caps); memcpy (GST_BUFFER_DATA (inbuffer), (guint8 *) kate_header_0x8x, sizeof (kate_header_0x8x)); GST_BUFFER_DATA (inbuffer)[0] = 0x80 | i; @@ -625,10 +636,13 @@ test_kate_send_headers (GstPad * pad) } inbuffer = gst_buffer_new (); + gst_buffer_set_caps (inbuffer, caps); GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x88; GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x88); GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0; fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK); + + gst_caps_unref (caps); } GST_START_TEST (test_kate_parse) |