mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
playsink: Don't fail if there are subtitles and audio but no video
Change playbin2 to not error out if there are subtitles and audio but no video. If visualizations are enabled the subtitles are rendered on top of the visualization stream, otherwise the subtitles are not linked at all and only the audio is played (and a warning message is posted). If there are only subtitles but neither audio nor video an error message is still posted. Fixes bug #610866.
This commit is contained in:
parent
5d0957525a
commit
71ca26fc7f
1 changed files with 79 additions and 61 deletions
|
@ -1829,20 +1829,16 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
|
||||||
|
|
||||||
/* figure out which components we need */
|
/* figure out which components we need */
|
||||||
if (flags & GST_PLAY_FLAG_TEXT && playsink->text_pad) {
|
if (flags & GST_PLAY_FLAG_TEXT && playsink->text_pad) {
|
||||||
/* we have a text_pad and we need text rendering, in this case we need a
|
/* we have subtitles and we are requested to show it */
|
||||||
* video_pad to combine the video with the text */
|
|
||||||
if (!playsink->video_pad)
|
|
||||||
goto subs_but_no_video;
|
|
||||||
|
|
||||||
/* we have subtitles and we are requested to show it, we also need to show
|
|
||||||
* video in this case. */
|
|
||||||
need_video = TRUE;
|
|
||||||
need_text = TRUE;
|
need_text = TRUE;
|
||||||
} else if (((flags & GST_PLAY_FLAG_VIDEO)
|
}
|
||||||
|
|
||||||
|
if (((flags & GST_PLAY_FLAG_VIDEO)
|
||||||
|| (flags & GST_PLAY_FLAG_NATIVE_VIDEO)) && playsink->video_pad) {
|
|| (flags & GST_PLAY_FLAG_NATIVE_VIDEO)) && playsink->video_pad) {
|
||||||
/* we have video and we are requested to show it */
|
/* we have video and we are requested to show it */
|
||||||
need_video = TRUE;
|
need_video = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playsink->audio_pad) {
|
if (playsink->audio_pad) {
|
||||||
if ((flags & GST_PLAY_FLAG_AUDIO) || (flags & GST_PLAY_FLAG_NATIVE_AUDIO)) {
|
if ((flags & GST_PLAY_FLAG_AUDIO) || (flags & GST_PLAY_FLAG_NATIVE_AUDIO)) {
|
||||||
need_audio = TRUE;
|
need_audio = TRUE;
|
||||||
|
@ -1856,6 +1852,26 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* we have a text_pad and we need text rendering, in this case we need a
|
||||||
|
* video_pad to combine the video with the text or visualizations */
|
||||||
|
if (need_text && !need_video) {
|
||||||
|
if (playsink->video_pad) {
|
||||||
|
need_video = TRUE;
|
||||||
|
} else if (!need_audio) {
|
||||||
|
GST_ELEMENT_WARNING (playsink, STREAM, FORMAT,
|
||||||
|
(_("Can't play a text file without video or visualizations.")),
|
||||||
|
("Have text pad but no video pad or visualizations"));
|
||||||
|
need_text = FALSE;
|
||||||
|
} else {
|
||||||
|
GST_ELEMENT_ERROR (playsink, STREAM, FORMAT,
|
||||||
|
(_("Can't play a text file without video or visualizations.")),
|
||||||
|
("Have text pad but no video pad or visualizations"));
|
||||||
|
GST_PLAY_SINK_LOCK (playsink);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (playsink, "audio:%d, video:%d, vis:%d, text:%d", need_audio,
|
GST_DEBUG_OBJECT (playsink, "audio:%d, video:%d, vis:%d, text:%d", need_audio,
|
||||||
need_video, need_vis, need_text);
|
need_video, need_vis, need_text);
|
||||||
|
|
||||||
|
@ -1927,48 +1943,6 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
|
||||||
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL);
|
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_text) {
|
|
||||||
GST_DEBUG_OBJECT (playsink, "adding text");
|
|
||||||
if (!playsink->textchain) {
|
|
||||||
GST_DEBUG_OBJECT (playsink, "creating text chain");
|
|
||||||
playsink->textchain = gen_text_chain (playsink);
|
|
||||||
}
|
|
||||||
if (playsink->textchain) {
|
|
||||||
GST_DEBUG_OBJECT (playsink, "adding text chain");
|
|
||||||
if (playsink->textchain->overlay != NULL)
|
|
||||||
g_object_set (playsink->textchain->overlay, "silent", FALSE, NULL);
|
|
||||||
add_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
|
|
||||||
|
|
||||||
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->text_pad),
|
|
||||||
playsink->textchain->textsinkpad);
|
|
||||||
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad),
|
|
||||||
playsink->textchain->videosinkpad);
|
|
||||||
gst_pad_link (playsink->textchain->srcpad, playsink->videochain->sinkpad);
|
|
||||||
|
|
||||||
activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (playsink, "no text needed");
|
|
||||||
/* we have no subtitles/text or we are requested to not show them */
|
|
||||||
if (playsink->textchain) {
|
|
||||||
if (playsink->text_pad == NULL) {
|
|
||||||
/* no text pad, remove the chain entirely */
|
|
||||||
GST_DEBUG_OBJECT (playsink, "removing text chain");
|
|
||||||
add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
|
|
||||||
activate_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
|
|
||||||
} else {
|
|
||||||
/* we have a chain and a textpad, turn the subtitles off */
|
|
||||||
GST_DEBUG_OBJECT (playsink, "turning off the text");
|
|
||||||
g_object_set (G_OBJECT (playsink->textchain->overlay), "silent", TRUE,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!need_video && playsink->video_pad)
|
|
||||||
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL);
|
|
||||||
if (playsink->text_pad && !playsink->textchain)
|
|
||||||
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->text_pad), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (need_audio) {
|
if (need_audio) {
|
||||||
gboolean raw, queue;
|
gboolean raw, queue;
|
||||||
|
|
||||||
|
@ -2080,20 +2054,64 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
|
||||||
activate_chain (GST_PLAY_CHAIN (playsink->vischain), FALSE);
|
activate_chain (GST_PLAY_CHAIN (playsink->vischain), FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (need_text) {
|
||||||
|
GST_DEBUG_OBJECT (playsink, "adding text");
|
||||||
|
if (!playsink->textchain) {
|
||||||
|
GST_DEBUG_OBJECT (playsink, "creating text chain");
|
||||||
|
playsink->textchain = gen_text_chain (playsink);
|
||||||
|
}
|
||||||
|
if (playsink->textchain) {
|
||||||
|
GST_DEBUG_OBJECT (playsink, "adding text chain");
|
||||||
|
if (playsink->textchain->overlay)
|
||||||
|
g_object_set (G_OBJECT (playsink->textchain->overlay), "silent", FALSE, NULL);
|
||||||
|
add_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
|
||||||
|
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->text_pad),
|
||||||
|
playsink->textchain->textsinkpad);
|
||||||
|
|
||||||
|
if (need_vis) {
|
||||||
|
GstPad *srcpad;
|
||||||
|
|
||||||
|
srcpad =
|
||||||
|
gst_element_get_static_pad (playsink->vischain->chain.bin, "src");
|
||||||
|
gst_pad_unlink (srcpad, playsink->videochain->sinkpad);
|
||||||
|
gst_pad_link (srcpad, playsink->textchain->videosinkpad);
|
||||||
|
gst_object_unref (srcpad);
|
||||||
|
} else {
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad),
|
||||||
|
playsink->textchain->videosinkpad);
|
||||||
|
}
|
||||||
|
gst_pad_link (playsink->textchain->srcpad, playsink->videochain->sinkpad);
|
||||||
|
|
||||||
|
activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (playsink, "no text needed");
|
||||||
|
/* we have no subtitles/text or we are requested to not show them */
|
||||||
|
if (playsink->textchain) {
|
||||||
|
if (playsink->text_pad == NULL) {
|
||||||
|
/* no text pad, remove the chain entirely */
|
||||||
|
GST_DEBUG_OBJECT (playsink, "removing text chain");
|
||||||
|
add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
|
||||||
|
activate_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
|
||||||
|
} else {
|
||||||
|
/* we have a chain and a textpad, turn the subtitles off */
|
||||||
|
GST_DEBUG_OBJECT (playsink, "turning off the text");
|
||||||
|
g_object_set (G_OBJECT (playsink->textchain->overlay), "silent", TRUE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!need_video && playsink->video_pad)
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL);
|
||||||
|
if (playsink->text_pad && !playsink->textchain)
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->text_pad), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
do_async_done (playsink);
|
do_async_done (playsink);
|
||||||
GST_PLAY_SINK_UNLOCK (playsink);
|
GST_PLAY_SINK_UNLOCK (playsink);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
subs_but_no_video:
|
|
||||||
{
|
|
||||||
GST_ELEMENT_ERROR (playsink, STREAM, FORMAT,
|
|
||||||
(_("Can't play a text file without video.")),
|
|
||||||
("Have text pad but no video pad"));
|
|
||||||
GST_PLAY_SINK_UNLOCK (playsink);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue