[poppler] glib/poppler-media.cc glib/poppler-media.h glib/reference

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 15 20:43:40 UTC 2021


 glib/poppler-media.cc               |   61 ++++++++++++++++++++++++++++++++++++
 glib/poppler-media.h                |    6 +++
 glib/reference/poppler-sections.txt |    3 +
 3 files changed, 70 insertions(+)

New commits:
commit 81bee89c88d632ce6de878d338dd53a8150ea8aa
Author: Clément Pit-Claudel <clement.pitclaudel at gmail.com>
Date:   Mon Mar 15 20:43:38 2021 +0000

    [glib] Expose more fields from MediaRendition in PopplerMedia

diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc
index 6f1826b8..6b827485 100644
--- a/glib/poppler-media.cc
+++ b/glib/poppler-media.cc
@@ -39,6 +39,9 @@ struct _PopplerMedia
     GObject parent_instance;
 
     gchar *filename;
+    gboolean auto_play;
+    gboolean show_controls;
+    gfloat repeat_count;
 
     gchar *mime_type;
     Object stream;
@@ -98,6 +101,13 @@ PopplerMedia *_poppler_media_new(const MediaRendition *poppler_media)
         media->filename = g_strdup(poppler_media->getFileName()->c_str());
     }
 
+    const MediaParameters *mp = poppler_media->getBEParameters();
+    mp = mp ? mp : poppler_media->getMHParameters();
+
+    media->auto_play = mp ? mp->autoPlay : false;
+    media->show_controls = mp ? mp->showControls : false;
+    media->repeat_count = mp ? mp->repeatCount : 1.f;
+
     return media;
 }
 
@@ -140,6 +150,57 @@ gboolean poppler_media_is_embedded(PopplerMedia *poppler_media)
     return poppler_media->stream.isStream();
 }
 
+/**
+ * poppler_media_get_auto_play:
+ * @poppler_media: a #PopplerMedia
+ *
+ * Returns the auto-play parameter.
+ *
+ * Return value: %TRUE if media should auto-play, %FALSE otherwise
+ *
+ * Since: 20.04.0
+ */
+gboolean poppler_media_get_auto_play(PopplerMedia *poppler_media)
+{
+    g_return_val_if_fail(POPPLER_IS_MEDIA(poppler_media), FALSE);
+
+    return poppler_media->auto_play;
+}
+
+/**
+ * poppler_media_get_show_controls:
+ * @poppler_media: a #PopplerMedia
+ *
+ * Returns the show controls parameter.
+ *
+ * Return value: %TRUE if media should show controls, %FALSE otherwise
+ *
+ * Since: 20.04.0
+ */
+gboolean poppler_media_get_show_controls(PopplerMedia *poppler_media)
+{
+    g_return_val_if_fail(POPPLER_IS_MEDIA(poppler_media), FALSE);
+
+    return poppler_media->show_controls;
+}
+
+/**
+ * poppler_media_get_repeat_count:
+ * @poppler_media: a #PopplerMedia
+ *
+ * Returns the repeat count parameter.
+ *
+ * Return value: Repeat count parameter (float)
+ *
+ * Since: 20.04.0
+ */
+gfloat poppler_media_get_repeat_count(PopplerMedia *poppler_media)
+{
+    g_return_val_if_fail(POPPLER_IS_MEDIA(poppler_media), FALSE);
+
+    return poppler_media->repeat_count;
+}
+
 /**
  * poppler_media_get_mime_type:
  * @poppler_media: a #PopplerMedia
diff --git a/glib/poppler-media.h b/glib/poppler-media.h
index b5efdc0d..e4a278c6 100644
--- a/glib/poppler-media.h
+++ b/glib/poppler-media.h
@@ -61,6 +61,12 @@ const gchar *poppler_media_get_filename(PopplerMedia *poppler_media);
 POPPLER_PUBLIC
 const gchar *poppler_media_get_mime_type(PopplerMedia *poppler_media);
 POPPLER_PUBLIC
+gboolean poppler_media_get_auto_play(PopplerMedia *poppler_media);
+POPPLER_PUBLIC
+gboolean poppler_media_get_show_controls(PopplerMedia *poppler_media);
+POPPLER_PUBLIC
+gfloat poppler_media_get_repeat_count(PopplerMedia *poppler_media);
+POPPLER_PUBLIC
 gboolean poppler_media_save(PopplerMedia *poppler_media, const char *filename, GError **error);
 POPPLER_PUBLIC
 gboolean poppler_media_save_to_callback(PopplerMedia *poppler_media, PopplerMediaSaveFunc save_func, gpointer user_data, GError **error);
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index 828a8bf1..b6f8ecc9 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -584,8 +584,11 @@ poppler_layer_get_type
 <TITLE>Poppler Media</TITLE>
 PopplerMedia
 PopplerMediaSaveFunc
+poppler_media_get_auto_play
 poppler_media_get_filename
 poppler_media_get_mime_type
+poppler_media_get_repeat_count
+poppler_media_get_show_controls
 poppler_media_is_embedded
 poppler_media_save
 poppler_media_save_to_callback


More information about the poppler mailing list