Commit 6ed5bee3 authored by Jan Schmidt's avatar Jan Schmidt

check/elements/identity.c: Make the error a little clearer when the test fails...

check/elements/identity.c: Make the error a little clearer when the test fails because identity made a copy of the bu...

Original commit message from CVS:
* check/elements/identity.c: (GST_START_TEST):
Make the error a little clearer when the test fails because
identity made a copy of the buffer.
* docs/gst/gstreamer-sections.txt:
New symbols in gstbasetransform.h
* gst/base/gstbasetransform.c: (gst_base_transform_class_init),
(gst_base_transform_init), (gst_base_transform_transform_size),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_default_prepare_buf),
(gst_base_transform_get_unit_size),
(gst_base_transform_buffer_alloc),
(gst_base_transform_handle_buffer), (gst_base_transform_chain),
(gst_base_transform_change_state),
(gst_base_transform_set_passthrough),
(gst_base_transform_set_in_place),
(gst_base_transform_is_in_place):
* gst/base/gstbasetransform.h:
Change BaseTransform to separate in_place operate from same_caps
output. in_place implies that the element can perform the transform
on incoming buffers in-place, even if the caps on the output are
different.
Sub-class elements can now implement special buffer allocation
methods for outgoing buffers if they wish to.
Big documentation addition.
* gst/elements/gstcapsfilter.c: (gst_capsfilter_transform_ip):
* gst/elements/gstelements.c:
Changes for basetransform modifications.
* gst/elements/Makefile.am:
* gst/elements/gstfdsrc.c: (gst_fdsrc_init), (gst_fdsrc_create):
Compile fix. Extra debug output.
parent 8f90f92a
2005-09-09 Jan Schmidt <thaytan@mad.scientist.com>
* check/elements/identity.c: (GST_START_TEST):
Make the error a little clearer when the test fails because
identity made a copy of the buffer.
* docs/gst/gstreamer-sections.txt:
New symbols in gstbasetransform.h
* gst/base/gstbasetransform.c: (gst_base_transform_class_init),
(gst_base_transform_init), (gst_base_transform_transform_size),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_default_prepare_buf),
(gst_base_transform_get_unit_size),
(gst_base_transform_buffer_alloc),
(gst_base_transform_handle_buffer), (gst_base_transform_chain),
(gst_base_transform_change_state),
(gst_base_transform_set_passthrough),
(gst_base_transform_set_in_place),
(gst_base_transform_is_in_place):
* gst/base/gstbasetransform.h:
Change BaseTransform to separate in_place operate from same_caps
output. in_place implies that the element can perform the transform
on incoming buffers in-place, even if the caps on the output are
different.
Sub-class elements can now implement special buffer allocation
methods for outgoing buffers if they wish to.
Big documentation addition.
* gst/elements/gstcapsfilter.c: (gst_capsfilter_transform_ip):
* gst/elements/gstelements.c:
Changes for basetransform modifications.
* gst/elements/Makefile.am:
* gst/elements/gstfdsrc.c: (gst_fdsrc_init), (gst_fdsrc_create):
Compile fix. Extra debug output.
2005-09-09 Thomas Vander Stichele <thomas at apestaart dot org>
* check/gst/gstpad.c: (GST_START_TEST), (name_is_valid),
......
......@@ -101,7 +101,9 @@ GST_START_TEST (test_one_buffer)
memcpy (GST_BUFFER_DATA (buffer), "data", 4);
/* pushing gives away my reference ... */
gst_pad_push (mysrcpad, buffer);
/* ... but it ends up being collected on the global buffer list */
/* ... but it should end up being collected on the global buffer list */
fail_unless (g_list_length (buffers) == 1);
fail_unless ((GstBuffer *) (g_list_first (buffers)->data) == buffer);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
/* cleanup */
......
......@@ -2296,6 +2296,8 @@ GstBaseTransformClass
gst_base_transform_is_passthrough
gst_base_transform_set_passthrough
gst_base_transform_is_in_place
gst_base_transform_set_in_place
GST_BASE_TRANSFORM_SINK_NAME
GST_BASE_TRANSFORM_SRC_NAME
......
This diff is collapsed.
......@@ -47,9 +47,12 @@ struct _GstBaseTransform {
GstPad *sinkpad;
GstPad *srcpad;
/* Set by sub-class */
gboolean passthrough;
gboolean always_in_place;
gboolean in_place;
/* Set if caps on each pad are equal */
gboolean have_same_caps;
GstCaps *cache_caps1;
guint cache_caps1_size;
......@@ -121,7 +124,7 @@ struct _GstBaseTransformClass {
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
/* transform one incoming buffer to one outgoing buffer.
* Always needs to be implemented.
* Always needs to be implemented unless always operating in-place.
* transform function is allowed to change size/timestamp/duration of
* the outgoing buffer. */
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf,
......@@ -130,13 +133,29 @@ struct _GstBaseTransformClass {
/* transform a buffer inplace */
GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);
/* FIXME: When adjusting the padding, more these to nicer places in the class */
/* Set by child classes to automatically do passthrough mode */
gboolean passthrough_on_same_caps;
/* Subclasses can override this to do their own allocation of output buffers.
* Elements that only do analysis can return a subbuffer or even just
* increment the reference to the input buffer (if in passthrough mode)
*/
GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans,
GstBuffer *input, gint size, GstCaps *caps, GstBuffer **buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - 2];
};
void gst_base_transform_set_passthrough (GstBaseTransform *trans, gboolean passthrough);
void gst_base_transform_set_passthrough (GstBaseTransform *trans,
gboolean passthrough);
gboolean gst_base_transform_is_passthrough (GstBaseTransform *trans);
void gst_base_transform_set_in_place (GstBaseTransform *trans,
gboolean in_place);
gboolean gst_base_transform_is_in_place (GstBaseTransform *trans);
GType gst_base_transform_get_type (void);
G_END_DECLS
......
......@@ -12,6 +12,7 @@ libgstelements_la_SOURCES = \
gstcapsfilter.c \
gstfakesrc.c \
gstfakesink.c \
gstfdsrc.c \
gstfilesink.c \
gstfilesrc.c \
gstidentity.c \
......@@ -29,6 +30,7 @@ noinst_HEADERS = \
gstbufferstore.h \
gstfakesink.h \
gstfakesrc.h \
gstfdsrc.h \
gstfilesink.h \
gstfilesrc.h \
gstidentity.h \
......
......@@ -216,5 +216,15 @@ gst_capsfilter_transform_caps (GstBaseTransform * base,
static GstFlowReturn
gst_capsfilter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
{
/* Ensure that outgoing buffers have caps if we can, so that pipelines
* like:
* gst-launch filesrc location=rawsamples.raw !
* audio/x-raw-int,width=16,depth=16,rate=48000,channels=2,
* endianness=4321,signed='(boolean)'true ! alsasink
* will work.
*/
if (GST_BUFFER_CAPS (buf) == NULL) {
}
return GST_FLOW_OK;
}
......@@ -29,6 +29,7 @@
#include "gstfakesink.h"
#include "gstfakesrc.h"
#include "gstfdsrc.h"
#include "gstfilesink.h"
#include "gstfilesrc.h"
#include "gstidentity.h"
......@@ -50,6 +51,7 @@ static struct _elements_entry _elements[] = {
{"capsfilter", GST_RANK_NONE, gst_capsfilter_get_type},
{"fakesrc", GST_RANK_NONE, gst_fake_src_get_type},
{"fakesink", GST_RANK_NONE, gst_fake_sink_get_type},
{"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type},
{"filesrc", GST_RANK_NONE, gst_file_src_get_type},
{"identity", GST_RANK_NONE, gst_identity_get_type},
{"filesink", GST_RANK_NONE, gst_file_sink_get_type},
......
......@@ -136,7 +136,7 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
}
static void
gst_fdsrc_init (GstFdSrc * fdsrc)
gst_fdsrc_init (GstFdSrc * fdsrc, GstFdSrcClass * klass)
{
// TODO set live only if it's actually a live source
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
......@@ -260,9 +260,11 @@ gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
if (retval == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("select on file descriptor: %s.", g_strerror (errno)));
GST_DEBUG_OBJECT (psrc, "Error during select");
return GST_FLOW_ERROR;
} else if (retval == 0) {
g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0);
GST_DEBUG_OBJECT (psrc, "Timeout in select");
return GST_FLOW_ERROR;
}
#endif
......@@ -277,14 +279,18 @@ gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
src->curoffset += readbytes;
GST_DEBUG_OBJECT (psrc, "Read buffer of size %u.", readbytes);
/* we're done, return the buffer */
*outbuf = buf;
return GST_FLOW_OK;
} else if (readbytes == 0) {
GST_DEBUG_OBJECT (psrc, "Read 0 bytes. EOS.");
return GST_FLOW_ERROR;
} else {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("read on file descriptor: %s.", g_strerror (errno)));
GST_DEBUG_OBJECT (psrc, "Error reading from fd");
return GST_FLOW_ERROR;
}
}
This diff is collapsed.
......@@ -47,9 +47,12 @@ struct _GstBaseTransform {
GstPad *sinkpad;
GstPad *srcpad;
/* Set by sub-class */
gboolean passthrough;
gboolean always_in_place;
gboolean in_place;
/* Set if caps on each pad are equal */
gboolean have_same_caps;
GstCaps *cache_caps1;
guint cache_caps1_size;
......@@ -121,7 +124,7 @@ struct _GstBaseTransformClass {
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
/* transform one incoming buffer to one outgoing buffer.
* Always needs to be implemented.
* Always needs to be implemented unless always operating in-place.
* transform function is allowed to change size/timestamp/duration of
* the outgoing buffer. */
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf,
......@@ -130,13 +133,29 @@ struct _GstBaseTransformClass {
/* transform a buffer inplace */
GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);
/* FIXME: When adjusting the padding, more these to nicer places in the class */
/* Set by child classes to automatically do passthrough mode */
gboolean passthrough_on_same_caps;
/* Subclasses can override this to do their own allocation of output buffers.
* Elements that only do analysis can return a subbuffer or even just
* increment the reference to the input buffer (if in passthrough mode)
*/
GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans,
GstBuffer *input, gint size, GstCaps *caps, GstBuffer **buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - 2];
};
void gst_base_transform_set_passthrough (GstBaseTransform *trans, gboolean passthrough);
void gst_base_transform_set_passthrough (GstBaseTransform *trans,
gboolean passthrough);
gboolean gst_base_transform_is_passthrough (GstBaseTransform *trans);
void gst_base_transform_set_in_place (GstBaseTransform *trans,
gboolean in_place);
gboolean gst_base_transform_is_in_place (GstBaseTransform *trans);
GType gst_base_transform_get_type (void);
G_END_DECLS
......
......@@ -12,6 +12,7 @@ libgstelements_la_SOURCES = \
gstcapsfilter.c \
gstfakesrc.c \
gstfakesink.c \
gstfdsrc.c \
gstfilesink.c \
gstfilesrc.c \
gstidentity.c \
......@@ -29,6 +30,7 @@ noinst_HEADERS = \
gstbufferstore.h \
gstfakesink.h \
gstfakesrc.h \
gstfdsrc.h \
gstfilesink.h \
gstfilesrc.h \
gstidentity.h \
......
......@@ -216,5 +216,15 @@ gst_capsfilter_transform_caps (GstBaseTransform * base,
static GstFlowReturn
gst_capsfilter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
{
/* Ensure that outgoing buffers have caps if we can, so that pipelines
* like:
* gst-launch filesrc location=rawsamples.raw !
* audio/x-raw-int,width=16,depth=16,rate=48000,channels=2,
* endianness=4321,signed='(boolean)'true ! alsasink
* will work.
*/
if (GST_BUFFER_CAPS (buf) == NULL) {
}
return GST_FLOW_OK;
}
......@@ -29,6 +29,7 @@
#include "gstfakesink.h"
#include "gstfakesrc.h"
#include "gstfdsrc.h"
#include "gstfilesink.h"
#include "gstfilesrc.h"
#include "gstidentity.h"
......@@ -50,6 +51,7 @@ static struct _elements_entry _elements[] = {
{"capsfilter", GST_RANK_NONE, gst_capsfilter_get_type},
{"fakesrc", GST_RANK_NONE, gst_fake_src_get_type},
{"fakesink", GST_RANK_NONE, gst_fake_sink_get_type},
{"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type},
{"filesrc", GST_RANK_NONE, gst_file_src_get_type},
{"identity", GST_RANK_NONE, gst_identity_get_type},
{"filesink", GST_RANK_NONE, gst_file_sink_get_type},
......
......@@ -136,7 +136,7 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
}
static void
gst_fdsrc_init (GstFdSrc * fdsrc)
gst_fdsrc_init (GstFdSrc * fdsrc, GstFdSrcClass * klass)
{
// TODO set live only if it's actually a live source
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
......@@ -260,9 +260,11 @@ gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
if (retval == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("select on file descriptor: %s.", g_strerror (errno)));
GST_DEBUG_OBJECT (psrc, "Error during select");
return GST_FLOW_ERROR;
} else if (retval == 0) {
g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0);
GST_DEBUG_OBJECT (psrc, "Timeout in select");
return GST_FLOW_ERROR;
}
#endif
......@@ -277,14 +279,18 @@ gst_fdsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
src->curoffset += readbytes;
GST_DEBUG_OBJECT (psrc, "Read buffer of size %u.", readbytes);
/* we're done, return the buffer */
*outbuf = buf;
return GST_FLOW_OK;
} else if (readbytes == 0) {
GST_DEBUG_OBJECT (psrc, "Read 0 bytes. EOS.");
return GST_FLOW_ERROR;
} else {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("read on file descriptor: %s.", g_strerror (errno)));
GST_DEBUG_OBJECT (psrc, "Error reading from fd");
return GST_FLOW_ERROR;
}
}
......@@ -101,7 +101,9 @@ GST_START_TEST (test_one_buffer)
memcpy (GST_BUFFER_DATA (buffer), "data", 4);
/* pushing gives away my reference ... */
gst_pad_push (mysrcpad, buffer);
/* ... but it ends up being collected on the global buffer list */
/* ... but it should end up being collected on the global buffer list */
fail_unless (g_list_length (buffers) == 1);
fail_unless ((GstBuffer *) (g_list_first (buffers)->data) == buffer);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
/* cleanup */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment