From a02a5c2320ad2dffbb698e1d5c3cb742ca0abedb Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 14 Sep 2010 16:04:02 +0200 Subject: [PATCH] Update for factorylist/convertframe being merged to gst core/base --- configure.ac | 12 +- docs/libs/ges-sections.txt | 2 +- ges/Makefile.am | 6 +- ges/ges-screenshot.c | 246 +---------------------------------- ges/ges-screenshot.h | 2 +- ges/ges-timeline-pipeline.c | 4 +- ges/ges-timeline-pipeline.h | 2 +- ges/ges-timeline.c | 2 +- tests/examples/concatenate.c | 2 +- tests/examples/test4.c | 2 +- tests/examples/thumbnails.c | 2 +- tools/ges-launch.c | 2 +- 12 files changed, 21 insertions(+), 263 deletions(-) diff --git a/configure.ac b/configure.ac index a9464a0879..ae90b49f5b 100644 --- a/configure.ac +++ b/configure.ac @@ -156,13 +156,13 @@ GSTPB_PLUGINS_DIR=`$PKG_CONFIG gstreamer-plugins-base-$GST_MAJORMINOR --variable AC_SUBST(GSTPB_PLUGINS_DIR) AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR) -dnl check for gstreamer-pbutils -PKG_CHECK_MODULES(GST_PBUTILS, gstreamer-pbutils-$GST_MAJORMINOR, HAVE_GST_PBUTILS="yes", HAVE_GST_PBUTILS="no") -if test "x$HAVE_GST_PBUTILS" != "xyes"; then - AC_ERROR([gst-pbutils is required for rendering support]) +dnl check for gstreamer-profile +PKG_CHECK_MODULES(GST_PROFILE, gstreamer-profile-$GST_MAJORMINOR, HAVE_GST_PROFILE="yes", HAVE_GST_PROFILE="no") +if test "x$HAVE_GST_PROFILE" != "xyes"; then + AC_ERROR([gst-profile is required for rendering support]) fi -AC_SUBST(GST_PBUTILS_LIBS) -AC_SUBST(GST_PBUTILS_CFLAGS) +AC_SUBST(GST_PROFILE_LIBS) +AC_SUBST(GST_PROFILE_CFLAGS) dnl check for gstreamer-discoverer PKG_CHECK_MODULES(GST_DISCOVERER, gstreamer-discoverer-$GST_MAJORMINOR, HAVE_GST_DISCOVERER="yes", HAVE_GST_DISCOVERER="no") diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index eb75df147e..c34714ee21 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -293,7 +293,7 @@ ges_timeline_pipeline_get_thumbnail_buffer ges_timeline_pipeline_get_thumbnail_rgb24 ges_timeline_pipeline_save_thumbnail -gst_play_sink_convert_frame +ges_play_sink_convert_frame ges_timeline_pipeline_get_type GES_TIMELINE_PIPELINE GES_TIMELINE_PIPELINE_CLASS diff --git a/ges/Makefile.am b/ges/Makefile.am index 880f88327d..b117f3a964 100644 --- a/ges/Makefile.am +++ b/ges/Makefile.am @@ -76,9 +76,9 @@ libges_@GST_MAJORMINOR@include_HEADERS = \ ges-screenshot.h \ ges-utils.h -libges_@GST_MAJORMINOR@_la_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_DISCOVERER_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -libges_@GST_MAJORMINOR@_la_LIBADD = $(GST_PBUTILS_CFLAGS) $(GST_DISCOVERER_LIBS) $(GST_CONTROLLER_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) -libges_@GST_MAJORMINOR@_la_LDFLAGS = -lgstpbutils-@GST_MAJORMINOR@ $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) +libges_@GST_MAJORMINOR@_la_CFLAGS = -I$(top_srcdir) $(GST_PROFILE_CFLAGS) $(GST_DISCOVERER_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) +libges_@GST_MAJORMINOR@_la_LIBADD = $(GST_PROFILE_LIBS) $(GST_DISCOVERER_LIBS) $(GST_CONTROLLER_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) +libges_@GST_MAJORMINOR@_la_LDFLAGS = -lgstprofile-@GST_MAJORMINOR@ $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) DISTCLEANFILE = $(CLEANFILES) diff --git a/ges/ges-screenshot.c b/ges/ges-screenshot.c index 324ee3a397..55546c86f1 100644 --- a/ges/ges-screenshot.c +++ b/ges/ges-screenshot.c @@ -21,41 +21,12 @@ #include #include #include +#include #include "ges-screenshot.h" #include "ges-internal.h" -/* FIXME (merge into core): This code is duplicated from gstscreenshot.c and - * gstplaysink.c, adapted to handle encoding the converted frame into - * arbitrary formats using gst-convenience. - */ - -/* takes ownership of the input buffer */ -GstBuffer *gst_play_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps); - -static gboolean -create_element (const gchar * factory_name, GstElement ** element, - GError ** err); - -static GstElement *get_encoder (GstCaps * caps); - -static gboolean caps_are_raw (GstCaps * caps); - -static gboolean -caps_are_raw (GstCaps * caps) -{ - static GstCaps *raw_video = NULL; - static gsize once = 0; - - if (g_once_init_enter (&once)) { - raw_video = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb"); - g_once_init_leave (&once, 1); - } - - return gst_caps_can_intersect (caps, raw_video); -} - GstBuffer * -gst_play_sink_convert_frame (GstElement * playsink, GstCaps * caps) +ges_play_sink_convert_frame (GstElement * playsink, GstCaps * caps) { GstBuffer *result = NULL; @@ -66,220 +37,9 @@ gst_play_sink_convert_frame (GstElement * playsink, GstCaps * caps) if (result != NULL && caps != NULL) { GstBuffer *temp; - temp = gst_play_frame_conv_convert (result, caps); + temp = gst_video_convert_frame (result, caps, 25 * GST_SECOND, NULL); gst_buffer_unref (result); result = temp; } return result; } - -static gboolean -create_element (const gchar * factory_name, GstElement ** element, - GError ** err) -{ - *element = gst_element_factory_make (factory_name, NULL); - if (*element) - return TRUE; - - if (err && *err == NULL) { - *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN, - "cannot create element '%s' - please check your GStreamer installation", - factory_name); - } - - return FALSE; -} - -GstElement * -get_encoder (GstCaps * caps) -{ - GList *encoders = NULL; - GList *filtered = NULL; - GstElementFactory *factory = NULL; - GstElement *encoder = NULL; - - encoders = - gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_LIST_ENCODER | - GST_ELEMENT_FACTORY_LIST_MEDIA_IMAGE, GST_RANK_NONE); - - GST_INFO ("got factory list %p", encoders); - gst_plugin_feature_list_debug (encoders); - if (encoders == NULL) - goto beach; - - filtered = - gst_element_factory_list_filter (encoders, caps, GST_PAD_SRC, FALSE); - GST_INFO ("got filtered list %p", filtered); - gst_plugin_feature_list_debug (filtered); - if (filtered == NULL) - goto beach; - - factory = (GstElementFactory *) filtered->data; - - GST_INFO ("got factory %p", factory); - if (!factory) - goto beach; - encoder = gst_element_factory_create (factory, NULL); - - GST_INFO ("created encoder element %p, %s", encoder, - gst_element_get_name (encoder)); - -beach: - if (filtered) - gst_plugin_feature_list_free (filtered); - if (encoders) - gst_plugin_feature_list_free (encoders); - - return encoder; -} - -/* takes ownership of the input buffer */ -GstBuffer * -gst_play_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps) -{ - GstElement *src, *csp, *vscale, *sink, *encoder, *pipeline; - GstMessage *msg; - GstBuffer *result = NULL; - GError *error = NULL; - GstBus *bus; - GstCaps *from_caps; - GstFlowReturn ret; - - from_caps = GST_BUFFER_CAPS (buf); - - g_return_val_if_fail (from_caps != NULL, NULL); - - /* videoscale is here to correct for the pixel-aspect-ratio for us */ - GST_DEBUG ("creating elements"); - if (!create_element ("appsrc", &src, &error) || - !create_element ("ffmpegcolorspace", &csp, &error) || - !create_element ("videoscale", &vscale, &error) || - !create_element ("appsink", &sink, &error)) - goto no_elements; - - pipeline = gst_pipeline_new ("screenshot-pipeline"); - if (pipeline == NULL) - goto no_pipeline; - - GST_DEBUG ("adding elements"); - gst_bin_add_many (GST_BIN (pipeline), src, csp, vscale, sink, NULL); - - /* set caps */ - g_object_set (src, "caps", from_caps, NULL); - g_object_set (sink, "caps", to_caps, NULL); - - /* FIXME: linking is still way too expensive, profile this properly */ - GST_DEBUG ("linking src->csp"); - if (!gst_element_link_pads (src, "src", csp, "sink")) - goto link_failed; - - GST_DEBUG ("linking csp->vscale"); - if (!gst_element_link_pads (csp, "src", vscale, "sink")) - goto link_failed; - - if (caps_are_raw (to_caps)) { - GST_DEBUG ("linking vscale->sink"); - - if (!gst_element_link_pads (vscale, "src", sink, "sink")) - goto link_failed; - } - - else { - encoder = get_encoder (to_caps); - if (!encoder) - goto no_encoder; - gst_bin_add (GST_BIN (pipeline), encoder); - - GST_DEBUG ("linking vscale->encoder"); - if (!gst_element_link (vscale, encoder)) - goto link_failed; - - GST_DEBUG ("linking encoder->sink"); - if (!gst_element_link_pads (encoder, "src", sink, "sink")) - goto link_failed; - } - - /* now set the pipeline to the paused state, after we push the buffer into - * appsrc, this should preroll the converted buffer in appsink */ - GST_DEBUG ("running conversion pipeline to caps %" GST_PTR_FORMAT, to_caps); - gst_element_set_state (pipeline, GST_STATE_PAUSED); - - /* feed buffer in appsrc */ - GST_DEBUG ("feeding buffer %p, size %u, caps %" GST_PTR_FORMAT, - buf, GST_BUFFER_SIZE (buf), from_caps); - g_signal_emit_by_name (src, "push-buffer", buf, &ret); - - /* now see what happens. We either got an error somewhere or the pipeline - * prerolled */ - bus = gst_element_get_bus (pipeline); - msg = - gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_ASYNC_DONE, - 25 * GST_SECOND); - - if (msg) { - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_ASYNC_DONE: - { - /* we're prerolled, get the frame from appsink */ - g_signal_emit_by_name (sink, "pull-preroll", &result); - - if (result) { - GST_DEBUG ("conversion successful: result = %p", result); - } else { - GST_WARNING ("prerolled but no result frame?!"); - } - break; - } - case GST_MESSAGE_ERROR:{ - gchar *dbg = NULL; - - gst_message_parse_error (msg, &error, &dbg); - if (error) { - g_warning ("Could not take screenshot: %s", error->message); - GST_DEBUG ("%s [debug: %s]", error->message, GST_STR_NULL (dbg)); - g_error_free (error); - } else { - g_warning ("Could not take screenshot (and NULL error!)"); - } - g_free (dbg); - break; - } - default:{ - g_return_val_if_reached (NULL); - } - } - gst_message_unref (msg); - } else { - g_warning ("Could not take screenshot: %s", "timeout during conversion"); - } - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (bus); - gst_object_unref (pipeline); - - return result; - - /* ERRORS */ -no_encoder: - { - g_warning ("could not find an encoder for provided caps"); - return NULL; - } -no_elements: - { - g_warning ("Could not take screenshot: %s", error->message); - g_error_free (error); - return NULL; - } -no_pipeline: - { - g_warning ("Could not take screenshot: %s", "no pipeline (unknown error)"); - return NULL; - } -link_failed: - { - g_warning ("Could not take screenshot: %s", "failed to link elements"); - gst_object_unref (pipeline); - return NULL; - } -} diff --git a/ges/ges-screenshot.h b/ges/ges-screenshot.h index 054b5ee5e9..d8933e4b02 100644 --- a/ges/ges-screenshot.h +++ b/ges/ges-screenshot.h @@ -26,7 +26,7 @@ G_BEGIN_DECLS GstBuffer * -gst_play_sink_convert_frame (GstElement * playsink, GstCaps * caps); +ges_play_sink_convert_frame (GstElement * playsink, GstCaps * caps); G_END_DECLS diff --git a/ges/ges-timeline-pipeline.c b/ges/ges-timeline-pipeline.c index 6d7c141495..be22ce9702 100644 --- a/ges/ges-timeline-pipeline.c +++ b/ges/ges-timeline-pipeline.c @@ -726,9 +726,7 @@ ges_timeline_pipeline_get_thumbnail_buffer (GESTimelinePipeline * self, return NULL; } - /* FIXME (merge into core): this should be replaced with the "convert-frame" - * action */ - buf = gst_play_sink_convert_frame (sink, caps); + buf = ges_play_sink_convert_frame (sink, caps); return buf; } diff --git a/ges/ges-timeline-pipeline.h b/ges/ges-timeline-pipeline.h index 12db35e42d..3872d4791b 100644 --- a/ges/ges-timeline-pipeline.h +++ b/ges/ges-timeline-pipeline.h @@ -23,7 +23,7 @@ #include #include -#include +#include G_BEGIN_DECLS diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 518776a935..e2c42db500 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -200,7 +200,7 @@ ges_timeline_init (GESTimeline * self) self); g_signal_connect (self->discoverer, "discovered", G_CALLBACK (discoverer_discovered_cb), self); - gst_discoverer_start (self->discoverer, NULL); + gst_discoverer_start (self->discoverer); } /** diff --git a/tests/examples/concatenate.c b/tests/examples/concatenate.c index 23e9b311d5..f2fc1ce7a0 100644 --- a/tests/examples/concatenate.c +++ b/tests/examples/concatenate.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include GstDiscovererInformation *get_info_for_file (GstDiscoverer * disco, diff --git a/tests/examples/test4.c b/tests/examples/test4.c index fceb108009..d1ab3c3881 100644 --- a/tests/examples/test4.c +++ b/tests/examples/test4.c @@ -18,7 +18,7 @@ */ #include -#include +#include GstEncodingProfile *make_ogg_vorbis_profile (void); diff --git a/tests/examples/thumbnails.c b/tests/examples/thumbnails.c index 49189a27c9..a2bf082657 100644 --- a/tests/examples/thumbnails.c +++ b/tests/examples/thumbnails.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include /* GLOBAL VARIABLE */ diff --git a/tools/ges-launch.c b/tools/ges-launch.c index 34d6c58a5c..9d9620cc04 100644 --- a/tools/ges-launch.c +++ b/tools/ges-launch.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include /* GLOBAL VARIABLE */