summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2022-03-07 12:16:08 +0100
committerBastien Nocera <hadess@hadess.net>2022-03-09 17:49:33 +0100
commit02a3856b3d9812f87b67e7bfba439d5db0254efb (patch)
treeccec35bbab28b3dc3b930563a29b6dede4ce38df
parent307ce47e7d7eb331c1a647a743ce0744c69f42cf (diff)
downloadtotem-02a3856b3d9812f87b67e7bfba439d5db0254efb.tar.gz
gst: Add error-reporting to screenshot helper
Make totem_gst_playbin_get_frame() report (untranslated) errors back up to the caller.
-rw-r--r--src/backend/bacon-video-widget.c2
-rw-r--r--src/gst/totem-gst-pixbuf-helpers.c21
-rw-r--r--src/gst/totem-gst-pixbuf-helpers.h2
-rw-r--r--src/totem-gallery-thumbnailer.c2
-rw-r--r--src/totem-video-thumbnailer.c4
5 files changed, 16 insertions, 15 deletions
diff --git a/src/backend/bacon-video-widget.c b/src/backend/bacon-video-widget.c
index 296aae16f..eb518944e 100644
--- a/src/backend/bacon-video-widget.c
+++ b/src/backend/bacon-video-widget.c
@@ -5368,7 +5368,7 @@ bacon_video_widget_get_current_frame (BaconVideoWidget * bvw)
return NULL;
}
- return totem_gst_playbin_get_frame (bvw->play);
+ return totem_gst_playbin_get_frame (bvw->play, NULL);
}
/* =========================================== */
diff --git a/src/gst/totem-gst-pixbuf-helpers.c b/src/gst/totem-gst-pixbuf-helpers.c
index 081bba39e..d234637ba 100644
--- a/src/gst/totem-gst-pixbuf-helpers.c
+++ b/src/gst/totem-gst-pixbuf-helpers.c
@@ -42,7 +42,7 @@ destroy_pixbuf (guchar *pix, gpointer data)
}
GdkPixbuf *
-totem_gst_playbin_get_frame (GstElement *play)
+totem_gst_playbin_get_frame (GstElement *play, GError **error)
{
GstStructure *s;
GstSample *sample = NULL;
@@ -74,17 +74,15 @@ totem_gst_playbin_get_frame (GstElement *play)
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");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "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");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "No caps on output buffer");
return NULL;
}
@@ -93,8 +91,11 @@ totem_gst_playbin_get_frame (GstElement *play)
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)
+ if (outwidth <= 0 || outheight <= 0) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Could not prepare buffer memory for image dimensions %dx%d", outwidth, outheight);
goto done;
+ }
memory = gst_buffer_get_memory (gst_sample_get_buffer (sample), 0);
gst_memory_map (memory, &info, GST_MAP_READ);
@@ -109,8 +110,8 @@ totem_gst_playbin_get_frame (GstElement *play)
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");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Could not create pixbuf");
gst_sample_unref (sample);
}
diff --git a/src/gst/totem-gst-pixbuf-helpers.h b/src/gst/totem-gst-pixbuf-helpers.h
index 45be95320..fe08d47df 100644
--- a/src/gst/totem-gst-pixbuf-helpers.h
+++ b/src/gst/totem-gst-pixbuf-helpers.h
@@ -30,5 +30,5 @@
#include <gst/gst.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-GdkPixbuf * totem_gst_playbin_get_frame (GstElement *play);
+GdkPixbuf * totem_gst_playbin_get_frame (GstElement *play, GError **error);
GdkPixbuf * totem_gst_tag_list_get_cover (GstTagList *tag_list);
diff --git a/src/totem-gallery-thumbnailer.c b/src/totem-gallery-thumbnailer.c
index d066d1301..d893de908 100644
--- a/src/totem-gallery-thumbnailer.c
+++ b/src/totem-gallery-thumbnailer.c
@@ -452,7 +452,7 @@ capture_frame_at_time (ThumbApp *app,
if (milliseconds != 0)
thumb_app_seek (app, milliseconds);
- return totem_gst_playbin_get_frame (app->play);
+ return totem_gst_playbin_get_frame (app->play, NULL);
}
static GdkPixbuf *
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 70d5a7950..de6a1ee49 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -536,7 +536,7 @@ capture_frame_at_time (ThumbApp *app,
if (milliseconds != 0)
thumb_app_seek (app, milliseconds);
- return totem_gst_playbin_get_frame (app->play);
+ return totem_gst_playbin_get_frame (app->play, NULL);
}
static GdkPixbuf *
@@ -566,7 +566,7 @@ capture_interesting_frame (ThumbApp *app)
/* Pull the frame, if it's interesting we bail early */
PROGRESS_DEBUG("About to get frame for iter %d", current);
- pixbuf = totem_gst_playbin_get_frame (app->play);
+ pixbuf = totem_gst_playbin_get_frame (app->play, NULL);
if (pixbuf != NULL && is_image_interesting (pixbuf) != FALSE) {
PROGRESS_DEBUG("Frame for iter %d is interesting", current);
break;