playback: GstStreamType is a flag

Therefor don't use equality
This commit is contained in:
Edward Hervey 2016-10-13 11:42:28 +02:00 committed by Edward Hervey
parent acc3a9d242
commit 8485a8d786
2 changed files with 62 additions and 92 deletions

View File

@ -1796,7 +1796,7 @@ reconfigure_output_stream (DecodebinOutputStream * output,
can_reuse_decoder = FALSE; can_reuse_decoder = FALSE;
if (can_reuse_decoder) { if (can_reuse_decoder) {
if (output->type == GST_STREAM_TYPE_VIDEO && output->drop_probe_id == 0) { if (output->type & GST_STREAM_TYPE_VIDEO && output->drop_probe_id == 0) {
GST_DEBUG_OBJECT (dbin, "Adding keyframe-waiter probe"); GST_DEBUG_OBJECT (dbin, "Adding keyframe-waiter probe");
output->drop_probe_id = output->drop_probe_id =
gst_pad_add_probe (slot->src_pad, GST_PAD_PROBE_TYPE_BUFFER, gst_pad_add_probe (slot->src_pad, GST_PAD_PROBE_TYPE_BUFFER,
@ -1863,7 +1863,7 @@ reconfigure_output_stream (DecodebinOutputStream * output,
} }
output->decoder_sink = gst_element_get_static_pad (output->decoder, "sink"); output->decoder_sink = gst_element_get_static_pad (output->decoder, "sink");
output->decoder_src = gst_element_get_static_pad (output->decoder, "src"); output->decoder_src = gst_element_get_static_pad (output->decoder, "src");
if (output->type == GST_STREAM_TYPE_VIDEO) { if (output->type & GST_STREAM_TYPE_VIDEO) {
GST_DEBUG_OBJECT (dbin, "Adding keyframe-waiter probe"); GST_DEBUG_OBJECT (dbin, "Adding keyframe-waiter probe");
output->drop_probe_id = output->drop_probe_id =
gst_pad_add_probe (slot->src_pad, GST_PAD_PROBE_TYPE_BUFFER, gst_pad_add_probe (slot->src_pad, GST_PAD_PROBE_TYPE_BUFFER,
@ -2395,27 +2395,22 @@ create_output_stream (GstDecodebin3 * dbin, GstStreamType type)
res->type = type; res->type = type;
res->dbin = dbin; res->dbin = dbin;
switch (type) { if (type & GST_STREAM_TYPE_VIDEO) {
case GST_STREAM_TYPE_VIDEO:
templ = &video_src_template; templ = &video_src_template;
counter = &dbin->vpadcount; counter = &dbin->vpadcount;
prefix = "video"; prefix = "video";
break; } else if (type & GST_STREAM_TYPE_AUDIO) {
case GST_STREAM_TYPE_AUDIO:
templ = &audio_src_template; templ = &audio_src_template;
counter = &dbin->apadcount; counter = &dbin->apadcount;
prefix = "audio"; prefix = "audio";
break; } else if (type & GST_STREAM_TYPE_TEXT) {
case GST_STREAM_TYPE_TEXT:
templ = &text_src_template; templ = &text_src_template;
counter = &dbin->tpadcount; counter = &dbin->tpadcount;
prefix = "text"; prefix = "text";
break; } else {
default:
templ = &src_template; templ = &src_template;
counter = &dbin->opadcount; counter = &dbin->opadcount;
prefix = "src"; prefix = "src";
break;
} }
pad_name = g_strdup_printf ("%s_%u", prefix, *counter); pad_name = g_strdup_printf ("%s_%u", prefix, *counter);

View File

@ -1167,21 +1167,15 @@ update_combiner_info (GstPlayBin3 * playbin)
gst_stream_collection_get_stream (playbin->collection, i); gst_stream_collection_get_stream (playbin->collection, i);
GstStreamType stype = gst_stream_get_stream_type (stream); GstStreamType stype = gst_stream_get_stream_type (stream);
switch (stype) { if (stype & GST_STREAM_TYPE_AUDIO) {
case GST_STREAM_TYPE_AUDIO:
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_AUDIO].streams, g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_AUDIO].streams,
gst_object_ref (stream)); gst_object_ref (stream));
break; } else if (stype & GST_STREAM_TYPE_VIDEO) {
case GST_STREAM_TYPE_VIDEO:
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_VIDEO].streams, g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_VIDEO].streams,
gst_object_ref (stream)); gst_object_ref (stream));
break; } else if (stype & GST_STREAM_TYPE_TEXT) {
case GST_STREAM_TYPE_TEXT:
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_TEXT].streams, g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_TEXT].streams,
gst_object_ref (stream)); gst_object_ref (stream));
break;
default:
break;
} }
} }
@ -1198,20 +1192,14 @@ static void
set_selected_stream (GstPlayBin3 * playbin, GstStream * stream) set_selected_stream (GstPlayBin3 * playbin, GstStream * stream)
{ {
GstSourceCombine *combine = NULL; GstSourceCombine *combine = NULL;
GstStreamType stype = gst_stream_get_stream_type (stream);
switch (gst_stream_get_stream_type (stream)) { if (stype & GST_STREAM_TYPE_AUDIO)
case GST_STREAM_TYPE_AUDIO:
combine = &playbin->combiner[PLAYBIN_STREAM_AUDIO]; combine = &playbin->combiner[PLAYBIN_STREAM_AUDIO];
break; else if (stype & GST_STREAM_TYPE_VIDEO)
case GST_STREAM_TYPE_VIDEO:
combine = &playbin->combiner[PLAYBIN_STREAM_VIDEO]; combine = &playbin->combiner[PLAYBIN_STREAM_VIDEO];
break; else if (stype & GST_STREAM_TYPE_TEXT)
case GST_STREAM_TYPE_TEXT:
combine = &playbin->combiner[PLAYBIN_STREAM_TEXT]; combine = &playbin->combiner[PLAYBIN_STREAM_TEXT];
break;
default:
break;
}
if (combine) { if (combine) {
if (combine->combiner == NULL) { if (combine->combiner == NULL) {
@ -2460,8 +2448,7 @@ do_stream_selection (GstPlayBin3 * playbin)
gint pb_stream_type = -1; gint pb_stream_type = -1;
gboolean select_this = FALSE; gboolean select_this = FALSE;
switch (stream_type) { if (stream_type & GST_STREAM_TYPE_AUDIO) {
case GST_STREAM_TYPE_AUDIO:
pb_stream_type = PLAYBIN_STREAM_AUDIO; pb_stream_type = PLAYBIN_STREAM_AUDIO;
/* Select the stream if it's the current one or if there's a custom selector */ /* Select the stream if it's the current one or if there's a custom selector */
select_this = select_this =
@ -2469,25 +2456,20 @@ do_stream_selection (GstPlayBin3 * playbin)
(playbin->current_audio == -1 && nb_audio == 0) || (playbin->current_audio == -1 && nb_audio == 0) ||
playbin->audio_stream_combiner != NULL); playbin->audio_stream_combiner != NULL);
nb_audio++; nb_audio++;
break; } else if (stream_type & GST_STREAM_TYPE_VIDEO) {
case GST_STREAM_TYPE_VIDEO:
pb_stream_type = PLAYBIN_STREAM_AUDIO; pb_stream_type = PLAYBIN_STREAM_AUDIO;
select_this = select_this =
(nb_video == playbin->current_video || (nb_video == playbin->current_video ||
(playbin->current_video == -1 && nb_video == 0) || (playbin->current_video == -1 && nb_video == 0) ||
playbin->video_stream_combiner != NULL); playbin->video_stream_combiner != NULL);
nb_video++; nb_video++;
break; } else if (stream_type & GST_STREAM_TYPE_TEXT) {
case GST_STREAM_TYPE_TEXT:
pb_stream_type = PLAYBIN_STREAM_TEXT; pb_stream_type = PLAYBIN_STREAM_TEXT;
select_this = select_this =
(nb_text == playbin->current_text || (nb_text == playbin->current_text ||
(playbin->current_text == -1 && nb_text == 0) || (playbin->current_text == -1 && nb_text == 0) ||
playbin->text_stream_combiner != NULL); playbin->text_stream_combiner != NULL);
nb_text++; nb_text++;
break;
default:
break;
} }
if (pb_stream_type < 0) { if (pb_stream_type < 0) {
GST_DEBUG_OBJECT (playbin, GST_DEBUG_OBJECT (playbin,
@ -3070,19 +3052,12 @@ select_stream_cb (GstElement * decodebin, GstStreamCollection * collection,
GstStreamType stype = gst_stream_get_stream_type (stream); GstStreamType stype = gst_stream_get_stream_type (stream);
GstElement *combiner = NULL; GstElement *combiner = NULL;
switch (stype) { if (stype & GST_STREAM_TYPE_AUDIO)
case GST_STREAM_TYPE_AUDIO:
combiner = playbin->audio_stream_combiner; combiner = playbin->audio_stream_combiner;
break; else if (stype & GST_STREAM_TYPE_VIDEO)
case GST_STREAM_TYPE_VIDEO:
combiner = playbin->video_stream_combiner; combiner = playbin->video_stream_combiner;
break; else if (stype & GST_STREAM_TYPE_TEXT)
case GST_STREAM_TYPE_TEXT:
combiner = playbin->text_stream_combiner; combiner = playbin->text_stream_combiner;
break;
default:
break;
}
if (combiner) { if (combiner) {
GST_DEBUG_OBJECT (playbin, "Got a combiner, requesting stream activation"); GST_DEBUG_OBJECT (playbin, "Got a combiner, requesting stream activation");