API: simplify playbin flags detect function

This commit is contained in:
Rafał Dzięgiel
2021-04-27 12:26:02 +02:00
parent 9b07ff7dc5
commit de65eee106

View File

@@ -1987,6 +1987,16 @@ streams_selected_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg,
g_mutex_unlock (&self->lock); g_mutex_unlock (&self->lock);
} }
static gboolean
clapper_get_has_flag (GstClapper * self, gint pos)
{
gint flags;
g_object_get (self->playbin, "flags", &flags, NULL);
return (flags & pos) == pos;
}
static void static void
clapper_set_flag (GstClapper * self, gint pos) clapper_set_flag (GstClapper * self, gint pos)
{ {
@@ -2285,19 +2295,6 @@ gst_clapper_stream_info_find_from_stream_id (GstClapperMediaInfo * media_info,
return NULL; return NULL;
} }
static gboolean
is_track_enabled (GstClapper * self, gint pos)
{
gint flags;
g_object_get (G_OBJECT (self->playbin), "flags", &flags, NULL);
if ((flags & pos))
return TRUE;
return FALSE;
}
static GstClapperStreamInfo * static GstClapperStreamInfo *
gst_clapper_stream_info_get_current (GstClapper * self, const gchar * prop, gst_clapper_stream_info_get_current (GstClapper * self, const gchar * prop,
GType type) GType type)
@@ -3720,7 +3717,7 @@ gst_clapper_get_current_audio_track (GstClapper * self)
g_return_val_if_fail (GST_IS_CLAPPER (self), NULL); g_return_val_if_fail (GST_IS_CLAPPER (self), NULL);
if (!is_track_enabled (self, GST_PLAY_FLAG_AUDIO)) if (!clapper_get_has_flag (self, GST_PLAY_FLAG_AUDIO))
return NULL; return NULL;
if (self->use_playbin3) { if (self->use_playbin3) {
@@ -3752,7 +3749,7 @@ gst_clapper_get_current_video_track (GstClapper * self)
g_return_val_if_fail (GST_IS_CLAPPER (self), NULL); g_return_val_if_fail (GST_IS_CLAPPER (self), NULL);
if (!is_track_enabled (self, GST_PLAY_FLAG_VIDEO)) if (!clapper_get_has_flag (self, GST_PLAY_FLAG_VIDEO))
return NULL; return NULL;
if (self->use_playbin3) { if (self->use_playbin3) {
@@ -3784,7 +3781,7 @@ gst_clapper_get_current_subtitle_track (GstClapper * self)
g_return_val_if_fail (GST_IS_CLAPPER (self), NULL); g_return_val_if_fail (GST_IS_CLAPPER (self), NULL);
if (!is_track_enabled (self, GST_PLAY_FLAG_SUBTITLE)) if (!clapper_get_has_flag (self, GST_PLAY_FLAG_SUBTITLE))
return NULL; return NULL;
if (self->use_playbin3) { if (self->use_playbin3) {
@@ -4063,7 +4060,7 @@ gst_clapper_get_current_visualization (GstClapper * self)
g_return_val_if_fail (GST_IS_CLAPPER (self), NULL); g_return_val_if_fail (GST_IS_CLAPPER (self), NULL);
if (!is_track_enabled (self, GST_PLAY_FLAG_VIS)) if (!clapper_get_has_flag (self, GST_PLAY_FLAG_VIS))
return NULL; return NULL;
g_object_get (self->playbin, "vis-plugin", &vis_plugin, NULL); g_object_get (self->playbin, "vis-plugin", &vis_plugin, NULL);