Commit 6fe9a537 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Add Media thumbnail support

parent 05c72b1c
......@@ -371,6 +371,34 @@ class MediaEventManager : public EventManager
(*callback)( media != nullptr ? std::make_shared<Media>( media, true ) : nullptr );
});
}
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
/**
* \brief onThumbnailGenerated is invoked upon success & failure of a thumbnail generation
* \param A std::function<void(const Picture*)> (or an equivalent Callable type)
* The provided picture will be null if the thumbnail generation failed.
* In case of success, the thumbnail is only valid for the duration
* of the callback, but can be safely copied if needed.
*/
template <typename Func>
RegisteredEvent onThumbnailGenerated( Func&& f)
{
EXPECT_SIGNATURE(void(const Picture*));
return handle(libvlc_MediaThumbnailGenerated, std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
{
auto callback = static_cast<DecayPtr<Func>>(data);
auto pic = e->u.media_thumbnail_generated.p_thumbnail;
if ( pic != nullptr )
{
Picture p{ pic };
(*callback)( &p );
}
else
(*callback)( nullptr );
});
}
#endif
};
/**
......
......@@ -743,6 +743,48 @@ public:
return res;
}
#endif
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
using ThumbnailRequest = libvlc_media_thumbnail_request_t;
enum class ThumbnailSeekSpeed
{
Precise = libvlc_media_thumbnail_seek_precise,
Fast = libvlc_media_thumbnail_seek_fast,
};
ThumbnailRequest* thumbnailRequestByTime( libvlc_time_t time, ThumbnailSeekSpeed speed,
uint32_t width, uint32_t height,
Picture::Type type, libvlc_time_t timeout )
{
return libvlc_media_thumbnail_request_by_time( *this, time,
static_cast<libvlc_thumbnailer_seek_speed>( speed ), width,
height, static_cast<libvlc_picture_type_t>( type ), timeout );
}
ThumbnailRequest* thumbnailRequestByPos( float pos, ThumbnailSeekSpeed speed,
uint32_t width, uint32_t height,
Picture::Type type, libvlc_time_t timeout )
{
return libvlc_media_thumbnail_request_by_pos( *this, pos,
static_cast<libvlc_thumbnailer_seek_speed>( speed ), width,
height, static_cast<libvlc_picture_type_t>( type ), timeout );
}
/**
* @brief thumbnailCancel cancels a thumbnailing request
* @param request An opaque thumbnail request object.
*
* Cancelling the request will still cause onThumbnailGenerated callback
* to be invoked, with nullptr as the picture instance.
* If the request is cancelled after its completion, the behavior is undefined.
*/
void thumbnailCancel( ThumbnailRequest* request )
{
libvlc_media_thumbnail_cancel( request );
}
#endif
private:
......
Markdown is supported
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