[vlc-commits] [Git][videolan/vlc][master] 12 commits: lib: set libvlc_media_parse_local > 0
Thomas Guillem (@tguillem)
gitlab at videolan.org
Tue Apr 4 08:01:38 UTC 2023
Thomas Guillem pushed to branch master at VideoLAN / VLC
Commits:
a82b0976 by Thomas Guillem at 2023-04-04T07:39:58+00:00
lib: set libvlc_media_parse_local > 0
This will allow to use the preparser to only fetch metadata.
- - - - -
5d2278c4 by Thomas Guillem at 2023-04-04T07:39:58+00:00
input_item: avoid constant use in input_item_meta_request_option_t
- - - - -
5a6942eb by Thomas Guillem at 2023-04-04T07:39:58+00:00
input_item: move META_REQUEST_OPTION NO_SKIP to SCOPE_FORCED
SCOPE_* enums are for the preparser (not for the fetcher) and this
option only touches the preparser.
- - - - -
41323953 by Thomas Guillem at 2023-04-04T07:39:58+00:00
lib: move libvlc_media_ no_skip to parse_forced
- - - - -
e5a3f4fc by Thomas Guillem at 2023-04-04T07:39:58+00:00
preparse: also use input_preparser_Push() to only fetch meta
- - - - -
8638652a by Thomas Guillem at 2023-04-04T07:39:58+00:00
preparser: notify if an art was fetched
- - - - -
99b11788 by Thomas Guillem at 2023-04-04T07:39:58+00:00
qt: use libvlc_MetadataRequest()
Instead of libvlc_ArtRequest()
- - - - -
538fcb20 by Thomas Guillem at 2023-04-04T07:39:58+00:00
core: remove libvlc_ArtRequest()
- - - - -
d59a5127 by Thomas Guillem at 2023-04-04T07:39:58+00:00
core: rename input_preparser to vlc_preparser
and input_preparser_callbacks_t to struct vlc_metadata_cbs
- - - - -
3d526a6a by Thomas Guillem at 2023-04-04T07:39:58+00:00
core: move preparser.h into vlc_preparser.h
- - - - -
9c3caa7b by Thomas Guillem at 2023-04-04T07:39:58+00:00
preparser: improve documentation
- - - - -
bc056eb4 by Thomas Guillem at 2023-04-04T07:39:58+00:00
core: expose vlc_preparser API
- - - - -
18 changed files:
- include/meson.build
- include/vlc/libvlc_media.h
- include/vlc_input_item.h
- src/preparser/preparser.h → include/vlc_preparser.h
- lib/media.c
- modules/gui/macosx/library/VLCInputItem.m
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/player_controller.hpp
- src/Makefile.am
- src/libvlc.c
- src/libvlc.h
- src/libvlccore.sym
- src/media_source/media_tree.c
- src/meson.build
- src/playlist/preparse.c
- src/preparser/fetcher.h
- src/preparser/preparser.c
- test/libvlc/media.c
Changes:
=====================================
include/meson.build
=====================================
@@ -85,6 +85,7 @@ install_headers(
'vlc_playlist.h',
'vlc_playlist_export.h',
'vlc_plugin.h',
+ 'vlc_preparser.h',
'vlc_probe.h',
'vlc_rand.h',
'vlc_renderer_discovery.h',
=====================================
include/vlc/libvlc_media.h
=====================================
@@ -147,29 +147,29 @@ typedef enum libvlc_media_parse_flag_t
/**
* Parse media if it's a local file
*/
- libvlc_media_parse_local = 0x00,
+ libvlc_media_parse_local = 0x01,
/**
* Parse media even if it's a network file
*/
- libvlc_media_parse_network = 0x01,
+ libvlc_media_parse_network = 0x02,
+ /**
+ * Force parsing the media even if it would be skipped.
+ */
+ libvlc_media_parse_forced = 0x04,
/**
* Fetch meta and cover art using local resources
*/
- libvlc_media_fetch_local = 0x02,
+ libvlc_media_fetch_local = 0x08,
/**
* Fetch meta and cover art using network resources
*/
- libvlc_media_fetch_network = 0x04,
+ libvlc_media_fetch_network = 0x10,
/**
* Interact with the user (via libvlc_dialog_cbs) when preparsing this item
* (and not its sub items). Set this flag in order to receive a callback
* when the input is asking for credentials.
*/
- libvlc_media_do_interact = 0x08,
- /**
- * Force parsing the media even if it would be skipped.
- */
- libvlc_media_no_skip = 0x10,
+ libvlc_media_do_interact = 0x20,
} libvlc_media_parse_flag_t;
/**
=====================================
include/vlc_input_item.h
=====================================
@@ -38,7 +38,6 @@
typedef struct input_item_opaque input_item_opaque_t;
typedef struct input_item_slave input_item_slave_t;
-typedef struct input_preparser_callbacks_t input_preparser_callbacks_t;
struct info_t
{
@@ -478,12 +477,14 @@ typedef enum input_item_meta_request_option_t
META_REQUEST_OPTION_NONE = 0x00,
META_REQUEST_OPTION_SCOPE_LOCAL = 0x01,
META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
- META_REQUEST_OPTION_SCOPE_ANY = 0x03,
- META_REQUEST_OPTION_FETCH_LOCAL = 0x04,
- META_REQUEST_OPTION_FETCH_NETWORK = 0x08,
- META_REQUEST_OPTION_FETCH_ANY = 0x0C,
- META_REQUEST_OPTION_DO_INTERACT = 0x10,
- META_REQUEST_OPTION_NO_SKIP = 0x20,
+ META_REQUEST_OPTION_SCOPE_ANY =
+ META_REQUEST_OPTION_SCOPE_LOCAL|META_REQUEST_OPTION_SCOPE_NETWORK,
+ META_REQUEST_OPTION_SCOPE_FORCED = 0x04,
+ META_REQUEST_OPTION_FETCH_LOCAL = 0x08,
+ META_REQUEST_OPTION_FETCH_NETWORK = 0x10,
+ META_REQUEST_OPTION_FETCH_ANY =
+ META_REQUEST_OPTION_FETCH_LOCAL|META_REQUEST_OPTION_FETCH_NETWORK,
+ META_REQUEST_OPTION_DO_INTERACT = 0x20,
} input_item_meta_request_option_t;
/* status of the on_preparse_ended() callback */
@@ -495,24 +496,17 @@ enum input_item_preparse_status
ITEM_PREPARSE_DONE
};
-typedef struct input_preparser_callbacks_t {
+struct vlc_metadata_cbs {
void (*on_preparse_ended)(input_item_t *, enum input_item_preparse_status status, void *userdata);
- void (*on_subtree_added)(input_item_t *, input_item_node_t *subtree, void *userdata);
-} input_preparser_callbacks_t;
-
-typedef struct input_fetcher_callbacks_t {
void (*on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata);
-} input_fetcher_callbacks_t;
+ void (*on_subtree_added)(input_item_t *, input_item_node_t *subtree, void *userdata);
+};
VLC_API int libvlc_MetadataRequest( libvlc_int_t *, input_item_t *,
input_item_meta_request_option_t,
- const input_preparser_callbacks_t *cbs,
+ const struct vlc_metadata_cbs *cbs,
void *cbs_userdata,
int, void * );
-VLC_API int libvlc_ArtRequest(libvlc_int_t *, input_item_t *,
- input_item_meta_request_option_t,
- const input_fetcher_callbacks_t *cbs,
- void *cbs_userdata );
VLC_API void libvlc_MetadataCancel( libvlc_int_t *, void * );
/******************
=====================================
src/preparser/preparser.h → include/vlc_preparser.h
=====================================
@@ -1,7 +1,7 @@
/*****************************************************************************
* preparser.h
*****************************************************************************
- * Copyright (C) 1999-2008 VLC authors and VideoLAN
+ * Copyright (C) 1999-2023 VLC authors and VideoLAN
*
* Authors: Samuel Hocevar <sam at zoy.org>
* Clément Stenac <zorglub at videolan.org>
@@ -21,10 +21,19 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#ifndef _INPUT_PREPARSER_H
-#define _INPUT_PREPARSER_H 1
+#ifndef VLC_PREPARSER_H
+#define VLC_PREPARSER_H 1
#include <vlc_input_item.h>
+
+/**
+ * @defgroup vlc_preparser Preparser
+ * @ingroup input
+ * @{
+ * @file
+ * VLC Preparser API
+ */
+
/**
* Preparser opaque structure.
*
@@ -32,60 +41,69 @@
* an asynchronous way.
* It will also issue art fetching requests.
*/
-typedef struct input_preparser_t input_preparser_t;
+typedef struct vlc_preparser_t vlc_preparser_t;
/**
* This function creates the preparser object and thread.
+ *
+ * @param obj the parent object
+ * @return a valid preparser object or NULL in case of error
*/
-input_preparser_t *input_preparser_New( vlc_object_t * );
+VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj );
/**
- * This function enqueues the provided item to be preparsed.
+ * This function enqueues the provided item to be preparsed or fetched.
*
* The input item is retained until the preparsing is done or until the
* preparser object is deleted.
*
+ * @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 cbs callback to listen to events (can't be NULL)
+ * @param cbs_userdata opaque pointer used by the callbacks
* @param timeout maximum time allowed to preparse the item. If -1, the default
* "preparse-timeout" option will be used as a timeout. If 0, it will wait
* indefinitely. If > 0, the timeout will be used (in milliseconds).
* @param id unique id provided by the caller. This is can be used to cancel
- * the request with input_preparser_Cancel()
+ * the request with vlc_preparser_Cancel()
* @returns VLC_SUCCESS if the item was scheduled for preparsing, an error code
* otherwise
* If this returns an error, the on_preparse_ended will *not* be invoked
*/
-int input_preparser_Push( input_preparser_t *, input_item_t *,
- input_item_meta_request_option_t,
- const input_preparser_callbacks_t *cbs,
- void *cbs_userdata,
- int timeout, void *id );
-
-void input_preparser_fetcher_Push( input_preparser_t *, input_item_t *,
- input_item_meta_request_option_t,
- const input_fetcher_callbacks_t *cbs,
- void *cbs_userdata );
+VLC_API int vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item,
+ input_item_meta_request_option_t option,
+ const struct vlc_metadata_cbs *cbs,
+ void *cbs_userdata,
+ int timeout, void *id );
/**
* This function cancel all preparsing requests for a given id
*
- * @param id unique id given to input_preparser_Push()
+ * @param preparser the preparser object
+ * @param id unique id given to vlc_preparser_Push()
*/
-void input_preparser_Cancel( input_preparser_t *, void *id );
+VLC_API void vlc_preparser_Cancel( vlc_preparser_t *preparser, void *id );
/**
* This function destroys the preparser object and thread.
*
+ * @param preparser the preparser object
* All pending input items will be released.
*/
-void input_preparser_Delete( input_preparser_t * );
+VLC_API void vlc_preparser_Delete( vlc_preparser_t *preparser );
/**
* This function deactivates the preparser
*
* All pending requests will be removed, and it will block until the currently
* running entity has finished (if any).
+ *
+ * @param preparser the preparser object
*/
-void input_preparser_Deactivate( input_preparser_t * );
+VLC_API void vlc_preparser_Deactivate( vlc_preparser_t *preparser );
+
+/** @} vlc_preparser */
#endif
=====================================
lib/media.c
=====================================
@@ -820,7 +820,7 @@ libvlc_media_get_filestat( libvlc_media_t *p_md, unsigned type, uint64_t *out )
return 1;
}
-static const input_preparser_callbacks_t input_preparser_callbacks = {
+static const struct vlc_metadata_cbs preparser_callbacks = {
.on_preparse_ended = input_item_preparse_ended,
.on_subtree_added = input_item_subtree_added,
};
@@ -839,7 +839,7 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
libvlc_int_t *libvlc = inst->p_libvlc_int;
input_item_t *item = media->p_input_item;
- input_item_meta_request_option_t parse_scope = META_REQUEST_OPTION_SCOPE_LOCAL;
+ input_item_meta_request_option_t parse_scope = 0;
int ret;
unsigned int ref = atomic_load_explicit(&media->worker_count,
memory_order_relaxed);
@@ -853,19 +853,21 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
memory_order_relaxed,
memory_order_relaxed));
+ if (parse_flag & libvlc_media_parse_local)
+ parse_scope |= META_REQUEST_OPTION_SCOPE_LOCAL;
if (parse_flag & libvlc_media_parse_network)
parse_scope |= META_REQUEST_OPTION_SCOPE_NETWORK;
+ if (parse_flag & libvlc_media_parse_forced)
+ parse_scope |= META_REQUEST_OPTION_SCOPE_FORCED;
if (parse_flag & libvlc_media_fetch_local)
parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
if (parse_flag & libvlc_media_fetch_network)
parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
if (parse_flag & libvlc_media_do_interact)
parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
- if (parse_flag & libvlc_media_no_skip)
- parse_scope |= META_REQUEST_OPTION_NO_SKIP;
ret = libvlc_MetadataRequest(libvlc, item, parse_scope,
- &input_preparser_callbacks, media,
+ &preparser_callbacks, media,
timeout, media);
if (ret != VLC_SUCCESS)
{
=====================================
modules/gui/macosx/library/VLCInputItem.m
=====================================
@@ -81,7 +81,7 @@ static void cb_preparse_ended(input_item_t *p_item, enum input_item_preparse_sta
});
}
-static const struct input_preparser_callbacks_t preparseCallbacks = {
+static const struct vlc_metadata_cbs preparseCallbacks = {
cb_preparse_ended,
cb_subtree_added,
};
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1126,7 +1126,7 @@ PlayerController::PlayerController( qt_intf_t *_p_intf )
connect( &d_ptr->m_position_timer, &QTimer::timeout, this, &PlayerController::updatePositionFromTimer );
connect( &d_ptr->m_time_timer, &QTimer::timeout, this, &PlayerController::updateTimeFromTimer );
- input_fetcher_cbs.on_art_fetch_ended = onArtFetchEnded_callback;
+ input_preparser_cbs.on_art_fetch_ended = onArtFetchEnded_callback;
}
PlayerController::~PlayerController()
@@ -1850,10 +1850,10 @@ void PlayerController::requestArtUpdate( input_item_t *p_item, bool b_forced )
if ( status & ( ITEM_ART_NOTFOUND|ITEM_ART_FETCHED ) )
return;
}
- libvlc_ArtRequest( vlc_object_instance(d->p_intf), p_item,
- (b_forced) ? META_REQUEST_OPTION_FETCH_ANY
- : META_REQUEST_OPTION_FETCH_LOCAL,
- &input_fetcher_cbs, this );
+ libvlc_MetadataRequest( vlc_object_instance(d->p_intf), p_item,
+ (b_forced) ? META_REQUEST_OPTION_FETCH_ANY
+ : META_REQUEST_OPTION_FETCH_LOCAL,
+ &input_preparser_cbs, this, 0, NULL );
}
}
=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -487,7 +487,7 @@ private:
QSignalMapper *menusAudioMapper; //used by VLCMenuBar
/* updateArt gui request */
- input_fetcher_callbacks_t input_fetcher_cbs;
+ struct vlc_metadata_cbs input_preparser_cbs;
static void onArtFetchEnded_callback(input_item_t *, bool fetched, void *userdata);
void onArtFetchEnded(input_item_t *, bool fetched);
};
=====================================
src/Makefile.am
=====================================
@@ -92,6 +92,7 @@ pluginsinclude_HEADERS = \
../include/vlc_playlist_export.h \
../include/vlc_plugin.h \
../include/vlc_probe.h \
+ ../include/vlc_preparser.h \
../include/vlc_queue.h \
../include/vlc_rand.h \
../include/vlc_renderer_discovery.h \
@@ -260,7 +261,6 @@ libvlccore_la_SOURCES = \
preparser/fetcher.c \
preparser/fetcher.h \
preparser/preparser.c \
- preparser/preparser.h \
input/item.c \
input/access.c \
clock/clock_internal.c \
=====================================
src/libvlc.c
=====================================
@@ -36,11 +36,11 @@
#endif
#include <vlc_common.h>
+#include <vlc_preparser.h>
#include "../lib/libvlc_internal.h"
#include "modules/modules.h"
#include "config/configuration.h"
-#include "preparser/preparser.h"
#include "media_source/media_source.h"
#include <stdio.h> /* sprintf() */
@@ -230,7 +230,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/*
* Meta data handling
*/
- priv->parser = input_preparser_New(VLC_OBJECT(p_libvlc));
+ priv->parser = vlc_preparser_New(VLC_OBJECT(p_libvlc));
if( !priv->parser )
goto error;
@@ -343,7 +343,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
libvlc_priv_t *priv = libvlc_priv (p_libvlc);
if (priv->parser != NULL)
- input_preparser_Deactivate(priv->parser);
+ vlc_preparser_Deactivate(priv->parser);
/* Ask the interfaces to stop and destroy them */
msg_Dbg( p_libvlc, "removing all interfaces" );
@@ -376,7 +376,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
#endif
if (priv->parser != NULL)
- input_preparser_Delete(priv->parser);
+ vlc_preparser_Delete(priv->parser);
if (priv->main_playlist)
vlc_playlist_Delete(priv->main_playlist);
@@ -452,7 +452,7 @@ static void GetFilenames( libvlc_int_t *p_vlc, unsigned n,
int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
input_item_meta_request_option_t i_options,
- const input_preparser_callbacks_t *cbs,
+ const struct vlc_metadata_cbs *cbs,
void *cbs_userdata,
int timeout, void *id)
{
@@ -461,7 +461,7 @@ int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
if (unlikely(priv->parser == NULL))
return VLC_ENOMEM;
- return input_preparser_Push( priv->parser, item, i_options, cbs,
+ return vlc_preparser_Push( priv->parser, item, i_options, cbs,
cbs_userdata, timeout, id );
}
@@ -472,7 +472,7 @@ int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
*/
int libvlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
input_item_meta_request_option_t i_options,
- const input_preparser_callbacks_t *cbs,
+ const struct vlc_metadata_cbs *cbs,
void *cbs_userdata,
int timeout, void *id)
{
@@ -490,26 +490,6 @@ int libvlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
return vlc_MetadataRequest(libvlc, item, i_options, cbs, cbs_userdata, timeout, id);
}
-/**
- * Requests retrieving/downloading art for an input item.
- * The retrieval is performed asynchronously.
- */
-int libvlc_ArtRequest(libvlc_int_t *libvlc, input_item_t *item,
- input_item_meta_request_option_t i_options,
- const input_fetcher_callbacks_t *cbs,
- void *cbs_userdata)
-{
- libvlc_priv_t *priv = libvlc_priv(libvlc);
- assert(i_options & META_REQUEST_OPTION_FETCH_ANY);
-
- if (unlikely(priv->parser == NULL))
- return VLC_ENOMEM;
-
- input_preparser_fetcher_Push(priv->parser, item, i_options,
- cbs, cbs_userdata);
- return VLC_SUCCESS;
-}
-
/**
* Cancels extraction of the meta data for an input item.
*
@@ -523,5 +503,5 @@ void libvlc_MetadataCancel(libvlc_int_t *libvlc, void *id)
if (unlikely(priv->parser == NULL))
return;
- input_preparser_Cancel(priv->parser, id);
+ vlc_preparser_Cancel(priv->parser, id);
}
=====================================
src/libvlc.h
=====================================
@@ -186,7 +186,7 @@ typedef struct libvlc_priv_t
vlc_keystore *p_memory_keystore; ///< memory keystore
intf_thread_t *interfaces; ///< Linked-list of interfaces
vlc_playlist_t *main_playlist;
- struct input_preparser_t *parser; ///< Input item meta data handler
+ struct vlc_preparser_t *parser; ///< Input item meta data handler
vlc_media_source_provider_t *media_source_provider;
vlc_actions_t *actions; ///< Hotkeys handler
struct vlc_medialibrary_t *p_media_library; ///< Media library instance
@@ -208,7 +208,7 @@ void intf_DestroyAll( libvlc_int_t * );
int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
input_item_meta_request_option_t i_options,
- const input_preparser_callbacks_t *cbs,
+ const struct vlc_metadata_cbs *cbs,
void *cbs_userdata,
int timeout, void *id);
=====================================
src/libvlccore.sym
=====================================
@@ -243,7 +243,6 @@ libvlc_Quit
libvlc_SetExitHandler
libvlc_MetadataRequest
libvlc_MetadataCancel
-libvlc_ArtRequest
vlc_UrlParse
vlc_UrlParseFixup
vlc_UrlClean
@@ -1027,3 +1026,8 @@ vlc_executor_WaitIdle
vlc_input_attachment_Release
vlc_input_attachment_New
vlc_input_attachment_Hold
+vlc_preparser_New
+vlc_preparser_Push
+vlc_preparser_Cancel
+vlc_preparser_Delete
+vlc_preparser_Deactivate
=====================================
src/media_source/media_tree.c
=====================================
@@ -334,7 +334,7 @@ vlc_media_tree_Remove(vlc_media_tree_t *tree, input_item_t *media)
return true;
}
-static const input_preparser_callbacks_t input_preparser_callbacks = {
+static const struct vlc_metadata_cbs preparser_callbacks = {
.on_subtree_added = media_subtree_changed,
.on_preparse_ended = media_subtree_preparse_ended
};
@@ -348,12 +348,12 @@ vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
VLC_UNUSED(libvlc);
VLC_UNUSED(media);
VLC_UNUSED(id);
- VLC_UNUSED(input_preparser_callbacks);
+ VLC_UNUSED(preparser_callbacks);
#else
media->i_preparse_depth = 1;
vlc_MetadataRequest(libvlc, media, META_REQUEST_OPTION_SCOPE_ANY |
META_REQUEST_OPTION_DO_INTERACT,
- &input_preparser_callbacks, tree, 0, id);
+ &preparser_callbacks, tree, 0, id);
#endif
}
=====================================
src/meson.build
=====================================
@@ -121,7 +121,6 @@ libvlccore_sources_base = files(
'preparser/fetcher.c',
'preparser/fetcher.h',
'preparser/preparser.c',
- 'preparser/preparser.h',
'input/item.c',
'input/access.c',
'clock/clock_internal.c',
=====================================
src/playlist/preparse.c
=====================================
@@ -106,7 +106,7 @@ on_preparse_ended(input_item_t *media,
vlc_playlist_Unlock(playlist);
}
-static const input_preparser_callbacks_t input_preparser_callbacks = {
+static const struct vlc_metadata_cbs preparser_callbacks = {
.on_preparse_ended = on_preparse_ended,
.on_subtree_added = on_subtree_added,
};
@@ -117,13 +117,13 @@ vlc_playlist_Preparse(vlc_playlist_t *playlist, input_item_t *input)
#ifdef TEST_PLAYLIST
VLC_UNUSED(playlist);
VLC_UNUSED(input);
- VLC_UNUSED(input_preparser_callbacks);
+ VLC_UNUSED(preparser_callbacks);
#else
/* vlc_MetadataRequest is not exported */
vlc_MetadataRequest(playlist->libvlc, input,
META_REQUEST_OPTION_SCOPE_LOCAL |
META_REQUEST_OPTION_FETCH_LOCAL,
- &input_preparser_callbacks, playlist, -1, NULL);
+ &preparser_callbacks, playlist, -1, NULL);
#endif
}
=====================================
src/preparser/fetcher.h
=====================================
@@ -34,6 +34,10 @@
*/
typedef struct input_fetcher_t input_fetcher_t;
+typedef struct input_fetcher_callbacks_t {
+ void (*on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata);
+} input_fetcher_callbacks_t;
+
/**
* This function creates the fetcher object and thread.
*/
=====================================
src/preparser/preparser.c
=====================================
@@ -25,13 +25,13 @@
#include <vlc_common.h>
#include <vlc_atomic.h>
#include <vlc_executor.h>
+#include <vlc_preparser.h>
#include "input/input_interface.h"
#include "input/input_internal.h"
-#include "preparser.h"
#include "fetcher.h"
-struct input_preparser_t
+struct vlc_preparser_t
{
vlc_object_t* owner;
input_fetcher_t* fetcher;
@@ -45,10 +45,10 @@ struct input_preparser_t
struct task
{
- input_preparser_t *preparser;
+ vlc_preparser_t *preparser;
input_item_t *item;
input_item_meta_request_option_t options;
- const input_preparser_callbacks_t *cbs;
+ const struct vlc_metadata_cbs *cbs;
void *userdata;
void *id;
vlc_tick_t timeout;
@@ -59,18 +59,19 @@ struct task
vlc_sem_t fetch_ended;
atomic_int preparse_status;
atomic_bool interrupted;
+ bool art_fetched;
struct vlc_runnable runnable; /**< to be passed to the executor */
- struct vlc_list node; /**< node of input_preparser_t.submitted_tasks */
+ struct vlc_list node; /**< node of vlc_preparser_t.submitted_tasks */
};
static void RunnableRun(void *);
static struct task *
-TaskNew(input_preparser_t *preparser, input_item_t *item,
+TaskNew(vlc_preparser_t *preparser, input_item_t *item,
input_item_meta_request_option_t options,
- const input_preparser_callbacks_t *cbs, void *userdata,
+ const struct vlc_metadata_cbs *cbs, void *userdata,
void *id, vlc_tick_t timeout)
{
assert(timeout >= 0);
@@ -86,6 +87,7 @@ TaskNew(input_preparser_t *preparser, input_item_t *item,
task->userdata = userdata;
task->id = id;
task->timeout = timeout;
+ task->art_fetched = false;
input_item_Hold(item);
@@ -109,7 +111,7 @@ TaskDelete(struct task *task)
}
static void
-PreparserAddTask(input_preparser_t *preparser, struct task *task)
+PreparserAddTask(vlc_preparser_t *preparser, struct task *task)
{
vlc_mutex_lock(&preparser->lock);
vlc_list_append(&task->node, &preparser->submitted_tasks);
@@ -117,7 +119,7 @@ PreparserAddTask(input_preparser_t *preparser, struct task *task)
}
static void
-PreparserRemoveTask(input_preparser_t *preparser, struct task *task)
+PreparserRemoveTask(vlc_preparser_t *preparser, struct task *task)
{
vlc_mutex_lock(&preparser->lock);
vlc_list_remove(&task->node);
@@ -127,7 +129,15 @@ PreparserRemoveTask(input_preparser_t *preparser, struct task *task)
static void
NotifyPreparseEnded(struct task *task)
{
- if (task->cbs && task->cbs->on_preparse_ended) {
+ if (task->cbs == NULL)
+ return;
+
+ if (task->options & META_REQUEST_OPTION_FETCH_ANY
+ && task->cbs->on_art_fetch_ended)
+ task->cbs->on_art_fetch_ended(task->item, task->art_fetched,
+ task->userdata);
+
+ if (task->cbs->on_preparse_ended) {
int status = atomic_load_explicit(&task->preparse_status,
memory_order_relaxed);
task->cbs->on_preparse_ended(task->item, status, task->userdata);
@@ -172,6 +182,7 @@ OnArtFetchEnded(input_item_t *item, bool fetched, void *userdata)
VLC_UNUSED(fetched);
struct task *task = userdata;
+ task->art_fetched = fetched;
vlc_sem_post(&task->fetch_ended);
}
@@ -240,10 +251,14 @@ RunnableRun(void *userdata)
vlc_tick_t deadline = task->timeout ? vlc_tick_now() + task->timeout
: VLC_TICK_INVALID;
- if (atomic_load(&task->interrupted))
- goto end;
+ if (task->options & (META_REQUEST_OPTION_SCOPE_ANY|
+ META_REQUEST_OPTION_SCOPE_FORCED))
+ {
+ if (atomic_load(&task->interrupted))
+ goto end;
- Parse(task, deadline);
+ Parse(task, deadline);
+ }
if (atomic_load(&task->interrupted))
goto end;
@@ -257,7 +272,7 @@ RunnableRun(void *userdata)
end:
NotifyPreparseEnded(task);
- input_preparser_t *preparser = task->preparser;
+ vlc_preparser_t *preparser = task->preparser;
PreparserRemoveTask(preparser, task);
TaskDelete(task);
}
@@ -273,9 +288,9 @@ Interrupt(struct task *task)
vlc_sem_post(&task->preparse_ended);
}
-input_preparser_t* input_preparser_New( vlc_object_t *parent )
+vlc_preparser_t* vlc_preparser_New( vlc_object_t *parent )
{
- input_preparser_t* preparser = malloc( sizeof *preparser );
+ vlc_preparser_t* preparser = malloc( sizeof *preparser );
if (!preparser)
return NULL;
@@ -308,9 +323,9 @@ input_preparser_t* input_preparser_New( vlc_object_t *parent )
return preparser;
}
-int input_preparser_Push( input_preparser_t *preparser,
+int vlc_preparser_Push( vlc_preparser_t *preparser,
input_item_t *item, input_item_meta_request_option_t i_options,
- const input_preparser_callbacks_t *cbs, void *cbs_userdata,
+ const struct vlc_metadata_cbs *cbs, void *cbs_userdata,
int timeout_ms, void *id )
{
if( atomic_load( &preparser->deactivated ) )
@@ -323,7 +338,7 @@ int input_preparser_Push( input_preparser_t *preparser,
item->b_preparse_interact = true;
vlc_mutex_unlock( &item->lock );
- if (!(i_options & META_REQUEST_OPTION_NO_SKIP))
+ if (!(i_options & META_REQUEST_OPTION_SCOPE_FORCED))
{
switch( i_type )
{
@@ -335,9 +350,16 @@ int input_preparser_Push( input_preparser_t *preparser,
break;
/* fallthrough */
default:
- if (cbs && cbs->on_preparse_ended)
- cbs->on_preparse_ended(item, ITEM_PREPARSE_SKIPPED, cbs_userdata);
- return VLC_SUCCESS;
+ if( ( i_options & META_REQUEST_OPTION_FETCH_ANY ) == 0 )
+ {
+ /* Nothing to do (no preparse and not fetch), notify it */
+ if (cbs && cbs->on_preparse_ended)
+ cbs->on_preparse_ended(item, ITEM_PREPARSE_SKIPPED,
+ cbs_userdata);
+ return VLC_SUCCESS;
+ }
+ /* Continue without parsing (but fetching) */
+ i_options &= ~META_REQUEST_OPTION_SCOPE_ANY;
}
}
@@ -354,16 +376,7 @@ int input_preparser_Push( input_preparser_t *preparser,
return VLC_SUCCESS;
}
-void input_preparser_fetcher_Push( input_preparser_t *preparser,
- input_item_t *item, input_item_meta_request_option_t options,
- const input_fetcher_callbacks_t *cbs, void *cbs_userdata )
-{
- if( preparser->fetcher )
- input_fetcher_Push( preparser->fetcher, item, options,
- cbs, cbs_userdata );
-}
-
-void input_preparser_Cancel( input_preparser_t *preparser, void *id )
+void vlc_preparser_Cancel( vlc_preparser_t *preparser, void *id )
{
vlc_mutex_lock(&preparser->lock);
@@ -389,16 +402,16 @@ void input_preparser_Cancel( input_preparser_t *preparser, void *id )
vlc_mutex_unlock(&preparser->lock);
}
-void input_preparser_Deactivate( input_preparser_t* preparser )
+void vlc_preparser_Deactivate( vlc_preparser_t* preparser )
{
atomic_store( &preparser->deactivated, true );
- input_preparser_Cancel(preparser, NULL);
+ vlc_preparser_Cancel(preparser, NULL);
}
-void input_preparser_Delete( input_preparser_t *preparser )
+void vlc_preparser_Delete( vlc_preparser_t *preparser )
{
- /* In case input_preparser_Deactivate() has not been called */
- input_preparser_Cancel(preparser, NULL);
+ /* In case vlc_preparser_Deactivate() has not been called */
+ vlc_preparser_Cancel(preparser, NULL);
vlc_executor_Delete(preparser->executor);
=====================================
test/libvlc/media.c
=====================================
@@ -169,7 +169,7 @@ static void test_input_metadata_timeout(libvlc_instance_t *vlc, int timeout,
vlc_sem_t sem;
vlc_sem_init (&sem, 0);
- const struct input_preparser_callbacks_t cbs = {
+ const struct vlc_metadata_cbs cbs = {
.on_preparse_ended = input_item_preparse_timeout,
};
i_ret = libvlc_MetadataRequest(vlc->p_libvlc_int, p_item,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dc397a76c1a8ff536c82050074c21b5418c856de...bc056eb4803b31b3e701c604560bc7384cde471f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dc397a76c1a8ff536c82050074c21b5418c856de...bc056eb4803b31b3e701c604560bc7384cde471f
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