summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Stambulchik <fnevgeny@gmail.com>2019-08-21 01:08:31 +0300
committerAlbert Astals Cid <aacid@kde.org>2019-08-21 17:10:07 +0200
commit365a92e5ed21c642a45dfb75295b7dfa7fc4499a (patch)
tree243a588491d28f6662b02fa915fea74169d150fa
parent764dd94a7f5cac3426a58d3f7efbcf8d1b8c787f (diff)
Use guint64 for time-related values of movie objects (in ns)
-rw-r--r--glib/demo/utils.c7
-rw-r--r--glib/poppler-movie.cc50
-rw-r--r--glib/poppler-movie.h20
3 files changed, 34 insertions, 43 deletions
diff --git a/glib/demo/utils.c b/glib/demo/utils.c
index a8b0c68d..aad6c88c 100644
--- a/glib/demo/utils.c
+++ b/glib/demo/utils.c
@@ -564,7 +564,6 @@ pgd_movie_view_set_movie (GtkWidget *movie_view,
GtkWidget *button;
GEnumValue *enum_value;
gint row = 0;
- PopplerMovieTime start, duration;
table = gtk_bin_get_child (GTK_BIN (movie_view));
if (table) {
@@ -595,10 +594,8 @@ pgd_movie_view_set_movie (GtkWidget *movie_view,
pgd_table_add_property (GTK_GRID (table), "<b>Synchronous Play:</b>", poppler_movie_is_synchronous (movie) ? "Yes" : "No", &row);
pgd_table_add_property (GTK_GRID (table), "<b>Volume:</b>", g_strdup_printf("%g", poppler_movie_get_volume (movie)), &row);
pgd_table_add_property (GTK_GRID (table), "<b>Rate:</b>", g_strdup_printf("%g", poppler_movie_get_rate (movie)), &row);
- poppler_movie_get_start (movie, &start);
- pgd_table_add_property (GTK_GRID (table), "<b>Start:</b>", g_strdup_printf("%lu/%i s", start.units, start.units_per_second), &row);
- poppler_movie_get_duration (movie, &duration);
- pgd_table_add_property (GTK_GRID (table), "<b>Duration:</b>", g_strdup_printf("%lu/%i s", duration.units, duration.units_per_second), &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Start:</b>", g_strdup_printf("%g s", poppler_movie_get_start (movie)/1e9), &row);
+ pgd_table_add_property (GTK_GRID (table), "<b>Duration:</b>", g_strdup_printf("%g s", poppler_movie_get_duration (movie)/1e9), &row);
pgd_table_add_property (GTK_GRID (table), "<b>Rotation Angle:</b>", g_strdup_printf("%u", poppler_movie_get_rotation_angle (movie)), &row);
button = gtk_button_new_with_mnemonic ("_Play");
diff --git a/glib/poppler-movie.cc b/glib/poppler-movie.cc
index ce5e7ba3..aa40aa15 100644
--- a/glib/poppler-movie.cc
+++ b/glib/poppler-movie.cc
@@ -41,8 +41,8 @@ struct _PopplerMovie
gboolean synchronous_play;
gint volume;
gdouble rate;
- PopplerMovieTime start;
- PopplerMovieTime duration;
+ guint64 start;
+ guint64 duration;
gushort rotation_angle;
};
@@ -117,11 +117,21 @@ _poppler_movie_new (const Movie *poppler_movie)
movie->rate = poppler_movie->getActivationParameters()->rate;
- movie->start.units = poppler_movie->getActivationParameters()->start.units;
- movie->start.units_per_second = poppler_movie->getActivationParameters()->start.units_per_second;
+ if (poppler_movie->getActivationParameters()->start.units_per_second > 0) {
+ movie->start = 1000000000L*
+ poppler_movie->getActivationParameters()->start.units/
+ poppler_movie->getActivationParameters()->start.units_per_second;
+ } else {
+ movie->start = 0L;
+ }
- movie->duration.units = poppler_movie->getActivationParameters()->duration.units;
- movie->duration.units_per_second = poppler_movie->getActivationParameters()->duration.units_per_second;
+ if (poppler_movie->getActivationParameters()->duration.units_per_second > 0) {
+ movie->duration = 1000000000L*
+ poppler_movie->getActivationParameters()->duration.units/
+ poppler_movie->getActivationParameters()->duration.units_per_second;
+ } else {
+ movie->duration = 0L;
+ }
movie->rotation_angle = poppler_movie->getRotationAngle();
@@ -280,35 +290,35 @@ poppler_movie_get_rotation_angle (PopplerMovie *poppler_movie)
/**
* poppler_movie_get_start:
* @poppler_movie: a #PopplerMovie
- * @start: (out): a return location for a #PopplerMovieTime
*
- * Obtains the start position of the movie playback
+ * Returns the start position of the movie playback
+ *
+ * Return value: the start position of the movie playback (in ns)
*
* Since: 0.80
*/
-void
-poppler_movie_get_start (PopplerMovie *poppler_movie,
- PopplerMovieTime *start)
+guint64
+poppler_movie_get_start (PopplerMovie *poppler_movie)
{
- g_return_if_fail (POPPLER_IS_MOVIE (poppler_movie));
+ g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), 0L);
- *start = poppler_movie->start;
+ return poppler_movie->start;
}
/**
* poppler_movie_get_duration:
* @poppler_movie: a #PopplerMovie
- * @duration: (out): a return location for a #PopplerMovieTime
*
- * Obtains the duration of the movie playback
+ * Returns the duration of the movie playback
+ *
+ * Return value: the duration of the movie playback (in ns)
*
* Since: 0.80
*/
-void
-poppler_movie_get_duration (PopplerMovie *poppler_movie,
- PopplerMovieTime *duration)
+guint64
+poppler_movie_get_duration (PopplerMovie *poppler_movie)
{
- g_return_if_fail (POPPLER_IS_MOVIE (poppler_movie));
+ g_return_val_if_fail (POPPLER_IS_MOVIE (poppler_movie), 0L);
- *duration = poppler_movie->duration;
+ return poppler_movie->duration;
}
diff --git a/glib/poppler-movie.h b/glib/poppler-movie.h
index 52b3d7b7..9350a073 100644
--- a/glib/poppler-movie.h
+++ b/glib/poppler-movie.h
@@ -51,20 +51,6 @@ typedef enum
POPPLER_MOVIE_PLAY_MODE_PALINDROME
} PopplerMoviePlayMode;
-/**
- * PopplerMovieTime:
- *
- * Time-related entities (start position, duration); to get the equivalent
- * value in seconds, calculate (double) units/units_per_second. Note that
- * units_per_second may be zero if the respective entity is undefined.
- *
- * Since: 0.80
- */
-typedef struct {
- gulong units;
- gint units_per_second;
-} PopplerMovieTime;
-
POPPLER_PUBLIC
GType poppler_movie_get_type (void) G_GNUC_CONST;
POPPLER_PUBLIC
@@ -84,11 +70,9 @@ gdouble poppler_movie_get_rate (PopplerMovie *poppler_movie);
POPPLER_PUBLIC
gushort poppler_movie_get_rotation_angle (PopplerMovie *poppler_movie);
POPPLER_PUBLIC
-void poppler_movie_get_start (PopplerMovie *poppler_movie,
- PopplerMovieTime *start);
+guint64 poppler_movie_get_start (PopplerMovie *poppler_movie);
POPPLER_PUBLIC
-void poppler_movie_get_duration (PopplerMovie *poppler_movie,
- PopplerMovieTime *duration);
+guint64 poppler_movie_get_duration (PopplerMovie *poppler_movie);
G_END_DECLS