[vlc-commits] Add libvlc_video_get_spu_delay and libvlc_video_set_spu_delay
John Hendrikx
git at videolan.org
Thu Dec 1 22:51:25 CET 2011
vlc | branch: master | John Hendrikx <hjohn at xs4all.nl> | Thu Dec 1 14:08:33 2011 +0100| [3cd41963f1e4030a84010e94288dc9431fa5c9e0] | committer: Jean-Baptiste Kempf
Add libvlc_video_get_spu_delay and libvlc_video_set_spu_delay
Allows control of the subtitle delay through libvlc.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3cd41963f1e4030a84010e94288dc9431fa5c9e0
---
include/vlc/libvlc_media_player.h | 24 +++++++++++++++++++++++
lib/libvlc.sym | 2 +
lib/video.c | 38 +++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index a2b5748..152a95d 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1039,6 +1039,30 @@ LIBVLC_API int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu
LIBVLC_API int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi, const char *psz_subtitle );
/**
+ * Get the current subtitle delay. Positive values means subtitles are being
+ * displayed later, negative values earlier.
+ *
+ * \param p_mi media player
+ * \return time (in microseconds) the display of subtitles is being delayed
+ * \version LibVLC 1.2.0 or later
+ */
+LIBVLC_API int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi );
+
+/**
+ * Set the subtitle delay. This affects the timing of when the subtitle will
+ * be displayed. Positive values result in subtitles being displayed later,
+ * while negative values will result in subtitles being displayed earlier.
+ *
+ * The subtitle delay will be reset to zero each time the media changes.
+ *
+ * \param p_mi media player
+ * \param i_delay time (in microseconds) the display of subtitles should be delayed
+ * \return 0 on success, -1 on error
+ * \version LibVLC 1.2.0 or later
+ */
+LIBVLC_API int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi, int64_t i_delay );
+
+/**
* Get the description of available titles.
*
* \param p_mi the media player
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 6582a96..45327d5 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -189,6 +189,7 @@ libvlc_video_get_marquee_string
libvlc_video_get_scale
libvlc_video_get_spu
libvlc_video_get_spu_count
+libvlc_video_get_spu_delay
libvlc_video_get_spu_description
libvlc_video_get_teletext
libvlc_video_get_title_description
@@ -212,6 +213,7 @@ libvlc_video_set_marquee_string
libvlc_video_set_mouse_input
libvlc_video_set_scale
libvlc_video_set_spu
+libvlc_video_set_spu_delay
libvlc_video_set_subtitle_file
libvlc_video_set_teletext
libvlc_video_set_track
diff --git a/lib/video.c b/lib/video.c
index b659c88..163bca3 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -365,6 +365,44 @@ int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
return b_ret;
}
+int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
+{
+ input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
+ int64_t val = 0;
+
+ if( p_input_thread )
+ {
+ val = var_GetTime( p_input_thread, "spu-delay" );
+ vlc_object_release( p_input_thread );
+ }
+ else
+ {
+ libvlc_printerr( "No active input" );
+ }
+
+ return val;
+}
+
+int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
+ int64_t i_delay )
+{
+ input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
+ int ret = -1;
+
+ if( p_input_thread )
+ {
+ var_SetTime( p_input_thread, "spu-delay", i_delay );
+ vlc_object_release( p_input_thread );
+ ret = 0;
+ }
+ else
+ {
+ libvlc_printerr( "No active input" );
+ }
+
+ return ret;
+}
+
libvlc_track_description_t *
libvlc_video_get_title_description( libvlc_media_player_t *p_mi )
{
More information about the vlc-commits
mailing list