Commit 7eb7e720 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Don't expose TrackList anymore

parent 7a026fa6
...@@ -655,12 +655,19 @@ public: ...@@ -655,12 +655,19 @@ public:
* \return a vector containing all tracks * \return a vector containing all tracks
*/ */
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0) #if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
std::shared_ptr<TrackList> tracks( libvlc_track_type_t type ) std::vector<MediaTrack> tracks( libvlc_track_type_t type )
{ {
auto trackList = libvlc_media_get_tracklist( *this, type ); using TrackListPtr = std::unique_ptr<libvlc_media_tracklist_t,
decltype(&libvlc_media_tracklist_delete)>;
TrackListPtr trackList{ libvlc_media_get_tracklist( *this, type ),
&libvlc_media_tracklist_delete };
if ( trackList == nullptr ) if ( trackList == nullptr )
return nullptr; return {};
return std::make_shared<TrackList>( trackList ); auto count = libvlc_media_tracklist_count( trackList.get() );
std::vector<MediaTrack> res{};
for ( auto i = 0u; i < count; ++i )
res.emplace_back( libvlc_media_tracklist_at( trackList.get(), i ) );
return res;
} }
#elif LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0) #elif LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
std::vector<MediaTrack> tracks() std::vector<MediaTrack> tracks()
......
...@@ -1843,12 +1843,19 @@ public: ...@@ -1843,12 +1843,19 @@ public:
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0) #if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
std::shared_ptr<TrackList> tracks( libvlc_track_type_t type ) std::vector<MediaTrack> tracks( libvlc_track_type_t type )
{ {
auto trackList = libvlc_media_player_get_tracklist( *this, type ); using TrackListPtr = std::unique_ptr<libvlc_media_tracklist_t,
decltype(&libvlc_media_tracklist_delete)>;
TrackListPtr trackList{ libvlc_media_player_get_tracklist( *this, type ),
&libvlc_media_tracklist_delete };
if ( trackList == nullptr ) if ( trackList == nullptr )
return nullptr; return {};
return std::make_shared<TrackList>( trackList ); auto count = libvlc_media_tracklist_count( trackList.get() );
std::vector<MediaTrack> res{};
for ( auto i = 0u; i < count; ++i )
res.emplace_back( libvlc_media_tracklist_at( trackList.get(), i ) );
return res;
} }
#endif #endif
......
...@@ -759,28 +759,5 @@ private: ...@@ -759,28 +759,5 @@ private:
#endif #endif
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
class TrackList : public Internal<libvlc_media_tracklist_t>
{
public:
explicit TrackList( libvlc_media_tracklist_t *trackList )
: Internal{ trackList, libvlc_media_tracklist_delete }
{
}
size_t count() const
{
return libvlc_media_tracklist_count( *this );
}
MediaTrack at( size_t index ) const
{
return MediaTrack{ libvlc_media_tracklist_at( *this, index ) };
}
};
#endif
} // namespace VLC } // namespace VLC
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment