gst/mpegstream/: Check for error codes from the negotiation functions. Make sure we really set the pad caps when a ne...

Original commit message from CVS:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_process_private):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_send_data):
Check for error codes from the negotiation functions. Make sure
we really set the pad caps when a new pad is created.
This commit is contained in:
Wim Taymans 2004-07-26 15:17:25 +00:00
parent 7f5110c404
commit 48858d6543
3 changed files with 40 additions and 16 deletions

View file

@ -1,3 +1,12 @@
2004-07-26 Wim Taymans <wim@fluendo.com>
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_process_private):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_send_data):
Check for error codes from the negotiation functions. Make sure
we really set the pad caps when a new pad is created.
2004-07-26 Thomas Vander Stichele <thomas at apestaart dot org> 2004-07-26 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/ffmpegcolorspace/gstffmpegcodecmap.c: * gst/ffmpegcolorspace/gstffmpegcodecmap.c:

View file

@ -370,6 +370,7 @@ gst_mpeg_demux_get_video_stream (GstMPEGDemux * mpeg_demux,
GstMPEGVideoStream *video_str; GstMPEGVideoStream *video_str;
gchar *name; gchar *name;
GstCaps *caps; GstCaps *caps;
gboolean set_caps = FALSE;
g_return_val_if_fail (stream_nr < GST_MPEG_DEMUX_NUM_VIDEO_STREAMS, NULL); g_return_val_if_fail (stream_nr < GST_MPEG_DEMUX_NUM_VIDEO_STREAMS, NULL);
g_return_val_if_fail (type > GST_MPEG_DEMUX_VIDEO_UNKNOWN && g_return_val_if_fail (type > GST_MPEG_DEMUX_VIDEO_UNKNOWN &&
@ -380,7 +381,6 @@ gst_mpeg_demux_get_video_stream (GstMPEGDemux * mpeg_demux,
if (str == NULL) { if (str == NULL) {
video_str = g_new0 (GstMPEGVideoStream, 1); video_str = g_new0 (GstMPEGVideoStream, 1);
str = (GstMPEGStream *) video_str; str = (GstMPEGStream *) video_str;
str->type = GST_MPEG_DEMUX_VIDEO_UNKNOWN;
name = g_strdup_printf ("video_%02d", stream_nr); name = g_strdup_printf ("video_%02d", stream_nr);
CLASS (mpeg_demux)->init_stream (mpeg_demux, type, str, stream_nr, name, CLASS (mpeg_demux)->init_stream (mpeg_demux, type, str, stream_nr, name,
@ -388,6 +388,8 @@ gst_mpeg_demux_get_video_stream (GstMPEGDemux * mpeg_demux,
g_free (name); g_free (name);
mpeg_demux->video_stream[stream_nr] = str; mpeg_demux->video_stream[stream_nr] = str;
set_caps = TRUE;
} else { } else {
/* This stream may have been created by a derived class, reset the /* This stream may have been created by a derived class, reset the
size. */ size. */
@ -395,16 +397,18 @@ gst_mpeg_demux_get_video_stream (GstMPEGDemux * mpeg_demux,
mpeg_demux->video_stream[stream_nr] = str = (GstMPEGStream *) video_str; mpeg_demux->video_stream[stream_nr] = str = (GstMPEGStream *) video_str;
} }
if (str->type != GST_MPEG_DEMUX_VIDEO_MPEG || if (set_caps || video_str->mpeg_version != mpeg_version) {
video_str->mpeg_version != mpeg_version) {
/* We need to set new caps for this pad. */ /* We need to set new caps for this pad. */
caps = gst_caps_new_simple ("video/mpeg", caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, mpeg_version, "mpegversion", G_TYPE_INT, mpeg_version,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL); "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
gst_pad_set_explicit_caps (str->pad, caps); if (!gst_pad_set_explicit_caps (str->pad, caps)) {
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_demux),
CORE, NEGOTIATION, (NULL), ("failed to set caps"));
return str;
}
/* Store the current values. */ /* Store the current values. */
str->type = GST_MPEG_DEMUX_VIDEO_MPEG;
video_str->mpeg_version = mpeg_version; video_str->mpeg_version = mpeg_version;
} }
@ -418,6 +422,7 @@ gst_mpeg_demux_get_audio_stream (GstMPEGDemux * mpeg_demux,
GstMPEGStream *str; GstMPEGStream *str;
gchar *name; gchar *name;
GstCaps *caps; GstCaps *caps;
gboolean set_caps = FALSE;
g_return_val_if_fail (stream_nr < GST_MPEG_DEMUX_NUM_AUDIO_STREAMS, NULL); g_return_val_if_fail (stream_nr < GST_MPEG_DEMUX_NUM_AUDIO_STREAMS, NULL);
g_return_val_if_fail (type > GST_MPEG_DEMUX_AUDIO_UNKNOWN && g_return_val_if_fail (type > GST_MPEG_DEMUX_AUDIO_UNKNOWN &&
@ -427,7 +432,6 @@ gst_mpeg_demux_get_audio_stream (GstMPEGDemux * mpeg_demux,
if (str == NULL) { if (str == NULL) {
str = g_new0 (GstMPEGStream, 1); str = g_new0 (GstMPEGStream, 1);
str->type = GST_MPEG_DEMUX_AUDIO_MPEG;
name = g_strdup_printf ("audio_%02d", stream_nr); name = g_strdup_printf ("audio_%02d", stream_nr);
CLASS (mpeg_demux)->init_stream (mpeg_demux, type, str, stream_nr, name, CLASS (mpeg_demux)->init_stream (mpeg_demux, type, str, stream_nr, name,
@ -435,19 +439,24 @@ gst_mpeg_demux_get_audio_stream (GstMPEGDemux * mpeg_demux,
g_free (name); g_free (name);
mpeg_demux->audio_stream[stream_nr] = str; mpeg_demux->audio_stream[stream_nr] = str;
/* new pad, set caps */
set_caps = TRUE;
} else { } else {
/* This stream may have been created by a derived class, reset the /* This stream may have been created by a derived class, reset the
size. */ size. */
str = g_renew (GstMPEGStream, str, 1); str = g_renew (GstMPEGStream, str, 1);
} }
if (str->type != GST_MPEG_DEMUX_AUDIO_MPEG) { if (set_caps) {
/* We need to set new caps for this pad. */ /* We need to set new caps for this pad. */
caps = gst_caps_new_simple ("audio/mpeg", caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1, NULL); "mpegversion", G_TYPE_INT, 1, NULL);
gst_pad_set_explicit_caps (str->pad, caps); if (!gst_pad_set_explicit_caps (str->pad, caps)) {
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_demux),
str->type = GST_MPEG_DEMUX_AUDIO_MPEG; CORE, NEGOTIATION, (NULL), ("failed to set caps"));
return str;
}
} }
return str; return str;

View file

@ -306,14 +306,20 @@ gst_mpeg_parse_send_data (GstMPEGParse * mpeg_parse, GstData * data,
break; break;
} }
} else { } else {
if (!GST_PAD_CAPS (mpeg_parse->srcpad)) { if (!gst_pad_is_negotiated (mpeg_parse->srcpad)) {
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize); gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
GstCaps *caps;
gst_pad_set_explicit_caps (mpeg_parse->srcpad, caps = gst_caps_new_simple ("video/mpeg",
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1), "mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE, "systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)); "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
if (!gst_pad_set_explicit_caps (mpeg_parse->srcpad, caps)) {
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_parse),
CORE, NEGOTIATION, (NULL), ("failed to set caps"));
return;
}
} }
GST_BUFFER_TIMESTAMP (data) = time; GST_BUFFER_TIMESTAMP (data) = time;