libvlcpp | branch: master | Jean-Baptiste Kempf <[email protected]> | Mon Jun 15 14:09:50 2015 +0200| [d3bbaa20ab335326e595eb2a20fc34057386394e] | committer: Hugo Beauzée-Luyssen
Map the new chapters description calls Signed-off-by: Hugo Beauzée-Luyssen <[email protected]> > http://git.videolan.org/gitweb.cgi/libvlcpp.git/?a=commit;h=d3bbaa20ab335326e595eb2a20fc34057386394e --- vlcpp/MediaPlayer.hpp | 22 +++++++++++++++++++++- vlcpp/structures.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/vlcpp/MediaPlayer.hpp b/vlcpp/MediaPlayer.hpp index b6d670d..9315bf9 100644 --- a/vlcpp/MediaPlayer.hpp +++ b/vlcpp/MediaPlayer.hpp @@ -1369,14 +1369,34 @@ public: * * \param i_title selected title * - * \return list containing description of available chapter for title + * \return list containing description of available chapters for title * i_title */ +#if LIBVLC_VERSION_INT < LIBVLC_VERSION(3, 0, 0, 0) std::vector<TrackDescription> chapterDescription(int i_title) { libvlc_track_description_t* result = libvlc_video_get_chapter_description( *this, i_title ); return getTracksDescription( result ); } +#else + std::vector<ChapterDescription> chapterDescription(int i_title) + { + libvlc_chapter_description_t **chapters; + int nbChapters = libvlc_media_player_get_full_chapter_descriptions( *this, i_title, &chapters ); + auto cleanupCb = [nbChapters](libvlc_chapter_description_t** cs) { + libvlc_chapter_descriptions_release( cs, nbChapters ); + }; + std::unique_ptr<libvlc_chapter_description_t*[], decltype(cleanupCb)> ptr( chapters, cleanupCb ); + + std::vector<ChapterDescription> res; + + if ( nbChapters < 1 ) + return res; + + for ( int i = 0; i < nbChapters; ++i ) + res.emplace_back( ptr[i] ); + } +#endif /** * Get current crop filter geometry. diff --git a/vlcpp/structures.hpp b/vlcpp/structures.hpp index 1060074..317e0e9 100644 --- a/vlcpp/structures.hpp +++ b/vlcpp/structures.hpp @@ -512,6 +512,48 @@ private: bool m_menu; }; +/// +/// \brief The ChapterDescription class describes a chapter +/// +class ChapterDescription +{ +public: + /// + /// \brief timeoffset The chapter start time in (ms) + /// + int64_t starttime() const + { + return m_starttime; + } + + /// + /// \brief duration The chapter duration in (ms) + /// + int64_t duration() const + { + return m_duration; + } + + /// + /// \brief name The chapter name + /// + const std::string& name() const + { + return m_name; + } + + explicit ChapterDescription( libvlc_chapter_description_t* c ) + : m_duration( c->i_duration ), m_starttime( c->i_time_offset ) + { + if ( c->psz_name != nullptr ) + m_name = c->psz_name; + } + +private: + int64_t m_duration, m_starttime; + std::string m_name; +}; + } // namespace VLC #endif _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
