Comment all code using buffer caps.
Rework capsfilter code a little.
Fix some unit tests
gboolean want_in_place;
GstClockTime running_time;
GstClockTime timestamp;
+#if 0
GstCaps *incaps;
+#endif
gsize insize;
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
+#if 0
if (G_LIKELY ((incaps = GST_BUFFER_CAPS (inbuf)))) {
gboolean reconfigure;
goto not_negotiated;
}
}
+#endif
insize = gst_buffer_get_size (inbuf);
GSList *insert_pos = NULL;
gsize buf_size;
guint64 buf_offset;
+#if 0
GstCaps *caps;
+#endif
helper = (GstTypeFindHelper *) data;
if (ret != GST_FLOW_OK)
goto error;
+#if 0
caps = GST_BUFFER_CAPS (buffer);
if (caps && !gst_caps_is_empty (caps) && !gst_caps_is_any (caps)) {
gst_buffer_unref (buffer);
return NULL;
}
+#endif
/* getrange might silently return shortened buffers at the end of a file,
* we must, however, always return either the full requested data or NULL */
gst_check_element_push_buffer_list (const gchar * element_name,
GList * buffer_in, GList * buffer_out, GstFlowReturn last_flow_return)
{
+#if 0
GstCaps *sink_caps;
GstCaps *src_caps = NULL;
+#endif
GstElement *element;
GstPad *pad_peer;
GstPad *sink_pad = NULL;
buffer = GST_BUFFER (buffer_in->data);
fail_unless (GST_IS_BUFFER (buffer), "There should be a buffer in buffer_in");
+#if 0
src_caps = GST_BUFFER_CAPS (buffer);
+#endif
src_pad = gst_pad_new (NULL, GST_PAD_SRC);
+#if 0
gst_pad_set_caps (src_pad, src_caps);
+#endif
pad_peer = gst_element_get_static_pad (element, "sink");
fail_if (pad_peer == NULL);
fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK,
GST_DEBUG ("src pad activated");
/* don't create the sink_pad if there is no buffer_out list */
if (buffer_out != NULL) {
+#if 0
gchar *temp;
+#endif
GST_DEBUG ("buffer out detected, creating the sink pad");
/* get the sink caps */
+#if 0
sink_caps = GST_BUFFER_CAPS (GST_BUFFER (buffer_out->data));
fail_unless (GST_IS_CAPS (sink_caps), "buffer out don't have caps");
temp = gst_caps_to_string (sink_caps);
GST_DEBUG ("sink caps requested by buffer out: '%s'", temp);
g_free (temp);
fail_unless (gst_caps_is_fixed (sink_caps), "we need fixed caps");
+#endif
/* get the sink pad */
sink_pad = gst_pad_new (NULL, GST_PAD_SINK);
fail_unless (GST_IS_PAD (sink_pad));
+#if 0
gst_pad_set_caps (sink_pad, sink_caps);
+#endif
/* get the peer pad */
pad_peer = gst_element_get_static_pad (element, "src");
fail_unless (gst_pad_link (pad_peer, sink_pad) == GST_PAD_LINK_OK,
newdata = gst_buffer_map (new, &newsize, NULL, GST_MAP_READ);
origdata = gst_buffer_map (orig, &origsize, NULL, GST_MAP_READ);
- GST_LOG ("orig buffer: size %u, caps %" GST_PTR_FORMAT,
- origsize, GST_BUFFER_CAPS (orig));
- GST_LOG ("new buffer: size %u, caps %" GST_PTR_FORMAT,
- newsize, GST_BUFFER_CAPS (new));
+ GST_LOG ("orig buffer: size %u", origsize);
+ GST_LOG ("new buffer: size %u", newsize);
GST_MEMDUMP ("orig buffer", origdata, origsize);
GST_MEMDUMP ("new buffer", newdata, newsize);
fail_unless (origsize == newsize, "size of the buffers are not the same");
fail_unless (memcmp (origdata, newdata, newsize) == 0,
"data is not the same");
+#if 0
gst_check_caps_equal (GST_BUFFER_CAPS (orig), GST_BUFFER_CAPS (new));
+#endif
gst_buffer_unmap (orig, origdata, origsize);
gst_buffer_unmap (new, newdata, newsize);
{
GstFlowReturn ret = GST_FLOW_OK;
- if (GST_BUFFER_CAPS (input) != NULL) {
- /* Output buffer already has caps */
- GST_LOG_OBJECT (trans, "Input buffer already has caps (implicitely fixed)");
- /* FIXME : Move this behaviour to basetransform. The given caps are the ones
- * of the source pad, therefore our outgoing buffers should always have
- * those caps. */
- if (GST_BUFFER_CAPS (input) != caps) {
- /* caps are different, make a metadata writable output buffer to set
- * caps */
- if (gst_buffer_is_writable (input)) {
- /* input is writable, just set caps and use this as the output */
- *buf = input;
- gst_buffer_set_caps (*buf, caps);
- gst_buffer_ref (input);
- } else {
- GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
- *buf = gst_buffer_copy (input);
- gst_buffer_set_caps (*buf, caps);
- }
- } else {
- /* caps are right, just use a ref of the input as the outbuf */
- *buf = input;
- gst_buffer_ref (input);
- }
- } else {
+ /* always ref input as output buffer */
+ *buf = input;
+ gst_buffer_ref (input);
+
+ if (!gst_pad_has_current_caps (trans->sinkpad)) {
/* Buffer has no caps. See if the output pad only supports fixed caps */
GstCaps *out_caps;
+ GST_LOG_OBJECT (trans, "Input pad does not have caps");
+
out_caps = gst_pad_get_current_caps (trans->srcpad);
if (out_caps == NULL) {
out_caps = gst_pad_get_allowed_caps (trans->srcpad);
if (gst_caps_is_fixed (out_caps) && !gst_caps_is_empty (out_caps)) {
GST_DEBUG_OBJECT (trans, "Have fixed output caps %"
- GST_PTR_FORMAT " to apply to buffer with no caps", out_caps);
- if (gst_buffer_is_writable (input)) {
- gst_buffer_ref (input);
- *buf = input;
- } else {
- GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
- *buf = gst_buffer_copy (input);
- }
- GST_BUFFER_CAPS (*buf) = out_caps;
+ GST_PTR_FORMAT " to apply to srcpad", out_caps);
if (!gst_pad_has_current_caps (trans->srcpad))
gst_pad_set_caps (trans->srcpad, out_caps);
goto no_data;
buffer = gst_adapter_take_buffer (typefind->adapter, avail);
- buffer = gst_buffer_make_writable (buffer);
-
- gst_buffer_set_caps (buffer, typefind->caps);
GST_OBJECT_UNLOCK (typefind);
if (!push_cached_buffers) {
goto no_data;
buffer = gst_adapter_take_buffer (typefind->adapter, avail);
- buffer = gst_buffer_make_writable (buffer);
- gst_buffer_set_caps (buffer, typefind->caps);
GST_OBJECT_UNLOCK (typefind);
GST_DEBUG_OBJECT (typefind, "Pushing buffer: %d", avail);
return GST_FLOW_ERROR;
case MODE_NORMAL:
/* don't take object lock as typefind->caps should not change anymore */
- buffer = gst_buffer_make_writable (buffer);
- gst_buffer_set_caps (buffer, typefind->caps);
return gst_pad_push (typefind->src, buffer);
case MODE_TYPEFIND:
{
ret = gst_pad_pull_range (typefind->sink, offset, length, buffer);
- if (ret == GST_FLOW_OK && buffer && *buffer) {
- /* don't take object lock as typefind->caps should not change anymore */
- /* we assume that pulled buffers are meta-data writable */
- gst_buffer_set_caps (*buffer, typefind->caps);
- }
-
return ret;
}
#include <gst/check/gstcheck.h>
-GST_START_TEST (test_caps)
-{
- GstBuffer *buffer;
- GstCaps *caps, *caps2;
-
- buffer = gst_buffer_new_and_alloc (4);
- caps = gst_caps_from_string ("audio/x-raw-int");
- ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
-
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
-
- gst_buffer_set_caps (buffer, caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
-
- fail_unless (GST_BUFFER_CAPS (buffer) == caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
-
- fail_unless (gst_buffer_get_caps (buffer) == caps);
- gst_caps_unref (caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
-
- caps2 = gst_caps_from_string ("audio/x-raw-float");
- ASSERT_CAPS_REFCOUNT (caps2, "caps2", 1);
-
- gst_buffer_set_caps (buffer, caps2);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- ASSERT_CAPS_REFCOUNT (caps2, "caps2", 2);
-
- gst_buffer_set_caps (buffer, NULL);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- ASSERT_CAPS_REFCOUNT (caps2, "caps2", 1);
-
- /* clean up, with caps2 still set as caps */
- gst_buffer_set_caps (buffer, caps2);
- ASSERT_CAPS_REFCOUNT (caps2, "caps2", 2);
- gst_buffer_unref (buffer);
- ASSERT_CAPS_REFCOUNT (caps2, "caps2", 1);
- gst_caps_unref (caps);
- gst_caps_unref (caps2);
-}
-
-GST_END_TEST;
-
-
GST_START_TEST (test_subbuffer)
{
GstBuffer *buffer, *sub;
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_caps);
tcase_add_test (tc_chain, test_subbuffer);
tcase_add_test (tc_chain, test_subbuffer_make_writable);
tcase_add_test (tc_chain, test_make_writable);
caps = gst_caps_from_string ("foo/bar");
gst_pad_set_caps (src, caps);
+ gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
}
MAIN_STOP_THREADS ();
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_caps_unref (caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_object_unref (src);
gst_object_unref (sink);
}
/* one for me */
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- gst_pad_set_caps (src, caps);
- gst_pad_set_caps (sink, caps);
+ fail_unless (gst_pad_set_caps (src, caps) == TRUE);
+ /* can't set caps on flushing sinkpad */
+ fail_if (gst_pad_set_caps (sink, caps) == TRUE);
/* one for me and one for each set_caps */
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+
+ gst_pad_set_active (sink, TRUE);
+ fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ /* caps replaced by src caps */
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_pad_unlink (src, sink);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
/* cleanup */
gst_object_unref (src);
caps = gst_caps_from_string ("foo/bar");
sink = gst_pad_new ("sink", GST_PAD_SINK);
- gst_pad_set_caps (src, caps);
- gst_pad_set_caps (sink, caps);
+ fail_unless (gst_pad_set_caps (src, caps) == TRUE);
+ fail_if (gst_pad_set_caps (sink, caps) == TRUE);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+
+ gst_pad_set_active (sink, TRUE);
+ fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
gst_pad_unlink (src, sink);
/* cleanup */
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_pad_set_caps (src, caps);
+ gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
/* one for me and one for each set_caps */
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
buffer = gst_buffer_new ();
#if 0
/* teardown */
gst_pad_unlink (src, sink);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_object_unref (src);
gst_object_unref (sink);
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
caps = gst_caps_from_string ("foo/bar");
gst_pad_set_caps (src, caps);
+ gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
plr = gst_pad_link (src, sink);
/* Should fail if src pad caps are incompatible with sink pad caps */
gst_pad_set_caps (src, caps);
- gst_buffer_set_caps (buffer, caps);
- gst_buffer_ref (buffer);
- fail_unless (gst_pad_push (src, buffer) == GST_FLOW_NOT_NEGOTIATED);
- ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
- gst_buffer_unref (buffer);
+ fail_unless (gst_pad_set_caps (sink, caps) == FALSE);
/* teardown */
gst_pad_unlink (src, sink);
caps = gst_caps_from_string ("foo/bar");
gst_pad_set_caps (src, caps);
+ gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
plr = gst_pad_link (src, sink);
caps = gst_caps_from_string ("foo/bar");
gst_pad_set_caps (src, caps);
+ gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
plr = gst_pad_link (src, sink);
if (img) {
gchar *caps_str;
- caps_str = GST_BUFFER_CAPS (img) ?
- gst_caps_to_string (GST_BUFFER_CAPS (img)) : g_strdup ("unknown");
+ caps_str = g_strdup ("unknown");
str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, type: %s",
gst_buffer_get_size (img), caps_str);
g_free (caps_str);