Commit d099dbde authored by Guido Gunther's avatar Guido Gunther
Browse files

Indicate wheter we're using v4l stateless codec

Add an indicator when we think things are fast. This works for most
mobile devices running mobile Linux.
parent bfc408c0
......@@ -32,6 +32,7 @@ struct _LiviWindow
GtkRevealer *revealer_info;
GtkLabel *lbl_title;
GtkLabel *lbl_status;
GtkImage *img_accel;
GtkRevealer *revealer_controls;
GtkButton *btn_play;
......@@ -157,6 +158,41 @@ on_player_buffering (GstPlayer *player, gint percent, gpointer user_data)
}
static void
check_pipeline (LiviWindow *self, GstPlayer *player)
{
g_autoptr (GstElement) bin = gst_player_get_pipeline (player);
g_autoptr (GstIterator) iter = gst_bin_iterate_recurse (GST_BIN (bin));
GtkStyleContext *context;
GValue item = { 0, };
gboolean found = FALSE;
const char *icons[] = { "speedometer2-symbolic",
"speedometer4-symbolic" };
const char *style_class[] = { "no-accel",
"accel" };
while (iter && gst_iterator_next (iter, &item) == GST_ITERATOR_OK) {
GstElement *elem = g_value_get_object (&item);
if (g_str_has_prefix (GST_OBJECT_NAME (elem), "v4l2slh264dec")) {
found = TRUE;
g_value_unset (&item);
break;
}
g_value_unset (&item);
}
if (!found)
g_warning ("V4L stateless codec not in use, playback will likely be slow");
g_object_set (self->img_accel, "icon-name", icons[found], NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (self->img_accel));
gtk_style_context_add_class (context, style_class[found]);
gtk_style_context_remove_class (context, style_class[!found]);
}
static void
on_player_state_changed (GstPlayer *player, GstPlayerState state, gpointer user_data)
{
......@@ -176,6 +212,7 @@ on_player_state_changed (GstPlayer *player, GstPlayerState state, gpointer user_
GTK_WINDOW (self),
GTK_APPLICATION_INHIBIT_SUSPEND | GTK_APPLICATION_INHIBIT_IDLE,
"Playing video");
check_pipeline (self, player);
} else {
icon = "media-playback-start-symbolic";
if (self->cookie) {
......@@ -319,6 +356,7 @@ livi_window_class_init (LiviWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, LiviWindow, btn_mute);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, btn_play);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, img_fullscreen);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, img_accel);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, img_play);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, img_mute);
gtk_widget_class_bind_template_child (widget_class, LiviWindow, lbl_status);
......
......@@ -47,6 +47,12 @@
<property name="ellipsize">middle</property>
</object>
</child>
<child>
<object class="GtkImage" id="img_accel">
<property name="icon-name"></property>
<property name="pixel-size">16</property>
</object>
</child>
<style>
<class name="livi-info"/>
</style>
......
......@@ -4,5 +4,7 @@
<file>livi-window.ui</file>
<file>style.css</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/actions/view-unfullscreen-symbolic.svg">../data/icons/view-restore-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/status/speedometer2-symbolic.svg">../data/icons/speedometer2-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/status/speedometer4-symbolic.svg">../data/icons/speedometer4-symbolic.svg</file>
</gresource>
</gresources>
......@@ -24,3 +24,15 @@
margin: 6px;
border-radius: 4px;
}
.livi-info image {
margin: 6px;
}
.livi-info image.no-accel {
color: red;
}
.livi-info image.accel {
color: green;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment