/**
* SECTION:gststreams
+ * @title: GstStreams
* @short_description: Base class for stream objects
*
* A #GstStream is a high-level object defining a stream of data which is, or
* Elements that do not modify the nature of the stream can add extra information
* on it (such as enrich the #GstCaps, or #GstTagList). This is typically done
* by parsing elements.
+ *
+ * Since: 1.10
*/
#include "gst_private.h"
GST_DEBUG_CATEGORY_STATIC (streams_debug);
#define GST_CAT_DEFAULT streams_debug
-#define GST_STREAM_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_STREAM, GstStreamPrivate))
-
struct _GstStreamPrivate
{
GstStreamFlags flags;
}
#define gst_stream_parent_class parent_class
-G_DEFINE_TYPE_WITH_CODE (GstStream, gst_stream, GST_TYPE_OBJECT, _do_init);
+G_DEFINE_TYPE_WITH_CODE (GstStream, gst_stream, GST_TYPE_OBJECT,
+ G_ADD_PRIVATE (GstStream) _do_init);
static void
gst_stream_class_init (GstStreamClass * klass)
gobject_class = (GObjectClass *) klass;
- g_type_class_add_private (klass, sizeof (GstStreamPrivate));
-
gobject_class->set_property = gst_stream_set_property;
gobject_class->get_property = gst_stream_get_property;
static void
gst_stream_init (GstStream * stream)
{
- stream->priv = GST_STREAM_GET_PRIVATE (stream);
+ stream->priv = gst_stream_get_instance_private (stream);
stream->priv->type = GST_STREAM_TYPE_UNKNOWN;
}
* Create a new #GstStream for the given @stream_id, @caps, @type
* and @flags
*
- * Returns: The new #GstStream
+ * Returns: (transfer full): The new #GstStream
+ *
+ * Since: 1.10
*/
GstStream *
gst_stream_new (const gchar * stream_id, GstCaps * caps, GstStreamType type,
GstStreamFlags flags)
{
- return g_object_new (GST_TYPE_STREAM, "stream-id", stream_id, "caps", caps,
+ GstStream *stream;
+
+ stream = g_object_new (GST_TYPE_STREAM, "stream-id", stream_id, "caps", caps,
"stream-type", type, "stream-flags", flags, NULL);
+
+ /* Clear floating flag */
+ gst_object_ref_sink (stream);
+
+ return stream;
}
static void
gst_stream_set_stream_id (GstStream * stream, const gchar * stream_id)
{
+ g_return_if_fail (GST_IS_STREAM (stream));
+
GST_OBJECT_LOCK (stream);
g_assert (stream->stream_id == NULL);
if (stream_id)
stream->stream_id = g_strdup (stream_id);
else {
- /* Create a randoom stream_id if NULL */
+ /* Create a random stream_id if NULL */
GST_FIXME_OBJECT (stream, "Creating random stream-id, consider "
"implementing a deterministic way of creating a stream-id");
stream->stream_id =
*
* Returns: (transfer none) (nullable): the stream ID of @stream. Only valid
* during the lifetime of @stream.
+ *
+ * Since: 1.10
*/
const gchar *
gst_stream_get_stream_id (GstStream * stream)
{
+ g_return_val_if_fail (GST_IS_STREAM (stream), NULL);
+
return stream->stream_id;
}
* @flags: the flags to set on @stream
*
* Set the @flags for the @stream.
+ *
+ * Since: 1.10
*/
void
gst_stream_set_stream_flags (GstStream * stream, GstStreamFlags flags)
{
+ g_return_if_fail (GST_IS_STREAM (stream));
+
GST_OBJECT_LOCK (stream);
stream->priv->flags = flags;
GST_OBJECT_UNLOCK (stream);
*
* Returns: The #GstStreamFlags for @stream
*
+ * Since: 1.10
*/
GstStreamFlags
gst_stream_get_stream_flags (GstStream * stream)
{
GstStreamFlags res;
+ g_return_val_if_fail (GST_IS_STREAM (stream), GST_STREAM_FLAG_NONE);
+
GST_OBJECT_LOCK (stream);
res = stream->priv->flags;
GST_OBJECT_UNLOCK (stream);
* @stream_type: the type to set on @stream
*
* Set the stream type of @stream
+ *
+ * Since: 1.10
*/
void
gst_stream_set_stream_type (GstStream * stream, GstStreamType stream_type)
{
+ g_return_if_fail (GST_IS_STREAM (stream));
+
GST_OBJECT_LOCK (stream);
stream->priv->type = stream_type;
GST_OBJECT_UNLOCK (stream);
*
* Returns: The #GstStreamType for @stream
*
+ * Since: 1.10
*/
GstStreamType
gst_stream_get_stream_type (GstStream * stream)
{
GstStreamType res;
+ g_return_val_if_fail (GST_IS_STREAM (stream), GST_STREAM_TYPE_UNKNOWN);
+
GST_OBJECT_LOCK (stream);
res = stream->priv->type;
GST_OBJECT_UNLOCK (stream);
*
* Set the tags for the #GstStream
*
+ * Since: 1.10
*/
void
gst_stream_set_tags (GstStream * stream, GstTagList * tags)
{
+ gboolean notify = FALSE;
+
+ g_return_if_fail (GST_IS_STREAM (stream));
+
GST_OBJECT_LOCK (stream);
- gst_mini_object_replace ((GstMiniObject **) & stream->priv->tags,
- (GstMiniObject *) tags);
+ if (stream->priv->tags == NULL || tags == NULL
+ || !gst_tag_list_is_equal (stream->priv->tags, tags)) {
+ gst_mini_object_replace ((GstMiniObject **) & stream->priv->tags,
+ (GstMiniObject *) tags);
+ notify = TRUE;
+ }
GST_OBJECT_UNLOCK (stream);
- g_object_notify_by_pspec (G_OBJECT (stream), gst_stream_pspecs[PROP_TAGS]);
+
+ if (notify)
+ g_object_notify_by_pspec (G_OBJECT (stream), gst_stream_pspecs[PROP_TAGS]);
}
/**
*
* Returns: (transfer full) (nullable): The #GstTagList for @stream
*
+ * Since: 1.10
*/
GstTagList *
gst_stream_get_tags (GstStream * stream)
{
GstTagList *res = NULL;
+ g_return_val_if_fail (GST_IS_STREAM (stream), NULL);
+
GST_OBJECT_LOCK (stream);
if (stream->priv->tags)
res = gst_tag_list_ref (stream->priv->tags);
*
* Set the caps for the #GstStream
*
+ * Since: 1.10
*/
void
gst_stream_set_caps (GstStream * stream, GstCaps * caps)
{
gboolean notify = FALSE;
+ g_return_if_fail (GST_IS_STREAM (stream));
+
GST_OBJECT_LOCK (stream);
if (stream->priv->caps == NULL || (caps
&& !gst_caps_is_equal (stream->priv->caps, caps))) {
*
* Returns: (transfer full) (nullable): The #GstCaps for @stream
*
+ * Since: 1.10
*/
GstCaps *
gst_stream_get_caps (GstStream * stream)
{
GstCaps *res = NULL;
+ g_return_val_if_fail (GST_IS_STREAM (stream), NULL);
+
GST_OBJECT_LOCK (stream);
if (stream->priv->caps)
res = gst_caps_ref (stream->priv->caps);
*
* Get a descriptive string for a given #GstStreamType
*
- * Returns: A string describing the stream type
+ * Returns: (nullable): A string describing the stream type
+ *
+ * Since: 1.10
*/
const gchar *
gst_stream_type_get_name (GstStreamType stype)