[totem] Port to GStreamer 1.0
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Port to GStreamer 1.0
- Date: Thu, 12 Jul 2012 16:47:52 +0000 (UTC)
commit 64f8b8e163cd804240a1427205c4bedb39793e59
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jul 4 19:05:19 2012 +0100
Port to GStreamer 1.0
Thumbnailer, audio preview, properties page and totem tested and working.
https://bugzilla.gnome.org/show_bug.cgi?id=674078
configure.in | 34 +++---
src/backend/bacon-video-widget-gst-0.10.c | 111 +++++++++----------
.../bacon-video-widget-gst-missing-plugins.c | 10 ++-
src/gst/totem-gst-helpers.c | 77 +++++++++-----
src/gst/totem-gst-helpers.h | 4 +-
src/test-properties-page.c | 1 +
src/totem-audio-preview.c | 4 +-
src/totem-menu.c | 1 +
src/totem-properties-main.c | 1 +
src/totem-properties-view.c | 3 +
src/totem-video-thumbnailer.c | 9 +-
11 files changed, 145 insertions(+), 110 deletions(-)
---
diff --git a/configure.in b/configure.in
index d11e981..1eeed8b 100644
--- a/configure.in
+++ b/configure.in
@@ -77,7 +77,7 @@ AC_SUBST(PLUGINDIR)
dnl the two versions here implicate the gstreamer core and gst-plugins
dnl release versions.
-GST_MAJORMINOR=0.10
+GST_MAJORMINOR=1.0
GST_REQS=0.10.30
GST_PLUG_BASE_REQS=0.10.36.1
GSTPLUG_REQS=0.10.30
@@ -109,44 +109,44 @@ AC_ARG_ENABLE([easy-codec-installation],
AC_MSG_RESULT([$enable_easy_codec_installation])
if test "x$enable_easy_codec_installation" != "xno"; then
- PKG_CHECK_MODULES(MISSING_PLUGINS, gstreamer-pbutils-0.10,
+ PKG_CHECK_MODULES(MISSING_PLUGINS, gstreamer-pbutils-1.0,
[
AC_DEFINE([ENABLE_MISSING_PLUGIN_INSTALLATION], 1,
[Whether we can and want to do installation of missing plugins])
])
fi
-MM="gstreamer-0.10 >= $GST_REQS gstreamer-base-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GST_PLUG_BASE_REQS gstreamer-tag-0.10 >= $GSTPLUG_REQS gstreamer-audio-0.10 clutter-1.0 >= $CLUTTER_REQS clutter-gst-1.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 gsettings-desktop-schemas"
+MM="gstreamer-1.0 >= $GST_REQS gstreamer-base-1.0 >= $GST_REQS gstreamer-plugins-base-1.0 >= $GST_PLUG_BASE_REQS gstreamer-tag-1.0 >= $GSTPLUG_REQS gstreamer-audio-1.0 gstreamer-video-1.0 clutter-1.0 >= $CLUTTER_REQS clutter-gst-2.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 gsettings-desktop-schemas"
PKG_CHECK_MODULES(GST, $MM)
dnl Check for required plugins
-gst010_toolsdir=`$PKG_CONFIG --variable=toolsdir gstreamer-0.10`
-gst010_inspect="$gst010_toolsdir/gst-inspect-0.10"
+gst010_toolsdir=`$PKG_CONFIG --variable=toolsdir gstreamer-1.0`
+gst010_inspect="$gst010_toolsdir/gst-inspect-1.0"
dnl Give error and exit if we don't have the gst_inspect tool
-AC_MSG_CHECKING([GStreamer 0.10 inspection tool])
+AC_MSG_CHECKING([GStreamer 1.0 inspection tool])
if test -r "$gst010_inspect"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([
- Cannot find required GStreamer-0.10 tool 'gst-inspect-0.10'.
- It should be part of gstreamer-0_10-utils. Please install it.
+ Cannot find required GStreamer-1.0 tool 'gst-inspect-1.0'.
+ It should be part of gstreamer-1_0-utils. Please install it.
])
fi
dnl Check for elements from gst-plugins-base
dnl Set plugins which contain below elements
-set -- playback ffmpegcolorspace videoscale
-for base_element in playbin2 ffmpegcolorspace videoscale
+set -- playback videoscale
+for base_element in playbin videoscale
do
- AC_MSG_CHECKING([GStreamer 0.10 $base_element element])
+ AC_MSG_CHECKING([GStreamer 1.0 $base_element element])
if $gst010_inspect $base_element >/dev/null 2>/dev/null; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([
- Cannot find required GStreamer-0.10 plugin '$1'.
+ Cannot find required GStreamer-1.0 plugin '$1'.
It should be part of gst-plugins-base. Please install it.
])
@@ -159,13 +159,13 @@ dnl Set plugins which contain below elements
set -- autodetect goom
for good_element in autoaudiosink goom
do
- AC_MSG_CHECKING([GStreamer 0.10 $good_element element])
+ AC_MSG_CHECKING([GStreamer 1.0 $good_element element])
if $gst010_inspect $good_element >/dev/null 2>/dev/null; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([
- Cannot find required GStreamer-0.10 plugin '$1'.
+ Cannot find required GStreamer-1.0 plugin '$1'.
It should be part of gst-plugins-good. Please install it.
])
fi
@@ -177,13 +177,13 @@ dnl Set plugins which contain below elements
set -- soundtouch
for bad_element in pitch
do
- AC_MSG_CHECKING([GStreamer 0.10 $bad_element element])
+ AC_MSG_CHECKING([GStreamer 1.0 $bad_element element])
if $gst010_inspect $bad_element >/dev/null 2>/dev/null; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([
- Cannot find required GStreamer-0.10 plugin '$1'.
+ Cannot find required GStreamer-1.0 plugin '$1'.
It should be part of gst-plugins-bad. Please install it.
])
fi
@@ -243,7 +243,7 @@ PKG_CHECK_MODULES([DEPENDENCY],[
gdk-x11-3.0 >= $GTK_REQS
gmodule-2.0
totem-plparser >= $TOTEM_PLPARSER_REQS
- gstreamer-tag-0.10 >= 0.10.26
+ gstreamer-tag-1.0 >= 0.10.26
clutter-gtk-1.0 >= $CLUTTER_GTK_REQS
cairo])
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 1782bf7..3fdd808 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -43,19 +43,21 @@
#include <config.h>
+#define GST_USE_UNSTABLE_API 1
+
#include <gst/gst.h>
/* GStreamer Interfaces */
-#include <gst/interfaces/navigation.h>
-#include <gst/interfaces/colorbalance.h>
+#include <gst/video/navigation.h>
+#include <gst/video/colorbalance.h>
/* for detecting sources of errors */
#include <gst/video/gstvideosink.h>
#include <gst/video/video.h>
-#include <gst/audio/gstbaseaudiosink.h>
+#include <gst/audio/gstaudiosink.h>
/* for pretty multichannel strings */
-#include <gst/audio/multichannel.h>
+#include <gst/audio/audio-channels.h>
/* for the volume property */
-#include <gst/interfaces/streamvolume.h>
+#include <gst/audio/streamvolume.h>
/* for missing decoder/demuxer detection */
#include <gst/pbutils/pbutils.h>
@@ -1206,12 +1208,14 @@ bvw_update_stream_info (BaconVideoWidget *bvw)
static void
bvw_handle_application_message (BaconVideoWidget *bvw, GstMessage *msg)
{
+ const GstStructure *structure;
const gchar *msg_name;
- msg_name = gst_structure_get_name (msg->structure);
+ structure = gst_message_get_structure (msg);
+ msg_name = gst_structure_get_name (structure);
g_return_if_fail (msg_name != NULL);
- GST_DEBUG ("Handling application message: %" GST_PTR_FORMAT, msg->structure);
+ GST_DEBUG ("Handling application message: %" GST_PTR_FORMAT, structure);
if (strcmp (msg_name, "stream-changed") == 0) {
bvw_update_stream_info (bvw);
@@ -1290,14 +1294,17 @@ mount_cb (GObject *obj, GAsyncResult *res, gpointer user_data)
static void
bvw_handle_element_message (BaconVideoWidget *bvw, GstMessage *msg)
{
+ const GstStructure *structure;
const gchar *type_name = NULL;
gchar *src_name;
src_name = gst_object_get_name (msg->src);
- if (msg->structure)
- type_name = gst_structure_get_name (msg->structure);
- GST_DEBUG ("from %s: %" GST_PTR_FORMAT, src_name, msg->structure);
+ structure = gst_message_get_structure (msg);
+ if (structure)
+ type_name = gst_structure_get_name (structure);
+
+ GST_DEBUG ("from %s: %" GST_PTR_FORMAT, src_name, structure);
if (type_name == NULL)
goto unhandled;
@@ -1305,7 +1312,7 @@ bvw_handle_element_message (BaconVideoWidget *bvw, GstMessage *msg)
if (strcmp (type_name, "redirect") == 0) {
const gchar *new_location;
- new_location = gst_structure_get_string (msg->structure, "new-location");
+ new_location = gst_structure_get_string (structure, "new-location");
GST_DEBUG ("Got redirect to '%s'", GST_STR_NULL (new_location));
if (new_location && *new_location) {
@@ -1319,7 +1326,7 @@ bvw_handle_element_message (BaconVideoWidget *bvw, GstMessage *msg)
if (!bvw->priv->buffering) {
gint percent = 0;
- if (gst_structure_get_int (msg->structure, "percent", &percent)) {
+ if (gst_structure_get_int (structure, "percent", &percent)) {
gdouble fraction = (gdouble) percent / 100.0;
g_signal_emit (bvw, bvw_signals[SIGNAL_BUFFERING], 0, fraction);
}
@@ -1351,7 +1358,7 @@ bvw_handle_element_message (BaconVideoWidget *bvw, GstMessage *msg)
if (toplevel == GTK_WIDGET (bvw) || !GTK_IS_WINDOW (toplevel))
toplevel = NULL;
- val = gst_structure_get_value (msg->structure, "file");
+ val = gst_structure_get_value (structure, "file");
if (val == NULL)
goto done;
@@ -2319,7 +2326,7 @@ bvw_set_referrer_on_element (BaconVideoWidget * bvw, GstElement * element)
g_object_get (element, "extra-headers", &extra_headers, NULL);
if (extra_headers == NULL) {
- extra_headers = gst_structure_empty_new ("extra-headers");
+ extra_headers = gst_structure_new_empty ("extra-headers");
}
g_assert (GST_IS_STRUCTURE (extra_headers));
@@ -2379,19 +2386,18 @@ playbin_deep_notify_cb (GstObject *gstobject,
static gboolean
bvw_query_timeout (BaconVideoWidget *bvw)
{
- GstFormat fmt = GST_FORMAT_TIME;
gint64 pos = -1, len = -1;
/* check length/pos of stream */
- if (gst_element_query_duration (bvw->priv->play, &fmt, &len)) {
- if (len != -1 && fmt == GST_FORMAT_TIME)
+ if (gst_element_query_duration (bvw->priv->play, GST_FORMAT_TIME, &len)) {
+ if (len != -1)
bvw->priv->stream_length = len / GST_MSECOND;
} else {
GST_DEBUG ("could not get duration");
}
- if (gst_element_query_position (bvw->priv->play, &fmt, &pos)) {
- if (pos != -1 && fmt == GST_FORMAT_TIME) {
+ if (gst_element_query_position (bvw->priv->play, GST_FORMAT_TIME, &pos)) {
+ if (pos != -1) {
got_time_tick (GST_ELEMENT (bvw->priv->play), pos, bvw);
}
} else {
@@ -2473,7 +2479,7 @@ caps_set (GObject * obj,
GstStructure *s;
GstCaps *caps;
- if (!(caps = gst_pad_get_negotiated_caps (pad)))
+ if (!(caps = gst_pad_get_current_caps (pad)))
return;
/* Get video decoder caps */
@@ -2549,7 +2555,7 @@ parse_stream_info (BaconVideoWidget *bvw)
if (videopad) {
GstCaps *caps;
- if ((caps = gst_pad_get_negotiated_caps (videopad))) {
+ if ((caps = gst_pad_get_current_caps (videopad))) {
caps_set (G_OBJECT (videopad), NULL, bvw);
gst_caps_unref (caps);
}
@@ -2573,7 +2579,7 @@ playbin_stream_changed_cb (GstElement * obj, gpointer data)
/* we're being called from the streaming thread, so don't do anything here */
GST_LOG ("streams have changed");
msg = gst_message_new_application (GST_OBJECT (bvw->priv->play),
- gst_structure_new ("stream-changed", NULL));
+ gst_structure_new_empty ("stream-changed"));
gst_element_post_message (bvw->priv->play, msg);
}
@@ -3154,7 +3160,7 @@ set_audio_filter (BaconVideoWidget *bvw)
{
gint channels;
GstCaps *caps, *res;
- GstPad *pad;
+ GstPad *pad, *peer_pad;
/* reset old */
g_object_set (bvw->priv->audio_capsfilter, "caps", NULL, NULL);
@@ -3163,9 +3169,12 @@ set_audio_filter (BaconVideoWidget *bvw)
/* Start with what the audio sink supports, but limit the allowed
* channel count to our speaker output configuration */
pad = gst_element_get_static_pad (bvw->priv->audio_capsfilter, "src");
- caps = gst_pad_peer_get_caps (pad);
+ peer_pad = gst_pad_get_peer (pad);
gst_object_unref (pad);
+ caps = gst_pad_get_current_caps (peer_pad);
+ gst_object_unref (peer_pad);
+
if ((channels = get_num_audio_channels (bvw)) == -1)
return;
@@ -3952,7 +3961,7 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw,
bvw_set_playback_direction (bvw, TRUE);
fmt = gst_format_get_by_nick (fmt_name);
- if (gst_element_query_position (bvw->priv->play, &fmt, &val)) {
+ if (gst_element_query_position (bvw->priv->play, fmt, &val)) {
GST_DEBUG ("current %s is: %" G_GINT64_FORMAT, fmt_name, val);
val += dir;
GST_DEBUG ("seeking to %s: %" G_GINT64_FORMAT, fmt_name, val);
@@ -4482,7 +4491,7 @@ setup_vis (BaconVideoWidget * bvw)
}
/* We created the bin, now ref and sink to make sure we own it */
gst_object_ref (vis_bin);
- gst_object_sink (vis_bin);
+ gst_object_ref_sink (vis_bin);
gst_bin_add_many (GST_BIN (vis_bin), vis_element, vis_capsfilter, NULL);
@@ -4595,7 +4604,7 @@ filter_features (GstPluginFeature * feature, gpointer data)
static GList *
get_visualization_features (void)
{
- return gst_registry_feature_filter (gst_registry_get_default (),
+ return gst_registry_feature_filter (gst_registry_get (),
filter_features, FALSE, NULL);
}
@@ -5158,10 +5167,9 @@ bacon_video_widget_get_stream_length (BaconVideoWidget * bvw)
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), -1);
if (bvw->priv->stream_length == 0 && bvw->priv->play != NULL) {
- GstFormat fmt = GST_FORMAT_TIME;
gint64 len = -1;
- if (gst_element_query_duration (bvw->priv->play, &fmt, &len) && len != -1) {
+ if (gst_element_query_duration (bvw->priv->play, GST_FORMAT_TIME, &len) && len != -1) {
bvw->priv->stream_length = len / GST_MSECOND;
}
}
@@ -5315,7 +5323,7 @@ bvw_get_caps_of_current_stream (BaconVideoWidget * bvw,
g_free (lower);
if (current != NULL) {
- caps = gst_pad_get_negotiated_caps (current);
+ caps = gst_pad_get_current_caps (current);
gst_object_unref (current);
}
GST_LOG ("current %s stream caps: %" GST_PTR_FORMAT, stream_type, caps);
@@ -5325,26 +5333,20 @@ bvw_get_caps_of_current_stream (BaconVideoWidget * bvw,
static gboolean
audio_caps_have_LFE (GstStructure * s)
{
- GstAudioChannelPosition *positions;
- gint i, channels;
+ guint64 mask;
+ int channels;
- if (!gst_structure_get_value (s, "channel-positions") ||
- !gst_structure_get_int (s, "channels", &channels)) {
+ if (!gst_structure_get_int (s, "channels", &channels) ||
+ channels == 0)
return FALSE;
- }
- positions = gst_audio_get_channel_positions (s);
- if (positions == NULL)
+ if (!gst_structure_get (s, "channel-mask", GST_TYPE_BITMASK, &mask, NULL))
return FALSE;
- for (i = 0; i < channels; ++i) {
- if (positions[i] == GST_AUDIO_CHANNEL_POSITION_LFE) {
- g_free (positions);
- return TRUE;
- }
- }
+ if (mask & GST_AUDIO_CHANNEL_POSITION_LFE1 ||
+ mask & GST_AUDIO_CHANNEL_POSITION_LFE2)
+ return TRUE;
- g_free (positions);
return FALSE;
}
@@ -5825,14 +5827,12 @@ bvw_set_playback_direction (BaconVideoWidget *bvw, gboolean forward)
if (forward == FALSE) {
GstEvent *event;
- GstFormat fmt;
gint64 cur = 0;
- fmt = GST_FORMAT_TIME;
- if (gst_element_query_position (bvw->priv->play, &fmt, &cur)) {
+ if (gst_element_query_position (bvw->priv->play, GST_FORMAT_TIME, &cur)) {
GST_DEBUG ("Setting playback direction to reverse at %"G_GINT64_FORMAT"", cur);
event = gst_event_new_seek (REVERSE_RATE,
- fmt, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
GST_SEEK_TYPE_SET, cur);
if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
@@ -5848,15 +5848,13 @@ bvw_set_playback_direction (BaconVideoWidget *bvw, gboolean forward)
}
} else {
GstEvent *event;
- GstFormat fmt;
gint64 cur = 0;
- fmt = GST_FORMAT_TIME;
cur = 0;
- if (gst_element_query_position (bvw->priv->play, &fmt, &cur)) {
+ if (gst_element_query_position (bvw->priv->play, GST_FORMAT_TIME, &cur)) {
GST_DEBUG ("Setting playback direction to forward at %"G_GINT64_FORMAT"", cur);
event = gst_event_new_seek (FORWARD_RATE,
- fmt, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
GST_SEEK_TYPE_SET, cur,
GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
@@ -5915,7 +5913,7 @@ bacon_video_widget_initable_init (GInitable *initable,
gst_pb_utils_init ();
/* Instantiate all the fallible plugins */
- bvw->priv->play = element_make_or_warn ("playbin2", "play");
+ bvw->priv->play = element_make_or_warn ("playbin", "play");
bvw->priv->audio_pitchcontrol = element_make_or_warn ("pitch", "audiopitch");
video_sink = element_make_or_warn ("cluttersink", "video-sink");
audio_sink = element_make_or_warn ("autoaudiosink", "audio-sink");
@@ -6103,7 +6101,6 @@ bacon_video_widget_set_rate (BaconVideoWidget *bvw,
{
GstEvent *event;
gboolean retval = FALSE;
- GstFormat fmt;
gint64 cur;
gfloat pitch, ratio;
@@ -6117,12 +6114,10 @@ bacon_video_widget_set_rate (BaconVideoWidget *bvw,
return TRUE;
ratio = new_rate / bvw->priv->rate;
- fmt = GST_FORMAT_TIME;
-
- if (gst_element_query_position (bvw->priv->play, &fmt, &cur)) {
+ if (gst_element_query_position (bvw->priv->play, GST_FORMAT_TIME, &cur)) {
GST_DEBUG ("Setting new rate at %"G_GINT64_FORMAT"", cur);
event = gst_event_new_seek (new_rate,
- fmt, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
GST_SEEK_TYPE_SET, cur,
GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
diff --git a/src/backend/bacon-video-widget-gst-missing-plugins.c b/src/backend/bacon-video-widget-gst-missing-plugins.c
index bbe54f2..871402a 100644
--- a/src/backend/bacon-video-widget-gst-missing-plugins.c
+++ b/src/backend/bacon-video-widget-gst-missing-plugins.c
@@ -23,6 +23,8 @@
#include "config.h"
#include "bacon-video-widget-gst-missing-plugins.h"
+
+#define GST_USE_UNSTABLE_API 1
#include <gst/gst.h> /* for gst_registry_update and functions in bacon_video_widget_gst_missing_plugins_blacklist */
#ifdef ENABLE_MISSING_PLUGIN_INSTALLATION
@@ -349,13 +351,17 @@ void
bacon_video_widget_gst_missing_plugins_blacklist (void)
{
const gchar *blacklisted_elements[] = { "ffdemux_flv", "avdemux_flv" };
+ GstRegistry *registry;
guint i;
+ registry = gst_registry_get ();
+
for (i = 0; i < G_N_ELEMENTS (blacklisted_elements); ++i) {
GstPluginFeature *feature;
- feature = gst_default_registry_find_feature (blacklisted_elements[i],
- GST_TYPE_ELEMENT_FACTORY);
+ feature = gst_registry_find_feature (registry,
+ blacklisted_elements[i],
+ GST_TYPE_ELEMENT_FACTORY);
if (feature)
gst_plugin_feature_set_rank (feature, GST_RANK_NONE);
diff --git a/src/gst/totem-gst-helpers.c b/src/gst/totem-gst-helpers.c
index 7926c24..17b2f05 100644
--- a/src/gst/totem-gst-helpers.c
+++ b/src/gst/totem-gst-helpers.c
@@ -30,9 +30,11 @@
*
*/
-#include <gst/tag/tag.h>
#include "totem-gst-helpers.h"
+#include <gst/tag/tag.h>
+#include <gst/video/video-format.h>
+
void
totem_gst_message_print (GstMessage *msg,
GstElement *play,
@@ -73,26 +75,27 @@ totem_gst_message_print (GstMessage *msg,
static void
destroy_pixbuf (guchar *pix, gpointer data)
{
- gst_buffer_unref (GST_BUFFER (data));
+ gst_sample_unref (GST_SAMPLE (data));
}
GdkPixbuf *
totem_gst_playbin_get_frame (GstElement *play)
{
GstStructure *s;
- GstBuffer *buf = NULL;
+ GstSample *sample = NULL;
GdkPixbuf *pixbuf;
- GstCaps *to_caps;
+ GstCaps *to_caps, *sample_caps;
gint outwidth = 0;
gint outheight = 0;
+ GstMemory *memory;
+ GstMapInfo info;
g_return_val_if_fail (play != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (play), NULL);
/* our desired output format (RGB24) */
- to_caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, 24,
- "depth", G_TYPE_INT, 24,
+ to_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. We also don't ask for a
@@ -100,17 +103,13 @@ totem_gst_playbin_get_frame (GstElement *play)
* necessarily match the output framerate if there's a deinterlacer
* in the pipeline. */
"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);
/* get frame */
- g_signal_emit_by_name (play, "convert-frame", to_caps, &buf);
+ g_signal_emit_by_name (play, "convert-sample", to_caps, &sample);
gst_caps_unref (to_caps);
- if (!buf) {
+ if (!sample) {
GST_DEBUG ("Could not take screenshot: %s",
"failed to retrieve or convert video frame");
g_warning ("Could not take screenshot: %s",
@@ -118,28 +117,36 @@ totem_gst_playbin_get_frame (GstElement *play)
return NULL;
}
- if (!GST_BUFFER_CAPS (buf)) {
+ sample_caps = gst_sample_get_caps (sample);
+ if (!sample_caps) {
GST_DEBUG ("Could not take screenshot: %s", "no caps on output buffer");
g_warning ("Could not take screenshot: %s", "no caps on output buffer");
return NULL;
}
- GST_DEBUG ("frame caps: %" GST_PTR_FORMAT, GST_BUFFER_CAPS (buf));
+ GST_DEBUG ("frame caps: %" GST_PTR_FORMAT, sample_caps);
- s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
+ s = gst_caps_get_structure (sample_caps, 0);
gst_structure_get_int (s, "width", &outwidth);
gst_structure_get_int (s, "height", &outheight);
- g_return_val_if_fail (outwidth > 0 && outheight > 0, NULL);
+ if (outwidth <= 0 || outheight <= 0)
+ goto done;
+
+ memory = gst_buffer_get_memory (gst_sample_get_buffer (sample), 0);
+ gst_memory_map (memory, &info, GST_MAP_READ);
/* create pixbuf from that - use our own destroy function */
- pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buf),
+ pixbuf = gdk_pixbuf_new_from_data (info.data,
GDK_COLORSPACE_RGB, FALSE, 8, outwidth, outheight,
- GST_ROUND_UP_4 (outwidth * 3), destroy_pixbuf, buf);
+ GST_ROUND_UP_4 (outwidth * 3), destroy_pixbuf, sample);
+ gst_memory_unmap (memory, &info);
+
+done:
if (!pixbuf) {
GST_DEBUG ("Could not take screenshot: %s", "could not create pixbuf");
g_warning ("Could not take screenshot: %s", "could not create pixbuf");
- gst_buffer_unref (buf);
+ gst_sample_unref (sample);
}
return pixbuf;
@@ -151,10 +158,23 @@ totem_gst_buffer_to_pixbuf (GstBuffer *buffer)
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf = NULL;
GError *err = NULL;
+ GstMemory *memory;
+ GstMapInfo info;
+
+ memory = gst_buffer_get_memory (buffer, 0);
+ if (!memory) {
+ GST_WARNING("could not get memory for buffer");
+ return NULL;
+ }
+
+ if (!gst_memory_map (memory, &info, GST_MAP_READ)) {
+ GST_WARNING("could not map memory buffer");
+ return NULL;
+ }
loader = gdk_pixbuf_loader_new ();
- if (gdk_pixbuf_loader_write (loader, buffer->data, buffer->size, &err) &&
+ if (gdk_pixbuf_loader_write (loader, info.data, info.size, &err) &&
gdk_pixbuf_loader_close (loader, &err)) {
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (pixbuf)
@@ -165,6 +185,9 @@ totem_gst_buffer_to_pixbuf (GstBuffer *buffer)
}
g_object_unref (loader);
+
+ gst_memory_unmap (memory, &info);
+
return pixbuf;
}
@@ -176,8 +199,8 @@ totem_gst_tag_list_get_cover_real (GstTagList *tag_list)
for (i = 0; ; i++) {
const GValue *value;
- GstBuffer *buffer;
- GstStructure *caps_struct;
+ GstSample *sample;
+ const GstStructure *caps_struct;
int type;
value = gst_tag_list_get_value_index (tag_list,
@@ -186,9 +209,9 @@ totem_gst_tag_list_get_cover_real (GstTagList *tag_list)
if (value == NULL)
break;
- buffer = gst_value_get_buffer (value);
- caps_struct = gst_caps_get_structure (buffer->caps, 0);
+ sample = gst_value_get_sample (value);
+ caps_struct = gst_sample_get_info (sample);
gst_structure_get_enum (caps_struct,
"image-type",
GST_TYPE_TAG_IMAGE_TYPE,
@@ -222,9 +245,11 @@ totem_gst_tag_list_get_cover (GstTagList *tag_list)
if (cover_value) {
GstBuffer *buffer;
+ GstSample *sample;
GdkPixbuf *pixbuf;
- buffer = gst_value_get_buffer (cover_value);
+ sample = gst_value_get_sample (cover_value);
+ buffer = gst_sample_get_buffer (sample);
pixbuf = totem_gst_buffer_to_pixbuf (buffer);
return pixbuf;
}
diff --git a/src/gst/totem-gst-helpers.h b/src/gst/totem-gst-helpers.h
index 4fe7670..3e05b27 100644
--- a/src/gst/totem-gst-helpers.h
+++ b/src/gst/totem-gst-helpers.h
@@ -28,12 +28,14 @@
#ifndef HAVE_TOTEM_GST_HELPERS_H
#define HAVE_TOTEM_GST_HELPERS_H
+#define GST_USE_UNSTABLE_API 1
+
#include <gst/gst.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
G_BEGIN_DECLS
-/* GstPlayFlags flags from playbin2 */
+/* GstPlayFlags flags from playbin */
typedef enum {
GST_PLAY_FLAG_VIDEO = (1 << 0),
GST_PLAY_FLAG_AUDIO = (1 << 1),
diff --git a/src/test-properties-page.c b/src/test-properties-page.c
index bfbb6a8..8dd3f2e 100644
--- a/src/test-properties-page.c
+++ b/src/test-properties-page.c
@@ -27,6 +27,7 @@
#include <config.h>
#include <string.h>
+#define GST_USE_UNSTABLE_API 1
#include <gst/gst.h>
#include <glib/gi18n-lib.h>
#include "totem-properties-view.h"
diff --git a/src/totem-audio-preview.c b/src/totem-audio-preview.c
index 2cf1996..57b9402 100644
--- a/src/totem-audio-preview.c
+++ b/src/totem-audio-preview.c
@@ -128,7 +128,7 @@ setup_errors (GstElement *play)
GstBus *bus;
bus = gst_element_get_bus (play);
- gst_bus_set_sync_handler (bus, (GstBusSyncHandler) error_handler, play);
+ gst_bus_set_sync_handler (bus, (GstBusSyncHandler) error_handler, play, NULL);
}
static void
@@ -198,7 +198,7 @@ int main (int argc, char **argv)
return 1;
}
- play = gst_element_factory_make ("playbin2", "play");
+ play = gst_element_factory_make ("playbin", "play");
setup_play (play);
setup_filename (play);
setup_errors (play);
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 89e7320..1293ed2 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#define GST_USE_UNSTABLE_API 1
#include <gst/tag/tag.h>
#include <string.h>
#include <libpeas-gtk/peas-gtk-plugin-manager.h>
diff --git a/src/totem-properties-main.c b/src/totem-properties-main.c
index c73535a..7d6a948 100644
--- a/src/totem-properties-main.c
+++ b/src/totem-properties-main.c
@@ -27,6 +27,7 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n-lib.h>
+#define GST_USE_UNSTABLE_API 1
#include <gst/gst.h>
#include "totem-properties-view.h"
diff --git a/src/totem-properties-view.c b/src/totem-properties-view.c
index a49c061..7dc1070 100644
--- a/src/totem-properties-view.c
+++ b/src/totem-properties-view.c
@@ -30,6 +30,9 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
+
+#define GST_USE_UNSTABLE_API 1
+#include <gst/tag/tag.h>
#include <gst/pbutils/pbutils.h>
#include "totem-properties-view.h"
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 010ac22..b40fe9a 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -27,6 +27,8 @@
#include "config.h"
+#define GST_USE_UNSTABLE_API 1
+
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -185,7 +187,7 @@ thumb_app_set_error_handler (ThumbApp *app)
GstBus *bus;
bus = gst_element_get_bus (app->play);
- gst_bus_set_sync_handler (bus, (GstBusSyncHandler) error_handler, app->play);
+ gst_bus_set_sync_handler (bus, (GstBusSyncHandler) error_handler, app->play, NULL);
}
static void
@@ -225,10 +227,9 @@ thumb_app_check_for_cover (ThumbApp *app)
static gboolean
thumb_app_set_duration (ThumbApp *app)
{
- GstFormat fmt = GST_FORMAT_TIME;
gint64 len = -1;
- if (gst_element_query_duration (app->play, &fmt, &len) && len != -1) {
+ if (gst_element_query_duration (app->play, GST_FORMAT_TIME, &len) && len != -1) {
app->duration = len / GST_MSECOND;
return TRUE;
}
@@ -304,7 +305,7 @@ thumb_app_setup_play (ThumbApp *app)
GstElement *play;
GstElement *audio_sink, *video_sink;
- play = gst_element_factory_make ("playbin2", "play");
+ play = gst_element_factory_make ("playbin", "play");
audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");
video_sink = gst_element_factory_make ("fakesink", "video-fake-sink");
g_object_set (video_sink, "sync", TRUE, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]