From 2070a885859c3621928a001ba23b80f14f0624ea Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Fri, 29 Oct 2004 15:27:10 +0000 Subject: [PATCH] gst/playback/: Make caps explicitely available. Makes testing for unsupported types possible. Improves error reporting. Original commit message from CVS: * gst/playback/gstplaybasebin.c: (unknown_type), (add_element_stream), (new_decoded_pad), (gst_play_base_bin_change_state): * gst/playback/gststreaminfo.c: (gst_stream_info_class_init), (gst_stream_info_init), (gst_stream_info_new), (gst_stream_info_dispose), (gst_stream_info_get_property): * gst/playback/gststreaminfo.h: Make caps explicitely available. Makes testing for unsupported types possible. Improves error reporting. --- ChangeLog | 12 ++++++++++++ gst/playback/gstplaybasebin.c | 31 +++++++++++++++---------------- gst/playback/gststreaminfo.c | 22 ++++++++++++++++++++-- gst/playback/gststreaminfo.h | 6 +++++- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1745591141..7144bb9be6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-10-29 Ronald S. Bultje + + * gst/playback/gstplaybasebin.c: (unknown_type), + (add_element_stream), (new_decoded_pad), + (gst_play_base_bin_change_state): + * gst/playback/gststreaminfo.c: (gst_stream_info_class_init), + (gst_stream_info_init), (gst_stream_info_new), + (gst_stream_info_dispose), (gst_stream_info_get_property): + * gst/playback/gststreaminfo.h: + Make caps explicitely available. Makes testing for unsupported + types possible. Improves error reporting. + 2004-10-29 Ronald S. Bultje * gst/audioconvert/gstaudioconvert.c: diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index 35239fe1af..92ef040e92 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -280,7 +280,8 @@ unknown_type (GstElement * element, GstPad * pad, GstCaps * caps, g_warning ("don't know how to handle %s", capsstr); /* add the stream to the list */ - info = gst_stream_info_new (GST_OBJECT (pad), GST_STREAM_TYPE_UNKNOWN, NULL); + info = gst_stream_info_new (GST_OBJECT (pad), GST_STREAM_TYPE_UNKNOWN, + NULL, caps); play_base_bin->streaminfo = g_list_append (play_base_bin->streaminfo, info); g_free (capsstr); @@ -298,7 +299,8 @@ add_element_stream (GstElement * element, GstPlayBaseBin * play_base_bin) /* add the stream to the list */ info = - gst_stream_info_new (GST_OBJECT (element), GST_STREAM_TYPE_ELEMENT, NULL); + gst_stream_info_new (GST_OBJECT (element), GST_STREAM_TYPE_ELEMENT, + NULL, NULL); play_base_bin->streaminfo = g_list_append (play_base_bin->streaminfo, info); } @@ -390,7 +392,7 @@ new_decoded_pad (GstElement * element, GstPad * pad, gboolean last, } /* add the stream to the list */ - info = gst_stream_info_new (GST_OBJECT (srcpad), type, NULL); + info = gst_stream_info_new (GST_OBJECT (srcpad), type, NULL, caps); play_base_bin->streaminfo = g_list_append (play_base_bin->streaminfo, info); /* signal the no more pads after adding the stream */ @@ -756,20 +758,17 @@ gst_play_base_bin_change_state (GstElement * element) /* We're no audio/video and the only stream... We could * be something not-media that's detected because then our * typefind doesn't mess up with mp3 (bz2, gz, elf, ...) */ - if (GST_IS_PAD (info->object)) { - const GstCaps *caps = GST_PAD_CAPS (GST_PAD (info->object)); + if (info->caps) { + const gchar *mime = + gst_structure_get_name (gst_caps_get_structure (info->caps, + 0)); - if (caps) { - const gchar *mime = - gst_structure_get_name (gst_caps_get_structure (caps, 0)); - - if (!strcmp (mime, "application/x-executable") || - !strcmp (mime, "application/x-bzip") || - !strcmp (mime, "application/x-gzip") || - !strcmp (mime, "application/zip") || - !strcmp (mime, "application/x-compress")) { - no_media = TRUE; - } + if (!strcmp (mime, "application/x-executable") || + !strcmp (mime, "application/x-bzip") || + !strcmp (mime, "application/x-gzip") || + !strcmp (mime, "application/zip") || + !strcmp (mime, "application/x-compress")) { + no_media = TRUE; } } } diff --git a/gst/playback/gststreaminfo.c b/gst/playback/gststreaminfo.c index e1fd17247c..978e225a6b 100644 --- a/gst/playback/gststreaminfo.c +++ b/gst/playback/gststreaminfo.c @@ -33,6 +33,7 @@ enum ARG_TYPE, ARG_DECODER, ARG_MUTE, + ARG_CAPS }; /* signals */ @@ -55,7 +56,7 @@ gst_stream_type_get_type (void) {GST_STREAM_TYPE_VIDEO, "GST_STREAM_TYPE_VIDEO", "Video stream"}, {GST_STREAM_TYPE_TEXT, "GST_STREAM_TYPE_TEXT", "Text stream"}, {GST_STREAM_TYPE_ELEMENT, "GST_STREAM_TYPE_ELEMENT", - "Stream handled by element"}, + "Stream handled by element"}, {0, NULL, NULL}, }; @@ -128,6 +129,10 @@ gst_stream_info_class_init (GstStreamInfoClass * klass) g_object_class_install_property (gobject_klass, ARG_MUTE, g_param_spec_boolean ("mute", "Mute", "Mute or unmute this stream", FALSE, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_klass, ARG_CAPS, + g_param_spec_boxed ("caps", "Capabilities", + "Capabilities (or type) of this stream", GST_TYPE_CAPS, + G_PARAM_READABLE)); gst_stream_info_signals[SIGNAL_MUTED] = g_signal_new ("muted", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -145,10 +150,12 @@ gst_stream_info_init (GstStreamInfo * stream_info) stream_info->type = GST_STREAM_TYPE_UNKNOWN; stream_info->decoder = NULL; stream_info->mute = FALSE; + stream_info->caps = NULL; } GstStreamInfo * -gst_stream_info_new (GstObject * object, GstStreamType type, gchar * decoder) +gst_stream_info_new (GstObject * object, + GstStreamType type, const gchar * decoder, const GstCaps * caps) { GstStreamInfo *info; @@ -158,6 +165,9 @@ gst_stream_info_new (GstObject * object, GstStreamType type, gchar * decoder) info->object = object; info->type = type; info->decoder = g_strdup (decoder); + if (caps) { + info->caps = gst_caps_copy (caps); + } return info; } @@ -173,6 +183,11 @@ gst_stream_info_dispose (GObject * object) stream_info->object = NULL; stream_info->type = GST_STREAM_TYPE_UNKNOWN; g_free (stream_info->decoder); + stream_info->decoder = NULL; + if (stream_info->caps) { + gst_caps_free (stream_info->caps); + stream_info->caps = NULL; + } if (G_OBJECT_CLASS (parent_class)->dispose) { G_OBJECT_CLASS (parent_class)->dispose (object); @@ -268,6 +283,9 @@ gst_stream_info_get_property (GObject * object, guint prop_id, GValue * value, case ARG_MUTE: g_value_set_boolean (value, stream_info->mute); break; + case ARG_CAPS: + g_value_set_boxed (value, stream_info->caps); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gst/playback/gststreaminfo.h b/gst/playback/gststreaminfo.h index e1504b1eb8..41f09a125e 100644 --- a/gst/playback/gststreaminfo.h +++ b/gst/playback/gststreaminfo.h @@ -49,6 +49,7 @@ struct _GstStreamInfo { GstStreamType type; gchar *decoder; gboolean mute; + GstCaps *caps; }; struct _GstStreamInfoClass { @@ -60,7 +61,10 @@ struct _GstStreamInfoClass { GType gst_stream_info_get_type (void); -GstStreamInfo* gst_stream_info_new (GstObject *object, GstStreamType type, gchar *decoder); +GstStreamInfo* gst_stream_info_new (GstObject *object, + GstStreamType type, + const gchar *decoder, + const GstCaps *caps); G_END_DECLS