Commit b4cfc787 authored by Paolo Bacchilega's avatar Paolo Bacchilega

video viewer: added option to use opengl instead of cairo

parent 7d0cad26
......@@ -25,6 +25,9 @@
<key name="volume" type="i">
<default>100</default>
</key>
<key name="use-hardware-acceleration" type="b">
<default>false</default>
</key>
</schema>
</schemalist>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkBox" id="dialog_content">
......@@ -7,33 +7,59 @@
<property name="can_focus">False</property>
<property name="border_width">15</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel" id="label1">
<object class="GtkCheckButton" id="use_hardware_acceleration_checkbutton">
<property name="label" translatable="yes">Use hardware acceleration</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Screenshots location:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">screenshots_filechooserbutton</property>
<property name="xalign">0</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="screenshots_filechooserbutton">
<property name="width_request">300</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action">select-folder</property>
<property name="local_only">False</property>
<property name="title" translatable="yes"/>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Screenshots location:</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="screenshots_filechooserbutton">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action">select-folder</property>
<property name="local_only">False</property>
<property name="title" translatable="yes"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
......
......@@ -39,14 +39,12 @@ update_settings (DialogData *data)
char *uri;
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (gtk_builder_get_object (data->builder, "screenshots_filechooserbutton")));
if (uri == NULL)
return;
if (uri != NULL) {
_g_settings_set_uri (data->settings, PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION, uri);
g_free (uri);
}
_g_settings_set_uri (data->settings,
PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION,
uri);
g_free (uri);
g_settings_set_boolean (data->settings, PREF_GSTREAMER_USE_HARDWARE_ACCEL, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, "use_hardware_acceleration_checkbutton"))));
}
......@@ -92,6 +90,8 @@ dlg_media_viewer_preferences (GtkWindow *parent)
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (gtk_builder_get_object (data->builder, "screenshots_filechooserbutton")), uri);
g_free (uri);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, "use_hardware_acceleration_checkbutton")), g_settings_get_boolean (data->settings, PREF_GSTREAMER_USE_HARDWARE_ACCEL));
/* Set the signals handlers. */
g_signal_connect (G_OBJECT (data->dialog),
......
......@@ -806,8 +806,31 @@ create_playbin (GthMediaViewerPage *self)
return;
self->priv->playbin = gst_element_factory_make ("playbin", "playbin");
video_sink = gst_element_factory_make ("gtksink", NULL);
g_object_set (self->priv->playbin, "video-sink", video_sink, NULL);
settings = g_settings_new (GTHUMB_GSTREAMER_TOOLS_SCHEMA);
if (g_settings_get_boolean (settings, PREF_GSTREAMER_USE_HARDWARE_ACCEL)) {
GstElement *video_bin;
GstElement *glupload;
GstPad *pad;
GstPad *ghost_pad;
/* pipeline taken from GNOME Twitch */
video_sink = gst_element_factory_make ("gtkglsink", "sink");
video_bin = gst_bin_new ("video_bin");
glupload = gst_element_factory_make ("glupload", NULL);
gst_bin_add_many (GST_BIN(video_bin), glupload, video_sink, NULL);
gst_element_link_many (glupload, video_sink, NULL);
pad = gst_element_get_static_pad (glupload, "sink");
ghost_pad = gst_ghost_pad_new ("sink", pad);
gst_pad_set_active (ghost_pad, TRUE);
gst_element_add_pad (video_bin, ghost_pad);
g_object_set (self->priv->playbin, "video-sink", video_bin, NULL);
}
else {
video_sink = gst_element_factory_make ("gtksink", "sink");
g_object_set (self->priv->playbin, "video-sink", video_sink, NULL);
}
g_object_get (video_sink, "widget", &self->priv->video_area, NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->video_area), "video-player");
......@@ -847,7 +870,6 @@ create_playbin (GthMediaViewerPage *self)
gtk_stack_add_named (GTK_STACK (self->priv->area_box), self->priv->video_area, "video-area");
gtk_widget_show (self->priv->video_area);
settings = g_settings_new (GTHUMB_GSTREAMER_TOOLS_SCHEMA);
g_object_set (self->priv->playbin,
"volume", (double) g_settings_get_int (settings, PREF_GSTREAMER_TOOLS_VOLUME) / 100.0,
"force-aspect-ratio", TRUE,
......
......@@ -30,5 +30,6 @@
#define PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION "screenshot-location"
#define PREF_GSTREAMER_TOOLS_VOLUME "volume"
#define PREF_GSTREAMER_USE_HARDWARE_ACCEL "use-hardware-acceleration"
#endif /* PREFERENCES_H */
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