* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
+#include <math.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <string.h>
-#include <X11/Xlib.h>
+#include <gdk/gdk.h>
+#if defined (GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
+#elif defined (GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#endif
+
#include <gst/interfaces/xoverlay.h>
-#include <gst/video/gstvideosink.h>
+
+#if (!GTK_CHECK_VERSION(2, 23, 0) || GTK_CHECK_VERSION(2, 90, 0)) && !GTK_CHECK_VERSION(2, 91, 1)
+#define gtk_combo_box_text_new gtk_combo_box_new_text
+#define gtk_combo_box_text_append_text gtk_combo_box_append_text
+#define gtk_combo_box_text_remove gtk_combo_box_remove_text
+#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
+#endif
GST_DEBUG_CATEGORY_STATIC (seek_debug);
#define GST_CAT_DEFAULT (seek_debug)
+#if !GTK_CHECK_VERSION (2, 17, 7)
+static void
+gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
+{
+ *a = w->allocation;
+}
+#endif
+
/* configuration */
-//#define SOURCE "filesrc"
-#define SOURCE "gnomevfssrc"
+#define SOURCE "filesrc"
-#define ASINK "alsasink"
+#define ASINK DEFAULT_AUDIOSINK
+//#define ASINK "pulsesink"
+//#define ASINK "alsasink"
//#define ASINK "osssink"
+//#define ASINK "directsoundsink"
+#ifdef G_OS_WIN32
+#define VSINK "directdrawsink"
+#else
#define VSINK "xvimagesink"
+#endif
//#define VSINK "sdlvideosink"
//#define VSINK "ximagesink"
//#define VSINK "aasink"
//#define VSINK "cacasink"
+//#define VSINK "dshowvideosink"
+//#define VSINK "sdlvideosink"
+//#define VSINK "glimagesink"
#define FILL_INTERVAL 100
//#define UPDATE_INTERVAL 500
//#define UPDATE_INTERVAL 100
-#define UPDATE_INTERVAL 10
+#define UPDATE_INTERVAL 40
/* number of milliseconds to play for after a seek */
#define SCRUB_TIME 100
#define DEFAULT_VIDEO_HEIGHT 300
+/* the state to go to when stop is pressed */
+#define STOP_STATE GST_STATE_READY
+
+#define N_GRAD 1000.0
static GList *seekable_pads = NULL;
static GList *rate_pads = NULL;
static gboolean flush_seek = TRUE;
static gboolean scrub = TRUE;
static gboolean play_scrub = FALSE;
+static gboolean skip_seek = FALSE;
static gdouble rate = 1.0;
static GstElement *pipeline;
static GtkWidget *video_combo, *audio_combo, *text_combo, *vis_combo;
static GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
static GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
-static GtkWidget *video_window;
-static guint embed_xid = 0;
+static GtkWidget *skip_checkbox, *video_window, *download_checkbox;
+static GtkWidget *buffer_checkbox, *rate_spinbutton;
-GList *paths = NULL, *l = NULL;
+static GStaticMutex state_mutex = G_STATIC_MUTEX_INIT;
+
+static GtkWidget *format_combo, *step_amount_spinbutton, *step_rate_spinbutton;
+static GtkWidget *shuttle_checkbox, *step_button;
+static GtkWidget *shuttle_hscale;
+static GtkAdjustment *shuttle_adjustment;
+
+static GList *paths = NULL, *l = NULL;
/* we keep an array of the visualisation entries so that we can easily switch
* with the combo box index. */
static GArray *vis_entries;
static void clear_streams (GstElement * pipeline);
+static void volume_notify_cb (GstElement * pipeline, GParamSpec * arg,
+ gpointer user_dat);
/* pipeline construction */
dyn_link;
static GstElement *
-gst_element_factory_make_or_warn (gchar * type, gchar * name)
+gst_element_factory_make_or_warn (const gchar * type, const gchar * name)
{
GstElement *element = gst_element_factory_make (type, name);
make_mp3_pipeline (const gchar * location)
{
GstElement *pipeline;
- GstElement *src, *decoder, *osssink, *queue;
+ GstElement *src, *parser, *decoder, *audiosink, *queue;
GstPad *seekable;
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
+ parser = gst_element_factory_make_or_warn ("mp3parse", "parse");
decoder = gst_element_factory_make_or_warn ("mad", "dec");
queue = gst_element_factory_make_or_warn ("queue", "queue");
- osssink = gst_element_factory_make_or_warn (ASINK, "sink");
+ audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
- seekable_elements = g_list_prepend (seekable_elements, osssink);
+ seekable_elements = g_list_prepend (seekable_elements, audiosink);
g_object_set (G_OBJECT (src), "location", location, NULL);
- //g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL);
+ //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
gst_bin_add (GST_BIN (pipeline), src);
+ gst_bin_add (GST_BIN (pipeline), parser);
gst_bin_add (GST_BIN (pipeline), decoder);
gst_bin_add (GST_BIN (pipeline), queue);
- gst_bin_add (GST_BIN (pipeline), osssink);
+ gst_bin_add (GST_BIN (pipeline), audiosink);
- gst_element_link (src, decoder);
+ gst_element_link (src, parser);
+ gst_element_link (parser, decoder);
gst_element_link (decoder, queue);
- gst_element_link (queue, osssink);
+ gst_element_link (queue, audiosink);
seekable = gst_element_get_static_pad (queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
gchar *uri;
/* Add "file://" prefix for convenience */
- if (g_str_has_prefix (location, "/")) {
- uri = g_strconcat ("file://", location, NULL);
+ if (g_str_has_prefix (location, "/") || !gst_uri_is_valid (location)) {
+ uri = gst_filename_to_uri (location, NULL);
+ g_print ("Setting URI: %s\n", uri);
g_object_set (G_OBJECT (player), "uri", uri, NULL);
g_free (uri);
} else {
+ g_print ("Setting URI: %s\n", location);
g_object_set (G_OBJECT (player), "uri", location, NULL);
}
}
static GstElement *
make_playerbin2_pipeline (const gchar * location)
{
- return construct_playerbin ("playbin2", location);
+ GstElement *pipeline = construct_playerbin ("playbin2", location);
+
+ /* FIXME: this is not triggered, playbin2 is not forwarding it from the sink */
+ g_signal_connect (pipeline, "notify::volume", G_CALLBACK (volume_notify_cb),
+ NULL);
+ return pipeline;
}
#ifndef GST_DISABLE_PARSE
typedef struct
{
- gchar *name;
+ const gchar *name;
GstElement *(*func) (const gchar * location);
}
Pipeline;
gint64 seconds;
gint64 subseconds;
- real = value * duration / 100;
+ real = value * duration / N_GRAD;
seconds = (gint64) real / GST_SECOND;
- subseconds = (gint64) real / (GST_SECOND / 100);
+ subseconds = (gint64) real / (GST_SECOND / N_GRAD);
return g_strdup_printf ("%02" G_GINT64_FORMAT ":%02" G_GINT64_FORMAT ":%02"
G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
}
+
+static gchar *
+shuttle_format_value (GtkScale * scale, gdouble value)
+{
+ return g_strdup_printf ("%0.*g", gtk_scale_get_digits (scale), value);
+}
+
typedef struct
{
const gchar *name;
query = gst_query_new_buffering (GST_FORMAT_PERCENT);
if (gst_element_query (element, query)) {
- gint64 start, stop;
+ gint64 start, stop, buffering_total;
GstFormat format;
gdouble fill;
gboolean busy;
gint percent;
+ GstBufferingMode mode;
+ gint avg_in, avg_out;
+ gint64 buffering_left;
gst_query_parse_buffering_percent (query, &busy, &percent);
-
- if (buffering && !busy) {
- /* if we were buffering but not anymore, start playing */
- if (state == GST_STATE_PLAYING && !is_live) {
- fprintf (stderr, "setting pipeline to PLAYING ...\n");
- gst_element_set_state (pipeline, GST_STATE_PLAYING);
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id,
- "Playing");
- }
- state = GST_STATE_PAUSED;
- buffering = FALSE;
- }
-
- gst_query_parse_buffering_range (query, &format, &start, &stop, NULL);
-
+ gst_query_parse_buffering_range (query, &format, &start, &stop,
+ &buffering_total);
+ gst_query_parse_buffering_stats (query, &mode, &avg_in, &avg_out,
+ &buffering_left);
+
+ /* note that we could start the playback when buffering_left < remaining
+ * playback time */
+ GST_DEBUG ("buffering total %" G_GINT64_FORMAT " ms, left %"
+ G_GINT64_FORMAT " ms", buffering_total, buffering_left);
GST_DEBUG ("start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT,
start, stop);
if (stop != -1)
- fill = 100.0 * stop / GST_FORMAT_PERCENT_MAX;
+ fill = N_GRAD * stop / GST_FORMAT_PERCENT_MAX;
else
- fill = 100.0;
+ fill = N_GRAD;
gtk_range_set_fill_level (GTK_RANGE (hscale), fill);
}
}
query_rates ();
}
+
if (position >= duration)
duration = position;
if (duration > 0) {
- set_scale (position * 100.0 / duration);
+ set_scale (position * N_GRAD / duration);
+ }
+
+ /* FIXME: see make_playerbin2_pipeline() and volume_notify_cb() */
+ if (pipeline_type == 16) {
+ g_object_notify (G_OBJECT (pipeline), "volume");
}
return TRUE;
GstEvent *s_event;
GstSeekFlags flags;
- real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
+ real = gtk_range_get_value (GTK_RANGE (widget)) * duration / N_GRAD;
+
+ GST_DEBUG ("value=%f, real=%" G_GINT64_FORMAT,
+ gtk_range_get_value (GTK_RANGE (widget)), real);
flags = 0;
if (flush_seek)
flags |= GST_SEEK_FLAG_KEY_UNIT;
if (loop_seek)
flags |= GST_SEEK_FLAG_SEGMENT;
+ if (skip_seek)
+ flags |= GST_SEEK_FLAG_SKIP;
if (rate >= 0) {
s_event = gst_event_new_seek (rate,
- GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET, -1);
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET,
+ GST_CLOCK_TIME_NONE);
GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
rate, GST_TIME_ARGS (real), GST_TIME_ARGS (duration));
} else {
if (active) {
if (fill_id == 0) {
fill_id =
- g_timeout_add (FILL_INTERVAL, (GtkFunction) update_fill, pipeline);
+ g_timeout_add (FILL_INTERVAL, (GSourceFunc) update_fill, pipeline);
}
} else {
if (fill_id) {
if (active) {
if (update_id == 0) {
update_id =
- g_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ g_timeout_add (UPDATE_INTERVAL, (GSourceFunc) update_scale, pipeline);
}
} else {
if (update_id) {
}
if (changed_id == 0 && flush_seek && scrub) {
- changed_id = gtk_signal_connect (GTK_OBJECT (hscale),
- "value_changed", G_CALLBACK (seek_cb), pipeline);
+ changed_id =
+ g_signal_connect (hscale, "value_changed", G_CALLBACK (seek_cb),
+ pipeline);
}
return FALSE;
stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
if (changed_id) {
- g_signal_handler_disconnect (GTK_OBJECT (hscale), changed_id);
+ g_signal_handler_disconnect (hscale, changed_id);
changed_id = 0;
}
state = GST_STATE_PLAYING;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
}
+
return;
failed:
static void
pause_cb (GtkButton * button, gpointer data)
{
+ g_static_mutex_lock (&state_mutex);
if (state != GST_STATE_PAUSED) {
GstStateChangeReturn ret;
state = GST_STATE_PAUSED;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Paused");
}
+ g_static_mutex_unlock (&state_mutex);
+
return;
failed:
{
+ g_static_mutex_unlock (&state_mutex);
g_print ("PAUSE failed\n");
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Pause failed");
}
static void
stop_cb (GtkButton * button, gpointer data)
{
- if (state != GST_STATE_READY) {
+ if (state != STOP_STATE) {
GstStateChangeReturn ret;
g_print ("READY pipeline\n");
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
- ret = gst_element_set_state (pipeline, GST_STATE_READY);
+ g_static_mutex_lock (&state_mutex);
+ ret = gst_element_set_state (pipeline, STOP_STATE);
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
- state = GST_STATE_READY;
+ state = STOP_STATE;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
is_live = FALSE;
if (pipeline_type == 16)
clear_streams (pipeline);
+ g_static_mutex_unlock (&state_mutex);
+#if 0
/* if one uses parse_launch, play, stop and play again it fails as all the
* pads after the demuxer can't be reconnected
*/
pipeline = pipelines[pipeline_type].func (pipeline_spec);
g_assert (pipeline);
- gst_element_set_state (pipeline, GST_STATE_READY);
+ gst_element_set_state (pipeline, STOP_STATE);
connect_bus_signals (pipeline);
}
+#endif
}
return;
failed:
{
+ g_static_mutex_unlock (&state_mutex);
g_print ("STOP failed\n");
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stop failed");
}
}
static void
+skip_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+{
+ skip_seek = gtk_toggle_button_get_active (button);
+ if (state == GST_STATE_PLAYING) {
+ do_seek (hscale);
+ }
+}
+
+static void
rate_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
{
gboolean res = FALSE;
rate = gtk_spin_button_get_value (button);
+ GST_DEBUG ("rate changed to %lf", rate);
+
flags = 0;
if (flush_seek)
flags |= GST_SEEK_FLAG_FLUSH;
flags |= GST_SEEK_FLAG_ACCURATE;
if (keyframe_seek)
flags |= GST_SEEK_FLAG_KEY_UNIT;
+ if (skip_seek)
+ flags |= GST_SEEK_FLAG_SKIP;
- if (rate >= 0) {
+ if (rate >= 0.0) {
s_event = gst_event_new_seek (rate,
GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
- GST_SEEK_TYPE_SET, -1);
+ GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
} else {
s_event = gst_event_new_seek (rate,
GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
GST_SEEK_TYPE_SET, position);
}
- GST_DEBUG ("rate changed to %lf", rate);
-
res = send_event (s_event);
if (res) {
}
static void
+download_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+{
+ gboolean state;
+
+ state = gtk_toggle_button_get_active (button);
+ update_flag (pipeline, 7, state);
+}
+
+static void
+buffer_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+{
+ gboolean state;
+
+ state = gtk_toggle_button_get_active (button);
+ update_flag (pipeline, 8, state);
+}
+
+static void
clear_streams (GstElement * pipeline)
{
gint i;
/* remove previous info */
for (i = 0; i < n_video; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (video_combo), 0);
+ gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (video_combo), 0);
for (i = 0; i < n_audio; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (audio_combo), 0);
+ gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (audio_combo), 0);
for (i = 0; i < n_text; i++)
- gtk_combo_box_remove_text (GTK_COMBO_BOX (text_combo), 0);
+ gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (text_combo), 0);
n_audio = n_video = n_text = 0;
gtk_widget_set_sensitive (video_combo, FALSE);
if (pipeline_type == 16 && need_streams) {
GstTagList *tags;
- gchar *name;
+ gchar *name, *str;
gint active_idx;
gboolean state;
active_idx = 0;
for (i = 0; i < n_video; i++) {
g_signal_emit_by_name (pipeline, "get-video-tags", i, &tags);
+ if (tags) {
+ str = gst_structure_to_string ((GstStructure *) tags);
+ g_print ("video %d: %s\n", i, str);
+ g_free (str);
+ }
/* find good name for the label */
name = g_strdup_printf ("video %d", i + 1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (video_combo), name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (video_combo), name);
g_free (name);
}
state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (video_checkbox));
active_idx = 0;
for (i = 0; i < n_audio; i++) {
g_signal_emit_by_name (pipeline, "get-audio-tags", i, &tags);
+ if (tags) {
+ str = gst_structure_to_string ((GstStructure *) tags);
+ g_print ("audio %d: %s\n", i, str);
+ g_free (str);
+ }
/* find good name for the label */
name = g_strdup_printf ("audio %d", i + 1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (audio_combo), name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (audio_combo), name);
g_free (name);
}
state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (audio_checkbox));
active_idx = 0;
for (i = 0; i < n_text; i++) {
g_signal_emit_by_name (pipeline, "get-text-tags", i, &tags);
+
name = NULL;
if (tags) {
const GValue *value;
+ str = gst_structure_to_string ((GstStructure *) tags);
+ g_print ("text %d: %s\n", i, str);
+ g_free (str);
+
/* get the language code if we can */
value = gst_tag_list_get_value_index (tags, GST_TAG_LANGUAGE_CODE, 0);
if (value && G_VALUE_HOLDS_STRING (value)) {
if (name == NULL)
name = g_strdup_printf ("text %d", i + 1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (text_combo), name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (text_combo), name);
g_free (name);
}
state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_checkbox));
static void
video_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
{
- g_object_set (pipeline, "current-video", gtk_combo_box_get_active (combo),
- NULL);
+ gint active;
+
+ active = gtk_combo_box_get_active (combo);
+
+ g_print ("setting current video track %d\n", active);
+ g_object_set (pipeline, "current-video", active, NULL);
}
static void
audio_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
{
- g_object_set (pipeline, "current-audio", gtk_combo_box_get_active (combo),
- NULL);
+ gint active;
+
+ active = gtk_combo_box_get_active (combo);
+
+ g_print ("setting current audio track %d\n", active);
+ g_object_set (pipeline, "current-audio", active, NULL);
}
static void
text_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
{
- g_object_set (pipeline, "current-text", gtk_combo_box_get_active (combo),
- NULL);
+ gint active;
+
+ active = gtk_combo_box_get_active (combo);
+
+ g_print ("setting current text track %d\n", active);
+ g_object_set (pipeline, "current-text", active, NULL);
}
static gboolean
name = gst_element_factory_get_longname (entry.factory);
g_array_append_val (vis_entries, entry);
- gtk_combo_box_append_text (GTK_COMBO_BOX (vis_combo), name);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vis_combo), name);
}
gtk_combo_box_set_active (GTK_COMBO_BOX (vis_combo), 0);
}
/* get the selected index and get the factory for this index */
index = gtk_combo_box_get_active (GTK_COMBO_BOX (vis_combo));
- entry = &g_array_index (vis_entries, VisEntry, index);
- /* create an instance of the element from the factory */
- element = gst_element_factory_create (entry->factory, NULL);
- if (!element)
- return;
+ if (vis_entries->len > 0) {
+ entry = &g_array_index (vis_entries, VisEntry, index);
+
+ /* create an instance of the element from the factory */
+ element = gst_element_factory_create (entry->factory, NULL);
+ if (!element)
+ return;
- /* set vis plugin for playbin2 */
- g_object_set (pipeline, "vis-plugin", element, NULL);
+ /* set vis plugin for playbin2 */
+ g_object_set (pipeline, "vis-plugin", element, NULL);
+ }
}
static void
}
static void
+volume_notify_cb (GstElement * pipeline, GParamSpec * arg, gpointer user_dat)
+{
+ gdouble cur_volume, new_volume;
+
+ g_object_get (pipeline, "volume", &new_volume, NULL);
+ cur_volume = gtk_spin_button_get_value (GTK_SPIN_BUTTON (volume_spinbutton));
+ if (fabs (cur_volume - new_volume) > 0.001) {
+ g_signal_handlers_block_by_func (volume_spinbutton,
+ volume_spinbutton_changed_cb, pipeline);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), new_volume);
+ g_signal_handlers_unblock_by_func (volume_spinbutton,
+ volume_spinbutton_changed_cb, pipeline);
+ }
+}
+
+static void
shot_cb (GtkButton * button, gpointer data)
{
GstBuffer *buffer;
}
}
+/* called when the Step button is pressed */
+static void
+step_cb (GtkButton * button, gpointer data)
+{
+ GstEvent *event;
+ GstFormat format;
+ guint64 amount;
+ gdouble rate;
+ gboolean flush, res;
+ gint active;
+
+ active = gtk_combo_box_get_active (GTK_COMBO_BOX (format_combo));
+ amount =
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
+ (step_amount_spinbutton));
+ rate = gtk_spin_button_get_value (GTK_SPIN_BUTTON (step_rate_spinbutton));
+ flush = TRUE;
+
+ switch (active) {
+ case 0:
+ format = GST_FORMAT_BUFFERS;
+ break;
+ case 1:
+ format = GST_FORMAT_TIME;
+ amount *= GST_MSECOND;
+ break;
+ default:
+ format = GST_FORMAT_UNDEFINED;
+ break;
+ }
+
+ event = gst_event_new_step (format, amount, rate, flush, FALSE);
+
+ res = send_event (event);
+
+ if (!res) {
+ g_print ("Sending step event failed\n");
+ }
+}
+
static void
message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
}
}
+static gboolean shuttling = FALSE;
+static gdouble shuttle_rate = 0.0;
+static gdouble play_rate = 1.0;
+
+static void
+do_shuttle (GstElement * element)
+{
+ guint64 duration;
+
+ if (shuttling)
+ duration = 40 * GST_MSECOND;
+ else
+ duration = -1;
+
+ gst_element_send_event (element,
+ gst_event_new_step (GST_FORMAT_TIME, duration, shuttle_rate, FALSE,
+ FALSE));
+}
+
+static void
+msg_sync_step_done (GstBus * bus, GstMessage * message, GstElement * element)
+{
+ GstFormat format;
+ guint64 amount;
+ gdouble rate;
+ gboolean flush;
+ gboolean intermediate;
+ guint64 duration;
+ gboolean eos;
+
+ gst_message_parse_step_done (message, &format, &amount, &rate, &flush,
+ &intermediate, &duration, &eos);
+
+ if (eos) {
+ g_print ("stepped till EOS\n");
+ return;
+ }
+
+ if (g_static_mutex_trylock (&state_mutex)) {
+ if (shuttling)
+ do_shuttle (element);
+ g_static_mutex_unlock (&state_mutex);
+ } else {
+ /* ignore step messages that come while we are doing a state change */
+ g_print ("state change is busy\n");
+ }
+}
+
+static void
+shuttle_toggled (GtkToggleButton * button, GstElement * element)
+{
+ gboolean active;
+
+ active = gtk_toggle_button_get_active (button);
+
+ if (active != shuttling) {
+ shuttling = active;
+ g_print ("shuttling %s\n", shuttling ? "active" : "inactive");
+ if (active) {
+ shuttle_rate = 0.0;
+ play_rate = 1.0;
+ pause_cb (NULL, NULL);
+ gst_element_get_state (element, NULL, NULL, -1);
+ }
+ }
+}
+
+static void
+shuttle_rate_switch (GstElement * element)
+{
+ GstSeekFlags flags;
+ GstEvent *s_event;
+ gboolean res;
+
+ if (state == GST_STATE_PLAYING) {
+ /* pause when we need to */
+ pause_cb (NULL, NULL);
+ gst_element_get_state (element, NULL, NULL, -1);
+ }
+
+ if (play_rate == 1.0)
+ play_rate = -1.0;
+ else
+ play_rate = 1.0;
+
+ g_print ("rate changed to %lf %" GST_TIME_FORMAT "\n", play_rate,
+ GST_TIME_ARGS (position));
+
+ flags = GST_SEEK_FLAG_FLUSH;
+ flags |= GST_SEEK_FLAG_ACCURATE;
+
+ if (play_rate >= 0.0) {
+ s_event = gst_event_new_seek (play_rate,
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
+ GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
+ } else {
+ s_event = gst_event_new_seek (play_rate,
+ GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
+ GST_SEEK_TYPE_SET, position);
+ }
+ res = send_event (s_event);
+ if (res) {
+ gst_element_get_state (element, NULL, NULL, SEEK_TIMEOUT);
+ } else {
+ g_print ("seek failed\n");
+ }
+}
+
+static void
+shuttle_value_changed (GtkRange * range, GstElement * element)
+{
+ gdouble rate;
+
+ rate = gtk_adjustment_get_value (shuttle_adjustment);
+
+ if (rate == 0.0) {
+ g_print ("rate 0.0, pause\n");
+ pause_cb (NULL, NULL);
+ gst_element_get_state (element, NULL, NULL, -1);
+ } else {
+ g_print ("rate changed %0.3g\n", rate);
+
+ if ((rate < 0.0 && play_rate > 0.0) || (rate > 0.0 && play_rate < 0.0)) {
+ shuttle_rate_switch (element);
+ }
+
+ shuttle_rate = ABS (rate);
+ if (state != GST_STATE_PLAYING) {
+ do_shuttle (element);
+ play_cb (NULL, NULL);
+ }
+ }
+}
+
static void
msg_async_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{
/* in the segment-done callback we never flush as this would not make sense
* for seamless playback. */
if (loop_seek)
- flags = GST_SEEK_FLAG_SEGMENT;
+ flags |= GST_SEEK_FLAG_SEGMENT;
+ if (skip_seek)
+ flags |= GST_SEEK_FLAG_SKIP;
s_event = gst_event_new_seek (rate,
GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
if (state == GST_STATE_PLAYING && !is_live) {
fprintf (stderr, "Downloading, setting pipeline to PAUSED ...\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
+ /* user has to manually start the playback */
+ state = GST_STATE_PAUSED;
}
}
}
do_download_buffering (percent);
break;
case GST_BUFFERING_LIVE:
+ is_live = TRUE;
case GST_BUFFERING_TIMESHIFT:
case GST_BUFFERING_STREAM:
do_stream_buffering (percent);
}
}
+static void
+msg_clock_lost (GstBus * bus, GstMessage * message, GstPipeline * data)
+{
+ g_print ("clock lost! PAUSE and PLAY to select a new clock\n");
+ if (state == GST_STATE_PLAYING) {
+ gst_element_set_state (pipeline, GST_STATE_PAUSED);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ }
+}
+
+#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
+
+static gulong embed_xid = 0;
+
+/* We set the xid here in response to the prepare-xwindow-id message via a
+ * bus sync handler because we don't know the actual videosink used from the
+ * start (as we don't know the pipeline, or bin elements such as autovideosink
+ * or gconfvideosink may be used which create the actual videosink only once
+ * the pipeline is started) */
static GstBusSyncReply
bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
{
gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
- g_print ("got prepare-xwindow-id\n");
- if (!embed_xid) {
- embed_xid = GDK_WINDOW_XID (GDK_WINDOW (video_window->window));
- }
+ g_print ("got prepare-xwindow-id, setting XID %lu\n", embed_xid);
if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
"force-aspect-ratio")) {
g_object_set (element, "force-aspect-ratio", TRUE, NULL);
}
- gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
- embed_xid);
+ /* Should have been initialised from main thread before (can't use
+ * GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
+ * be called from a streaming thread and GDK_WINDOW_XID maps to more than
+ * a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
+ * shouldn't be done from a non-GUI thread without explicit locking). */
+ g_assert (embed_xid != 0);
+
+ gst_x_overlay_set_window_handle (GST_X_OVERLAY (element), embed_xid);
}
return GST_BUS_PASS;
}
+#endif
+
+static gboolean
+handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+{
+ if (state < GST_STATE_PAUSED) {
+ GtkAllocation allocation;
+ GdkWindow *window = gtk_widget_get_window (widget);
+ cairo_t *cr;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ cr = gdk_cairo_create (window);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+ }
+ return FALSE;
+}
+
+static void
+realize_cb (GtkWidget * widget, gpointer data)
+{
+#if GTK_CHECK_VERSION(2,18,0)
+ {
+ GdkWindow *window = gtk_widget_get_window (widget);
+
+ /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
+ * as well */
+ if (!gdk_window_ensure_native (window))
+ g_error ("Couldn't create native window needed for GstXOverlay!");
+ }
+#endif
+
+#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
+ {
+ GdkWindow *window = gtk_widget_get_window (video_window);
+
+#if defined (GDK_WINDOWING_WIN32)
+ embed_xid = GDK_WINDOW_HWND (window);
+#else
+ embed_xid = GDK_WINDOW_XID (window);
+#endif
+ g_print ("Window realize: video window XID = %lu\n", embed_xid);
+ }
+#endif
+}
static void
msg_eos (GstBus * bus, GstMessage * message, GstPipeline * data)
}
static void
+msg_step_done (GstBus * bus, GstMessage * message, GstPipeline * data)
+{
+ if (!shuttling)
+ message_received (bus, message, data);
+}
+
+static void
connect_bus_signals (GstElement * pipeline)
{
GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
/* handle prepare-xwindow-id element message synchronously */
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler,
pipeline);
+#endif
gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
+ gst_bus_enable_sync_message_emission (bus);
g_signal_connect (bus, "message::state-changed",
(GCallback) msg_state_changed, pipeline);
g_signal_connect (bus, "message::new-clock", (GCallback) message_received,
pipeline);
+ g_signal_connect (bus, "message::clock-lost", (GCallback) msg_clock_lost,
+ pipeline);
g_signal_connect (bus, "message::error", (GCallback) message_received,
pipeline);
g_signal_connect (bus, "message::warning", (GCallback) message_received,
pipeline);
g_signal_connect (bus, "message::buffering", (GCallback) msg_buffering,
pipeline);
+// g_signal_connect (bus, "message::step-done", (GCallback) msg_step_done,
+// pipeline);
+ g_signal_connect (bus, "message::step-start", (GCallback) msg_step_done,
+ pipeline);
+ g_signal_connect (bus, "sync-message::step-done",
+ (GCallback) msg_sync_step_done, pipeline);
gst_object_unref (bus);
}
int
main (int argc, char **argv)
{
- GtkWidget *window, *hbox, *vbox, *panel, *boxes, *flagtable, *boxes2;
+ GtkWidget *window, *hbox, *vbox, *panel, *expander, *pb2vbox, *boxes,
+ *flagtable, *boxes2, *step;
GtkWidget *play_button, *pause_button, *stop_button, *shot_button;
GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox, *flush_checkbox;
- GtkWidget *scrub_checkbox, *play_scrub_checkbox, *rate_spinbutton;
- GtkWidget *rate_label;
- GtkTooltips *tips;
+ GtkWidget *scrub_checkbox, *play_scrub_checkbox;
+ GtkWidget *rate_label, *volume_label;
GOptionEntry options[] = {
{"stats", 's', 0, G_OPTION_ARG_NONE, &stats,
"Show pad stats", NULL},
if (!g_thread_supported ())
g_thread_init (NULL);
- if (!XInitThreads ()) {
- g_print ("XInitThreads failed\n");
- exit (-1);
- }
-
ctx = g_option_context_new ("- test seeking in gsteamer");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
+ g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_print ("Error initializing: %s\n", err->message);
GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example");
- gtk_init (&argc, &argv);
-
if (argc != 3) {
print_usage (argc, argv);
exit (-1);
pipeline_spec = argv[2];
- if (g_strrstr (pipeline_spec, "*") != NULL ||
- g_strrstr (pipeline_spec, "?") != NULL) {
+ if (g_path_is_absolute (pipeline_spec) &&
+ (g_strrstr (pipeline_spec, "*") != NULL ||
+ g_strrstr (pipeline_spec, "?") != NULL)) {
paths = handle_wildcards (pipeline_spec);
} else {
paths = g_list_prepend (paths, g_strdup (pipeline_spec));
g_assert (pipeline);
/* initialize gui elements ... */
- tips = gtk_tooltips_new ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
video_window = gtk_drawing_area_new ();
+ g_signal_connect (video_window, "expose-event",
+ G_CALLBACK (handle_expose_cb), NULL);
+ g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
gtk_widget_set_double_buffered (video_window, FALSE);
+
statusbar = gtk_statusbar_new ();
status_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "seek");
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
flush_checkbox = gtk_check_button_new_with_label ("Flush");
scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
play_scrub_checkbox = gtk_check_button_new_with_label ("Play Scrub");
+ skip_checkbox = gtk_check_button_new_with_label ("Play Skip");
rate_spinbutton = gtk_spin_button_new_with_range (-100, 100, 0.1);
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (rate_spinbutton), 3);
rate_label = gtk_label_new ("Rate");
- gtk_tooltips_set_tip (tips, accurate_checkbox,
- "accurate position is requested, this might be considerably slower for some formats",
- NULL);
- gtk_tooltips_set_tip (tips, key_checkbox,
- "seek to the nearest keyframe. This might be faster but less accurate",
- NULL);
- gtk_tooltips_set_tip (tips, loop_checkbox, "loop playback", NULL);
- gtk_tooltips_set_tip (tips, flush_checkbox, "flush pipeline after seeking",
- NULL);
- gtk_tooltips_set_tip (tips, rate_spinbutton, "define the playback rate, "
- "negative value trigger reverse playback", NULL);
- gtk_tooltips_set_tip (tips, scrub_checkbox, "show images while seeking",
- NULL);
- gtk_tooltips_set_tip (tips, play_scrub_checkbox, "play video while seeking",
- NULL);
+ gtk_widget_set_tooltip_text (accurate_checkbox,
+ "accurate position is requested, this might be considerably slower for some formats");
+ gtk_widget_set_tooltip_text (key_checkbox,
+ "seek to the nearest keyframe. This might be faster but less accurate");
+ gtk_widget_set_tooltip_text (loop_checkbox, "loop playback");
+ gtk_widget_set_tooltip_text (flush_checkbox, "flush pipeline after seeking");
+ gtk_widget_set_tooltip_text (rate_spinbutton, "define the playback rate, "
+ "negative value trigger reverse playback");
+ gtk_widget_set_tooltip_text (scrub_checkbox, "show images while seeking");
+ gtk_widget_set_tooltip_text (play_scrub_checkbox, "play video while seeking");
+ gtk_widget_set_tooltip_text (skip_checkbox,
+ "Skip frames while playing at high frame rates");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrub_checkbox), TRUE);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (rate_spinbutton), rate);
+ /* step expander */
+ {
+ GtkWidget *hbox;
+
+ step = gtk_expander_new ("step options");
+ hbox = gtk_hbox_new (FALSE, 0);
+
+ format_combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (format_combo),
+ "frames");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (format_combo),
+ "time (ms)");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (format_combo), 0);
+ gtk_box_pack_start (GTK_BOX (hbox), format_combo, FALSE, FALSE, 2);
+
+ step_amount_spinbutton = gtk_spin_button_new_with_range (1, 1000, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_amount_spinbutton), 0);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_amount_spinbutton), 1.0);
+ gtk_box_pack_start (GTK_BOX (hbox), step_amount_spinbutton, FALSE, FALSE,
+ 2);
+
+ step_rate_spinbutton = gtk_spin_button_new_with_range (0.0, 100, 0.1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_rate_spinbutton), 3);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_rate_spinbutton), 1.0);
+ gtk_box_pack_start (GTK_BOX (hbox), step_rate_spinbutton, FALSE, FALSE, 2);
+
+ step_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_FORWARD);
+ gtk_button_set_label (GTK_BUTTON (step_button), "Step");
+ gtk_box_pack_start (GTK_BOX (hbox), step_button, FALSE, FALSE, 2);
+
+ g_signal_connect (G_OBJECT (step_button), "clicked", G_CALLBACK (step_cb),
+ pipeline);
+
+ /* shuttle scale */
+ shuttle_checkbox = gtk_check_button_new_with_label ("Shuttle");
+ gtk_box_pack_start (GTK_BOX (hbox), shuttle_checkbox, FALSE, FALSE, 2);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shuttle_checkbox), FALSE);
+ g_signal_connect (shuttle_checkbox, "toggled", G_CALLBACK (shuttle_toggled),
+ pipeline);
+
+ shuttle_adjustment =
+ GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -3.00, 4.0, 0.1, 1.0, 1.0));
+ shuttle_hscale = gtk_hscale_new (shuttle_adjustment);
+ gtk_scale_set_digits (GTK_SCALE (shuttle_hscale), 2);
+ gtk_scale_set_value_pos (GTK_SCALE (shuttle_hscale), GTK_POS_TOP);
+ g_signal_connect (shuttle_hscale, "value_changed",
+ G_CALLBACK (shuttle_value_changed), pipeline);
+ g_signal_connect (shuttle_hscale, "format_value",
+ G_CALLBACK (shuttle_format_value), pipeline);
+
+ gtk_box_pack_start (GTK_BOX (hbox), shuttle_hscale, TRUE, TRUE, 2);
+
+ gtk_container_add (GTK_CONTAINER (step), hbox);
+ }
+
/* seek bar */
adjustment =
- GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
+ GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, N_GRAD, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
-#if GTK_CHECK_VERSION(2,12,0)
+ gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_RIGHT);
gtk_range_set_show_fill_level (GTK_RANGE (hscale), TRUE);
- gtk_range_set_fill_level (GTK_RANGE (hscale), 100.0);
-#endif
- gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
+ gtk_range_set_fill_level (GTK_RANGE (hscale), N_GRAD);
- gtk_signal_connect (GTK_OBJECT (hscale),
- "button_press_event", G_CALLBACK (start_seek), pipeline);
- gtk_signal_connect (GTK_OBJECT (hscale),
- "button_release_event", G_CALLBACK (stop_seek), pipeline);
- gtk_signal_connect (GTK_OBJECT (hscale),
- "format_value", G_CALLBACK (format_value), pipeline);
+ g_signal_connect (hscale, "button_press_event", G_CALLBACK (start_seek),
+ pipeline);
+ g_signal_connect (hscale, "button_release_event", G_CALLBACK (stop_seek),
+ pipeline);
+ g_signal_connect (hscale, "format_value", G_CALLBACK (format_value),
+ pipeline);
if (pipeline_type == 16) {
/* the playbin2 panel controls for the video/audio/subtitle tracks */
panel = gtk_hbox_new (FALSE, 0);
- video_combo = gtk_combo_box_new_text ();
- audio_combo = gtk_combo_box_new_text ();
- text_combo = gtk_combo_box_new_text ();
+ video_combo = gtk_combo_box_text_new ();
+ audio_combo = gtk_combo_box_text_new ();
+ text_combo = gtk_combo_box_text_new ();
gtk_widget_set_sensitive (video_combo, FALSE);
gtk_widget_set_sensitive (audio_combo, FALSE);
gtk_widget_set_sensitive (text_combo, FALSE);
audio_checkbox = gtk_check_button_new_with_label ("Audio");
text_checkbox = gtk_check_button_new_with_label ("Text");
mute_checkbox = gtk_check_button_new_with_label ("Mute");
+ download_checkbox = gtk_check_button_new_with_label ("Download");
+ buffer_checkbox = gtk_check_button_new_with_label ("Buffer");
+ volume_label = gtk_label_new ("Volume");
volume_spinbutton = gtk_spin_button_new_with_range (0, 10.0, 0.1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), 1.0);
gtk_box_pack_start (GTK_BOX (boxes), video_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), text_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), vis_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), mute_checkbox, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (boxes), download_checkbox, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (boxes), buffer_checkbox, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (boxes), volume_label, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), volume_spinbutton, TRUE, TRUE, 2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vis_checkbox), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (audio_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_checkbox), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (download_checkbox), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buffer_checkbox), FALSE);
g_signal_connect (G_OBJECT (vis_checkbox), "toggled",
G_CALLBACK (vis_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (audio_checkbox), "toggled",
G_CALLBACK (text_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (mute_checkbox), "toggled",
G_CALLBACK (mute_toggle_cb), pipeline);
+ g_signal_connect (G_OBJECT (download_checkbox), "toggled",
+ G_CALLBACK (download_toggle_cb), pipeline);
+ g_signal_connect (G_OBJECT (buffer_checkbox), "toggled",
+ G_CALLBACK (buffer_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (volume_spinbutton), "value_changed",
G_CALLBACK (volume_spinbutton_changed_cb), pipeline);
/* playbin2 panel for snapshot */
boxes2 = gtk_hbox_new (FALSE, 0);
shot_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
- gtk_tooltips_set_tip (tips, shot_button,
- "save a screenshot .png in the current directory", NULL);
+ gtk_widget_set_tooltip_text (shot_button,
+ "save a screenshot .png in the current directory");
g_signal_connect (G_OBJECT (shot_button), "clicked", G_CALLBACK (shot_cb),
pipeline);
- vis_combo = gtk_combo_box_new_text ();
+ vis_combo = gtk_combo_box_text_new ();
g_signal_connect (G_OBJECT (vis_combo), "changed",
G_CALLBACK (vis_combo_cb), pipeline);
gtk_widget_set_sensitive (vis_combo, FALSE);
gtk_table_attach_defaults (GTK_TABLE (flagtable), scrub_checkbox, 1, 2, 1, 2);
gtk_table_attach_defaults (GTK_TABLE (flagtable), play_scrub_checkbox, 2, 3,
1, 2);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_label, 3, 4, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_spinbutton, 3, 4, 1,
+ gtk_table_attach_defaults (GTK_TABLE (flagtable), skip_checkbox, 3, 4, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_label, 4, 5, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_spinbutton, 4, 5, 1,
2);
if (panel && boxes && boxes2) {
- gtk_box_pack_start (GTK_BOX (vbox), panel, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), boxes, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), boxes2, FALSE, FALSE, 2);
+ expander = gtk_expander_new ("playbin2 options");
+ pb2vbox = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (pb2vbox), panel, FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (pb2vbox), boxes, FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (pb2vbox), boxes2, FALSE, FALSE, 2);
+ gtk_container_add (GTK_CONTAINER (expander), pb2vbox);
+ gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 2);
}
+ gtk_box_pack_start (GTK_BOX (vbox), step, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hscale, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 2);
G_CALLBACK (scrub_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (play_scrub_checkbox), "toggled",
G_CALLBACK (play_scrub_toggle_cb), pipeline);
+ g_signal_connect (G_OBJECT (skip_checkbox), "toggled",
+ G_CALLBACK (skip_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (rate_spinbutton), "value_changed",
G_CALLBACK (rate_spinbutton_changed_cb), pipeline);
/* show the gui. */
gtk_widget_show_all (window);
+ /* realize window now so that the video window gets created and we can
+ * obtain its XID before the pipeline is started up and the videosink
+ * asks for the XID of the window to render onto */
+ gtk_widget_realize (window);
+
+#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
+ /* we should have the XID now */
+ g_assert (embed_xid != 0);
+#endif
+
if (verbose) {
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_object_default_deep_notify), NULL);