diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2012-09-18 08:49:46 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2012-09-18 08:49:46 +0200 |
commit | e9c66bffc089df63904377cb88002300086e6440 (patch) | |
tree | 46ed128a686c01f8f45931c297951c83a54fd721 /gst | |
parent | e0655f96cc7e2ef783f3db82c6b087d34f1e2b87 (diff) |
Imported Upstream version 0.11.99upstream/0.11.99
Diffstat (limited to 'gst')
-rw-r--r-- | gst/Makefile.am | 1 | ||||
-rw-r--r-- | gst/Makefile.in | 1 | ||||
-rw-r--r-- | gst/gst.h | 5 | ||||
-rw-r--r-- | gst/gstpad.c | 29 | ||||
-rw-r--r-- | gst/gstpad.h | 10 | ||||
-rw-r--r-- | gst/gststructure.c | 2 | ||||
-rw-r--r-- | gst/gstvalue.c | 164 |
7 files changed, 194 insertions, 18 deletions
diff --git a/gst/Makefile.am b/gst/Makefile.am index 1cac7f2..714f69e 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -270,7 +270,6 @@ Gst-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libgstreamer-@GST_API_VERSIO -I$(top_srcdir) \ -I$(top_builddir) \ -DIN_GOBJECT_INTROSPECTION=1 \ - -DGST_USE_UNSTABLE_API \ --c-include='gst/gst.h' \ --library=libgstreamer-@GST_API_VERSION@.la \ --include=GLib-2.0 \ diff --git a/gst/Makefile.in b/gst/Makefile.in index 2891688..bd3a622 100644 --- a/gst/Makefile.in +++ b/gst/Makefile.in @@ -1847,7 +1847,6 @@ Android.mk: Makefile.am @HAVE_INTROSPECTION_TRUE@ -I$(top_srcdir) \ @HAVE_INTROSPECTION_TRUE@ -I$(top_builddir) \ @HAVE_INTROSPECTION_TRUE@ -DIN_GOBJECT_INTROSPECTION=1 \ -@HAVE_INTROSPECTION_TRUE@ -DGST_USE_UNSTABLE_API \ @HAVE_INTROSPECTION_TRUE@ --c-include='gst/gst.h' \ @HAVE_INTROSPECTION_TRUE@ --library=libgstreamer-@GST_API_VERSION@.la \ @HAVE_INTROSPECTION_TRUE@ --include=GLib-2.0 \ @@ -24,11 +24,6 @@ #ifndef __GST_H__ #define __GST_H__ -#ifndef GST_USE_UNSTABLE_API -#warning "The GStreamer 0.11 API is still unstable and will change in future." -#warning "Define GST_USE_UNSTABLE_API to avoid this warning." -#endif - #include <glib.h> #include <gst/glib-compat.h> diff --git a/gst/gstpad.c b/gst/gstpad.c index 60f1d6e..04c285e 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1836,11 +1836,23 @@ gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad) goto not_linked_together; if (GST_PAD_UNLINKFUNC (srcpad)) { - GST_PAD_UNLINKFUNC (srcpad) (srcpad); + GstObject *tmpparent; + + ACQUIRE_PARENT (srcpad, tmpparent, no_src_parent); + + GST_PAD_UNLINKFUNC (srcpad) (srcpad, tmpparent); + RELEASE_PARENT (parent); } +no_src_parent: if (GST_PAD_UNLINKFUNC (sinkpad)) { - GST_PAD_UNLINKFUNC (sinkpad) (sinkpad); + GstObject *tmpparent; + + ACQUIRE_PARENT (sinkpad, tmpparent, no_sink_parent); + + GST_PAD_UNLINKFUNC (sinkpad) (sinkpad, tmpparent); + RELEASE_PARENT (parent); } +no_sink_parent: /* first clear peers */ GST_PAD_PEER (srcpad) = NULL; @@ -2210,13 +2222,22 @@ gst_pad_link_full (GstPad * srcpad, GstPad * sinkpad, GstPadLinkCheck flags) GST_OBJECT_UNLOCK (srcpad); if (srcfunc) { + GstObject *tmpparent; + + ACQUIRE_PARENT (srcpad, tmpparent, no_parent); /* this one will call the peer link function */ - result = srcfunc (srcpad, sinkpad); + result = srcfunc (srcpad, tmpparent, sinkpad); + RELEASE_PARENT (tmpparent); } else if (sinkfunc) { + GstObject *tmpparent; + + ACQUIRE_PARENT (sinkpad, tmpparent, no_parent); /* if no source link function, we need to call the sink link * function ourselves. */ - result = sinkfunc (sinkpad, srcpad); + result = sinkfunc (sinkpad, tmpparent, srcpad); + RELEASE_PARENT (tmpparent); } + no_parent: GST_OBJECT_LOCK (srcpad); GST_OBJECT_LOCK (sinkpad); diff --git a/gst/gstpad.h b/gst/gstpad.h index f14e7fe..c6ac927 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -396,20 +396,26 @@ typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstObject *parent, /** * GstPadLinkFunction: * @pad: the #GstPad that is linked. + * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set, + * @parent is guaranteed to be not-NULL and remain valid during the + * execution of this function. * @peer: the peer #GstPad of the link * * Function signature to handle a new link on the pad. * * Returns: the result of the link with the specified peer. */ -typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer); +typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstObject *parent, GstPad *peer); /** * GstPadUnlinkFunction: * @pad: the #GstPad that is linked. + * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set, + * @parent is guaranteed to be not-NULL and remain valid during the + * execution of this function. * * Function signature to handle a unlinking the pad prom its peer. */ -typedef void (*GstPadUnlinkFunction) (GstPad *pad); +typedef void (*GstPadUnlinkFunction) (GstPad *pad, GstObject *parent); /* misc */ diff --git a/gst/gststructure.c b/gst/gststructure.c index 56b66bc..29fdf31 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1682,6 +1682,8 @@ gst_structure_get_abbrs (gint * n_abbrs) , {"bitmask", GST_TYPE_BITMASK} , + {"sample", GST_TYPE_SAMPLE} + , {"taglist", GST_TYPE_TAG_LIST} }; _num = G_N_ELEMENTS (dyn_abbrs); diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 997a5e1..80c59fe 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -1837,8 +1837,9 @@ gst_value_deserialize_caps (GValue * dest, const gchar * s) /************** * GstSegment * **************/ + static gchar * -gst_value_serialize_segment (const GValue * value) +gst_value_serialize_segment_internal (const GValue * value, gboolean escape) { GstSegment *seg = g_value_get_boxed (value); gchar *t, *res; @@ -1857,13 +1858,23 @@ gst_value_serialize_segment (const GValue * value) "position", G_TYPE_UINT64, seg->position, "duration", G_TYPE_UINT64, seg->duration, NULL); t = gst_structure_to_string (s); - res = g_strdup_printf ("\"%s\"", t); - g_free (t); + if (escape) { + res = g_strdup_printf ("\"%s\"", t); + g_free (t); + } else { + res = t; + } gst_structure_free (s); return res; } +static gchar * +gst_value_serialize_segment (const GValue * value) +{ + return gst_value_serialize_segment_internal (value, TRUE); +} + static gboolean gst_value_deserialize_segment (GValue * dest, const gchar * s) { @@ -2151,6 +2162,149 @@ gst_value_compare_sample (const GValue * value1, const GValue * value2) return compare_buffer (buf1, buf2); } +static gchar * +gst_value_serialize_sample (const GValue * value) +{ + const GstStructure *info_structure; + GstSegment *segment; + GstBuffer *buffer; + GstCaps *caps; + GstSample *sample; + GValue val = { 0, }; + gchar *info_str, *caps_str, *tmp; + gchar *buf_str, *seg_str, *s; + + sample = g_value_get_boxed (value); + + buffer = gst_sample_get_buffer (sample); + if (buffer) { + g_value_init (&val, GST_TYPE_BUFFER); + g_value_set_boxed (&val, buffer); + buf_str = gst_value_serialize_buffer (&val); + g_value_unset (&val); + } else { + buf_str = g_strdup ("None"); + } + + caps = gst_sample_get_caps (sample); + if (caps) { + tmp = gst_caps_to_string (caps); + caps_str = g_base64_encode ((guchar *) tmp, strlen (tmp) + 1); + g_strdelimit (caps_str, "=", '_'); + g_free (tmp); + } else { + caps_str = g_strdup ("None"); + } + + segment = gst_sample_get_segment (sample); + if (segment) { + g_value_init (&val, GST_TYPE_SEGMENT); + g_value_set_boxed (&val, segment); + tmp = gst_value_serialize_segment_internal (&val, FALSE); + seg_str = g_base64_encode ((guchar *) tmp, strlen (tmp) + 1); + g_strdelimit (seg_str, "=", '_'); + g_free (tmp); + g_value_unset (&val); + } else { + seg_str = g_strdup ("None"); + } + + info_structure = gst_sample_get_info (sample); + if (info_structure) { + tmp = gst_structure_to_string (info_structure); + info_str = g_base64_encode ((guchar *) tmp, strlen (tmp) + 1); + g_strdelimit (info_str, "=", '_'); + g_free (tmp); + } else { + info_str = g_strdup ("None"); + } + + s = g_strconcat (buf_str, ":", caps_str, ":", seg_str, ":", info_str, NULL); + g_free (buf_str); + g_free (caps_str); + g_free (seg_str); + g_free (info_str); + + return s; +} + +static gboolean +gst_value_deserialize_sample (GValue * dest, const gchar * s) +{ + GValue bval = G_VALUE_INIT, sval = G_VALUE_INIT; + GstStructure *info; + GstSample *sample; + GstCaps *caps; + gboolean ret = FALSE; + gchar **fields; + gsize outlen; + gint len; + + GST_TRACE ("deserialize '%s'", s); + + fields = g_strsplit (s, ":", -1); + len = g_strv_length (fields); + if (len != 4) + goto wrong_length; + + g_value_init (&bval, GST_TYPE_BUFFER); + g_value_init (&sval, GST_TYPE_SEGMENT); + + if (!gst_value_deserialize_buffer (&bval, fields[0])) + goto fail; + + if (strcmp (fields[1], "None") != 0) { + g_strdelimit (fields[1], "_", '='); + g_base64_decode_inplace (fields[1], &outlen); + GST_TRACE ("caps : %s", fields[1]); + caps = gst_caps_from_string (fields[1]); + if (caps == NULL) + goto fail; + } else { + caps = NULL; + } + + if (strcmp (fields[2], "None") != 0) { + g_strdelimit (fields[2], "_", '='); + g_base64_decode_inplace (fields[2], &outlen); + GST_TRACE ("segment : %s", fields[2]); + if (!gst_value_deserialize_segment (&sval, fields[2])) + goto fail; + } + + if (strcmp (fields[3], "None") != 0) { + g_strdelimit (fields[3], "_", '='); + g_base64_decode_inplace (fields[3], &outlen); + GST_TRACE ("info : %s", fields[3]); + info = gst_structure_from_string (fields[3], NULL); + if (info == NULL) + goto fail; + } else { + info = NULL; + } + + sample = gst_sample_new (gst_value_get_buffer (&bval), caps, + g_value_get_boxed (&sval), info); + + g_value_take_boxed (dest, sample); + + if (caps) + gst_caps_unref (caps); + + ret = TRUE; + +fail: + + g_value_unset (&bval); + g_value_unset (&sval); + +wrong_length: + + g_strfreev (fields); + + return ret; +} + /*********** * boolean * ***********/ @@ -5801,8 +5955,8 @@ _priv_gst_value_initialize (void) static GstValueTable gst_value = { 0, gst_value_compare_sample, - NULL, - NULL, + gst_value_serialize_sample, + gst_value_deserialize_sample, }; gst_value.type = GST_TYPE_SAMPLE; |