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.
This commit is contained in:
Ronald S. Bultje 2004-10-29 15:27:10 +00:00
parent b463251864
commit 2070a88585
4 changed files with 52 additions and 19 deletions

View file

@ -1,3 +1,15 @@
2004-10-29 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* 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 <rbultje@ronald.bitfreak.net>
* gst/audioconvert/gstaudioconvert.c:

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -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