Merge remote-tracking branch 'origin/master' into 0.11

Conflicts:
	common
	gst/gstpad.h
	gst/gsttask.c
	libs/gst/base/gstcollectpads2.h
This commit is contained in:
Tim-Philipp Müller 2012-03-08 19:55:30 +00:00
commit e09fe53a22
7 changed files with 235 additions and 6 deletions

View file

@ -4750,7 +4750,7 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data)
task = gst_task_new (func, data);
gst_task_set_lock (task, GST_PAD_GET_STREAM_LOCK (pad));
gst_task_set_thread_callbacks (task, &thr_callbacks, pad, NULL);
GST_DEBUG_OBJECT (pad, "created task");
GST_INFO_OBJECT (pad, "created task %p", task);
GST_PAD_TASK (pad) = task;
gst_object_ref (task);
/* release lock to post the message */

View file

@ -777,7 +777,7 @@ struct _GstPadClass {
*
* Lock the stream lock of @pad.
*/
#define GST_PAD_STREAM_LOCK(pad) (g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)))
#define GST_PAD_STREAM_LOCK(pad) g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad))
/**
* GST_PAD_STREAM_TRYLOCK:
* @pad: a #GstPad
@ -785,14 +785,14 @@ struct _GstPadClass {
* Try to Lock the stream lock of the pad, return TRUE if the lock could be
* taken.
*/
#define GST_PAD_STREAM_TRYLOCK(pad) (g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)))
#define GST_PAD_STREAM_TRYLOCK(pad) g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad))
/**
* GST_PAD_STREAM_UNLOCK:
* @pad: a #GstPad
*
* Unlock the stream lock of @pad.
*/
#define GST_PAD_STREAM_UNLOCK(pad) (g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)))
#define GST_PAD_STREAM_UNLOCK(pad) g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad))
#define GST_PAD_BLOCK_GET_COND(pad) (&GST_PAD_CAST(pad)->block_cond)
#define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))

View file

@ -426,6 +426,7 @@ gst_task_set_lock (GstTask * task, GRecMutex * mutex)
GST_OBJECT_LOCK (task);
if (G_UNLIKELY (task->running))
goto is_running;
GST_INFO ("setting stream lock %p on task %p", mutex, task);
GST_TASK_GET_LOCK (task) = mutex;
GST_OBJECT_UNLOCK (task);

View file

@ -265,7 +265,7 @@ typedef GstFlowReturn (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, Gst
*
* Since: 0.10.36
*/
#define GST_COLLECT_PADS2_STREAM_LOCK(pads) (g_rec_mutex_lock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads)))
#define GST_COLLECT_PADS2_STREAM_LOCK(pads) g_rec_mutex_lock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))
/**
* GST_COLLECT_PADS2_STREAM_UNLOCK:
* @pads: a #GstCollectPads2
@ -274,7 +274,7 @@ typedef GstFlowReturn (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, Gst
*
* Since: 0.10.36
*/
#define GST_COLLECT_PADS2_STREAM_UNLOCK(pads) (g_rec_mutex_unlock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads)))
#define GST_COLLECT_PADS2_STREAM_UNLOCK(pads) g_rec_mutex_unlock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))
/**
* GstCollectPads2:

View file

@ -95,6 +95,7 @@ REGISTRY_CHECKS = \
libs/basesink \
libs/controller \
libs/typefindhelper \
pipelines/seek \
pipelines/stress \
pipelines/queue-error
endif

View file

@ -1,5 +1,6 @@
.dirstamp
cleanup
seek
simple-launch-lines
stress
parse-launch

View file

@ -0,0 +1,226 @@
/* GStreamer simple seek unit test
* Copyright (C) 2012 Collabora Ltd.
* Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
#include <gst/check/gstcheck.h>
#include <gst/check/gstconsistencychecker.h>
/* ========================================================================
* Dummy source, like a stripped down audio test source
* ======================================================================== */
#define SAMPLERATE 44100
#define CHUNKS_PER_SEC 10
typedef struct
{
GstBaseSrc parent;
GstClockTime next_time;
} TimedTestSrc;
typedef struct
{
GstBaseSrcClass parent_class;
} TimedTestSrcClass;
static GstStaticPadTemplate timed_test_src_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("timed/audio"));
static GType timed_test_src_get_type (void);
GST_BOILERPLATE (TimedTestSrc, timed_test_src, GstBaseSrc, GST_TYPE_BASE_SRC);
static gboolean timed_test_src_is_seekable (GstBaseSrc * basesrc);
static gboolean timed_test_src_check_get_range (GstBaseSrc * basesrc);
static gboolean timed_test_src_do_seek (GstBaseSrc * basesrc,
GstSegment * segment);
static gboolean timed_test_src_start (GstBaseSrc * basesrc);
static gboolean timed_test_src_stop (GstBaseSrc * basesrc);
static GstFlowReturn timed_test_src_create (GstBaseSrc * basesrc,
guint64 offset, guint length, GstBuffer ** buffer);
static void
timed_test_src_base_init (gpointer g_class)
{
gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (g_class),
&timed_test_src_src_template);
}
static void
timed_test_src_class_init (TimedTestSrcClass * klass)
{
GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass;
gstbasesrc_class->is_seekable = timed_test_src_is_seekable;
gstbasesrc_class->check_get_range = timed_test_src_check_get_range;
gstbasesrc_class->do_seek = timed_test_src_do_seek;
gstbasesrc_class->start = timed_test_src_start;
gstbasesrc_class->stop = timed_test_src_stop;
gstbasesrc_class->create = timed_test_src_create;
}
static void
timed_test_src_init (TimedTestSrc * src, TimedTestSrcClass * g_class)
{
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (src), FALSE);
}
static gboolean
timed_test_src_start (GstBaseSrc * basesrc)
{
TimedTestSrc *src = (TimedTestSrc *) basesrc;
src->next_time = 0;
return TRUE;
}
static gboolean
timed_test_src_stop (GstBaseSrc * basesrc)
{
return TRUE;
}
static gboolean
timed_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
{
TimedTestSrc *src = (TimedTestSrc *) basesrc;
src->next_time = segment->last_stop;
return TRUE;
}
static gboolean
timed_test_src_is_seekable (GstBaseSrc * basesrc)
{
return TRUE;
}
static gboolean
timed_test_src_check_get_range (GstBaseSrc * basesrc)
{
return FALSE;
}
static GstFlowReturn
timed_test_src_create (GstBaseSrc * basesrc, guint64 offset, guint length,
GstBuffer ** buf)
{
TimedTestSrc *src = (TimedTestSrc *) basesrc;
*buf = gst_buffer_new_and_alloc (SAMPLERATE / CHUNKS_PER_SEC);
GST_BUFFER_TIMESTAMP (*buf) = src->next_time;
GST_BUFFER_DURATION (*buf) = GST_SECOND / CHUNKS_PER_SEC;
src->next_time += GST_BUFFER_DURATION (*buf);
return GST_FLOW_OK;
}
/* ======================================================================== */
GST_START_TEST (test_seek)
{
GstStreamConsistency *consist;
GstMessage *msg;
GstElement *bin, *src1, *sink;
gboolean res;
GstPad *srcpad;
GstBus *bus;
GST_INFO ("preparing test");
/* build pipeline */
bin = gst_pipeline_new ("pipeline");
bus = gst_element_get_bus (bin);
gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
src1 = g_object_new (timed_test_src_get_type (), "name", "testsrc", NULL);
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add_many (GST_BIN (bin), src1, sink, NULL);
res = gst_element_link (src1, sink);
fail_unless (res == TRUE, NULL);
srcpad = gst_element_get_static_pad (src1, "src");
consist = gst_consistency_checker_new (srcpad);
gst_object_unref (srcpad);
GST_INFO ("starting test");
/* prepare playing */
res = gst_element_set_state (bin, GST_STATE_PAUSED);
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
/* wait for completion */
res =
gst_element_get_state (GST_ELEMENT (bin), NULL, NULL,
GST_CLOCK_TIME_NONE);
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
res = gst_element_send_event (bin,
gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, (GstClockTime) 0,
GST_SEEK_TYPE_SET, (GstClockTime) 2 * GST_SECOND));
fail_unless (res == TRUE, NULL);
GST_INFO ("seeked");
/* run pipeline */
res = gst_element_set_state (bin, GST_STATE_PLAYING);
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
fail_unless_equals_string (GST_MESSAGE_TYPE_NAME (msg), "eos");
gst_message_unref (msg);
res = gst_element_set_state (bin, GST_STATE_NULL);
fail_unless (res != GST_STATE_CHANGE_FAILURE, NULL);
/* cleanup */
gst_consistency_checker_free (consist);
gst_object_unref (bus);
gst_object_unref (bin);
}
GST_END_TEST;
static Suite *
pipelines_seek_suite (void)
{
Suite *s = suite_create ("pipelines-seek");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_seek);
return s;
}
GST_CHECK_MAIN (pipelines_seek);