Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (7)
......@@ -63,7 +63,7 @@ typedef enum input_item_meta_request_option_t
*
* @param obj the parent object
* @param max_threads the maximum number of threads used to parse, must be >= 1
* @param default_timeout default timeout of the preparser, 0 for no limits.
* @param timeout timeout of the preparser, 0 for no limits.
* @param request_type a combination of META_REQUEST_OPTION_PARSE,
* META_REQUEST_OPTION_FETCH_LOCAL and META_REQUEST_OPTION_FETCH_NETWORK, it is
* used to setup the executors for each domain.
......@@ -71,7 +71,7 @@ typedef enum input_item_meta_request_option_t
*/
VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj,
unsigned max_threads,
vlc_tick_t default_timeout,
vlc_tick_t timeout,
input_item_meta_request_option_t request_type );
/**
......
......@@ -32,84 +32,91 @@ typedef size_t vlc_thumbnailer_req_id;
#define VLC_THUMBNAILER_REQ_ID_INVALID 0
/**
* \brief vlc_thumbnailer_cb defines a callback invoked on thumbnailing completion or error
*
* This callback will always be called, provided vlc_thumbnailer_Request returned
* a non NULL request, and provided the request is not cancelled before its
* completion.
* In case of failure, p_thumbnail will be NULL.
* The picture, if any, is owned by the thumbnailer, and must be acquired by using
* \link picture_Hold \endlink to use it pass the callback's scope.
*
* \param data Is the opaque pointer passed as vlc_thumbnailer_Request last parameter
* \param thumbnail The generated thumbnail, or NULL in case of failure or timeout
* thumbnailer callbacks
*/
typedef void(*vlc_thumbnailer_cb)( void* data, picture_t* thumbnail );
struct vlc_thumbnailer_cbs
{
/**
* Event received on thumbnailing completion or error
*
* This callback will always be called, provided vlc_thumbnailer_Request
* returned a valid request, and provided the request is not cancelled
* before its completion.
*
* @note This callback is mandatory.
*
* In case of failure, p_thumbnail will be NULL. The picture, if any, is
* owned by the thumbnailer, and must be acquired by using \link
* picture_Hold \endlink to use it pass the callback's scope.
* \param thumbnail The generated thumbnail, or NULL in case of failure or
* timeout
* \param data Is the opaque pointer passed as vlc_thumbnailer_Request last
* parameter
*/
void (*on_ended)(picture_t* thumbnail, void *data);
};
/**
* \brief vlc_thumbnailer_Create Creates a thumbnailer object
* \param parent A VLC object
* @param timeout timeout of the thumbnailer, 0 for no limits.
* \return A thumbnailer object, or NULL in case of failure
*/
VLC_API vlc_thumbnailer_t*
vlc_thumbnailer_Create(vlc_object_t* parent)
VLC_USED;
vlc_thumbnailer_Create(vlc_object_t* parent, vlc_tick_t timeout) VLC_USED;
enum vlc_thumbnailer_seek_speed
/**
* Thumbnailer seek argument
*/
struct vlc_thumbnailer_seek_arg
{
/** Precise, but potentially slow */
VLC_THUMBNAILER_SEEK_PRECISE,
/** Fast, but potentially imprecise */
VLC_THUMBNAILER_SEEK_FAST,
enum
{
/** Don't seek */
VLC_THUMBNAILER_SEEK_NONE,
/** Seek by time */
VLC_THUMBNAILER_SEEK_TIME,
/** Seek by position */
VLC_THUMBNAILER_SEEK_POS,
} type;
union
{
/** Seek time if type == VLC_THUMBNAILER_SEEK_TIME */
vlc_tick_t time;
/** Seek position if type == VLC_THUMBNAILER_SEEK_POS */
double pos;
};
enum
{
/** Precise, but potentially slow */
VLC_THUMBNAILER_SEEK_PRECISE,
/** Fast, but potentially imprecise */
VLC_THUMBNAILER_SEEK_FAST,
} speed;
};
/**
* \brief vlc_thumbnailer_RequestByTime Requests a thumbnailer at a given time
* \brief vlc_thumbnailer_Request Requests a thumbnailer
* \param thumbnailer A thumbnailer object
* \param time The time at which the thumbnail should be taken
* \param speed The seeking speed \sa{enum vlc_thumbnailer_seek_speed}
* \param input_item The input item to generate the thumbnail for
* \param seek_arg pointer to a seek struct, that tell at which time the
* thumbnail should be taken, NULL to disable seek
* \param timeout A timeout value, or VLC_TICK_INVALID to disable timeout
* \param cb A user callback to be called on completion (success & error)
* \param user_data An opaque value, provided as pf_cb's first parameter
* \returns > 0 if the item was scheduled for thumbnailing, 0 in case of error.
* \param cbs callback to listen to events (can't be NULL)
* \param cbs_userdata opaque pointer used by the callbacks
* \return VLC_THUMBNAILER_REQ_ID_INVALID in case of error, or a valid id if the
* item was scheduled for thumbnailing. If this returns an
* error, the on_ended callback will *not* be invoked
*
* If this function returns a valid id, the callback is guaranteed
* to be called, even in case of later failure (except if cancelled early by
* the user).
* The provided input_item will be held by the thumbnailer and can safely be
* released safely after calling this function.
*/
VLC_API vlc_thumbnailer_req_id
vlc_thumbnailer_RequestByTime( vlc_thumbnailer_t *thumbnailer,
vlc_tick_t time,
enum vlc_thumbnailer_seek_speed speed,
input_item_t *input_item, vlc_tick_t timeout,
vlc_thumbnailer_cb cb, void* user_data );
/**
* \brief vlc_thumbnailer_RequestByTime Requests a thumbnailer at a given time
* \param thumbnailer A thumbnailer object
* \param pos The position at which the thumbnail should be taken
* \param speed The seeking speed \sa{enum vlc_thumbnailer_seek_speed}
* \param input_item The input item to generate the thumbnail for
* \param timeout A timeout value, or VLC_TICK_INVALID to disable timeout
* \param cb A user callback to be called on completion (success & error)
* \param user_data An opaque value, provided as pf_cb's first parameter
* @return VLC_THUMBNAILER_REQ_ID_INVALID in case of error, or a valid id if
* the item was scheduled for preparsing. If this function returns a valid id,
* the callback is guaranteed to be called, even in case of later failure
* (except if cancelled early by the user).
* The provided input_item will be held by the thumbnailer and can safely be
* released safely after calling this function.
*/
VLC_API vlc_thumbnailer_req_id
vlc_thumbnailer_RequestByPos( vlc_thumbnailer_t *thumbnailer,
double pos,
enum vlc_thumbnailer_seek_speed speed,
input_item_t *input_item, vlc_tick_t timeout,
vlc_thumbnailer_cb cb, void* user_data );
vlc_thumbnailer_Request( vlc_thumbnailer_t *thumbnailer,
input_item_t *input_item,
const struct vlc_thumbnailer_seek_arg *seek_arg,
const struct vlc_thumbnailer_cbs *cbs,
void *cbs_userdata );
/**
* \brief vlc_thumbnailer_Camcel Cancel a thumbnail request
......@@ -122,9 +129,15 @@ VLC_API size_t
vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id );
/**
* \brief vlc_thumbnailer_Release releases a thumbnailer and cancel all pending requests
* \brief vlc_thumbnailer_Delete Deletes a thumbnailer and cancel all pending requests
* \param thumbnailer A thumbnailer object
*/
VLC_API void vlc_thumbnailer_Release( vlc_thumbnailer_t* thumbnailer );
VLC_API void vlc_thumbnailer_Delete( vlc_thumbnailer_t* thumbnailer );
/**
* Do not use, libVLC only fonction, will be removed soon
*/
VLC_API void vlc_thumbnailer_SetTimeout( vlc_thumbnailer_t *thumbnailer,
vlc_tick_t timeout ) VLC_DEPRECATED;
#endif // VLC_THUMBNAILER_H
......@@ -110,7 +110,7 @@ void libvlc_release( libvlc_instance_t *p_instance )
if (p_instance->parser != NULL)
vlc_preparser_Delete(p_instance->parser);
if (p_instance->thumbnailer != NULL)
vlc_thumbnailer_Release(p_instance->thumbnailer);
vlc_thumbnailer_Delete(p_instance->thumbnailer);
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int );
......@@ -285,7 +285,7 @@ vlc_thumbnailer_t *libvlc_get_thumbnailer(libvlc_instance_t *instance)
if (thumb == NULL)
{
thumb = instance->thumbnailer =
vlc_thumbnailer_Create(VLC_OBJECT(instance->p_libvlc_int));
vlc_thumbnailer_Create(VLC_OBJECT(instance->p_libvlc_int), 0);
}
vlc_mutex_unlock(&instance->lazy_init_lock);
......
......@@ -927,7 +927,7 @@ struct libvlc_media_thumbnail_request_t
vlc_thumbnailer_req_id id;
};
static void media_on_thumbnail_ready( void* data, picture_t* thumbnail )
static void media_on_thumbnail_ready( picture_t* thumbnail, void* data )
{
libvlc_media_thumbnail_request_t *req = data;
libvlc_media_t *p_media = req->md;
......@@ -945,13 +945,13 @@ static void media_on_thumbnail_ready( void* data, picture_t* thumbnail )
}
// Start an asynchronous thumbnail generation
libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
libvlc_media_t *md, libvlc_time_t time,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
static libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request( libvlc_instance_t *inst,
libvlc_media_t *md,
const struct vlc_thumbnailer_seek_arg *seek_arg,
unsigned int width, unsigned int height,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
assert( md );
......@@ -959,6 +959,8 @@ libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
if (unlikely(thumb == NULL))
return NULL;
vlc_thumbnailer_SetTimeout( thumb, vlc_tick_from_libvlc_time( timeout ) );
libvlc_media_thumbnail_request_t *req = malloc( sizeof( *req ) );
if ( unlikely( req == NULL ) )
return NULL;
......@@ -970,13 +972,11 @@ libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
req->type = picture_type;
req->crop = crop;
libvlc_media_retain( md );
req->id = vlc_thumbnailer_RequestByTime( thumb,
vlc_tick_from_libvlc_time( time ),
speed == libvlc_media_thumbnail_seek_fast ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
md->p_input_item,
timeout > 0 ? vlc_tick_from_libvlc_time( timeout ) : VLC_TICK_INVALID,
media_on_thumbnail_ready, req );
static const struct vlc_thumbnailer_cbs cbs = {
.on_ended = media_on_thumbnail_ready,
};
req->id = vlc_thumbnailer_Request( thumb, md->p_input_item, seek_arg,
&cbs, req );
if ( req->id == VLC_PREPARSER_REQ_ID_INVALID )
{
free( req );
......@@ -987,6 +987,24 @@ libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
return req;
}
libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
libvlc_media_t *md, libvlc_time_t time,
libvlc_thumbnailer_seek_speed_t speed,
unsigned int width, unsigned int height,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
const struct vlc_thumbnailer_seek_arg seek_arg = {
.type = VLC_THUMBNAILER_SEEK_TIME,
.time = vlc_tick_from_libvlc_time( time ),
.speed = speed == libvlc_media_thumbnail_seek_fast ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
};
return libvlc_media_thumbnail_request( inst, md, &seek_arg, width, height,
crop, picture_type, timeout );
}
// Start an asynchronous thumbnail generation
libvlc_media_thumbnail_request_t*
libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst,
......@@ -996,37 +1014,14 @@ libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
assert( md );
vlc_thumbnailer_t *thumb = libvlc_get_thumbnailer(inst);
if (unlikely(thumb == NULL))
return NULL;
libvlc_media_thumbnail_request_t *req = malloc( sizeof( *req ) );
if ( unlikely( req == NULL ) )
return NULL;
req->instance = inst;
req->md = md;
req->width = width;
req->height = height;
req->crop = crop;
req->type = picture_type;
libvlc_media_retain( md );
req->id = vlc_thumbnailer_RequestByPos( thumb, pos,
speed == libvlc_media_thumbnail_seek_fast ?
const struct vlc_thumbnailer_seek_arg seek_arg = {
.type = VLC_THUMBNAILER_SEEK_POS,
.pos = pos,
.speed = speed == libvlc_media_thumbnail_seek_fast ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
md->p_input_item,
timeout > 0 ? vlc_tick_from_libvlc_time( timeout ) : VLC_TICK_INVALID,
media_on_thumbnail_ready, req );
if ( req->id == VLC_PREPARSER_REQ_ID_INVALID )
{
free( req );
libvlc_media_release( md );
return NULL;
}
libvlc_retain(inst);
return req;
};
return libvlc_media_thumbnail_request( inst, md, &seek_arg, width, height,
crop, picture_type, timeout );
}
// Destroy a thumbnail request
......
......@@ -35,14 +35,15 @@
Thumbnailer::Thumbnailer( vlc_medialibrary_module_t* ml )
: m_ml( ml )
, m_currentContext( nullptr )
, m_thumbnailer( nullptr, &vlc_thumbnailer_Release )
, m_thumbnailer( nullptr, &vlc_thumbnailer_Delete )
{
m_thumbnailer.reset( vlc_thumbnailer_Create( VLC_OBJECT( ml ) ) );
m_thumbnailer.reset( vlc_thumbnailer_Create( VLC_OBJECT( ml ),
VLC_TICK_FROM_SEC( 3 ) ) );
if ( unlikely( m_thumbnailer == nullptr ) )
throw std::runtime_error( "Failed to instantiate a vlc_thumbnailer_t" );
}
void Thumbnailer::onThumbnailComplete( void* data, picture_t* thumbnail )
void Thumbnailer::onThumbnailComplete( picture_t* thumbnail, void *data )
{
ThumbnailerCtx* ctx = static_cast<ThumbnailerCtx*>( data );
......@@ -70,11 +71,18 @@ bool Thumbnailer::generate( const medialibrary::IMedia&, const std::string& mrl,
{
vlc::threads::mutex_locker lock( m_mutex );
m_currentContext = &ctx;
struct vlc_thumbnailer_seek_arg seek_arg = {
.type = vlc_thumbnailer_seek_arg::VLC_THUMBNAILER_SEEK_POS,
.pos = position,
.speed = vlc_thumbnailer_seek_arg::VLC_THUMBNAILER_SEEK_FAST,
};
static const struct vlc_thumbnailer_cbs cbs = {
.on_ended = onThumbnailComplete,
};
vlc_thumbnailer_req_id requestId =
vlc_thumbnailer_RequestByPos( m_thumbnailer.get(), position,
VLC_THUMBNAILER_SEEK_FAST, item.get(),
VLC_TICK_FROM_SEC( 3 ),
&onThumbnailComplete, &ctx );
vlc_thumbnailer_Request( m_thumbnailer.get(), item.get(), &seek_arg,
&cbs, &ctx );
if (requestId == VLC_THUMBNAILER_REQ_ID_INVALID)
{
......
......@@ -137,7 +137,7 @@ public:
void stop() override;
private:
static void onThumbnailComplete( void* data, picture_t* thumbnail );
static void onThumbnailComplete( picture_t* thumbnail, void* data );
private:
vlc_medialibrary_module_t* m_ml;
......
......@@ -36,37 +36,18 @@ struct vlc_thumbnailer_t
vlc_cond_t cond_ended;
vlc_thumbnailer_req_id current_id;
vlc_tick_t timeout;
struct vlc_list submitted_tasks; /**< list of struct task */
};
struct seek_target
{
enum
{
VLC_THUMBNAILER_SEEK_TIME,
VLC_THUMBNAILER_SEEK_POS,
} type;
union
{
vlc_tick_t time;
double pos;
};
};
typedef struct task
{
vlc_thumbnailer_t *thumbnailer;
struct seek_target seek_target;
bool fast_seek;
struct vlc_thumbnailer_seek_arg seek_arg;
input_item_t *item;
/**
* A positive value will be used as the timeout duration
* VLC_TICK_INVALID means no timeout
*/
vlc_tick_t timeout;
vlc_thumbnailer_cb cb;
const struct vlc_thumbnailer_cbs *cbs;
void* userdata;
enum
......@@ -87,8 +68,8 @@ static void RunnableRun(void *);
static task_t *
TaskNew(vlc_thumbnailer_t *thumbnailer, input_item_t *item,
struct seek_target seek_target, bool fast_seek,
vlc_thumbnailer_cb cb, void *userdata, vlc_tick_t timeout)
const struct vlc_thumbnailer_seek_arg *seek_arg,
const struct vlc_thumbnailer_cbs *cbs, void *userdata )
{
task_t *task = malloc(sizeof(*task));
if (!task)
......@@ -96,11 +77,15 @@ TaskNew(vlc_thumbnailer_t *thumbnailer, input_item_t *item,
task->thumbnailer = thumbnailer;
task->item = item;
task->seek_target = seek_target;
task->fast_seek = fast_seek;
task->cb = cb;
if (seek_arg == NULL)
task->seek_arg = (struct vlc_thumbnailer_seek_arg) {
.type = VLC_THUMBNAILER_SEEK_NONE,
};
else
task->seek_arg = *seek_arg;
task->cbs = cbs;
task->userdata = userdata;
task->timeout = timeout;
task->status = RUNNING;
task->pic = NULL;
......@@ -122,8 +107,7 @@ TaskDestroy(task_t *task)
static void NotifyThumbnail(task_t *task, picture_t *pic)
{
assert(task->cb);
task->cb(task->userdata, pic);
task->cbs->on_ended(pic, task->userdata);
}
static void
......@@ -183,12 +167,22 @@ RunnableRun(void *userdata)
if (!input)
goto error;
if (task->seek_target.type == VLC_THUMBNAILER_SEEK_TIME)
input_SetTime(input, task->seek_target.time, task->fast_seek);
else
assert(task->seek_arg.speed == VLC_THUMBNAILER_SEEK_PRECISE
|| task->seek_arg.speed == VLC_THUMBNAILER_SEEK_FAST);
bool fast_seek = task->seek_arg.speed == VLC_THUMBNAILER_SEEK_FAST;
switch (task->seek_arg.type)
{
assert(task->seek_target.type == VLC_THUMBNAILER_SEEK_POS);
input_SetPosition(input, task->seek_target.pos, task->fast_seek);
case VLC_THUMBNAILER_SEEK_NONE:
break;
case VLC_THUMBNAILER_SEEK_TIME:
input_SetTime(input, task->seek_arg.time, fast_seek);
break;
case VLC_THUMBNAILER_SEEK_POS:
input_SetPosition(input, task->seek_arg.pos, fast_seek);
break;
default:
vlc_assert_unreachable();
}
int ret = input_Start(input);
......@@ -199,14 +193,14 @@ RunnableRun(void *userdata)
}
vlc_mutex_lock(&thumbnailer->lock);
if (task->timeout == VLC_TICK_INVALID)
if (thumbnailer->timeout == VLC_TICK_INVALID)
{
while (task->status == RUNNING)
vlc_cond_wait(&thumbnailer->cond_ended, &thumbnailer->lock);
}
else
{
vlc_tick_t deadline = now + task->timeout;
vlc_tick_t deadline = now + thumbnailer->timeout;
int timeout = 0;
while (task->status == RUNNING && timeout == 0)
timeout =
......@@ -233,14 +227,15 @@ error:
TaskDestroy(task);
}
static vlc_thumbnailer_req_id
RequestCommon(vlc_thumbnailer_t *thumbnailer, struct seek_target seek_target,
enum vlc_thumbnailer_seek_speed speed, input_item_t *item,
vlc_tick_t timeout, vlc_thumbnailer_cb cb, void *userdata)
vlc_thumbnailer_req_id
vlc_thumbnailer_Request( vlc_thumbnailer_t *thumbnailer,
input_item_t *item,
const struct vlc_thumbnailer_seek_arg *seek_arg,
const struct vlc_thumbnailer_cbs *cbs, void *userdata )
{
bool fast_seek = speed == VLC_THUMBNAILER_SEEK_FAST;
task_t *task = TaskNew(thumbnailer, item, seek_target, fast_seek, cb,
userdata, timeout);
assert( cbs != NULL && cbs->on_ended != NULL );
task_t *task = TaskNew(thumbnailer, item, seek_arg, cbs, userdata);
if (!task)
return 0;
......@@ -257,35 +252,6 @@ RequestCommon(vlc_thumbnailer_t *thumbnailer, struct seek_target seek_target,
return id;
}
vlc_thumbnailer_req_id
vlc_thumbnailer_RequestByTime( vlc_thumbnailer_t *thumbnailer,
vlc_tick_t time,
enum vlc_thumbnailer_seek_speed speed,
input_item_t *item, vlc_tick_t timeout,
vlc_thumbnailer_cb cb, void* userdata )
{
struct seek_target seek_target = {
.type = VLC_THUMBNAILER_SEEK_TIME,
.time = time,
};
return RequestCommon(thumbnailer, seek_target, speed, item, timeout, cb,
userdata);
}
vlc_thumbnailer_req_id
vlc_thumbnailer_RequestByPos( vlc_thumbnailer_t *thumbnailer,
double pos, enum vlc_thumbnailer_seek_speed speed,
input_item_t *item, vlc_tick_t timeout,
vlc_thumbnailer_cb cb, void* userdata )
{
struct seek_target seek_target = {
.type = VLC_THUMBNAILER_SEEK_POS,
.pos = pos,
};
return RequestCommon(thumbnailer, seek_target, speed, item, timeout, cb,
userdata);
}
size_t vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id )
{
vlc_mutex_lock(&thumbnailer->lock);
......@@ -318,8 +284,10 @@ size_t vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_r
return count;
}
vlc_thumbnailer_t *vlc_thumbnailer_Create( vlc_object_t* parent)
vlc_thumbnailer_t *vlc_thumbnailer_Create( vlc_object_t* parent, vlc_tick_t timeout )
{
assert(timeout >= 0);
vlc_thumbnailer_t *thumbnailer = malloc( sizeof( *thumbnailer ) );
if ( unlikely( thumbnailer == NULL ) )
return NULL;
......@@ -333,6 +301,7 @@ vlc_thumbnailer_t *vlc_thumbnailer_Create( vlc_object_t* parent)
thumbnailer->parent = parent;
thumbnailer->current_id = 1;
thumbnailer->timeout = timeout;
vlc_mutex_init(&thumbnailer->lock);
vlc_cond_init(&thumbnailer->cond_ended);
vlc_list_init(&thumbnailer->submitted_tasks);
......@@ -340,7 +309,13 @@ vlc_thumbnailer_t *vlc_thumbnailer_Create( vlc_object_t* parent)
return thumbnailer;
}
void vlc_thumbnailer_Release( vlc_thumbnailer_t *thumbnailer )
void vlc_thumbnailer_SetTimeout( vlc_thumbnailer_t *thumbnailer,
vlc_tick_t timeout )
{
thumbnailer->timeout = timeout;
}
void vlc_thumbnailer_Delete( vlc_thumbnailer_t *thumbnailer )
{
vlc_executor_Delete(thumbnailer->executor);
free( thumbnailer );
......
......@@ -831,10 +831,10 @@ vlc_es_id_GetStrId
vlc_es_id_IsStrIdStable
vlc_encoder_Destroy
vlc_thumbnailer_Create
vlc_thumbnailer_RequestByTime
vlc_thumbnailer_RequestByPos
vlc_thumbnailer_Request
vlc_thumbnailer_Cancel
vlc_thumbnailer_Release
vlc_thumbnailer_Delete
vlc_thumbnailer_SetTimeout
vlc_player_AddAssociatedMedia
vlc_player_AddListener
vlc_player_AddMetadataListener
......
......@@ -36,7 +36,7 @@ struct vlc_preparser_t
vlc_object_t* owner;
input_fetcher_t* fetcher;
vlc_executor_t *executor;
vlc_tick_t default_timeout;
vlc_tick_t timeout;
atomic_bool deactivated;
vlc_mutex_t lock;
......@@ -52,7 +52,6 @@ struct task
const input_item_parser_cbs_t *cbs;
void *userdata;
vlc_preparser_req_id id;
vlc_tick_t timeout;
input_item_parser_id_t *parser;
......@@ -70,10 +69,8 @@ static void RunnableRun(void *);
static struct task *
TaskNew(vlc_preparser_t *preparser, input_item_t *item,
input_item_meta_request_option_t options,
const input_item_parser_cbs_t *cbs, void *userdata, vlc_tick_t timeout)
const input_item_parser_cbs_t *cbs, void *userdata)
{
assert(timeout >= 0);
struct task *task = malloc(sizeof(*task));
if (!task)
return NULL;
......@@ -83,7 +80,6 @@ TaskNew(vlc_preparser_t *preparser, input_item_t *item,
task->options = options;
task->cbs = cbs;
task->userdata = userdata;
task->timeout = timeout;
input_item_Hold(item);
......@@ -275,8 +271,8 @@ RunnableRun(void *userdata)
struct task *task = userdata;
vlc_preparser_t *preparser = task->preparser;
vlc_tick_t deadline = task->timeout ? vlc_tick_now() + task->timeout
: VLC_TICK_INVALID;
vlc_tick_t deadline = preparser->timeout ? vlc_tick_now() + preparser->timeout
: VLC_TICK_INVALID;
if (task->options & META_REQUEST_OPTION_PARSE)
{
......@@ -319,11 +315,11 @@ Interrupt(struct task *task)
}
vlc_preparser_t* vlc_preparser_New( vlc_object_t *parent, unsigned max_threads,
vlc_tick_t default_timeout,
vlc_tick_t timeout,
input_item_meta_request_option_t request_type )
{
assert(max_threads >= 1);
assert(default_timeout >= 0);
assert(timeout >= 0);
assert(request_type & (META_REQUEST_OPTION_FETCH_ANY|META_REQUEST_OPTION_PARSE));
vlc_preparser_t* preparser = malloc( sizeof *preparser );
......@@ -342,7 +338,7 @@ vlc_preparser_t* vlc_preparser_New( vlc_object_t *parent, unsigned max_threads,
else
preparser->executor = NULL;
preparser->default_timeout = default_timeout;
preparser->timeout = timeout;
preparser->owner = parent;
if (request_type & META_REQUEST_OPTION_FETCH_ANY)
......@@ -385,8 +381,7 @@ vlc_preparser_req_id vlc_preparser_Push( vlc_preparser_t *preparser, input_item_
|| preparser->fetcher != NULL);
struct task *task =
TaskNew(preparser, item, i_options, cbs, cbs_userdata,
preparser->default_timeout);
TaskNew(preparser, item, i_options, cbs, cbs_userdata);
if( !task )
return 0;
......@@ -451,7 +446,7 @@ void vlc_preparser_Deactivate( vlc_preparser_t* preparser )
void vlc_preparser_SetTimeout( vlc_preparser_t *preparser,
vlc_tick_t timeout )
{
preparser->default_timeout = timeout;
preparser->timeout = timeout;
}
void vlc_preparser_Delete( vlc_preparser_t *preparser )
......
......@@ -68,7 +68,7 @@ struct test_ctx
bool b_done;
};
static void thumbnailer_callback( void* data, picture_t* thumbnail )
static void thumbnailer_callback( picture_t* thumbnail, void *data )
{
struct test_ctx* p_ctx = data;
vlc_mutex_lock( &p_ctx->lock );
......@@ -108,10 +108,6 @@ static void thumbnailer_callback( void* data, picture_t* thumbnail )
static void test_thumbnails( libvlc_instance_t* p_vlc )
{
vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create(
VLC_OBJECT( p_vlc->p_libvlc_int ) );
assert( p_thumbnailer != NULL );
struct test_ctx ctx;
vlc_cond_init( &ctx.cond );
vlc_mutex_init( &ctx.lock );
......@@ -123,6 +119,11 @@ static void test_thumbnails( libvlc_instance_t* p_vlc )
ctx.test_idx = i;
ctx.b_done = false;
vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create(
VLC_OBJECT( p_vlc->p_libvlc_int ), test_params[i].i_timeout );
assert( p_thumbnailer != NULL );
if ( asprintf( &psz_mrl, "mock://video_track_count=%u;audio_track_count=%u"
";length=%" PRId64 ";can_control_pace=%s;video_chroma=ARGB;video_add_track_at=%" PRId64,
test_params[i].i_nb_video_tracks,
......@@ -136,20 +137,26 @@ static void test_thumbnails( libvlc_instance_t* p_vlc )
vlc_mutex_lock( &ctx.lock );
vlc_thumbnailer_req_id id;
struct vlc_thumbnailer_seek_arg seek_arg;
if ( test_params[i].b_use_pos )
{
id = vlc_thumbnailer_RequestByPos( p_thumbnailer, test_params[i].f_pos,
test_params[i].b_fast_seek ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx );
seek_arg.type = VLC_THUMBNAILER_SEEK_POS;
seek_arg.pos = test_params[i].f_pos;
seek_arg.speed = test_params[i].b_fast_seek ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE;
}
else
{
id = vlc_thumbnailer_RequestByTime( p_thumbnailer, test_params[i].i_time,
test_params[i].b_fast_seek ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx );
seek_arg.type = VLC_THUMBNAILER_SEEK_TIME;
seek_arg.time = test_params[i].i_time;
seek_arg.speed = test_params[i].b_fast_seek ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE;
}
static const struct vlc_thumbnailer_cbs cbs = {
.on_ended = thumbnailer_callback,
};
id = vlc_thumbnailer_Request( p_thumbnailer, p_item, &seek_arg,
&cbs, &ctx );
assert( id != VLC_THUMBNAILER_REQ_ID_INVALID );
while ( ctx.b_done == false )
......@@ -159,11 +166,12 @@ static void test_thumbnails( libvlc_instance_t* p_vlc )
input_item_Release( p_item );
free( psz_mrl );
vlc_thumbnailer_Delete( p_thumbnailer );
}
vlc_thumbnailer_Release( p_thumbnailer );
}
static void thumbnailer_callback_cancel( void* data, picture_t* p_thumbnail )
static void thumbnailer_callback_cancel( picture_t* p_thumbnail, void *data )
{
(void) data; (void) p_thumbnail;
/* This callback should not be called since the request is cancelled */
......@@ -173,7 +181,7 @@ static void thumbnailer_callback_cancel( void* data, picture_t* p_thumbnail )
static void test_cancel_thumbnail( libvlc_instance_t* p_vlc )
{
vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create(
VLC_OBJECT( p_vlc->p_libvlc_int ) );
VLC_OBJECT( p_vlc->p_libvlc_int ), VLC_TICK_INVALID );
assert( p_thumbnailer != NULL );
const char* psz_mrl = "mock://video_track_count=0;audio_track_count=1;"
......@@ -183,9 +191,12 @@ static void test_cancel_thumbnail( libvlc_instance_t* p_vlc )
input_item_t* p_item = input_item_New( psz_mrl, "mock item" );
assert( p_item != NULL );
vlc_thumbnailer_req_id id = vlc_thumbnailer_RequestByTime( p_thumbnailer,
VLC_TICK_INVALID, VLC_THUMBNAILER_SEEK_PRECISE, p_item,
VLC_TICK_INVALID, thumbnailer_callback_cancel, NULL );
static const struct vlc_thumbnailer_cbs cbs = {
.on_ended = thumbnailer_callback_cancel,
};
vlc_thumbnailer_req_id id =
vlc_thumbnailer_Request( p_thumbnailer, p_item, NULL, &cbs, NULL );
vlc_thumbnailer_Cancel( p_thumbnailer, id );
......@@ -195,7 +206,7 @@ static void test_cancel_thumbnail( libvlc_instance_t* p_vlc )
input_item_Release( p_item );
vlc_thumbnailer_Release( p_thumbnailer );
vlc_thumbnailer_Delete( p_thumbnailer );
}
int main( void )
......