mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
Add seeking support for avi subtitle
Original commit message from CVS: * gst/avi/gstavisubtitle.c: * tests/check/elements/avisubtitle.c: Add seeking support for avi subtitle
This commit is contained in:
parent
5cf1668a8f
commit
587583b4fe
3 changed files with 47 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-12-18 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
|
||||
* gst/avi/gstavisubtitle.c:
|
||||
* tests/check/elements/avisubtitle.c:
|
||||
Add seeking support for avi subtitle
|
||||
|
||||
2007-12-18 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* FIXME: handle seeks, documentation */
|
||||
/* FIXME: documentation */
|
||||
|
||||
/* example of a subtitle chunk in an avi file
|
||||
* 00000000: 47 41 42 32 00 02 00 10 00 00 00 45 00 6e 00 67 GAB2.......E.n.g
|
||||
|
@ -60,6 +60,8 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
static GstFlowReturn gst_avi_subtitle_chain (GstPad * pad, GstBuffer * buffer);
|
||||
static GstStateChangeReturn gst_avi_subtitle_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
static gboolean gst_avi_subtitle_send_event (GstElement * element,
|
||||
GstEvent * event);
|
||||
|
||||
GST_BOILERPLATE (GstAviSubtitle, gst_avi_subtitle, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
|
@ -244,6 +246,23 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_avi_subtitle_send_event (GstElement * element, GstEvent * event)
|
||||
{
|
||||
GstAviSubtitle *avisubtitle = GST_AVI_SUBTITLE (element);
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (GST_EVENT_TYPE (event) == GST_EVENT_SEEK) {
|
||||
if (avisubtitle->subfile) {
|
||||
if (gst_pad_push (avisubtitle->src,
|
||||
gst_buffer_ref (avisubtitle->subfile)) == GST_FLOW_OK)
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
gst_event_unref (event);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_avi_subtitle_base_init (gpointer klass)
|
||||
{
|
||||
|
@ -269,6 +288,8 @@ gst_avi_subtitle_class_init (GstAviSubtitleClass * klass)
|
|||
|
||||
gstelement_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_avi_subtitle_change_state);
|
||||
gstelement_class->send_event =
|
||||
GST_DEBUG_FUNCPTR (gst_avi_subtitle_send_event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -281,6 +302,8 @@ gst_avi_subtitle_init (GstAviSubtitle * self, GstAviSubtitleClass * klass)
|
|||
gst_pad_set_chain_function (self->sink,
|
||||
GST_DEBUG_FUNCPTR (gst_avi_subtitle_chain));
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->sink);
|
||||
|
||||
self->subfile = NULL;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
|
|
|
@ -125,6 +125,7 @@ check_correct_buffer (guint8 * src_data, guint src_size, guint8 * dst_data,
|
|||
GstBuffer *buffer = gst_buffer_new ();
|
||||
GstBuffer *newBuffer;
|
||||
GstElement *avisubtitle = setup_avisubtitle ();
|
||||
GstEvent *event;
|
||||
|
||||
fail_unless (g_list_length (buffers) == 0, "Buffers list needs to be empty");
|
||||
gst_buffer_set_data (buffer, src_data, src_size);
|
||||
|
@ -132,21 +133,34 @@ check_correct_buffer (guint8 * src_data, guint src_size, guint8 * dst_data,
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
ASSERT_BUFFER_REFCOUNT (buffer, "inbuffer", 1);
|
||||
event = gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
|
||||
GST_SEEK_TYPE_SET, 2 * GST_SECOND, GST_SEEK_TYPE_SET, 5 * GST_SECOND);
|
||||
fail_unless (gst_element_send_event (avisubtitle, event) == FALSE,
|
||||
"Seeking is not possible when there is no buffer yet");
|
||||
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK,
|
||||
"not accepted a correct buffer");
|
||||
ASSERT_BUFFER_REFCOUNT (buffer, "inbuffer", 1);
|
||||
/* a new buffer is created in the list */
|
||||
fail_unless (g_list_length (buffers) == 1,
|
||||
"No new buffer in the buffers list");
|
||||
event = gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
|
||||
GST_SEEK_TYPE_SET, 2 * GST_SECOND, GST_SEEK_TYPE_SET, 5 * GST_SECOND);
|
||||
fail_unless (gst_element_send_event (avisubtitle, event) == TRUE,
|
||||
"seeking should be working now");
|
||||
fail_unless (g_list_length (buffers) == 2,
|
||||
"After seeking we need another buffer in the buffers");
|
||||
newBuffer = GST_BUFFER (buffers->data);
|
||||
buffers = g_list_remove (buffers, newBuffer);
|
||||
fail_unless (g_list_length (buffers) == 0, "Buffers list needs to be empty");
|
||||
fail_unless (g_list_length (buffers) == 1, "Buffers list needs to be empty");
|
||||
fail_unless (GST_BUFFER_SIZE (newBuffer) == dst_size,
|
||||
"size of the new buffer is wrong ( %d != %d)",
|
||||
GST_BUFFER_SIZE (newBuffer), dst_size);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (newBuffer), dst_data, dst_size) == 0,
|
||||
"data of the buffer is not correct");
|
||||
gst_buffer_unref (newBuffer);
|
||||
/* free the buffer from seeking */
|
||||
gst_buffer_unref (GST_BUFFER (buffers->data));
|
||||
buffers = g_list_remove (buffers, buffers->data);
|
||||
fail_unless (gst_element_set_state (avisubtitle,
|
||||
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
||||
cleanup_avisubtitle (avisubtitle);
|
||||
|
@ -157,7 +171,8 @@ GST_START_TEST (test_avisubtitle_negative)
|
|||
{
|
||||
guint8 wrong_magic[] =
|
||||
{ 0x47, 0x41, 0x41, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00 };
|
||||
0x00, 0x00
|
||||
};
|
||||
guint8 wrong_fixed_word_2[] = {
|
||||
0x47, 0x41, 0x42, 0x32, 0x00, 0x02, 0x01, 0x10,
|
||||
0x00, 0x00, 0x00, 0x45, 0x00, 0x6e, 0x00, 0x67,
|
||||
|
|
Loading…
Reference in a new issue