mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
libs/gst/check/Makefile.am (libgstcheck_@GST_MAJORMINOR@include_HEADERS)
Original commit message from CVS: 2006-07-21 Andy Wingo <wingo@pobox.com> * libs/gst/check/Makefile.am (libgstcheck_@GST_MAJORMINOR@include_HEADERS) (libgstcheck_@GST_MAJORMINOR@_la_SOURCES): * libs/gst/check/gstbufferstraw.h: * libs/gst/check/gstbufferstraw.c: Add some new hype testing functions, thus proving I am still a GStreamer haxor. OK I wrote them a long time ago, but anyways.
This commit is contained in:
parent
4cb08fa3f2
commit
1cd7bc447b
5 changed files with 211 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2006-07-21 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
* libs/gst/check/Makefile.am
|
||||
(libgstcheck_@GST_MAJORMINOR@include_HEADERS)
|
||||
(libgstcheck_@GST_MAJORMINOR@_la_SOURCES):
|
||||
* libs/gst/check/gstbufferstraw.h:
|
||||
* libs/gst/check/gstbufferstraw.c: Add some new hype testing
|
||||
functions, thus proving I am still a GStreamer haxor. OK I wrote
|
||||
them a long time ago, but anyways.
|
||||
|
||||
2006-07-21 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -3,6 +3,7 @@ lib_LTLIBRARIES = libgstcheck-@GST_MAJORMINOR@.la
|
|||
libgstcheck_@GST_MAJORMINOR@_la_DEPENDENCIES = \
|
||||
$(top_builddir)/gst/libgstreamer-@GST_MAJORMINOR@.la
|
||||
libgstcheck_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
gstbufferstraw.c \
|
||||
gstcheck.c
|
||||
|
||||
libgstcheck_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS)
|
||||
|
@ -15,6 +16,7 @@ libgstcheck_@GST_MAJORMINOR@includedir = \
|
|||
$(includedir)/gstreamer-@GST_MAJORMINOR@/gst/check
|
||||
|
||||
libgstcheck_@GST_MAJORMINOR@include_HEADERS = \
|
||||
gstbufferstraw.h \
|
||||
gstcheck.h
|
||||
|
||||
CLEANFILES = *.gcno *.gcda *.gcov
|
||||
|
|
165
libs/gst/check/gstbufferstraw.c
Normal file
165
libs/gst/check/gstbufferstraw.c
Normal file
|
@ -0,0 +1,165 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* unit testing helper lib
|
||||
*
|
||||
* Copyright (C) 2006 Andy Wingo <wingo at pobox.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "gstbufferstraw.h"
|
||||
|
||||
static GCond *cond = NULL;
|
||||
static GMutex *lock = NULL;
|
||||
static GstBuffer *buf = NULL;
|
||||
static gulong id;
|
||||
|
||||
/* called for every buffer. Waits until the global "buf" variable is unset,
|
||||
* then sets it to the buffer received, and signals. */
|
||||
static gboolean
|
||||
buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused)
|
||||
{
|
||||
g_mutex_lock (lock);
|
||||
|
||||
while (buf != NULL)
|
||||
g_cond_wait (cond, lock);
|
||||
|
||||
/* increase the refcount because we store it globally for others to use */
|
||||
buf = gst_buffer_ref (buffer);
|
||||
|
||||
g_cond_signal (cond);
|
||||
|
||||
g_mutex_unlock (lock);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_straw_start_pipeline:
|
||||
* @bin: the pipeline to run
|
||||
* @pad: a pad on an element in @bin
|
||||
*
|
||||
* Sets up a pipeline for buffer sucking. This will allow you to call
|
||||
* gst_buffer_straw_get_buffer() to access buffers as they pass over @pad.
|
||||
*
|
||||
* This function is normally used in unit tests that want to verify that a
|
||||
* particular element is outputting correct buffers. For example, you would make
|
||||
* a pipeline via gst_parse_launch(), pull out the pad you want to monitor, then
|
||||
* call gst_buffer_straw_get_buffer() to get the buffers that pass through @pad.
|
||||
* The pipeline will block until you have sucked off the buffers.
|
||||
*
|
||||
* This function will set the state of @bin to PLAYING; to clean up, be sure to
|
||||
* call gst_buffer_straw_stop_pipeline().
|
||||
*
|
||||
* Note that you may not start two buffer straws at the same time. This function
|
||||
* is intended for unit tests, not general API use. In fact it calls fail_if
|
||||
* from libcheck, so you cannot use it outside unit tests.
|
||||
*/
|
||||
void
|
||||
gst_buffer_straw_start_pipeline (GstElement * bin, GstPad * pad)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe), NULL);
|
||||
|
||||
cond = g_cond_new ();
|
||||
lock = g_mutex_new ();
|
||||
|
||||
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not start test pipeline");
|
||||
if (ret == GST_STATE_CHANGE_ASYNC) {
|
||||
ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
|
||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_straw_get_buffer:
|
||||
* @bin: the pipeline previously started via gst_buffer_straw_start_pipeline()
|
||||
* @pad: the pad previously passed to gst_buffer_straw_start_pipeline()
|
||||
*
|
||||
* Get one buffer from @pad. Implemented via buffer probes. This function will
|
||||
* block until the pipeline passes a buffer over @pad, so for robust behavior
|
||||
* in unit tests, you need to use check's timeout to fail out in the case that a
|
||||
* buffer never arrives.
|
||||
*
|
||||
* You must have previously called gst_buffer_straw_start_pipeline() on
|
||||
* @pipeline and @pad.
|
||||
*/
|
||||
GstBuffer *
|
||||
gst_buffer_straw_get_buffer (GstElement * bin, GstPad * pad)
|
||||
{
|
||||
GstBuffer *ret;
|
||||
|
||||
g_mutex_lock (lock);
|
||||
|
||||
while (buf == NULL)
|
||||
g_cond_wait (cond, lock);
|
||||
|
||||
ret = buf;
|
||||
buf = NULL;
|
||||
|
||||
g_cond_signal (cond);
|
||||
|
||||
g_mutex_unlock (lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_straw_stop_pipeline:
|
||||
* @bin: the pipeline previously started via gst_buffer_straw_start_pipeline()
|
||||
* @pad: the pad previously passed to gst_buffer_straw_start_pipeline()
|
||||
*
|
||||
* Set @bin to #GST_STATE_NULL and release resource allocated in
|
||||
* gst_buffer_straw_start_pipeline().
|
||||
*
|
||||
* You must have previously called gst_buffer_straw_start_pipeline() on
|
||||
* @pipeline and @pad.
|
||||
*/
|
||||
void
|
||||
gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
g_mutex_lock (lock);
|
||||
if (buf)
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
gst_pad_remove_buffer_probe (pad, (guint) id);
|
||||
id = 0;
|
||||
g_cond_signal (cond);
|
||||
g_mutex_unlock (lock);
|
||||
|
||||
ret = gst_element_set_state (bin, GST_STATE_NULL);
|
||||
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not stop test pipeline");
|
||||
if (ret == GST_STATE_CHANGE_ASYNC) {
|
||||
ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
|
||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
|
||||
}
|
||||
|
||||
g_mutex_lock (lock);
|
||||
if (buf)
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
g_mutex_unlock (lock);
|
||||
|
||||
g_mutex_free (lock);
|
||||
g_cond_free (cond);
|
||||
|
||||
lock = NULL;
|
||||
cond = NULL;
|
||||
}
|
33
libs/gst/check/gstbufferstraw.h
Normal file
33
libs/gst/check/gstbufferstraw.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2006 Andy Wingo <wingo at pobox.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_BUFFER_STRAW_H__
|
||||
#define __GST_BUFFER_STRAW_H__
|
||||
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
|
||||
void gst_buffer_straw_start_pipeline (GstElement * bin, GstPad * pad);
|
||||
GstBuffer *gst_buffer_straw_get_buffer (GstElement * bin, GstPad * pad);
|
||||
void gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad);
|
||||
|
||||
|
||||
#endif /* __GST_BUFFER_STRAW_H__ */
|
|
@ -175,7 +175,7 @@
|
|||
#define HAVE_WIN32 1
|
||||
|
||||
/* Define host CPU */
|
||||
#define HOST_CPU "i686"
|
||||
#define HOST_CPU "x86_64"
|
||||
|
||||
/* library dir */
|
||||
#ifdef _DEBUG
|
||||
|
|
Loading…
Reference in a new issue