]> git.sesse.net Git - vlc/commitdiff
Core playlist: provide playlist_GetNodeDuration
authorOlafs Vandāns <lunaroverlord@gmail.com>
Thu, 20 Dec 2012 16:19:30 +0000 (17:19 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 20 Dec 2012 16:31:12 +0000 (17:31 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
include/vlc_playlist.h
src/libvlccore.sym
src/playlist/item.c

index 89b2edf5460fd4a762a25e9e54f30b172e126e8e..10108cb2842b00126466353057cb8975dd825817 100644 (file)
@@ -283,6 +283,10 @@ VLC_API int playlist_Control( playlist_t *p_playlist, int i_query, bool b_locked
  */
 VLC_API input_thread_t * playlist_CurrentInput( playlist_t *p_playlist ) VLC_USED;
 
+/** Get the duration of all items in a node.
+ */
+VLC_API mtime_t playlist_GetNodeDuration( playlist_item_t * );
+
 /** Clear the playlist
  * \param b_locked TRUE if playlist is locked when entering this function
  */
index 8c5be173c0cee93add34c541f2dc95330fe4ef67..85cc03c1285f3a25253453169747f5dac7fa6407 100644 (file)
@@ -331,6 +331,7 @@ playlist_DeleteFromInput
 playlist_Export
 playlist_GetNextLeaf
 playlist_GetPrevLeaf
+playlist_GetNodeDuration
 playlist_Import
 playlist_IsServicesDiscoveryLoaded
 playlist_ItemGetById
index f5fde96e9e2217a9528d0d8dde7189416d8239d5..205cb169a1667198fb5b285cc9dc685ce79ac7ec 100644 (file)
@@ -719,6 +719,24 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
     var_SetAddress( p_playlist, "playlist-item-append", &add );
 }
 
+/**
+ * Get the duration of all items in a node.
+ */
+mtime_t playlist_GetNodeDuration( playlist_item_t* node )
+{
+    /* For the assert */
+    playlist_t *p_playlist = node->p_playlist;
+    PL_ASSERT_LOCKED;
+
+    mtime_t mt_duration = 0;
+
+    if( node->i_children != -1 )
+        for( int i = 0; i < node->i_children; i++ )
+            mt_duration += input_item_GetDuration( node->pp_children[i]->p_input );
+
+    return mt_duration;
+}
+
 /***************************************************************************
  * The following functions are local
  ***************************************************************************/