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 (21)
Showing
with 247 additions and 589 deletions
......@@ -101,7 +101,6 @@ install_headers(
'vlc_subpicture.h',
'vlc_text_style.h',
'vlc_threads.h',
'vlc_thumbnailer.h',
'vlc_tick.h',
'vlc_timestamp_helper.h',
'vlc_tls.h',
......
......@@ -46,33 +46,119 @@ typedef size_t vlc_preparser_req_id;
#define VLC_PREPARSER_REQ_ID_INVALID 0
typedef enum input_item_meta_request_option_t
#define VLC_PREPARSER_TYPE_PARSE 0x01
#define VLC_PREPARSER_TYPE_FETCHMETA_LOCAL 0x02
#define VLC_PREPARSER_TYPE_FETCHMETA_NET 0x04
#define VLC_PREPARSER_TYPE_THUMBNAIL 0x08
#define VLC_PREPARSER_TYPE_FETCHMETA_ALL \
(VLC_PREPARSER_TYPE_FETCHMETA_LOCAL|VLC_PREPARSER_TYPE_FETCHMETA_NET)
#define VLC_PREPARSER_OPTION_INTERACT 0x1000
#define VLC_PREPARSER_OPTION_SUBITEMS 0x2000
/** Preparser thumbnailer callbacks */
struct vlc_thumbnailer_cbs
{
/**
* Event received on thumbnailing completion or error
*
* This callback will always be called, provided
* vlc_preparser_GenerateThumbnail() returned a valid request, and provided
* the request is not cancelled before its completion.
*
* @note This callback is mandatory if calling
* vlc_preparser_GenerateThumbnail()
*
* In case of failure, timeout or cancellation, 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 item item used for the thumbnailer
*
* @param status VLC_SUCCESS in case of success, VLC_ETIMEOUT in case of
* timeout, -EINTR if cancelled, an error otherwise
*
* @param thumbnail The generated thumbnail, or NULL in case of failure or
* timeout
*
* @param data opaque pointer passed by
* vlc_preparser_GenerateThumbnail()
*
*/
void (*on_ended)(input_item_t *item, int status, picture_t* thumbnail,
void *data);
};
/**
* Preparser seek argument
*/
struct vlc_preparser_seek_arg
{
META_REQUEST_OPTION_NONE = 0x00,
META_REQUEST_OPTION_PARSE = 0x01,
META_REQUEST_OPTION_FETCH_LOCAL = 0x02,
META_REQUEST_OPTION_FETCH_NETWORK = 0x04,
META_REQUEST_OPTION_FETCH_ANY =
META_REQUEST_OPTION_FETCH_LOCAL|META_REQUEST_OPTION_FETCH_NETWORK,
META_REQUEST_OPTION_DO_INTERACT = 0x08,
META_REQUEST_OPTION_PARSE_SUBITEMS = 0x10,
} input_item_meta_request_option_t;
enum
{
/** Don't seek */
VLC_PREPARSER_SEEK_NONE,
/** Seek by time */
VLC_PREPARSER_SEEK_TIME,
/** Seek by position */
VLC_PREPARSER_SEEK_POS,
} type;
union
{
/** Seek time if type == VLC_PREPARSER_SEEK_TIME */
vlc_tick_t time;
/** Seek position if type == VLC_PREPARSER_SEEK_POS */
double pos;
};
enum
{
/** Precise, but potentially slow */
VLC_PREPARSER_SEEK_PRECISE,
/** Fast, but potentially imprecise */
VLC_PREPARSER_SEEK_FAST,
} speed;
};
/**
* Preparser creation configuration
*/
struct vlc_preparser_cfg
{
/**
* A combination of VLC_PREPARSER_TYPE_* flags, it is used to
* setup the executors for each domain. Its possible to select more than
* one type
*/
int types;
/**
* The maximum number of threads used by the parser, 0 for default
* (1 thread)
*/
unsigned max_parser_threads;
/**
* The maximum number of threads used by the thumbnailer, 0 for default
* (1 thread)
*/
unsigned max_thumbnailer_threads;
/**
* Timeout of the preparser and/or thumbnailer, 0 for no limits.
*/
vlc_tick_t timeout;
};
/**
* This function creates the preparser object and thread.
*
* @param obj the parent object
* @param max_threads the maximum number of threads used to parse, must be >= 1
* @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.
* @param cfg a pointer to a valid confiuration struct
* @return a valid preparser object or NULL in case of error
*/
VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj,
unsigned max_threads,
vlc_tick_t timeout,
input_item_meta_request_option_t request_type );
const struct vlc_preparser_cfg *cfg );
/**
* This function enqueues the provided item to be preparsed or fetched.
......@@ -82,7 +168,9 @@ VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj,
*
* @param preparser the preparser object
* @param item a valid item to preparse
* @param option preparse flag, cf @ref input_item_meta_request_option_t
* @param type_option a combination of VLC_PREPARSER_TYPE_* and
* VLC_PREPARSER_OPTION_* flags. The type must be in the set specified in
* vlc_preparser_New() (it is possible to select less types).
* @param cbs callback to listen to events (can't be NULL)
* @param cbs_userdata opaque pointer used by the callbacks
* @param id unique id provided by the caller. This is can be used to cancel
......@@ -92,10 +180,32 @@ VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj,
* error, the on_preparse_ended will *not* be invoked
*/
VLC_API vlc_preparser_req_id
vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item,
input_item_meta_request_option_t option,
vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item, int type_option,
const input_item_parser_cbs_t *cbs, void *cbs_userdata );
/**
* This function enqueues the provided item for generating a thumbnail
*
* @param preparser the preparser object
* @param item a valid 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 cbs callback to listen to events (can't be NULL)
* @param cbs_userdata opaque pointer used by the callbacks
* @return VLC_PREPARSER_REQ_ID_INVALID in case of error, or a valid id if the
* item was scheduled for thumbnailing. If this returns an
* error, the thumbnailer.on_ended callback will *not* be invoked
*
* The provided input_item will be held by the thumbnailer and can safely be
* released safely after calling this function.
*/
VLC_API vlc_preparser_req_id
vlc_preparser_GenerateThumbnail( vlc_preparser_t *preparser, input_item_t *item,
const struct vlc_preparser_seek_arg *seek_arg,
const struct vlc_thumbnailer_cbs *cbs,
void *cbs_userdata );
/**
* This function cancel all preparsing requests for a given id
*
......
/*****************************************************************************
* vlc_thumbnailer.h: Thumbnailing API
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_THUMBNAILER_H
#define VLC_THUMBNAILER_H
#include <vlc_common.h>
#include <vlc_tick.h>
typedef struct vlc_thumbnailer_t vlc_thumbnailer_t;
typedef size_t vlc_thumbnailer_req_id;
#define VLC_THUMBNAILER_REQ_ID_INVALID 0
/**
* thumbnailer callbacks
*/
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, timeout or cancellation, 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_tick_t timeout) VLC_USED;
/**
* Thumbnailer seek argument
*/
struct vlc_thumbnailer_seek_arg
{
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_Request Requests a thumbnailer
* \param thumbnailer A thumbnailer object
* \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 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
*
* 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_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
* \param thumbnailer A thumbnailer object
* \param id unique id returned by vlc_thumbnailer_Request*(),
* VLC_THUMBNAILER_REQ_ID_INVALID to cancels all tasks
* \return number of tasks cancelled
*/
VLC_API size_t
vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id );
/**
* \brief vlc_thumbnailer_Delete Deletes a thumbnailer and cancel all pending requests
* \param thumbnailer A thumbnailer object
*/
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
......@@ -29,7 +29,6 @@
#include <vlc/vlc.h>
#include <vlc_preparser.h>
#include <vlc_thumbnailer.h>
#include <vlc_interface.h>
#include <stdarg.h>
......@@ -110,7 +109,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_Delete(p_instance->thumbnailer);
vlc_preparser_Delete(p_instance->thumbnailer);
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int );
......@@ -266,26 +265,34 @@ vlc_preparser_t *libvlc_get_preparser(libvlc_instance_t *instance)
if (default_timeout < 0)
default_timeout = 0;
const struct vlc_preparser_cfg cfg = {
.types = VLC_PREPARSER_TYPE_PARSE | VLC_PREPARSER_TYPE_FETCHMETA_ALL,
.max_parser_threads = max_threads,
.timeout = default_timeout,
};
parser = instance->parser =
vlc_preparser_New(VLC_OBJECT(instance->p_libvlc_int), max_threads,
default_timeout,
META_REQUEST_OPTION_PARSE |
META_REQUEST_OPTION_FETCH_ANY);
vlc_preparser_New(VLC_OBJECT(instance->p_libvlc_int), &cfg);
}
vlc_mutex_unlock(&instance->lazy_init_lock);
return parser;
}
vlc_thumbnailer_t *libvlc_get_thumbnailer(libvlc_instance_t *instance)
vlc_preparser_t *libvlc_get_thumbnailer(libvlc_instance_t *instance)
{
vlc_mutex_lock(&instance->lazy_init_lock);
vlc_thumbnailer_t *thumb = instance->thumbnailer;
vlc_preparser_t *thumb = instance->thumbnailer;
if (thumb == NULL)
{
const struct vlc_preparser_cfg cfg = {
.types = VLC_PREPARSER_TYPE_THUMBNAIL,
.timeout = 0,
};
thumb = instance->thumbnailer =
vlc_thumbnailer_Create(VLC_OBJECT(instance->p_libvlc_int), 0);
vlc_preparser_New(VLC_OBJECT(instance->p_libvlc_int), &cfg);
}
vlc_mutex_unlock(&instance->lazy_init_lock);
......
......@@ -36,7 +36,7 @@
#include <vlc_threads.h>
typedef struct vlc_preparser_t vlc_preparser_t;
typedef struct vlc_thumbnailer_t vlc_thumbnailer_t;
typedef struct vlc_preparser_t vlc_preparser_t;
/* Note well: this header is included from LibVLC core.
* Therefore, static inline functions MUST NOT call LibVLC functions here
......@@ -105,7 +105,7 @@ struct libvlc_instance_t
vlc_mutex_t lazy_init_lock;
vlc_preparser_t *parser;
vlc_thumbnailer_t *thumbnailer;
vlc_preparser_t *thumbnailer;
struct
{
......@@ -153,6 +153,6 @@ static inline vlc_tick_t vlc_tick_from_libvlc_time(libvlc_time_t time)
}
vlc_preparser_t *libvlc_get_preparser(libvlc_instance_t *instance);
vlc_thumbnailer_t *libvlc_get_thumbnailer(libvlc_instance_t *instance);
vlc_preparser_t *libvlc_get_thumbnailer(libvlc_instance_t *instance);
#endif
......@@ -37,7 +37,6 @@
#include <vlc_common.h>
#include <vlc_meta.h>
#include <vlc_url.h>
#include <vlc_thumbnailer.h>
#include <vlc_atomic.h>
#include "../src/libvlc.h"
......@@ -741,7 +740,7 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
return -1;
input_item_t *item = media->p_input_item;
input_item_meta_request_option_t parse_scope = 0;
int parse_scope = 0;
unsigned int ref = atomic_load_explicit(&media->worker_count,
memory_order_relaxed);
do
......@@ -784,17 +783,17 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
}
if (do_parse)
parse_scope |= META_REQUEST_OPTION_PARSE;
parse_scope |= VLC_PREPARSER_TYPE_PARSE;
do_fetch = false;
if (parse_flag & libvlc_media_fetch_local)
{
parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
parse_scope |= VLC_PREPARSER_TYPE_FETCHMETA_LOCAL;
do_fetch = true;
}
if (parse_flag & libvlc_media_fetch_network)
{
parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
parse_scope |= VLC_PREPARSER_TYPE_FETCHMETA_NET;
do_fetch = true;
}
......@@ -807,8 +806,8 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
}
if (parse_flag & libvlc_media_do_interact)
parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
parse_scope |= META_REQUEST_OPTION_PARSE_SUBITEMS;
parse_scope |= VLC_PREPARSER_OPTION_INTERACT;
parse_scope |= VLC_PREPARSER_OPTION_SUBITEMS;
if (timeout == -1)
timeout = var_InheritInteger(inst->p_libvlc_int, "preparse-timeout");
......@@ -924,11 +923,15 @@ struct libvlc_media_thumbnail_request_t
unsigned int height;
bool crop;
libvlc_picture_type_t type;
vlc_thumbnailer_req_id id;
vlc_preparser_req_id id;
};
static void media_on_thumbnail_ready( picture_t* thumbnail, void* data )
static void media_on_thumbnail_ready( input_item_t *item, int status,
picture_t* thumbnail, void* data )
{
(void) item;
(void) status;
libvlc_media_thumbnail_request_t *req = data;
libvlc_media_t *p_media = req->md;
libvlc_event_t event;
......@@ -948,18 +951,18 @@ static void media_on_thumbnail_ready( picture_t* thumbnail, void* data )
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,
const struct vlc_preparser_seek_arg *seek_arg,
unsigned int width, unsigned int height,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
assert( md );
vlc_thumbnailer_t *thumb = libvlc_get_thumbnailer(inst);
vlc_preparser_t *thumb = libvlc_get_thumbnailer(inst);
if (unlikely(thumb == NULL))
return NULL;
vlc_thumbnailer_SetTimeout( thumb, vlc_tick_from_libvlc_time( timeout ) );
vlc_preparser_SetTimeout( thumb, vlc_tick_from_libvlc_time( timeout ) );
libvlc_media_thumbnail_request_t *req = malloc( sizeof( *req ) );
if ( unlikely( req == NULL ) )
......@@ -975,8 +978,8 @@ libvlc_media_thumbnail_request( libvlc_instance_t *inst,
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 );
req->id = vlc_preparser_GenerateThumbnail( thumb, md->p_input_item, seek_arg,
&cbs, req );
if ( req->id == VLC_PREPARSER_REQ_ID_INVALID )
{
free( req );
......@@ -995,11 +998,11 @@ libvlc_media_thumbnail_request_by_time( libvlc_instance_t *inst,
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,
const struct vlc_preparser_seek_arg seek_arg = {
.type = VLC_PREPARSER_SEEK_TIME,
.time = vlc_tick_from_libvlc_time( time ),
.speed = speed == libvlc_media_thumbnail_seek_fast ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
VLC_PREPARSER_SEEK_FAST : VLC_PREPARSER_SEEK_PRECISE,
};
return libvlc_media_thumbnail_request( inst, md, &seek_arg, width, height,
crop, picture_type, timeout );
......@@ -1014,11 +1017,11 @@ libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst,
bool crop, libvlc_picture_type_t picture_type,
libvlc_time_t timeout )
{
const struct vlc_thumbnailer_seek_arg seek_arg = {
.type = VLC_THUMBNAILER_SEEK_POS,
const struct vlc_preparser_seek_arg seek_arg = {
.type = VLC_PREPARSER_SEEK_POS,
.pos = pos,
.speed = speed == libvlc_media_thumbnail_seek_fast ?
VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE,
VLC_PREPARSER_SEEK_FAST : VLC_PREPARSER_SEEK_PRECISE,
};
return libvlc_media_thumbnail_request( inst, md, &seek_arg, width, height,
crop, picture_type, timeout );
......@@ -1027,10 +1030,10 @@ libvlc_media_thumbnail_request_by_pos( libvlc_instance_t *inst,
// Destroy a thumbnail request
void libvlc_media_thumbnail_request_destroy( libvlc_media_thumbnail_request_t *req )
{
vlc_thumbnailer_t *thumb = libvlc_get_thumbnailer(req->instance);
vlc_preparser_t *thumb = libvlc_get_thumbnailer(req->instance);
assert(thumb != NULL);
vlc_thumbnailer_Cancel( thumb, req->id );
vlc_preparser_Cancel( thumb, req->id );
libvlc_media_release( req->md );
libvlc_release(req->instance);
free( req );
......
......@@ -155,8 +155,12 @@ int OpenIntf (vlc_object_t *p_this)
intf_thread_t *p_intf = (intf_thread_t*) p_this;
p_interface_thread = p_intf;
p_network_preparser = vlc_preparser_New(p_this, 1, 0,
META_REQUEST_OPTION_PARSE);
const struct vlc_preparser_cfg cfg = {
.types = VLC_PREPARSER_TYPE_PARSE,
.max_parser_threads = 1,
.timeout = 0,
};
p_network_preparser = vlc_preparser_New(p_this, &cfg);
if (p_network_preparser == nil)
{
retcode = VLC_ENOMEM;
......
......@@ -251,8 +251,14 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
QMetaObject::invokeMethod(m_medialib, &MediaLib::reload, Qt::QueuedConnection);
}
m_network_preparser = vlc_preparser_New(VLC_OBJECT(libvlc), 1, 0,
META_REQUEST_OPTION_PARSE);
const struct vlc_preparser_cfg cfg = []{
struct vlc_preparser_cfg cfg{};
cfg.types = VLC_PREPARSER_TYPE_PARSE;
cfg.max_parser_threads = 1;
cfg.timeout = 0;
return cfg;
}();
m_network_preparser = vlc_preparser_New(VLC_OBJECT(libvlc), &cfg);
#ifdef UPDATE_CHECK
/* Checking for VLC updates */
......
......@@ -20,7 +20,6 @@
#include <cassert>
#include <vlc_thumbnailer.h>
#include "mlhelper.hpp"
#include "util/vlctick.hpp"
......
......@@ -1955,17 +1955,21 @@ void PlayerController::requestArtUpdate( input_item_t *p_item )
if (default_timeout < 0)
default_timeout = 0;
d->m_preparser = vlc_preparser_New(VLC_OBJECT(d->p_intf), 1,
default_timeout,
META_REQUEST_OPTION_FETCH_ANY);
const struct vlc_preparser_cfg cfg = [default_timeout]{
struct vlc_preparser_cfg cfg{};
cfg.types = VLC_PREPARSER_TYPE_FETCHMETA_ALL;
cfg.max_parser_threads = 1;
cfg.timeout = default_timeout;
return cfg;
}();
d->m_preparser = vlc_preparser_New(VLC_OBJECT(d->p_intf), &cfg);
if (unlikely(d->m_preparser == nullptr))
return;
}
input_item_meta_request_option_t fetch_options =
var_InheritBool( d->p_intf, "metadata-network-access" ) ?
META_REQUEST_OPTION_FETCH_ANY :
META_REQUEST_OPTION_FETCH_LOCAL;
int fetch_options = var_InheritBool( d->p_intf, "metadata-network-access" ) ?
VLC_PREPARSER_TYPE_FETCHMETA_ALL :
VLC_PREPARSER_TYPE_FETCHMETA_LOCAL;
vlc_preparser_Push( d->m_preparser, p_item, fetch_options,
&art_fetcher_cbs, d );
......
......@@ -24,26 +24,31 @@
#include "medialibrary.h"
#include <vlc_thumbnailer.h>
#include <vlc_fs.h>
#include <vlc_block.h>
#include <vlc_url.h>
#include <vlc_cxx_helpers.hpp>
#include <vlc_preparser.h>
#include <stdexcept>
Thumbnailer::Thumbnailer( vlc_medialibrary_module_t* ml )
: m_ml( ml )
, m_currentContext( nullptr )
, m_thumbnailer( nullptr, &vlc_thumbnailer_Delete )
, m_thumbnailer( nullptr, &vlc_preparser_Delete )
{
m_thumbnailer.reset( vlc_thumbnailer_Create( VLC_OBJECT( ml ),
VLC_TICK_FROM_SEC( 3 ) ) );
const struct vlc_preparser_cfg cfg = []{
struct vlc_preparser_cfg cfg{};
cfg.types = VLC_PREPARSER_TYPE_THUMBNAIL;
cfg.timeout = VLC_TICK_FROM_SEC( 3 );
return cfg;
}();
m_thumbnailer.reset( vlc_preparser_New( VLC_OBJECT( ml ), &cfg ) );
if ( unlikely( m_thumbnailer == nullptr ) )
throw std::runtime_error( "Failed to instantiate a vlc_thumbnailer_t" );
throw std::runtime_error( "Failed to instantiate a vlc_preparser_t" );
}
void Thumbnailer::onThumbnailComplete( picture_t* thumbnail, void *data )
void Thumbnailer::onThumbnailComplete( input_item_t *, int, picture_t* thumbnail, void *data )
{
ThumbnailerCtx* ctx = static_cast<ThumbnailerCtx*>( data );
......@@ -71,20 +76,20 @@ 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,
struct vlc_preparser_seek_arg seek_arg = {
.type = vlc_preparser_seek_arg::VLC_PREPARSER_SEEK_POS,
.pos = position,
.speed = vlc_thumbnailer_seek_arg::VLC_THUMBNAILER_SEEK_FAST,
.speed = vlc_preparser_seek_arg::VLC_PREPARSER_SEEK_FAST,
};
static const struct vlc_thumbnailer_cbs cbs = {
.on_ended = onThumbnailComplete,
};
vlc_thumbnailer_req_id requestId =
vlc_thumbnailer_Request( m_thumbnailer.get(), item.get(), &seek_arg,
&cbs, &ctx );
vlc_preparser_req_id requestId =
vlc_preparser_GenerateThumbnail( m_thumbnailer.get(), item.get(),
&seek_arg, &cbs, &ctx );
if (requestId == VLC_THUMBNAILER_REQ_ID_INVALID)
if (requestId == VLC_PREPARSER_REQ_ID_INVALID)
{
m_currentContext = nullptr;
return false;
......
......@@ -40,7 +40,7 @@
struct vlc_event_t;
struct vlc_object_t;
struct vlc_thumbnailer_t;
struct vlc_preparser_t;
class Logger;
......@@ -137,14 +137,14 @@ public:
void stop() override;
private:
static void onThumbnailComplete( picture_t* thumbnail, void* data );
static void onThumbnailComplete( input_item_t *, int, picture_t* thumbnail, void *data );
private:
vlc_medialibrary_module_t* m_ml;
vlc::threads::mutex m_mutex;
vlc::threads::condition_variable m_cond;
ThumbnailerCtx* m_currentContext;
std::unique_ptr<vlc_thumbnailer_t, void(*)(vlc_thumbnailer_t*)> m_thumbnailer;
std::unique_ptr<vlc_preparser_t, void(*)(vlc_preparser_t*)> m_thumbnailer;
};
class MediaLibrary : public medialibrary::IMediaLibraryCb
......
......@@ -107,7 +107,6 @@ pluginsinclude_HEADERS.h = \
../include/vlc_subpicture.h \
../include/vlc_text_style.h \
../include/vlc_threads.h \
../include/vlc_thumbnailer.h \
../include/vlc_tick.h \
../include/vlc_timestamp_helper.h \
../include/vlc_tls.h \
......@@ -327,7 +326,6 @@ libvlccore_la_SOURCES = \
input/stream_filter.c \
input/stream_memory.c \
input/subtitles.c \
input/thumbnailer.c \
input/var.c \
audio_output/aout_internal.h \
audio_output/common.c \
......
/*****************************************************************************
* thumbnailer.c: Thumbnailing API
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_thumbnailer.h>
#include <vlc_executor.h>
#include "input_internal.h"
struct vlc_thumbnailer_t
{
vlc_object_t* parent;
vlc_executor_t *executor;
vlc_mutex_t lock;
vlc_cond_t cond_ended;
vlc_thumbnailer_req_id current_id;
vlc_tick_t timeout;
struct vlc_list submitted_tasks; /**< list of struct task */
};
typedef struct task
{
vlc_thumbnailer_t *thumbnailer;
struct vlc_thumbnailer_seek_arg seek_arg;
input_item_t *item;
const struct vlc_thumbnailer_cbs *cbs;
void* userdata;
enum
{
RUNNING,
INTERRUPTED,
ENDED,
} status;
picture_t *pic;
vlc_thumbnailer_req_id id;
struct vlc_runnable runnable; /**< to be passed to the executor */
struct vlc_list node; /**< node of vlc_thumbnailer_t.submitted_tasks */
} task_t;
static void RunnableRun(void *);
static task_t *
TaskNew(vlc_thumbnailer_t *thumbnailer, input_item_t *item,
const struct vlc_thumbnailer_seek_arg *seek_arg,
const struct vlc_thumbnailer_cbs *cbs, void *userdata )
{
task_t *task = malloc(sizeof(*task));
if (!task)
return NULL;
task->thumbnailer = thumbnailer;
task->item = item;
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->status = RUNNING;
task->pic = NULL;
task->runnable.run = RunnableRun;
task->runnable.userdata = task;
input_item_Hold(item);
return task;
}
static void
TaskDestroy(task_t *task)
{
input_item_Release(task->item);
free(task);
}
static void NotifyThumbnail(task_t *task, picture_t *pic)
{
task->cbs->on_ended(pic, task->userdata);
}
static void
on_thumbnailer_input_event( input_thread_t *input,
const struct vlc_input_event *event, void *userdata )
{
VLC_UNUSED(input);
if ( event->type != INPUT_EVENT_THUMBNAIL_READY &&
( event->type != INPUT_EVENT_STATE || ( event->state.value != ERROR_S &&
event->state.value != END_S ) ) )
return;
task_t *task = userdata;
vlc_thumbnailer_t *thumbnailer = task->thumbnailer;
vlc_mutex_lock(&thumbnailer->lock);
if (task->status != RUNNING)
{
/* We may receive a THUMBNAIL_READY event followed by an
* INPUT_EVENT_STATE (end of stream), we must only consider the first
* one. */
vlc_mutex_unlock(&thumbnailer->lock);
return;
}
task->status = ENDED;
if (event->type == INPUT_EVENT_THUMBNAIL_READY)
task->pic = picture_Hold(event->thumbnail);
vlc_cond_signal(&thumbnailer->cond_ended);
vlc_mutex_unlock(&thumbnailer->lock);
}
static void
RunnableRun(void *userdata)
{
vlc_thread_set_name("vlc-run-thumb");
task_t *task = userdata;
vlc_thumbnailer_t *thumbnailer = task->thumbnailer;
vlc_tick_t now = vlc_tick_now();
static const struct vlc_input_thread_callbacks cbs = {
.on_event = on_thumbnailer_input_event,
};
const struct vlc_input_thread_cfg cfg = {
.type = INPUT_TYPE_THUMBNAILING,
.cbs = &cbs,
.cbs_data = task,
};
input_thread_t* input =
input_Create( thumbnailer->parent, task->item, &cfg );
if (!input)
goto error;
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)
{
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);
if (ret != VLC_SUCCESS)
{
input_Close(input);
goto error;
}
vlc_mutex_lock(&thumbnailer->lock);
if (thumbnailer->timeout == VLC_TICK_INVALID)
{
while (task->status == RUNNING)
vlc_cond_wait(&thumbnailer->cond_ended, &thumbnailer->lock);
}
else
{
vlc_tick_t deadline = now + thumbnailer->timeout;
int timeout = 0;
while (task->status == RUNNING && timeout == 0)
timeout =
vlc_cond_timedwait(&thumbnailer->cond_ended, &thumbnailer->lock, deadline);
}
picture_t* pic = task->pic;
task->pic = NULL;
bool interrupted = task->status == INTERRUPTED;
vlc_list_remove(&task->node);
vlc_mutex_unlock(&thumbnailer->lock);
NotifyThumbnail(task, interrupted ? NULL : pic);
if (pic)
picture_Release(pic);
input_Stop(input);
input_Close(input);
error:
TaskDestroy(task);
}
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 )
{
assert( cbs != NULL && cbs->on_ended != NULL );
task_t *task = TaskNew(thumbnailer, item, seek_arg, cbs, userdata);
if (!task)
return 0;
vlc_mutex_lock(&thumbnailer->lock);
vlc_thumbnailer_req_id id = task->id = thumbnailer->current_id++;
static_assert(VLC_THUMBNAILER_REQ_ID_INVALID == 0, "Invalid id should be 0");
if (unlikely(thumbnailer->current_id == 0)) /* unsigned wrapping */
++thumbnailer->current_id;
vlc_list_append(&task->node, &thumbnailer->submitted_tasks);
vlc_mutex_unlock(&thumbnailer->lock);
vlc_executor_Submit(thumbnailer->executor, &task->runnable);
return id;
}
size_t vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id )
{
vlc_mutex_lock(&thumbnailer->lock);
task_t *task;
size_t count = 0;
vlc_list_foreach(task, &thumbnailer->submitted_tasks, node)
{
if (id == VLC_THUMBNAILER_REQ_ID_INVALID || task->id == id)
{
count++;
bool canceled =
vlc_executor_Cancel(thumbnailer->executor, &task->runnable);
if (canceled)
{
vlc_list_remove(&task->node);
vlc_mutex_unlock(&thumbnailer->lock);
NotifyThumbnail(task, NULL);
TaskDestroy(task);
/* Small optimisation in the likely case where the user cancel
* only one task */
if (id != VLC_THUMBNAILER_REQ_ID_INVALID)
return count;
vlc_mutex_lock(&thumbnailer->lock);
}
else
{
/* The task will be finished and destroyed after run() */
task->status = INTERRUPTED;
vlc_cond_signal(&thumbnailer->cond_ended);
}
}
}
vlc_mutex_unlock(&thumbnailer->lock);
return count;
}
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;
thumbnailer->executor = vlc_executor_New(1);
if (!thumbnailer->executor)
{
free(thumbnailer);
return NULL;
}
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);
return 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 );
}
......@@ -830,11 +830,6 @@ vlc_es_id_GetCat
vlc_es_id_GetStrId
vlc_es_id_IsStrIdStable
vlc_encoder_Destroy
vlc_thumbnailer_Create
vlc_thumbnailer_Request
vlc_thumbnailer_Cancel
vlc_thumbnailer_Delete
vlc_thumbnailer_SetTimeout
vlc_player_AddAssociatedMedia
vlc_player_AddListener
vlc_player_AddMetadataListener
......@@ -1042,6 +1037,7 @@ vlc_input_attachment_New
vlc_input_attachment_Hold
vlc_preparser_New
vlc_preparser_Push
vlc_preparser_GenerateThumbnail
vlc_preparser_Cancel
vlc_preparser_Delete
vlc_preparser_Deactivate
......
......@@ -347,10 +347,11 @@ vlc_media_tree_Preparse(vlc_media_tree_t *tree, vlc_preparser_t *parser,
VLC_UNUSED(parser);
VLC_UNUSED(media);
VLC_UNUSED(preparser_callbacks);
return VLC_PREPARSER_REQ_ID_INVALID;
#else
return vlc_preparser_Push(parser, media, META_REQUEST_OPTION_PARSE |
META_REQUEST_OPTION_DO_INTERACT |
META_REQUEST_OPTION_PARSE_SUBITEMS,
return vlc_preparser_Push(parser, media, VLC_PREPARSER_TYPE_PARSE |
VLC_PREPARSER_OPTION_INTERACT |
VLC_PREPARSER_OPTION_SUBITEMS,
&preparser_callbacks, tree);
#endif
}
......@@ -178,7 +178,6 @@ libvlccore_sources_base = files(
'input/stream_filter.c',
'input/stream_memory.c',
'input/subtitles.c',
'input/thumbnailer.c',
'input/var.c',
'audio_output/aout_internal.h',
'audio_output/common.c',
......
......@@ -40,10 +40,12 @@ vlc_playlist_New(vlc_object_t *parent, enum vlc_playlist_preparsing rec,
if (rec != VLC_PLAYLIST_PREPARSING_DISABLED)
{
playlist->parser = vlc_preparser_New(parent, preparse_max_threads,
preparse_timeout,
META_REQUEST_OPTION_PARSE |
META_REQUEST_OPTION_FETCH_LOCAL);
const struct vlc_preparser_cfg cfg = {
.types = VLC_PREPARSER_TYPE_PARSE | VLC_PREPARSER_TYPE_FETCHMETA_LOCAL,
.max_parser_threads = preparse_max_threads,
.timeout = preparse_timeout,
};
playlist->parser = vlc_preparser_New(parent, &cfg);
if (playlist->parser == NULL)
{
free(playlist);
......
......@@ -149,10 +149,9 @@ vlc_playlist_AutoPreparse(vlc_playlist_t *playlist, input_item_t *input,
return;
}
input_item_meta_request_option_t options =
META_REQUEST_OPTION_PARSE | META_REQUEST_OPTION_FETCH_LOCAL;
int options = VLC_PREPARSER_TYPE_PARSE | VLC_PREPARSER_TYPE_FETCHMETA_LOCAL;
if (parse_subitems)
options |= META_REQUEST_OPTION_PARSE_SUBITEMS;
options |= VLC_PREPARSER_OPTION_SUBITEMS;
vlc_preparser_Push(playlist->parser, input, options,
&preparser_callbacks, playlist);
......
......@@ -71,7 +71,7 @@ static void RunSearchNetwork(void *);
static struct task *
TaskNew(input_fetcher_t *fetcher, vlc_executor_t *executor, input_item_t *item,
input_item_meta_request_option_t options,
int options,
const input_fetcher_callbacks_t *cbs, void *userdata)
{
struct task *task = malloc(sizeof(*task));
......@@ -127,7 +127,7 @@ FetcherRemoveTask(input_fetcher_t *fetcher, struct task *task)
static int
Submit(input_fetcher_t *fetcher, vlc_executor_t *executor, input_item_t *item,
input_item_meta_request_option_t options,
int options,
const input_fetcher_callbacks_t *cbs, void *userdata)
{
struct task *task =
......@@ -380,7 +380,7 @@ static void RunSearchLocal(void *userdata)
if( SearchByScope( task, FETCHER_SCOPE_LOCAL ) == VLC_SUCCESS )
goto end; /* done */
if( task->options & META_REQUEST_OPTION_FETCH_NETWORK )
if( task->options & VLC_PREPARSER_TYPE_FETCHMETA_NET )
{
int ret = Submit(fetcher, fetcher->executor_network, task->item,
task->options, task->cbs, task->userdata);
......@@ -422,9 +422,9 @@ static void RunSearchNetwork(void *userdata)
}
input_fetcher_t* input_fetcher_New( vlc_object_t* owner,
input_item_meta_request_option_t request_type )
int request_type )
{
assert(request_type & META_REQUEST_OPTION_FETCH_ANY);
assert(request_type & VLC_PREPARSER_TYPE_FETCHMETA_ALL);
input_fetcher_t* fetcher = malloc( sizeof( *fetcher ) );
if( unlikely( !fetcher ) )
......@@ -434,7 +434,7 @@ input_fetcher_t* input_fetcher_New( vlc_object_t* owner,
if (max_threads < 1)
max_threads = 1;
if (request_type & META_REQUEST_OPTION_FETCH_LOCAL)
if (request_type & VLC_PREPARSER_TYPE_FETCHMETA_LOCAL)
{
fetcher->executor_local = vlc_executor_New(max_threads);
if (!fetcher->executor_local)
......@@ -446,7 +446,7 @@ input_fetcher_t* input_fetcher_New( vlc_object_t* owner,
else
fetcher->executor_local = NULL;
if (request_type & META_REQUEST_OPTION_FETCH_NETWORK)
if (request_type & VLC_PREPARSER_TYPE_FETCHMETA_NET)
{
fetcher->executor_network = vlc_executor_New(max_threads);
if (!fetcher->executor_network)
......@@ -483,16 +483,16 @@ input_fetcher_t* input_fetcher_New( vlc_object_t* owner,
}
int input_fetcher_Push(input_fetcher_t* fetcher, input_item_t* item,
input_item_meta_request_option_t options,
const input_fetcher_callbacks_t *cbs, void *cbs_userdata)
int options,
const input_fetcher_callbacks_t *cbs, void *cbs_userdata)
{
assert(options & META_REQUEST_OPTION_FETCH_ANY);
if (options & META_REQUEST_OPTION_FETCH_LOCAL)
assert(options & VLC_PREPARSER_TYPE_FETCHMETA_ALL);
if (options & VLC_PREPARSER_TYPE_FETCHMETA_LOCAL)
assert(fetcher->executor_local != NULL);
if (options & META_REQUEST_OPTION_FETCH_NETWORK)
if (options & VLC_PREPARSER_TYPE_FETCHMETA_NET)
assert(fetcher->executor_network != NULL);
vlc_executor_t *executor = options & META_REQUEST_OPTION_FETCH_LOCAL
vlc_executor_t *executor = options & VLC_PREPARSER_TYPE_FETCHMETA_LOCAL
? fetcher->executor_local
: fetcher->executor_network;
......