diff options
author | Philippe Normand <philn@igalia.com> | 2018-10-28 14:48:35 +0000 |
---|---|---|
committer | Philippe Normand <philn@igalia.com> | 2018-11-01 09:52:57 +0000 |
commit | de26abc88ad93fb18ca73aee1fe5704346f6d965 (patch) | |
tree | 435cc8d7e1e2d5ddcfa6e5123ecd6d679dd95dd9 /gst-libs | |
parent | 2e6e4cce0b682d6e81b30f7b395bcdcec7e514e5 (diff) | |
download | gstreamer-plugins-bad-de26abc88ad93fb18ca73aee1fe5704346f6d965.tar.gz |
player: API additions for subtitle-video-offset property
This new property contols the synchronisation offset between subtitles and video
in nanoseconds.
https://bugzilla.gnome.org/show_bug.cgi?id=797134
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/player/gstplayer.c | 53 | ||||
-rw-r--r-- | gst-libs/gst/player/gstplayer.h | 7 |
2 files changed, 60 insertions, 0 deletions
diff --git a/gst-libs/gst/player/gstplayer.c b/gst-libs/gst/player/gstplayer.c index 651d2a57c..04b6aef37 100644 --- a/gst-libs/gst/player/gstplayer.c +++ b/gst-libs/gst/player/gstplayer.c @@ -67,6 +67,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_player_debug); #define DEFAULT_RATE 1.0 #define DEFAULT_POSITION_UPDATE_INTERVAL_MS 100 #define DEFAULT_AUDIO_VIDEO_OFFSET 0 +#define DEFAULT_SUBTITLE_VIDEO_OFFSET 0 GQuark gst_player_error_quark (void) @@ -116,6 +117,7 @@ enum PROP_VIDEO_MULTIVIEW_MODE, PROP_VIDEO_MULTIVIEW_FLAGS, PROP_AUDIO_VIDEO_OFFSET, + PROP_SUBTITLE_VIDEO_OFFSET, PROP_LAST }; @@ -412,6 +414,11 @@ gst_player_class_init (GstPlayerClass * klass) "The synchronisation offset between audio and video in nanoseconds", G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + param_specs[PROP_SUBTITLE_VIDEO_OFFSET] = + g_param_spec_int64 ("subtitle-video-offset", "Text Video Offset", + "The synchronisation offset between text and video in nanoseconds", + G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (gobject_class, PROP_LAST, param_specs); signals[SIGNAL_URI_LOADED] = @@ -734,6 +741,9 @@ gst_player_set_property (GObject * object, guint prop_id, case PROP_AUDIO_VIDEO_OFFSET: g_object_set_property (G_OBJECT (self->playbin), "av-offset", value); break; + case PROP_SUBTITLE_VIDEO_OFFSET: + g_object_set_property (G_OBJECT (self->playbin), "text-offset", value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -831,6 +841,9 @@ gst_player_get_property (GObject * object, guint prop_id, case PROP_AUDIO_VIDEO_OFFSET: g_object_get_property (G_OBJECT (self->playbin), "av-offset", value); break; + case PROP_SUBTITLE_VIDEO_OFFSET: + g_object_get_property (G_OBJECT (self->playbin), "text-offset", value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -4345,6 +4358,46 @@ gst_player_set_audio_video_offset (GstPlayer * self, gint64 offset) g_object_set (self, "audio-video-offset", offset, NULL); } +/** + * gst_player_get_subtitle_video_offset: + * @player: #GstPlayer instance + * + * Retrieve the current value of subtitle-video-offset property + * + * Returns: The current value of subtitle-video-offset in nanoseconds + * + * Since 1.16 + */ +gint64 +gst_player_get_subtitle_video_offset (GstPlayer * self) +{ + gint64 val = 0; + + g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_SUBTITLE_VIDEO_OFFSET); + + g_object_get (self, "subtitle-video-offset", &val, NULL); + + return val; +} + +/** + * gst_player_set_subtitle_video_offset: + * @player: #GstPlayer instance + * @offset: #gint64 in nanoseconds + * + * Sets subtitle-video-offset property by value of @offset + * + * Since 1.16 + */ +void +gst_player_set_subtitle_video_offset (GstPlayer * self, gint64 offset) +{ + g_return_if_fail (GST_IS_PLAYER (self)); + + g_object_set (self, "subtitle-video-offset", offset, NULL); +} + + #define C_ENUM(v) ((gint) v) #define C_FLAGS(v) ((guint) v) diff --git a/gst-libs/gst/player/gstplayer.h b/gst-libs/gst/player/gstplayer.h index bea83ea50..d5737ca26 100644 --- a/gst-libs/gst/player/gstplayer.h +++ b/gst-libs/gst/player/gstplayer.h @@ -250,6 +250,13 @@ void gst_player_set_audio_video_offset (GstPlayer * player, gint64 offset); GST_PLAYER_API +gint64 gst_player_get_subtitle_video_offset (GstPlayer * player); + +GST_PLAYER_API +void gst_player_set_subtitle_video_offset (GstPlayer * player, + gint64 offset); + +GST_PLAYER_API gboolean gst_player_set_config (GstPlayer * player, GstStructure * config); |