[vlc-commits] Map the new TitleDescription calls
Jean-Baptiste Kempf
git at videolan.org
Tue Jun 16 02:41:47 CEST 2015
libvlcpp | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jun 15 14:02:11 2015 +0200| [4b09ea17da6ca269200108739fb587ae2b423861] | committer: Hugo Beauzée-Luyssen
Map the new TitleDescription calls
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/libvlcpp.git/?a=commit;h=4b09ea17da6ca269200108739fb587ae2b423861
---
vlcpp/MediaPlayer.hpp | 21 +++++++++++++++++++++
vlcpp/structures.hpp | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/vlcpp/MediaPlayer.hpp b/vlcpp/MediaPlayer.hpp
index 1d81d57..b6d670d 100644
--- a/vlcpp/MediaPlayer.hpp
+++ b/vlcpp/MediaPlayer.hpp
@@ -1337,11 +1337,32 @@ public:
*
* \return list containing description of available titles
*/
+#if LIBVLC_VERSION_INT < LIBVLC_VERSION(3, 0, 0, 0)
std::vector<TrackDescription> titleDescription()
{
libvlc_track_description_t* result = libvlc_video_get_title_description( *this );
return getTracksDescription( result );
}
+#else
+ std::vector<TitleDescription> titleDescription()
+ {
+ libvlc_title_description_t **titles;
+ int nbTitles = libvlc_media_player_get_full_title_descriptions( *this, &titles);
+ auto cleanupCb = [nbTitles]( libvlc_title_description_t** ts) {
+ libvlc_title_descriptions_release( ts, nbTitles );
+ };
+
+ std::unique_ptr<libvlc_title_description_t*[], decltype(cleanupCb)> ptr(
+ titles, cleanupCb);
+ std::vector<TitleDescription> res;
+
+ if ( nbTitles < 1 )
+ return res;
+
+ for ( int i = 0; i < nbTitles; ++i )
+ res.emplace_back( ptr[i] );
+ }
+#endif
/**
* Get the description of available chapters for specific title.
diff --git a/vlcpp/structures.hpp b/vlcpp/structures.hpp
index 2bc8e67..1060074 100644
--- a/vlcpp/structures.hpp
+++ b/vlcpp/structures.hpp
@@ -468,5 +468,50 @@ private:
std::string m_name;
};
+///
+/// \brief The TitleDescription class describes a title
+///
+class TitleDescription
+{
+public:
+ ///
+ /// \brief duration The title duration in (ms)
+ ///
+ int64_t duration() const
+ {
+ return m_duration;
+ }
+
+ ///
+ /// \brief name The title name
+ ///
+ const std::string& name() const
+ {
+ return m_name;
+ }
+
+ ///
+ /// \brief name Is the title a menu?
+ ///
+ bool isMenu() const
+ {
+ return m_menu;
+ }
+
+
+ explicit TitleDescription( libvlc_title_description_t* c )
+ : m_duration( c->i_duration ), m_menu( c->b_menu )
+ {
+ if ( c->psz_name != nullptr )
+ m_name = c->psz_name;
+ }
+
+private:
+ int64_t m_duration;
+ std::string m_name;
+ bool m_menu;
+};
+
+
} // namespace VLC
#endif
More information about the vlc-commits
mailing list