[vlc-commits] [Git][videolan/vlc][master] 7 commits: preparser: rename default_timeout
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Oct 29 10:15:16 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
d853c700 by Thomas Guillem at 2024-10-29T10:01:22+00:00
preparser: rename default_timeout
It is now the main timeout.
- - - - -
fb479437 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: move timeout from request to creator
In order to behave like the vlc_preparser.h API.
vlc_thumbnailer_SetTimeout Will be used by libvlc_media_t, temporarily,
waiting for the future libvlc_parser_t API.
- - - - -
50f830c0 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: rename vlc_thumbnailer_Release
The thumbnailer is not refcounted, so the name was misleading.
- - - - -
bb94b3b1 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: use a struct for seek arguments
And merge vlc_thumbnailer_RequestByTime and vlc_thumbnailer_RequestByPos
into vlc_thumbnailer_Request.
- - - - -
e8a01606 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: add a possibility to disable seek
- - - - -
7e22dbe1 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: use a struct of callbacks
In order to behave like the vlc_preparser.h API.
- - - - -
06993b63 by Thomas Guillem at 2024-10-29T10:01:22+00:00
thumbnailer: fix documentation with last id changes
- - - - -
10 changed files:
- include/vlc_preparser.h
- include/vlc_thumbnailer.h
- lib/core.c
- lib/media.c
- modules/misc/medialibrary/Thumbnailer.cpp
- modules/misc/medialibrary/medialibrary.h
- src/input/thumbnailer.c
- src/libvlccore.sym
- src/preparser/preparser.c
- test/src/input/thumbnail.c
Changes:
=====================================
include/vlc_preparser.h
=====================================
@@ -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 );
/**
=====================================
include/vlc_thumbnailer.h
=====================================
@@ -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
=====================================
lib/core.c
=====================================
@@ -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);
=====================================
lib/media.c
=====================================
@@ -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
=====================================
modules/misc/medialibrary/Thumbnailer.cpp
=====================================
@@ -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)
{
=====================================
modules/misc/medialibrary/medialibrary.h
=====================================
@@ -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;
=====================================
src/input/thumbnailer.c
=====================================
@@ -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 );
=====================================
src/libvlccore.sym
=====================================
@@ -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
=====================================
src/preparser/preparser.c
=====================================
@@ -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 )
=====================================
test/src/input/thumbnail.c
=====================================
@@ -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 )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d7bd60200ee54494ca092a1d7345dcbc41a86507...06993b63533258d345c44b8add900077e7903a05
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d7bd60200ee54494ca092a1d7345dcbc41a86507...06993b63533258d345c44b8add900077e7903a05
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list