#include <gdk/gdkquartzwindow.h>
#endif
-#include <gst/interfaces/xoverlay.h>
+#include <gst/video/videooverlay.h>
+#include <gst/video/colorbalance.h>
#include <gst/interfaces/navigation.h>
-#include <gst/interfaces/colorbalance.h>
GST_DEBUG_CATEGORY_STATIC (seek_debug);
#define GST_CAT_DEFAULT (seek_debug)
GstElement *navigation_element;
GstElement *colorbalance_element;
- GstElement *xoverlay_element;
+ GstElement *overlay_element;
/* Settings */
gboolean accurate_seek;
gboolean need_streams;
gint n_video, n_audio, n_text;
- GStaticMutex state_mutex;
+ GMutex state_mutex;
GArray *vis_entries; /* Array of VisEntry structs */
}
static void
-make_playbin2_pipeline (SeekApp * app, const gchar * location)
+make_playbin_pipeline (SeekApp * app, const gchar * location)
{
GstElement *pipeline;
- app->pipeline = pipeline = gst_element_factory_make ("playbin2", "playbin2");
+ app->pipeline = pipeline = gst_element_factory_make ("playbin", "playbin");
g_assert (pipeline);
playbin_set_uri (pipeline, location,
Pipeline;
static const Pipeline pipelines[] = {
- {"playbin2", make_playbin2_pipeline},
+ {"playbin", make_playbin_pipeline},
#ifndef GST_DISABLE_PARSE
{"parse-launch", make_parselaunch_pipeline},
#endif
format = seek_formats[i].format;
- if (gst_element_query_position (app->pipeline, &format, &position) &&
- gst_element_query_duration (app->pipeline, &format, &total)) {
+ if (gst_element_query_position (app->pipeline, format, &position) &&
+ gst_element_query_duration (app->pipeline, format, &total)) {
g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
seek_formats[i].name, position, total);
} else {
//position = 0;
//duration = 0;
- gst_element_query_position (app->pipeline, &format, &app->position);
- gst_element_query_duration (app->pipeline, &format, &app->duration);
+ gst_element_query_position (app->pipeline, format, &app->position);
+ gst_element_query_duration (app->pipeline, format, &app->duration);
if (app->stats)
query_positions (app);
if (app->seek_format) {
format = app->seek_format->value;
seek_pos = seek_dur = -1;
- gst_element_query_position (app->pipeline, &format, &seek_pos);
- gst_element_query_duration (app->pipeline, &format, &seek_dur);
+ gst_element_query_position (app->pipeline, format, &seek_pos);
+ gst_element_query_duration (app->pipeline, format, &seek_dur);
str = g_strdup_printf ("%" G_GINT64_FORMAT, seek_pos);
gtk_label_set_text (GTK_LABEL (app->seek_position_label), str);
static void
pause_cb (GtkButton * button, SeekApp * app)
{
- g_static_mutex_lock (&app->state_mutex);
+ g_mutex_lock (&app->state_mutex);
if (app->state != GST_STATE_PAUSED) {
GstStateChangeReturn ret;
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
"Paused");
}
- g_static_mutex_unlock (&app->state_mutex);
+ g_mutex_unlock (&app->state_mutex);
return;
failed:
{
- g_static_mutex_unlock (&app->state_mutex);
+ g_mutex_unlock (&app->state_mutex);
g_print ("PAUSE failed\n");
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
"Pause failed");
g_print ("READY pipeline\n");
gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
- g_static_mutex_lock (&app->state_mutex);
+ g_mutex_lock (&app->state_mutex);
ret = gst_element_set_state (app->pipeline, STOP_STATE);
if (ret == GST_STATE_CHANGE_FAILURE)
goto failed;
if (app->pipeline_type == 0)
clear_streams (app);
- g_static_mutex_unlock (&app->state_mutex);
+ g_mutex_unlock (&app->state_mutex);
gtk_widget_set_sensitive (GTK_WIDGET (app->seek_scale), TRUE);
for (i = 0; i < G_N_ELEMENTS (app->navigation_buttons); i++)
failed:
{
- g_static_mutex_unlock (&app->state_mutex);
+ g_mutex_unlock (&app->state_mutex);
g_print ("STOP failed\n");
gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
"Stop failed");
/* remove previous info */
clear_streams (app);
- /* here we get and update the different streams detected by playbin2 */
+ /* here we get and update the different streams detected by playbin */
g_object_get (app->pipeline, "n-video", &app->n_video, NULL);
g_object_get (app->pipeline, "n-audio", &app->n_audio, NULL);
g_object_get (app->pipeline, "n-text", &app->n_text, NULL);
app->vis_entries = g_array_new (FALSE, FALSE, sizeof (VisEntry));
- list = gst_registry_feature_filter (gst_registry_get_default (),
+ list = gst_registry_feature_filter (gst_registry_get (),
filter_vis_features, FALSE, NULL);
for (walk = list; walk; walk = g_list_next (walk)) {
if (!element)
return;
- /* set vis plugin for playbin2 */
+ /* set vis plugin for playbin */
g_object_set (app->pipeline, "vis-plugin", element, NULL);
}
}
static void
shot_cb (GtkButton * button, SeekApp * app)
{
- GstBuffer *buffer;
+ GstSample *sample = NULL;
GstCaps *caps;
+ GST_DEBUG ("taking snapshot");
+
/* convert to our desired format (RGB24) */
- caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24,
+ caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING, "RGB",
/* Note: we don't ask for a specific width/height here, so that
* videoscale can adjust dimensions from a non-1/1 pixel aspect
* ratio to a 1/1 pixel-aspect-ratio */
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
- "endianness", G_TYPE_INT, G_BIG_ENDIAN,
- "red_mask", G_TYPE_INT, 0xff0000,
- "green_mask", G_TYPE_INT, 0x00ff00,
- "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
-
- /* convert the latest frame to the requested format */
- g_signal_emit_by_name (app->pipeline, "convert-frame", caps, &buffer);
+ "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
+
+ /* convert the latest sample to the requested format */
+ g_signal_emit_by_name (app->pipeline, "convert-sample", caps, &sample);
gst_caps_unref (caps);
- if (buffer) {
+ if (sample) {
+ GstBuffer *buffer;
GstCaps *caps;
GstStructure *s;
gboolean res;
gint width, height;
GdkPixbuf *pixbuf;
GError *error = NULL;
+ GstMapInfo map;
/* get the snapshot buffer format now. We set the caps on the appsink so
* that it can only be an rgb buffer. The only thing we have not specified
* on the caps is the height, which is dependant on the pixel-aspect-ratio
* of the source material */
- caps = GST_BUFFER_CAPS (buffer);
+ caps = gst_sample_get_caps (sample);
if (!caps) {
g_warning ("could not get snapshot format\n");
goto done;
/* create pixmap from buffer and save, gstreamer video buffers have a stride
* that is rounded up to the nearest multiple of 4 */
- pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
+ buffer = gst_sample_get_buffer (sample);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ pixbuf = gdk_pixbuf_new_from_data (map.data,
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
GST_ROUND_UP_4 (width * 3), NULL, NULL);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
+ gst_buffer_unmap (buffer, &map);
done:
- gst_buffer_unref (buffer);
+ gst_sample_unref (sample);
}
}
return;
}
- if (g_static_mutex_trylock (&app->state_mutex)) {
+ if (g_mutex_trylock (&app->state_mutex)) {
if (app->shuttling)
do_shuttle (app);
- g_static_mutex_unlock (&app->state_mutex);
+ g_mutex_unlock (&app->state_mutex);
} else {
/* ignore step messages that come while we are doing a state change */
g_print ("state change is busy\n");
GstIterator *it;
gboolean done;
GList *l;
- gpointer item;
+ GValue item = { 0, };
gchar *selected;
gint selected_idx = 0, i;
while (!done) {
switch (gst_iterator_next (it, &item)) {
- case GST_ITERATOR_OK:
- app->formats = g_list_prepend (app->formats, item);
+ case GST_ITERATOR_OK:{
+ GstFormatDefinition *def = g_value_get_pointer (&item);
+
+ app->formats = g_list_prepend (app->formats, def);
+ g_value_reset (&item);
break;
+ }
case GST_ITERATOR_RESYNC:
g_list_free (app->formats);
app->formats = NULL;
break;
}
}
+ g_value_unset (&item);
app->formats = g_list_reverse (app->formats);
gst_iterator_free (it);
find_interface_elements (SeekApp * app)
{
GstIterator *it;
- gpointer item;
+ GValue item = { 0, };
gboolean done = FALSE, hardware = FALSE;
if (app->pipeline_type == 0)
while (!done) {
switch (gst_iterator_next (it, &item)) {
case GST_ITERATOR_OK:{
- GstElement *element = GST_ELEMENT (item);
+ GstElement *element = GST_ELEMENT (g_value_get_object (&item));
if (is_valid_color_balance_element (element)) {
if (!app->colorbalance_element) {
}
}
- gst_object_unref (element);
+ g_value_reset (&item);
if (hardware && app->colorbalance_element)
done = TRUE;
}
}
+ g_value_unset (&item);
gst_iterator_free (it);
}
static GstBusSyncReply
bus_sync_handler (GstBus * bus, GstMessage * message, SeekApp * app)
{
- if ((GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) &&
- gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
+ if (gst_is_video_overlay_prepare_window_handle_message (message)) {
GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
- if (app->xoverlay_element)
- gst_object_unref (app->xoverlay_element);
- app->xoverlay_element = GST_ELEMENT (gst_object_ref (element));
+ if (app->overlay_element)
+ gst_object_unref (app->overlay_element);
+ app->overlay_element = GST_ELEMENT (gst_object_ref (element));
g_print ("got prepare-xwindow-id, setting XID %" G_GUINTPTR_FORMAT "\n",
app->embed_xid);
* shouldn't be done from a non-GUI thread without explicit locking). */
g_assert (app->embed_xid != 0);
- gst_x_overlay_set_window_handle (GST_X_OVERLAY (element), app->embed_xid);
+ gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element),
+ app->embed_xid);
find_interface_elements (app);
}
return TRUE;
}
- if (app->xoverlay_element)
- gst_x_overlay_expose (GST_X_OVERLAY (app->xoverlay_element));
+ if (app->overlay_element)
+ gst_video_overlay_expose (GST_VIDEO_OVERLAY (app->overlay_element));
return FALSE;
}
#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
if (app->pipeline_type != 0) {
- /* handle prepare-xwindow-id element message synchronously, but only for non-playbin2 */
+ /* handle prepare-xwindow-id element message synchronously, but only for non-playbin */
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, app);
}
#endif
GtkWidget *volume_label, *shot_button;
GtkWidget *label;
- playbin = gtk_expander_new ("playbin2 options");
- /* the playbin2 panel controls for the video/audio/subtitle tracks */
+ playbin = gtk_expander_new ("playbin options");
+ /* the playbin panel controls for the video/audio/subtitle tracks */
panel = gtk_hbox_new (FALSE, 0);
app->video_combo = gtk_combo_box_text_new ();
app->audio_combo = gtk_combo_box_text_new ();
G_CALLBACK (audio_combo_cb), app);
g_signal_connect (G_OBJECT (app->text_combo), "changed",
G_CALLBACK (text_combo_cb), app);
- /* playbin2 panel for flag checkboxes and volume/mute */
+ /* playbin panel for flag checkboxes and volume/mute */
boxes = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (boxes), 2);
gtk_grid_set_row_homogeneous (GTK_GRID (boxes), FALSE);
G_CALLBACK (mute_toggle_cb), app);
g_signal_connect (G_OBJECT (app->volume_spinbutton), "value-changed",
G_CALLBACK (volume_spinbutton_changed_cb), app);
- /* playbin2 panel for snapshot */
+ /* playbin panel for snapshot */
boxes2 = gtk_hbox_new (FALSE, 0);
shot_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
gtk_widget_set_tooltip_text (shot_button,
app->need_streams = TRUE;
- g_static_mutex_init (&app->state_mutex);
+ g_mutex_init (&app->state_mutex);
app->play_rate = 1.0;
}
g_list_free (app->formats);
- g_static_mutex_free (&app->state_mutex);
+ g_mutex_clear (&app->state_mutex);
- if (app->xoverlay_element)
- gst_object_unref (app->xoverlay_element);
+ if (app->overlay_element)
+ gst_object_unref (app->overlay_element);
if (app->navigation_element)
gst_object_unref (app->navigation_element);
set_defaults (&app);
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- if (!g_thread_supported ())
- g_thread_init (NULL);
-#endif
-
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_assert (app.embed_xid != 0);
if (app.pipeline_type == 0) {
- gst_x_overlay_set_window_handle (GST_X_OVERLAY (app.pipeline),
+ gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (app.pipeline),
app.embed_xid);
}
#endif