[vlc-devel] [PATCH] libvlc: expand media player API to reveal full information about titles and chapters
Felix Paul Kühne
fkuehne at videolan.org
Mon Jan 26 20:37:02 CET 2015
---
include/vlc/libvlc_media_player.h | 61 +++++++++++++++++++++++++
lib/libvlc.sym | 4 ++
lib/media_player.c | 96 +++++++++++++++++++++++++++++++++++++++
3 files changed, 161 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index c55e85d..5a7d34f 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -60,6 +60,31 @@ typedef struct libvlc_track_description_t
} libvlc_track_description_t;
+
+/**
+ * Description for chapters.
+ * It contains information about time and byte off set as well as
+ * name (description string).
+ */
+typedef struct libvlc_chapter_description_t
+{
+ int64_t i_byte_offset;
+ int64_t i_time_offset;
+ char *psz_name;
+} libvlc_chapter_description_t;
+
+/**
+ * Description for titles. It contains id, name (description string), duration and size,
+ * and information if it is a menu.
+ */
+typedef struct libvlc_title_description_t
+{
+ bool b_menu;
+ char *psz_name;
+ int64_t i_duration;
+ int64_t i_size;
+} libvlc_title_description_t;
+
/**
* Description for audio output. It contains
* name, description and pointer to next record.
@@ -1129,6 +1154,24 @@ LIBVLC_API libvlc_track_description_t *
libvlc_video_get_title_description( libvlc_media_player_t *p_mi );
/**
+ * Get the full description of a title
+ *
+ * \param p_mi the media player
+ * \return structure containing the full description of the respective title
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API libvlc_title_description_t *
+ libvlc_media_player_get_full_title_description( libvlc_media_player_t *p_mi, int i_title );
+
+/**
+ * Release a title description
+ * \param p_desc the title description to release
+ * \version LibVLC 3.0.0 and later
+ */
+LIBVLC_API
+ void libvlc_title_description_release( libvlc_title_description_t *p_desc );
+
+/**
* Get the description of available chapters for specific title.
*
* \param p_mi the media player
@@ -1139,6 +1182,24 @@ LIBVLC_API libvlc_track_description_t *
libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi, int i_title );
/**
+ * Get the full description of a chapter
+ *
+ * \param p_mi the media player
+ * \return structure containing the full description of the respective chapter
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API libvlc_chapter_description_t *
+ libvlc_media_player_get_full_chapter_description( libvlc_media_player_t *p_mi, int i_title, int i_chapter );
+
+/**
+ * Release a chapter description
+ * \param p_desc the chapter description to release
+ * \version LibVLC 3.0.0 and later
+ */
+LIBVLC_API
+ void libvlc_chapter_description_release( libvlc_chapter_description_t *p_desc );
+
+/**
* Get current crop filter geometry.
*
* \param p_mi the media player
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 7810ed7..41a786b 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -43,6 +43,7 @@ libvlc_audio_set_format
libvlc_audio_set_format_callbacks
libvlc_audio_set_callbacks
libvlc_audio_set_volume_callback
+libvlc_chapter_description_release
libvlc_clock
libvlc_event_attach
libvlc_event_detach
@@ -141,6 +142,8 @@ libvlc_media_player_get_chapter
libvlc_media_player_get_chapter_count
libvlc_media_player_get_chapter_count_for_title
libvlc_media_player_get_fps
+libvlc_media_player_get_full_chapter_description
+libvlc_media_player_get_full_title_description
libvlc_media_player_get_hwnd
libvlc_media_player_get_length
libvlc_media_player_get_media
@@ -196,6 +199,7 @@ libvlc_set_fullscreen
libvlc_set_log_verbosity
libvlc_set_user_agent
libvlc_set_app_id
+libvlc_title_description_release
libvlc_toggle_fullscreen
libvlc_toggle_teletext
libvlc_track_description_release
diff --git a/lib/media_player.c b/lib/media_player.c
index 3ca1e10..7c98692 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1223,6 +1223,102 @@ int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
return i_ret == VLC_SUCCESS ? val.i_int : -1;
}
+libvlc_title_description_t *
+libvlc_media_player_get_full_title_description( libvlc_media_player_t *p_mi, int i_title )
+{
+ input_thread_t *p_input = libvlc_get_input_thread( p_mi );
+ libvlc_title_description_t *p_title_description = NULL;
+
+ if (!p_input)
+ return NULL;
+
+ input_title_t *p_title = NULL;
+
+ if (input_Control(p_input, INPUT_GET_TITLE_INFO, &p_title, &i_title) != VLC_SUCCESS) {
+ vlc_object_release(p_input);
+ return NULL;
+ }
+ vlc_object_release(p_input);
+
+ if (!p_title)
+ return NULL;
+
+ p_title_description = (libvlc_title_description_t *) malloc(sizeof(libvlc_title_description_t *));
+ if (!p_title_description) {
+ libvlc_printerr("Not enough memory");
+ vlc_input_title_Delete(p_title);
+ return NULL;
+ }
+
+ p_title_description->b_menu = p_title->b_menu;
+ if (p_title->psz_name)
+ p_title_description->psz_name = strdup(p_title->psz_name);
+ else
+ p_title_description->psz_name = NULL;
+ p_title_description->i_duration = p_title->i_length;
+ p_title_description->i_size = p_title->i_size;
+
+ vlc_input_title_Delete(p_title);
+
+ return p_title_description;
+}
+
+void libvlc_title_description_release( libvlc_title_description_t *p_desc )
+{
+ if (p_desc->psz_name)
+ free(p_desc->psz_name);
+ free(p_desc);
+}
+
+libvlc_chapter_description_t *
+libvlc_media_player_get_full_chapter_description( libvlc_media_player_t *p_mi, int i_title, int i_chapter )
+{
+ input_thread_t *p_input = libvlc_get_input_thread( p_mi );
+ libvlc_chapter_description_t *p_chapter_description = NULL;
+
+ if (!p_input)
+ return NULL;
+
+ input_title_t *p_title = NULL;
+
+ if (input_Control(p_input, INPUT_GET_TITLE_INFO, &p_title, &i_title) != VLC_SUCCESS) {
+ vlc_object_release(p_input);
+ return NULL;
+ }
+ vlc_object_release(p_input);
+
+ if (!p_title)
+ return NULL;
+
+ if (i_chapter >= p_title->i_seekpoint)
+ return NULL;
+
+ p_chapter_description = (libvlc_chapter_description_t *) malloc(sizeof(libvlc_chapter_description_t *));
+ if (!p_chapter_description) {
+ libvlc_printerr("Not enough memory");
+ vlc_input_title_Delete(p_title);
+ return NULL;
+ }
+
+ p_chapter_description->i_byte_offset = p_title->seekpoint[i_chapter]->i_byte_offset;
+ p_chapter_description->i_time_offset = p_title->seekpoint[i_chapter]->i_time_offset;
+ if (p_title->seekpoint[i_chapter]->psz_name)
+ p_chapter_description->psz_name = strdup(p_title->seekpoint[i_chapter]->psz_name);
+ else
+ p_chapter_description->psz_name = NULL;
+
+ vlc_input_title_Delete(p_title);
+
+ return p_chapter_description;
+}
+
+void libvlc_chapter_description_release( libvlc_chapter_description_t *p_desc )
+{
+ if (p_desc->psz_name)
+ free(p_desc->psz_name);
+ free(p_desc);
+}
+
void libvlc_media_player_next_chapter( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread;
--
1.9.3 (Apple Git-50)
More information about the vlc-devel
mailing list