diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-07-13 11:52:18 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-07-13 13:14:32 +0100 |
commit | de7fca7706bab4a1f6c9eaf2c23b7371839a5ffa (patch) | |
tree | 4bbf43d178c2ac6a9e1aa25ae987ec466dd75cbc /src | |
parent | 9e7f5c3e89184c4d5e71cbb5f709eee919553c64 (diff) | |
download | totem-de7fca7706bab4a1f6c9eaf2c23b7371839a5ffa.tar.gz |
build: Fix pkg-config usage
We shouldn't be concatenating outputs from pkg-config, it ends up
listing libraries twice and making a mess.
This commit also cleans up the dependencies for the thumbnailer,
audio preview and nautilus tabs, as they don't need clutter for
example.
https://bugzilla.gnome.org/show_bug.cgi?id=679461
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 69 | ||||
-rw-r--r-- | src/backend/Makefile.am | 24 | ||||
-rw-r--r-- | src/backend/bacon-video-widget.c | 1 | ||||
-rw-r--r-- | src/backend/video-utils.c | 35 | ||||
-rw-r--r-- | src/backend/video-utils.h | 2 | ||||
-rw-r--r-- | src/gst/Makefile.am | 63 | ||||
-rw-r--r-- | src/gst/totem-gst-helpers.c | 185 | ||||
-rw-r--r-- | src/gst/totem-gst-helpers.h | 5 | ||||
-rw-r--r-- | src/gst/totem-gst-pixbuf-helpers.c | 225 | ||||
-rw-r--r-- | src/gst/totem-gst-pixbuf-helpers.h | 44 | ||||
-rw-r--r-- | src/gst/totem-time-helpers.c | 63 | ||||
-rw-r--r-- | src/gst/totem-time-helpers.h | 35 | ||||
-rw-r--r-- | src/plugins/Makefile.plugins | 8 | ||||
-rw-r--r-- | src/plugins/grilo/Makefile.am | 6 | ||||
-rw-r--r-- | src/plugins/grilo/totem-grilo.c | 2 | ||||
-rw-r--r-- | src/plugins/skipto/totem-skipto.c | 1 | ||||
-rw-r--r-- | src/plugins/skipto/totem-time-entry.c | 2 | ||||
-rw-r--r-- | src/properties/Makefile.am | 2 | ||||
-rw-r--r-- | src/totem-statusbar.c | 2 | ||||
-rw-r--r-- | src/totem-time-label.c | 2 | ||||
-rw-r--r-- | src/totem-video-thumbnailer.c | 2 |
21 files changed, 468 insertions, 310 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 793cc4851..1d54d7184 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,13 +46,16 @@ libtotem_player_la_SOURCES = \ totem-time-label.c \ totem-time-label.h -libtotem_player_la_CPPFLAGS = \ +libtotem_player_la_CPPFLAGS = \ -DG_LOG_DOMAIN=\""Totem"\" \ $(AM_CPPFLAGS) -libtotem_player_la_LIBADD = $(DEPENDENCY_LIBS) -libtotem_player_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ +libtotem_player_la_LIBADD = \ + $(PLAYER_LIBS) \ + gst/libtotemtimehelpers.la +libtotem_player_la_CFLAGS = \ + $(LIBPLAYER_CFLAGS) \ + -I$(srcdir)/gst/ \ $(AM_CFLAGS) # Totem main library (used for main player; separate to allow gtk-doc to be used) @@ -97,9 +100,7 @@ libtotem_la_CPPFLAGS = \ $(AM_CPPFLAGS) libtotem_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(PEAS_CFLAGS) \ - $(PEASGTK_CFLAGS) \ + $(PLAYER_CFLAGS) \ $(AM_CFLAGS) libtotem_la_LDFLAGS = \ @@ -110,9 +111,7 @@ libtotem_la_LDFLAGS = \ libtotem_la_LIBADD = \ libtotem_player.la \ backend/libbaconvideowidget.la \ - $(PEAS_LIBS) \ - $(PEASGTK_LIBS) \ - $(DEPENDENCY_LIBS) + $(PLAYER_LIBS) if WITH_SMCLIENT libtotem_la_SOURCES += \ @@ -170,16 +169,13 @@ totem_CPPFLAGS = \ -DG_LOG_DOMAIN=\""Totem"\" \ $(AM_CPPFLAGS) -totem_CFLAGS = \ - $(PEAS_CFLAGS) \ - $(DEPENDENCY_CFLAGS) \ +totem_CFLAGS = \ + $(PLAYER_CFLAGS) \ $(AM_CFLAGS) -totem_LDADD = \ - libtotem.la \ - $(DEPENDENCY_LIBS) \ - $(X_LIBS) \ - $(PEAS_LIBS) +totem_LDADD = \ + libtotem.la \ + $(PLAYER_LIBS) # Totem video thumbnailer totem_video_thumbnailer_SOURCES = \ @@ -191,13 +187,15 @@ totem_video_thumbnailer_CPPFLAGS = \ -DG_LOG_DOMAIN=\""TotemVideoThumbnailer"\" \ $(AM_CPPFLAGS) -totem_video_thumbnailer_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ +totem_video_thumbnailer_CFLAGS = \ + $(THUMBNAILER_CFLAGS) \ $(AM_CFLAGS) -totem_video_thumbnailer_LDADD = \ - backend/libbaconvideowidget.la \ - $(DEPENDENCY_LIBS) +totem_video_thumbnailer_LDADD = \ + $(THUMBNAILER_LIBS) \ + gst/libtotemgstpixbufhelpers.la \ + gst/libtotemgsthelpers.la \ + gst/libtotemtimehelpers.la # Nautilus Property Page if HAVE_NAUTILUS @@ -215,20 +213,17 @@ libtotem_properties_page_la_CPPFLAGS = \ -DG_LOG_DOMAIN=\""TotemPropertiesPage"\"\ $(AM_CPPFLAGS) -libtotem_properties_page_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(NAUTILUS_CFLAGS) \ +libtotem_properties_page_la_CFLAGS = \ + $(NAUTILUS_CFLAGS) \ $(AM_CFLAGS) libtotem_properties_page_la_LDFLAGS = \ -export_dynamic -avoid-version -module -no-undefined \ $(AM_LDFLAGS) -libtotem_properties_page_la_LIBADD = \ - backend/libbaconvideowidget.la \ +libtotem_properties_page_la_LIBADD = \ properties/libbaconvideowidgetproperties.la \ libtotem_player.la \ - $(DEPENDENCY_LIBS) \ $(NAUTILUS_LIBS) noinst_PROGRAMS = test-properties-page @@ -244,8 +239,7 @@ test_properties_page_CPPFLAGS = \ -I$(top_srcdir)/src/properties \ $(AM_CPPFLAGS) -test_properties_page_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ +test_properties_page_CFLAGS = \ $(NAUTILUS_CFLAGS) \ $(AM_CFLAGS) @@ -253,7 +247,6 @@ test_properties_page_LDADD = \ backend/libbaconvideowidget.la \ properties/libbaconvideowidgetproperties.la \ libtotem_player.la \ - $(DEPENDENCY_LIBS) \ $(NAUTILUS_LIBS) endif # HAVE_NAUTILUS @@ -269,14 +262,13 @@ totem_audio_preview_CPPFLAGS = \ -DG_LOG_DOMAIN=\""TotemAudioPreview"\" \ $(AM_CPPFLAGS) -totem_audio_preview_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ +totem_audio_preview_CFLAGS = \ + $(PREVIEW_CFLAGS) \ $(AM_CFLAGS) totem_audio_preview_LDADD = \ gst/libtotemgsthelpers.la \ - backend/libbaconvideowidget.la \ - $(DEPENDENCY_LIBS) + $(PREVIEW_LIBS) # Introspection -include $(INTROSPECTION_MAKEFILE) @@ -293,9 +285,8 @@ introspection_sources = $(INST_H_FILES) $(filter %.c,$(libtotem_player_la_SOURCE Totem-1.0.gir: libtotem.la Totem_1_0_gir_INCLUDES = GLib-2.0 GObject-2.0 Gtk-3.0 TotemPlParser-1.0 Totem_1_0_gir_SCANNERFLAGS = --c-include=totem.h --pkg-export=totem -Totem_1_0_gir_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(PEAS_CFLAGS) \ +Totem_1_0_gir_CFLAGS = \ + $(PLAYER_CFLAGS) \ $(libtotem_la_CPPFLAGS) Totem_1_0_gir_LIBS = libtotem.la Totem_1_0_gir_FILES = $(introspection_sources) diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 60df37efe..8094242b6 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -11,14 +11,13 @@ bvw_test_CPPFLAGS = \ $(DISABLE_DEPRECATED) \ $(AM_CPPFLAGS) -bvw_test_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(MM_CFLAGS) \ +bvw_test_CFLAGS = \ + $(BACKEND_CFLAGS) \ $(AM_CFLAGS) -bvw_test_LDADD = \ +bvw_test_LDADD = \ libbaconvideowidget.la \ - $(DEPENDENCY_LIBS) + $(BACKEND_LIBS) # Marshallers BVW_MARSHAL_FILES = baconvideowidget-marshal.c baconvideowidget-marshal.h @@ -70,17 +69,14 @@ libbaconvideowidget_la_CPPFLAGS = \ $(DISABLE_DEPRECATED) \ $(AM_CPPFLAGS) -libbaconvideowidget_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(MM_CFLAGS) \ - $(MISSING_PLUGINS_CFLAGS) \ +libbaconvideowidget_la_CFLAGS = \ + $(BACKEND_CFLAGS) \ $(AM_CFLAGS) -libbaconvideowidget_la_LIBADD = \ - $(top_builddir)/src/gst/libtotemgsthelpers.la \ - $(MM_LIBS) \ - $(X_LIBS) \ - $(MISSING_PLUGINS_LIBS) \ +libbaconvideowidget_la_LIBADD = \ + $(top_builddir)/src/gst/libtotemgsthelpers.la \ + $(top_builddir)/src/gst/libtotemgstpixbufhelpers.la \ + $(BACKEND_LIBS) \ -lm libbaconvideowidget_la_LDFLAGS= \ diff --git a/src/backend/bacon-video-widget.c b/src/backend/bacon-video-widget.c index 7c1a676ae..17bd35423 100644 --- a/src/backend/bacon-video-widget.c +++ b/src/backend/bacon-video-widget.c @@ -84,6 +84,7 @@ #include <gdesktop-enums.h> #include "totem-gst-helpers.h" +#include "totem-gst-pixbuf-helpers.h" #include "bacon-video-widget.h" #include "bacon-video-widget-gst-missing-plugins.h" #include "bacon-video-osd-actor.h" diff --git a/src/backend/video-utils.c b/src/backend/video-utils.c index fe0093de0..05cc31191 100644 --- a/src/backend/video-utils.c +++ b/src/backend/video-utils.c @@ -29,9 +29,6 @@ #include "video-utils.h" -#include <glib/gi18n-lib.h> -#include <libintl.h> - #include <gdk/gdk.h> #include <stdlib.h> #include <unistd.h> @@ -60,38 +57,6 @@ totem_gdk_window_set_waiting_cursor (GdkWindow *window) gdk_flush (); } -char * -totem_time_to_string (gint64 msecs) -{ - int sec, min, hour, _time; - - _time = (int) (msecs / 1000); - sec = _time % 60; - _time = _time - sec; - min = (_time % (60*60)) / 60; - _time = _time - (min * 60); - hour = _time / (60*60); - - if (hour > 0) - { - /* hour:minutes:seconds */ - /* Translators: This is a time format, like "9:05:02" for 9 - * hours, 5 minutes, and 2 seconds. You may change ":" to - * the separator that your locale uses or use "%Id" instead - * of "%d" if your locale uses localized digits. - */ - return g_strdup_printf (C_("long time format", "%d:%02d:%02d"), hour, min, sec); - } - - /* minutes:seconds */ - /* Translators: This is a time format, like "5:02" for 5 - * minutes and 2 seconds. You may change ":" to the - * separator that your locale uses or use "%Id" instead of - * "%d" if your locale uses localized digits. - */ - return g_strdup_printf (C_("short time format", "%d:%02d"), min, sec); -} - static gboolean totem_ratio_fits_screen_helper (GtkWidget *video_widget, int new_w, int new_h, diff --git a/src/backend/video-utils.h b/src/backend/video-utils.h index eb3a14782..0ab73c27c 100644 --- a/src/backend/video-utils.h +++ b/src/backend/video-utils.h @@ -31,8 +31,6 @@ void totem_gdk_window_set_invisible_cursor (GdkWindow *window); void totem_gdk_window_set_waiting_cursor (GdkWindow *window); -char *totem_time_to_string (gint64 msecs); - gboolean totem_ratio_fits_screen (GtkWidget *widget, int video_width, int video_height, diff --git a/src/gst/Makefile.am b/src/gst/Makefile.am index c7cabfdb4..c5f11599b 100644 --- a/src/gst/Makefile.am +++ b/src/gst/Makefile.am @@ -1,27 +1,56 @@ -noinst_LTLIBRARIES = libtotemgsthelpers.la +noinst_LTLIBRARIES = \ + libtotemgsthelpers.la \ + libtotemgstpixbufhelpers.la \ + libtotemtimehelpers.la -libtotemgsthelpers_la_SOURCES = \ - totem-gst-helpers.c \ +libtotemgsthelpers_la_SOURCES = \ + totem-gst-helpers.c \ totem-gst-helpers.h -libtotemgsthelpers_la_CPPFLAGS = \ - -D_REENTRANT \ - $(DISABLE_DEPRECATED) \ +libtotemgsthelpers_la_CPPFLAGS = \ + -D_REENTRANT \ + $(DISABLE_DEPRECATED) \ $(AM_CPPFLAGS) -libtotemgsthelpers_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ - $(MM_CFLAGS) \ - $(MISSING_PLUGINS_CFLAGS) \ +libtotemgsthelpers_la_CFLAGS = \ + $(HELPER_CFLAGS) \ $(AM_CFLAGS) -libtotemgsthelpers_la_LIBADD = \ - $(MM_LIBS) \ - $(X_LIBS) \ - $(MISSING_PLUGINS_LIBS) \ - -lm +libtotemgsthelpers_la_LIBADD = $(HELPER_LIBS) +libtotemgsthelpers_la_LDFLAGS= -no-undefined -libtotemgsthelpers_la_LDFLAGS= \ - -no-undefined +libtotemgstpixbufhelpers_la_SOURCES = \ + totem-gst-pixbuf-helpers.c \ + totem-gst-pixbuf-helpers.h + +libtotemgstpixbufhelpers_la_CPPFLAGS = \ + -D_REENTRANT \ + $(DISABLE_DEPRECATED) \ + $(AM_CPPFLAGS) + +libtotemgstpixbufhelpers_la_CFLAGS = \ + $(PIXBUF_HELPER_CFLAGS) \ + $(AM_CFLAGS) + +libtotemgstpixbufhelpers_la_LIBADD = $(PIXBUF_HELPER_LIBS) +libtotemgstpixbufhelpers_la_LDFLAGS= -no-undefined + +libtotemtimehelpers_la_SOURCES = \ + totem-time-helpers.c \ + totem-time-helpers.h + +libtotemtimehelpers_la_CPPFLAGS = \ + -D_REENTRANT \ + $(DISABLE_DEPRECATED) \ + $(AM_CPPFLAGS) + +libtotemtimehelpers_la_CFLAGS = \ + $(TIME_HELPER_CFLAGS) \ + $(AM_CFLAGS) + +libtotemtimehelpers_la_LIBADD = $(TIME_HELPER_LIBS) +libtotemtimehelpers_la_LDFLAGS= -no-undefined + +EXTRA_DIST = totem-time-helpers.h -include $(top_srcdir)/git.mk diff --git a/src/gst/totem-gst-helpers.c b/src/gst/totem-gst-helpers.c index 17b2f0565..62dde28ad 100644 --- a/src/gst/totem-gst-helpers.c +++ b/src/gst/totem-gst-helpers.c @@ -72,191 +72,6 @@ totem_gst_message_print (GstMessage *msg, g_free (dbg); } -static void -destroy_pixbuf (guchar *pix, gpointer data) -{ - gst_sample_unref (GST_SAMPLE (data)); -} - -GdkPixbuf * -totem_gst_playbin_get_frame (GstElement *play) -{ - GstStructure *s; - GstSample *sample = NULL; - GdkPixbuf *pixbuf; - 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", - "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 - * specific framerate, because the input framerate won't - * necessarily match the output framerate if there's a deinterlacer - * in the pipeline. */ - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - NULL); - - /* get frame */ - g_signal_emit_by_name (play, "convert-sample", to_caps, &sample); - gst_caps_unref (to_caps); - - if (!sample) { - GST_DEBUG ("Could not take screenshot: %s", - "failed to retrieve or convert video frame"); - g_warning ("Could not take screenshot: %s", - "failed to retrieve or convert video frame"); - return NULL; - } - - 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, sample_caps); - - s = gst_caps_get_structure (sample_caps, 0); - gst_structure_get_int (s, "width", &outwidth); - gst_structure_get_int (s, "height", &outheight); - 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 (info.data, - GDK_COLORSPACE_RGB, FALSE, 8, outwidth, outheight, - 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_sample_unref (sample); - } - - return pixbuf; -} - -static GdkPixbuf * -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, info.data, info.size, &err) && - gdk_pixbuf_loader_close (loader, &err)) { - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) - g_object_ref (pixbuf); - } else { - GST_WARNING("could not convert tag image to pixbuf: %s", err->message); - g_error_free (err); - } - - g_object_unref (loader); - - gst_memory_unmap (memory, &info); - - return pixbuf; -} - -static const GValue * -totem_gst_tag_list_get_cover_real (GstTagList *tag_list) -{ - const GValue *cover_value = NULL; - guint i; - - for (i = 0; ; i++) { - const GValue *value; - GstSample *sample; - const GstStructure *caps_struct; - int type; - - value = gst_tag_list_get_value_index (tag_list, - GST_TAG_IMAGE, - i); - if (value == NULL) - break; - - - 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, - &type); - if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) { - if (cover_value == NULL) - cover_value = value; - } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) { - cover_value = value; - break; - } - } - - return cover_value; -} - -GdkPixbuf * -totem_gst_tag_list_get_cover (GstTagList *tag_list) -{ - const GValue *cover_value; - - g_return_val_if_fail (tag_list != NULL, FALSE); - - cover_value = totem_gst_tag_list_get_cover_real (tag_list); - /* Fallback to preview */ - if (!cover_value) { - cover_value = gst_tag_list_get_value_index (tag_list, - GST_TAG_PREVIEW_IMAGE, - 0); - } - - if (cover_value) { - GstBuffer *buffer; - GstSample *sample; - GdkPixbuf *pixbuf; - - sample = gst_value_get_sample (cover_value); - buffer = gst_sample_get_buffer (sample); - pixbuf = totem_gst_buffer_to_pixbuf (buffer); - return pixbuf; - } - - return NULL; -} - /* * vim: sw=2 ts=8 cindent noai bs=2 */ diff --git a/src/gst/totem-gst-helpers.h b/src/gst/totem-gst-helpers.h index 3e05b2743..5801eb5b6 100644 --- a/src/gst/totem-gst-helpers.h +++ b/src/gst/totem-gst-helpers.h @@ -31,7 +31,6 @@ #define GST_USE_UNSTABLE_API 1 #include <gst/gst.h> -#include <gdk-pixbuf/gdk-pixbuf.h> G_BEGIN_DECLS @@ -53,10 +52,6 @@ void totem_gst_message_print (GstMessage *msg, GstElement *play, const char *filename); -GdkPixbuf * totem_gst_playbin_get_frame (GstElement *play); - -GdkPixbuf * totem_gst_tag_list_get_cover (GstTagList *tag_list); - G_END_DECLS #endif /* HAVE_TOTEM_GST_HELPERS_H */ diff --git a/src/gst/totem-gst-pixbuf-helpers.c b/src/gst/totem-gst-pixbuf-helpers.c new file mode 100644 index 000000000..54ca32522 --- /dev/null +++ b/src/gst/totem-gst-pixbuf-helpers.c @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2003-2007 the GStreamer project + * Julien Moutte <julien@moutte.net> + * Ronald Bultje <rbultje@ronald.bitfreak.net> + * Copyright (C) 2005-2008 Tim-Philipp Müller <tim centricular net> + * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * Copyright © 2009 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission is above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add exception clause. + * See license_change file for details. + * + */ + +#include "totem-gst-pixbuf-helpers.h" + +#include <gst/tag/tag.h> +#include <gst/video/video-format.h> + +static void +destroy_pixbuf (guchar *pix, gpointer data) +{ + gst_sample_unref (GST_SAMPLE (data)); +} + +GdkPixbuf * +totem_gst_playbin_get_frame (GstElement *play) +{ + GstStructure *s; + GstSample *sample = NULL; + GdkPixbuf *pixbuf; + 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", + "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 + * specific framerate, because the input framerate won't + * necessarily match the output framerate if there's a deinterlacer + * in the pipeline. */ + "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, + NULL); + + /* get frame */ + g_signal_emit_by_name (play, "convert-sample", to_caps, &sample); + gst_caps_unref (to_caps); + + if (!sample) { + GST_DEBUG ("Could not take screenshot: %s", + "failed to retrieve or convert video frame"); + g_warning ("Could not take screenshot: %s", + "failed to retrieve or convert video frame"); + return NULL; + } + + 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, sample_caps); + + s = gst_caps_get_structure (sample_caps, 0); + gst_structure_get_int (s, "width", &outwidth); + gst_structure_get_int (s, "height", &outheight); + 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 (info.data, + GDK_COLORSPACE_RGB, FALSE, 8, outwidth, outheight, + 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_sample_unref (sample); + } + + return pixbuf; +} + +static GdkPixbuf * +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, info.data, info.size, &err) && + gdk_pixbuf_loader_close (loader, &err)) { + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + if (pixbuf) + g_object_ref (pixbuf); + } else { + GST_WARNING("could not convert tag image to pixbuf: %s", err->message); + g_error_free (err); + } + + g_object_unref (loader); + + gst_memory_unmap (memory, &info); + + return pixbuf; +} + +static const GValue * +totem_gst_tag_list_get_cover_real (GstTagList *tag_list) +{ + const GValue *cover_value = NULL; + guint i; + + for (i = 0; ; i++) { + const GValue *value; + GstSample *sample; + const GstStructure *caps_struct; + int type; + + value = gst_tag_list_get_value_index (tag_list, + GST_TAG_IMAGE, + i); + if (value == NULL) + break; + + + 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, + &type); + if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) { + if (cover_value == NULL) + cover_value = value; + } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) { + cover_value = value; + break; + } + } + + return cover_value; +} + +GdkPixbuf * +totem_gst_tag_list_get_cover (GstTagList *tag_list) +{ + const GValue *cover_value; + + g_return_val_if_fail (tag_list != NULL, FALSE); + + cover_value = totem_gst_tag_list_get_cover_real (tag_list); + /* Fallback to preview */ + if (!cover_value) { + cover_value = gst_tag_list_get_value_index (tag_list, + GST_TAG_PREVIEW_IMAGE, + 0); + } + + if (cover_value) { + GstBuffer *buffer; + GstSample *sample; + GdkPixbuf *pixbuf; + + sample = gst_value_get_sample (cover_value); + buffer = gst_sample_get_buffer (sample); + pixbuf = totem_gst_buffer_to_pixbuf (buffer); + return pixbuf; + } + + return NULL; +} + +/* + * vim: sw=2 ts=8 cindent noai bs=2 + */ diff --git a/src/gst/totem-gst-pixbuf-helpers.h b/src/gst/totem-gst-pixbuf-helpers.h new file mode 100644 index 000000000..b2d12c6e6 --- /dev/null +++ b/src/gst/totem-gst-pixbuf-helpers.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2001,2002,2003,2004,2005 Bastien Nocera <hadess@hadess.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission are above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add exception clause. + * See license_change file for details. + * + */ + +#ifndef HAVE_TOTEM_GST_PIXBUF_HELPERS_H +#define HAVE_TOTEM_GST_PIXBUF_HELPERS_H + +#define GST_USE_UNSTABLE_API 1 + +#include <gst/gst.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +G_BEGIN_DECLS + +GdkPixbuf * totem_gst_playbin_get_frame (GstElement *play); + +GdkPixbuf * totem_gst_tag_list_get_cover (GstTagList *tag_list); + +G_END_DECLS + +#endif /* HAVE_TOTEM_GST_PIXBUF_HELPERS_H */ diff --git a/src/gst/totem-time-helpers.c b/src/gst/totem-time-helpers.c new file mode 100644 index 000000000..2089b4b32 --- /dev/null +++ b/src/gst/totem-time-helpers.c @@ -0,0 +1,63 @@ +/* + * Copyright © 2002-2012 Bastien Nocera <hadess@hadess.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission is above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add exception clause. + * See license_change file for details. + * + */ + +#include <glib/gi18n.h> +#include <libintl.h> + +#include "totem-time-helpers.h" + +char * +totem_time_to_string (gint64 msecs) +{ + int sec, min, hour, _time; + + _time = (int) (msecs / 1000); + sec = _time % 60; + _time = _time - sec; + min = (_time % (60*60)) / 60; + _time = _time - (min * 60); + hour = _time / (60*60); + + if (hour > 0) + { + /* hour:minutes:seconds */ + /* Translators: This is a time format, like "9:05:02" for 9 + * hours, 5 minutes, and 2 seconds. You may change ":" to + * the separator that your locale uses or use "%Id" instead + * of "%d" if your locale uses localized digits. + */ + return g_strdup_printf (C_("long time format", "%d:%02d:%02d"), hour, min, sec); + } + + /* minutes:seconds */ + /* Translators: This is a time format, like "5:02" for 5 + * minutes and 2 seconds. You may change ":" to the + * separator that your locale uses or use "%Id" instead of + * "%d" if your locale uses localized digits. + */ + return g_strdup_printf (C_("short time format", "%d:%02d"), min, sec); +} diff --git a/src/gst/totem-time-helpers.h b/src/gst/totem-time-helpers.h new file mode 100644 index 000000000..fc3067edc --- /dev/null +++ b/src/gst/totem-time-helpers.h @@ -0,0 +1,35 @@ +/* + * Copyright © 2002-2012 Bastien Nocera <hadess@hadess.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * The Totem project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Totem. This + * permission is above and beyond the permissions granted by the GPL license + * Totem is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add exception clause. + * See license_change file for details. + * + */ + +#ifndef _TOTEM_TIME_HELPERS_H_ +#define _TOTEM_TIME_HELPERS_H_ + +#include <glib.h> + +char *totem_time_to_string (gint64 msecs); + +#endif /* _TOTEM_TIME_HELPERS_H_ */ diff --git a/src/plugins/Makefile.plugins b/src/plugins/Makefile.plugins index aed2e7060..d76f218cb 100644 --- a/src/plugins/Makefile.plugins +++ b/src/plugins/Makefile.plugins @@ -12,11 +12,11 @@ AM_CPPFLAGS = \ $(DISABLE_DEPRECATED) \ -I$(top_srcdir)/ \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/plugins + -I$(top_srcdir)/src/plugins \ + -I$(top_srcdir)/src/gst -plugin_cflags = \ - $(DEPENDENCY_CFLAGS) \ - $(PEAS_CFLAGS) \ +plugin_cflags = \ + $(PLAYER_CFLAGS) \ $(WARN_CFLAGS) plugin_ldflags = \ diff --git a/src/plugins/grilo/Makefile.am b/src/plugins/grilo/Makefile.am index 5e660b66f..5a1f44c40 100644 --- a/src/plugins/grilo/Makefile.am +++ b/src/plugins/grilo/Makefile.am @@ -25,9 +25,9 @@ libgrilo_la_LIBADD = \ $(plugin_libadd) \ $(LIBGRILO_LIBS) libgrilo_la_CFLAGS = \ - $(plugin_cflags) \ - $(LIBGRILO_CFLAGS) \ - -I $(top_srcdir)/src/backend + $(plugin_cflags) \ + $(LIBGRILO_CFLAGS) \ + -I $(top_srcdir)/src/gst/ -include $(top_srcdir)/git.mk diff --git a/src/plugins/grilo/totem-grilo.c b/src/plugins/grilo/totem-grilo.c index 89e90ebfe..4976b4467 100644 --- a/src/plugins/grilo/totem-grilo.c +++ b/src/plugins/grilo/totem-grilo.c @@ -44,7 +44,7 @@ #include <totem-dirs.h> #include <totem.h> -#include <video-utils.h> +#include <totem-time-helpers.h> #include "totem-search-entry.h" diff --git a/src/plugins/skipto/totem-skipto.c b/src/plugins/skipto/totem-skipto.c index c2d2a474d..e3ba487c5 100644 --- a/src/plugins/skipto/totem-skipto.c +++ b/src/plugins/skipto/totem-skipto.c @@ -40,7 +40,6 @@ #include "totem-dirs.h" #include "totem-skipto.h" #include "totem-uri.h" -#include "backend/video-utils.h" #include "backend/bacon-video-widget.h" static void totem_skipto_dispose (GObject *object); diff --git a/src/plugins/skipto/totem-time-entry.c b/src/plugins/skipto/totem-time-entry.c index 547c30097..7b2e97b91 100644 --- a/src/plugins/skipto/totem-time-entry.c +++ b/src/plugins/skipto/totem-time-entry.c @@ -33,7 +33,7 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include "backend/video-utils.h" +#include "totem-time-helpers.h" #include "totem-time-entry.h" static void dispose (GObject *object); diff --git a/src/properties/Makefile.am b/src/properties/Makefile.am index 209fcb87a..e95e71b92 100644 --- a/src/properties/Makefile.am +++ b/src/properties/Makefile.am @@ -10,7 +10,7 @@ libbaconvideowidgetproperties_la_CPPFLAGS = \ $(AM_CPPFLAGS) libbaconvideowidgetproperties_la_CFLAGS = \ - $(DEPENDENCY_CFLAGS) \ + $(PROPERTIES_CFLAGS) \ $(WARN_CFLAGS) \ $(AM_CFLAGS) diff --git a/src/totem-statusbar.c b/src/totem-statusbar.c index e8bd38b2e..e822f7eec 100644 --- a/src/totem-statusbar.c +++ b/src/totem-statusbar.c @@ -32,7 +32,7 @@ #include <gtk/gtk.h> #include "totem-statusbar.h" -#include "video-utils.h" +#include "totem-time-helpers.h" #define SPACING 4 #define NORMAL_CONTEXT "text" diff --git a/src/totem-time-label.c b/src/totem-time-label.c index 551cdf1b8..f1dc11f62 100644 --- a/src/totem-time-label.c +++ b/src/totem-time-label.c @@ -3,7 +3,7 @@ #include "totem-time-label.h" #include <glib/gi18n.h> -#include "video-utils.h" +#include "totem-time-helpers.h" struct _TotemTimeLabelPrivate { gint64 time; diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c index b40fe9a3b..657f1e2ea 100644 --- a/src/totem-video-thumbnailer.c +++ b/src/totem-video-thumbnailer.c @@ -46,6 +46,8 @@ #include <sys/stat.h> #include "gst/totem-gst-helpers.h" +#include "gst/totem-time-helpers.h" +#include "gst/totem-gst-pixbuf-helpers.h" #include "video-utils.h" #include "totem-resources.h" |