Commit 56e36380 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Always expose MediaTrack::Type instead of libvlc_track_type_t

parent 7eb7e720
......@@ -746,55 +746,54 @@ class MediaPlayerEventManager : public EventManager
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
/**
* \brief onESAdded Registers an event called when an elementary stream get added
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The new track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The new track type
* int: the new track index
*/
template <typename Func>
RegisteredEvent onESAdded( Func&& f )
{
//FIXME: Expose libvlc_track_type_t as an enum class
EXPECT_SIGNATURE(void(libvlc_track_type_t, const std::string&));
EXPECT_SIGNATURE(void(MediaTrack::Type, const std::string&));
return handle( libvlc_MediaPlayerESAdded, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type,
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
std::string{ e->u.media_player_es_changed.psz_id } );
});
}
/**
* \brief onESDeleted Registers an event called when an elementary stream get deleted
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The track type
* int: the track index
*/
template <typename Func>
RegisteredEvent onESDeleted( Func&& f )
{
EXPECT_SIGNATURE(void(libvlc_track_type_t, const std::string&));
EXPECT_SIGNATURE(void(MediaTrack::Type, const std::string&));
return handle( libvlc_MediaPlayerESDeleted, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type,
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
std::string{ e->u.media_player_es_changed.psz_id } );
});
}
/**
* \brief onESSelected Registers an event called when an elementary stream get selected
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The track type
* int: the track index
*/
template <typename Func>
RegisteredEvent onESSelected( Func&& f )
{
EXPECT_SIGNATURE(void(libvlc_track_type_t, const std::string&, const std::string&));
EXPECT_SIGNATURE(void(MediaTrack::Type, const std::string&, const std::string&));
return handle( libvlc_MediaPlayerESSelected, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type,
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
std::string{ e->u.media_player_es_selection_changed.psz_selected_id },
std::string{ e->u.media_player_es_selection_changed.psz_unselected_id } );
});
......@@ -818,53 +817,55 @@ class MediaPlayerEventManager : public EventManager
#elif LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
/**
* \brief onESAdded Registers an event called when an elementary stream get added
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The new track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The new track type
* int: the new track index
*/
template <typename Func>
RegisteredEvent onESAdded( Func&& f )
{
//FIXME: Expose libvlc_track_type_t as an enum class
EXPECT_SIGNATURE(void(libvlc_track_type_t, int));
EXPECT_SIGNATURE(void(MediaTrack::Type, int));
return handle( libvlc_MediaPlayerESAdded, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type, e->u.media_player_es_changed.i_id );
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
e->u.media_player_es_changed.i_id );
});
}
/**
* \brief onESDeleted Registers an event called when an elementary stream get deleted
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The track type
* int: the track index
*/
template <typename Func>
RegisteredEvent onESDeleted( Func&& f )
{
EXPECT_SIGNATURE(void(libvlc_track_type_t, int));
EXPECT_SIGNATURE(void(MediaTrack::Type, int));
return handle( libvlc_MediaPlayerESDeleted, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type, e->u.media_player_es_changed.i_id );
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
e->u.media_player_es_changed.i_id );
});
}
/**
* \brief onESSelected Registers an event called when an elementary stream get selected
* \param f A std::function<void(libvlc_track_type_t, int)> (or an equivalent Callable type)
* libvlc_track_type_t: The track type
* \param f A std::function<void(MediaTrack::Type, int)> (or an equivalent Callable type)
* MediaTrack::Type: The track type
* int: the track index
*/
template <typename Func>
RegisteredEvent onESSelected( Func&& f )
{
EXPECT_SIGNATURE(void(libvlc_track_type_t, int));
EXPECT_SIGNATURE(void(MediaTrack::Type, int));
return handle( libvlc_MediaPlayerESSelected, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>( data );
(*callback)( e->u.media_player_es_changed.i_type, e->u.media_player_es_changed.i_id );
(*callback)( static_cast<MediaTrack::Type>( e->u.media_player_es_changed.i_type ),
e->u.media_player_es_changed.i_id );
});
}
......
......@@ -655,11 +655,12 @@ public:
* \return a vector containing all tracks
*/
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
std::vector<MediaTrack> tracks( libvlc_track_type_t type )
std::vector<MediaTrack> tracks( MediaTrack::Type type )
{
using TrackListPtr = std::unique_ptr<libvlc_media_tracklist_t,
decltype(&libvlc_media_tracklist_delete)>;
TrackListPtr trackList{ libvlc_media_get_tracklist( *this, type ),
TrackListPtr trackList{ libvlc_media_get_tracklist( *this,
static_cast<libvlc_track_type_t>( type ) ),
&libvlc_media_tracklist_delete };
if ( trackList == nullptr )
return {};
......
......@@ -1843,11 +1843,12 @@ public:
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
std::vector<MediaTrack> tracks( libvlc_track_type_t type )
std::vector<MediaTrack> tracks( MediaTrack::Type type )
{
using TrackListPtr = std::unique_ptr<libvlc_media_tracklist_t,
decltype(&libvlc_media_tracklist_delete)>;
TrackListPtr trackList{ libvlc_media_player_get_tracklist( *this, type ),
TrackListPtr trackList{ libvlc_media_player_get_tracklist( *this,
static_cast<libvlc_track_type_t>( type ) ),
&libvlc_media_tracklist_delete };
if ( trackList == nullptr )
return {};
......
......@@ -103,13 +103,13 @@ public:
///
enum class Type
{
Unknown = -1,
Unknown = libvlc_track_unknown,
/// Audio track
Audio,
Audio = libvlc_track_audio,
/// Video track
Video,
Video = libvlc_track_video,
/// Subtitle track (also called SPU sometimes)
Subtitle
Subtitle = libvlc_track_text,
};
///
......
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