kate: fix up for additional subtitle/x-kate media type
This commit is contained in:
parent
71e6bbd19f
commit
71efbb1e73
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_KATE_MEDIA_TYPE "subtitle/x-kate"
|
/* nothing here any more */
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ enum
|
|||||||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
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",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
@ -133,7 +133,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
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,
|
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) {
|
if (rflow == GST_FLOW_OK) {
|
||||||
caps =
|
if (ke->category != NULL && strstr (ke->category, "subtitle")) {
|
||||||
gst_kate_util_set_header_on_caps (&ke->element,
|
caps = gst_kate_util_set_header_on_caps (&ke->element,
|
||||||
gst_pad_get_caps (ke->srcpad), headers);
|
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) {
|
if (caps) {
|
||||||
GST_DEBUG_OBJECT (ke, "here are the caps: %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (ke, "here are the caps: %" GST_PTR_FORMAT, caps);
|
||||||
gst_pad_set_caps (ke->srcpad, caps);
|
gst_pad_set_caps (ke->srcpad, caps);
|
||||||
|
@ -79,14 +79,14 @@ static GstStaticPadTemplate gst_kate_parse_sink_factory =
|
|||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
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 =
|
static GstStaticPadTemplate gst_kate_parse_src_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
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);
|
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 */
|
/* get the headers into the caps, passing them to kate as we go */
|
||||||
caps =
|
caps =
|
||||||
gst_kate_util_set_header_on_caps (&parse->element,
|
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)) {
|
if (G_UNLIKELY (!caps)) {
|
||||||
GST_ERROR_OBJECT (parse, "Failed to set headers on caps");
|
GST_ERROR_OBJECT (parse, "Failed to set headers on caps");
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
@ -389,6 +390,9 @@ gst_kate_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||||||
|
|
||||||
g_assert (klass->parse_packet != NULL);
|
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);
|
return klass->parse_packet (parse, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,14 +108,14 @@ enum
|
|||||||
ARG_DEFAULT_BACKGROUND_RED,
|
ARG_DEFAULT_BACKGROUND_RED,
|
||||||
ARG_DEFAULT_BACKGROUND_GREEN,
|
ARG_DEFAULT_BACKGROUND_GREEN,
|
||||||
ARG_DEFAULT_BACKGROUND_BLUE,
|
ARG_DEFAULT_BACKGROUND_BLUE,
|
||||||
ARG_DEFAULT_BACKGROUND_ALPHA,
|
ARG_DEFAULT_BACKGROUND_ALPHA
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate kate_sink_factory =
|
static GstStaticPadTemplate kate_sink_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("kate_sink",
|
GST_STATIC_PAD_TEMPLATE ("kate_sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_KATE_MEDIA_TYPE)
|
GST_STATIC_CAPS ("subtitle/x-kate; application/x-kate")
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate video_sink_factory =
|
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_DEBUG_FUNCPTR (gst_kate_tiger_kate_chain));
|
||||||
gst_pad_set_query_function (tiger->katesinkpad,
|
gst_pad_set_query_function (tiger->katesinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_sink_query));
|
GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_sink_query));
|
||||||
gst_pad_use_fixed_caps (tiger->katesinkpad);
|
gst_pad_set_event_function (tiger->katesinkpad,
|
||||||
gst_pad_set_caps (tiger->katesinkpad,
|
GST_DEBUG_FUNCPTR (gst_kate_tiger_kate_event));
|
||||||
gst_static_pad_template_get_caps (&kate_sink_factory));
|
|
||||||
gst_pad_set_event_function (tiger->katesinkpad, gst_kate_tiger_kate_event);
|
|
||||||
gst_element_add_pad (GST_ELEMENT (tiger), tiger->katesinkpad);
|
gst_element_add_pad (GST_ELEMENT (tiger), tiger->katesinkpad);
|
||||||
|
|
||||||
tiger->videosinkpad =
|
tiger->videosinkpad =
|
||||||
|
@ -33,6 +33,8 @@ gst_kate_util_set_header_on_caps (GstElement * element, GstCaps * caps,
|
|||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
GValue array = { 0 };
|
GValue array = { 0 };
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (element, "caps: %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
if (G_UNLIKELY (!caps))
|
if (G_UNLIKELY (!caps))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (G_UNLIKELY (!headers))
|
if (G_UNLIKELY (!headers))
|
||||||
|
@ -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= */
|
0x72, 0x29, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x54, 0x49, 0x54, 0x4c, 0x45, 0x3d, /* r)........TITLE= */
|
||||||
0x54, 0x69, 0x67, 0x65, 0x72, /* Tiger */
|
0x54, 0x69, 0x67, 0x65, 0x72, /* Tiger */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint8 kate_header_0x8x[10] = {
|
static const guint8 kate_header_0x8x[10] = {
|
||||||
0x80, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00
|
0x80, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint8 kate_header_0x88[11] = {
|
static const guint8 kate_header_0x88[11] = {
|
||||||
0x88, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x88, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint8 kate_header_0x00[45] = {
|
static const guint8 kate_header_0x00[45] = {
|
||||||
0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* ................ */
|
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 */
|
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.. */
|
0x69, 0x6e, 0x20, 0x6f, 0x6c, 0x64, 0x20, 0x74, 0x65, 0x78, 0x74, 0x08, 0x00 /* in old text.. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint8 kate_header_0x01[1] = {
|
static const guint8 kate_header_0x01[1] = {
|
||||||
0x01
|
0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
static const guint8 kate_header_0x7f[1] = {
|
static const guint8 kate_header_0x7f[1] = {
|
||||||
0x7f
|
0x7f
|
||||||
};
|
};
|
||||||
@ -600,16 +605,21 @@ static void
|
|||||||
test_kate_send_headers (GstPad * pad)
|
test_kate_send_headers (GstPad * pad)
|
||||||
{
|
{
|
||||||
GstBuffer *inbuffer;
|
GstBuffer *inbuffer;
|
||||||
|
GstCaps *caps;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple ("subtitle/x-kate", NULL);
|
||||||
|
|
||||||
/* push headers */
|
/* push headers */
|
||||||
inbuffer = gst_buffer_new ();
|
inbuffer = gst_buffer_new ();
|
||||||
|
gst_buffer_set_caps (inbuffer, caps);
|
||||||
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x80;
|
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x80;
|
||||||
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x80);
|
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x80);
|
||||||
GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0;
|
GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0;
|
||||||
fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK);
|
fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK);
|
||||||
|
|
||||||
inbuffer = gst_buffer_new ();
|
inbuffer = gst_buffer_new ();
|
||||||
|
gst_buffer_set_caps (inbuffer, caps);
|
||||||
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x81;
|
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x81;
|
||||||
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x81);
|
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x81);
|
||||||
GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0;
|
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) {
|
for (i = 2; i < 8; ++i) {
|
||||||
inbuffer = gst_buffer_new_and_alloc (sizeof (kate_header_0x8x));
|
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,
|
memcpy (GST_BUFFER_DATA (inbuffer), (guint8 *) kate_header_0x8x,
|
||||||
sizeof (kate_header_0x8x));
|
sizeof (kate_header_0x8x));
|
||||||
GST_BUFFER_DATA (inbuffer)[0] = 0x80 | i;
|
GST_BUFFER_DATA (inbuffer)[0] = 0x80 | i;
|
||||||
@ -625,10 +636,13 @@ test_kate_send_headers (GstPad * pad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inbuffer = gst_buffer_new ();
|
inbuffer = gst_buffer_new ();
|
||||||
|
gst_buffer_set_caps (inbuffer, caps);
|
||||||
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x88;
|
GST_BUFFER_DATA (inbuffer) = (guint8 *) kate_header_0x88;
|
||||||
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x88);
|
GST_BUFFER_SIZE (inbuffer) = sizeof (kate_header_0x88);
|
||||||
GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0;
|
GST_BUFFER_OFFSET (inbuffer) = GST_BUFFER_OFFSET_END (inbuffer) = 0;
|
||||||
fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK);
|
fail_unless_equals_int (gst_pad_push (pad, inbuffer), GST_FLOW_OK);
|
||||||
|
|
||||||
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_kate_parse)
|
GST_START_TEST (test_kate_parse)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user