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:
* \return a vector containing all tracks
*/
#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 )
return nullptr;
return std::make_shared<TrackList>( trackList );
return {};
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)
std::vector<MediaTrack> tracks()
......
......@@ -1843,12 +1843,19 @@ public:
#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 )
return nullptr;
return std::make_shared<TrackList>( trackList );
return {};
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
......
......@@ -759,28 +759,5 @@ private:
#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
#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