[vlc-commits] [Git][videolan/vlc][master] 12 commits: core: add libvlc_GetMainPreparser()
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Oct 9 10:04:42 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
b8e64e47 by Thomas Guillem at 2024-10-09T09:46:32+00:00
core: add libvlc_GetMainPreparser()
Will replace vlc_MetadataRequest().
- - - - -
0155ef5f by Thomas Guillem at 2024-10-09T09:46:32+00:00
media_tree: use vlc_preparser API directly
- - - - -
0c243f98 by Thomas Guillem at 2024-10-09T09:46:32+00:00
playlist: use vlc_preparser API directly
- - - - -
65978676 by Thomas Guillem at 2024-10-09T09:46:32+00:00
lib: media: use vlc_preparser API directly
- - - - -
ca5307f9 by Thomas Guillem at 2024-10-09T09:46:32+00:00
macosx: use vlc_preparser API directly
- - - - -
e9b324cd by Thomas Guillem at 2024-10-09T09:46:32+00:00
qt: use vlc_preparser API directly
- - - - -
b16dd8c3 by Thomas Guillem at 2024-10-09T09:46:32+00:00
test: libvlc: use vlc_preparser API directly
- - - - -
eec54aca by Thomas Guillem at 2024-10-09T09:46:32+00:00
input: remove useless and deprecated comment
- - - - -
378dfd3f by Thomas Guillem at 2024-10-09T09:46:32+00:00
lib: remove *vlc_Metadata* API
- - - - -
1999ce37 by Thomas Guillem at 2024-10-09T09:46:32+00:00
input_item: move preparser enums and structs
- - - - -
cb5ee637 by Thomas Guillem at 2024-10-09T09:46:32+00:00
media_tree: recquire a vlc_preparser instead of libvlc
- - - - -
d3c65e6b by Thomas Guillem at 2024-10-09T09:46:32+00:00
qt: store the parser internally
- - - - -
21 changed files:
- include/vlc_input_item.h
- include/vlc_media_source.h
- include/vlc_preparser.h
- lib/media.c
- modules/gui/macosx/library/VLCInputItem.m
- modules/gui/macosx/library/media-source/VLCMediaSource.m
- modules/gui/qt/dialogs/dialogs_provider.cpp
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/player/player_controller.cpp
- src/input/input.c
- src/libvlc.c
- src/libvlc.h
- src/libvlccore.sym
- src/media_source/media_tree.c
- src/playlist/playlist.c
- src/playlist/playlist.h
- src/playlist/preparse.c
- src/preparser/fetcher.h
- test/libvlc/media.c
Changes:
=====================================
include/vlc_input_item.h
=====================================
@@ -510,47 +510,6 @@ input_item_parser_id_Interrupt(input_item_parser_id_t *parser);
VLC_API void
input_item_parser_id_Release(input_item_parser_id_t *parser);
-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 =
- 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,
- META_REQUEST_OPTION_PARSE_SUBITEMS = 0x40,
-} input_item_meta_request_option_t;
-
-/* status of the on_preparse_ended() callback */
-enum input_item_preparse_status
-{
- ITEM_PREPARSE_SKIPPED,
- ITEM_PREPARSE_FAILED,
- ITEM_PREPARSE_TIMEOUT,
- ITEM_PREPARSE_DONE
-};
-
-struct vlc_metadata_cbs {
- void (*on_preparse_ended)(input_item_t *, enum input_item_preparse_status status, void *userdata);
- void (*on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata);
- void (*on_subtree_added)(input_item_t *, input_item_node_t *subtree, void *userdata);
- void (*on_attachments_added)(input_item_t *item,
- input_attachment_t *const *array,
- size_t count, void *userdata);
-};
-
-VLC_API int libvlc_MetadataRequest( libvlc_int_t *, input_item_t *,
- input_item_meta_request_option_t,
- const struct vlc_metadata_cbs *cbs,
- void *cbs_userdata,
- int, void * );
-VLC_API void libvlc_MetadataCancel( libvlc_int_t *, void * );
-
/******************
* Input stats
******************/
=====================================
include/vlc_media_source.h
=====================================
@@ -24,6 +24,7 @@
#include <vlc_common.h>
#include <vlc_input_item.h>
#include <vlc_services_discovery.h>
+#include <vlc_preparser.h>
#ifdef __cplusplus
extern "C" {
@@ -234,24 +235,15 @@ vlc_media_tree_Find(vlc_media_tree_t *tree, const input_item_t *media,
* Preparse a media, and expand it in the media tree on subitems added.
*
* \param tree the media tree (not necessarily locked)
- * \param libvlc the libvlc instance
+ * \param parser a valid preparser
* \param media the media to preparse
- * \param id a task identifier
+ * \param id a task identifier, cancel it via vlc_preparser_Cancel()
*/
VLC_API void
-vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
+vlc_media_tree_Preparse(vlc_media_tree_t *tree, vlc_preparser_t *parser,
input_item_t *media, void *id);
-/**
- * Cancel a media tree preparse request
- *
- * \param libvlc the libvlc instance
- * \param id the preparse task id
- */
-VLC_API void
-vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id);
-
/**
* Media source.
*
=====================================
include/vlc_preparser.h
=====================================
@@ -43,6 +43,40 @@
*/
typedef struct vlc_preparser_t vlc_preparser_t;
+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 =
+ 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,
+ META_REQUEST_OPTION_PARSE_SUBITEMS = 0x40,
+} input_item_meta_request_option_t;
+
+/* status of the on_preparse_ended() callback */
+enum input_item_preparse_status
+{
+ ITEM_PREPARSE_SKIPPED,
+ ITEM_PREPARSE_FAILED,
+ ITEM_PREPARSE_TIMEOUT,
+ ITEM_PREPARSE_DONE
+};
+
+struct vlc_metadata_cbs {
+ void (*on_preparse_ended)(input_item_t *, enum input_item_preparse_status status, void *userdata);
+ void (*on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata);
+ void (*on_subtree_added)(input_item_t *, input_item_node_t *subtree, void *userdata);
+ void (*on_attachments_added)(input_item_t *item,
+ input_attachment_t *const *array,
+ size_t count, void *userdata);
+};
+
/**
* This function creates the preparser object and thread.
*
@@ -103,6 +137,14 @@ VLC_API void vlc_preparser_Delete( vlc_preparser_t *preparser );
*/
VLC_API void vlc_preparser_Deactivate( vlc_preparser_t *preparser );
+/**
+ * Recover the main preparser from libvlc
+ *
+ * @param libvlc valid libvlc object
+ * @return the main preparser (can be NULL)
+ */
+VLC_API vlc_preparser_t *libvlc_GetMainPreparser(libvlc_int_t *libvlc);
+
/** @} vlc_preparser */
#endif
=====================================
lib/media.c
=====================================
@@ -39,6 +39,7 @@
#include <vlc_url.h>
#include <vlc_thumbnailer.h>
#include <vlc_atomic.h>
+#include <vlc_preparser.h>
#include "../src/libvlc.h"
@@ -740,6 +741,10 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
return -1;
libvlc_int_t *libvlc = inst->p_libvlc_int;
+ vlc_preparser_t *parser = libvlc_GetMainPreparser(libvlc);
+ if (unlikely(parser == NULL))
+ return -1;
+
input_item_t *item = media->p_input_item;
input_item_meta_request_option_t parse_scope = 0;
int ret;
@@ -769,9 +774,8 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
parse_scope |= META_REQUEST_OPTION_PARSE_SUBITEMS;
- ret = libvlc_MetadataRequest(libvlc, item, parse_scope,
- &preparser_callbacks, media,
- timeout, media);
+ ret = vlc_preparser_Push(parser, item, parse_scope,
+ &preparser_callbacks, media, timeout, media);
if (ret != VLC_SUCCESS)
{
atomic_fetch_sub_explicit(&media->worker_count, 1,
@@ -785,7 +789,10 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
void
libvlc_media_parse_stop(libvlc_instance_t *inst, libvlc_media_t *media)
{
- libvlc_MetadataCancel(inst->p_libvlc_int, media);
+ libvlc_int_t *libvlc = inst->p_libvlc_int;
+ vlc_preparser_t *parser = libvlc_GetMainPreparser(libvlc);
+ if (unlikely(parser != NULL))
+ vlc_preparser_Cancel(parser, media);
}
// Get Parsed status for media descriptor object
=====================================
modules/gui/macosx/library/VLCInputItem.m
=====================================
@@ -30,6 +30,7 @@
#import "library/VLCLibraryController.h"
#import <vlc_url.h>
+#import <vlc_preparser.h>
NSString *VLCInputItemParsingSucceeded = @"VLCInputItemParsingSucceeded";
NSString *VLCInputItemParsingFailed = @"VLCInputItemParsingFailed";
@@ -589,14 +590,16 @@ static const struct vlc_metadata_cbs preparseCallbacks = {
return VLC_ENOENT;
}
- return libvlc_MetadataRequest(vlc_object_instance(getIntf()),
- _vlcInputItem,
- META_REQUEST_OPTION_SCOPE_ANY |
- META_REQUEST_OPTION_FETCH_LOCAL |
- META_REQUEST_OPTION_PARSE_SUBITEMS,
- &preparseCallbacks,
- (__bridge void *)self,
- -1, NULL);
+ vlc_preparser_t *parser = libvlc_GetMainPreparser(vlc_object_instance(getIntf()));
+ if (unlikely(parser == NULL))
+ return VLC_ENOMEM;
+
+ return vlc_preparser_Push(parser, _vlcInputItem,
+ META_REQUEST_OPTION_SCOPE_ANY |
+ META_REQUEST_OPTION_FETCH_LOCAL |
+ META_REQUEST_OPTION_PARSE_SUBITEMS,
+ &preparseCallbacks,
+ (__bridge void *)self, -1, NULL);
}
- (void)subTreeAdded:(input_item_node_t *)p_node
=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.m
=====================================
@@ -316,7 +316,12 @@ static const char *const myFoldersDescription = "My Folders";
return;
}
- vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, inputNode.inputItem.vlcInputItem, NULL);
+ vlc_preparser_t *parser = libvlc_GetMainPreparser(_p_libvlcInstance);
+ if (unlikely(parser == NULL))
+ return;
+
+ vlc_media_tree_Preparse(_p_mediaSource->tree, parser,
+ inputNode.inputItem.vlcInputItem, NULL);
}
- (void)clearChildNodesForNode:(nonnull input_item_node_t*)inputNode
=====================================
modules/gui/qt/dialogs/dialogs_provider.cpp
=====================================
@@ -28,6 +28,7 @@
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_intf_strings.h>
+#include <vlc_preparser.h>
#include "qt.hpp"
#include "dialogs_provider.hpp"
@@ -385,15 +386,15 @@ void DialogsProvider::mediaInfoDialog( const MLItemId& itemId )
NULL
};
- const int result = libvlc_MetadataRequest( vlc_object_instance( p_intf ),
- inputItem,
- static_cast<input_item_meta_request_option_t>(META_REQUEST_OPTION_SCOPE_ANY | META_REQUEST_OPTION_SCOPE_FORCED | META_REQUEST_OPTION_PARSE_SUBITEMS),
- &cbs,
- this,
- 0,
- NULL );
+ vlc_preparser_t *parser = libvlc_GetMainPreparser( vlc_object_instance( p_intf ) );
+ if (unlikely(parser == NULL))
+ return;
+
+ const int result = vlc_preparser_Push( parser, inputItem,
+ static_cast<input_item_meta_request_option_t>(META_REQUEST_OPTION_SCOPE_ANY | META_REQUEST_OPTION_SCOPE_FORCED | META_REQUEST_OPTION_PARSE_SUBITEMS),
+ &cbs, this, 0, NULL );
if( Q_UNLIKELY( result != VLC_SUCCESS ) )
- msg_Warn( p_intf, "libvlc_MetadataRequest() failed for input item %p (%s, %s)",
+ msg_Warn( p_intf, "vlc_preparser_Push() failed for input item %p (%s, %s)",
inputItem, inputItem->psz_name, inputItem->psz_uri );
}
}
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -76,6 +76,7 @@
#endif
#include <vlc_interface.h>
+#include <vlc_preparser.h>
#define VLC_REFERENCE_SCALE_FACTOR 96.
@@ -221,6 +222,7 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
QMetaObject::invokeMethod(m_medialib, &MediaLib::reload, Qt::QueuedConnection);
}
+ m_preparser = libvlc_GetMainPreparser(libvlc);
#ifdef UPDATE_CHECK
/* Checking for VLC updates */
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -70,6 +70,7 @@ class VLCVarChoiceModel;
#ifdef UPDATE_CHECK
class UpdateModel;
#endif
+struct vlc_preparser_t;
namespace vlc {
namespace playlist {
@@ -166,6 +167,7 @@ public:
public:
/* Getters */
inline qt_intf_t* getIntf() const { return p_intf; }
+ inline vlc_preparser_t *getPreparser() const { return m_preparser; };
bool smoothScroll() const { return m_smoothScroll; }
VLCSystray* getSysTray() { return m_systray.get(); }
@@ -319,6 +321,7 @@ protected:
void initSystray();
qt_intf_t* p_intf = nullptr;
+ vlc_preparser_t *m_preparser = nullptr;
bool m_hasEmbededVideo = false;
VideoSurfaceProvider* m_videoSurfaceProvider = nullptr;
=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -355,8 +355,9 @@ public:
if (!q->m_ctx || !m_hasTree || m_qmlInitializing)
return false;
- auto libvlc = vlc_object_instance(q->m_ctx->getIntf());
-
+ auto parser = q->m_ctx->getPreparser();
+ if (unlikely(parser == NULL))
+ return false;
m_listener.reset();
m_items.clear();
@@ -408,7 +409,7 @@ public:
input_item_node_t* mediaNode = nullptr;
input_item_node_t* parent = nullptr;
vlc_media_tree_Lock(tree);
- vlc_media_tree_PreparseCancel( libvlc, this );
+ vlc_preparser_Cancel( parser, this );
std::vector<SharedInputItem> itemList;
q->m_path = {QVariant::fromValue(PathNode(q->m_treeItem, q->m_name))};
if (vlc_media_tree_Find( tree, q->m_treeItem.media.get(), &mediaNode, &parent))
@@ -436,7 +437,7 @@ public:
}
m_preparseSem.acquire();
- vlc_media_tree_Preparse( tree, libvlc, q->m_treeItem.media.get(), this );
+ vlc_media_tree_Preparse( tree, parser, q->m_treeItem.media.get(), this );
m_listener = std::move( l );
@@ -493,10 +494,13 @@ NetworkMediaModel::~NetworkMediaModel()
//this can only be acquired from UI thread
if (!d->m_preparseSem.tryAcquire())
{
- auto libvlc = vlc_object_instance(m_ctx->getIntf());
- vlc_media_tree_PreparseCancel( libvlc, this );
- //wait for the callback call on cancel
- d->m_preparseSem.acquire();
+ auto parser = m_ctx->getPreparser();
+ if (likely(parser != NULL))
+ {
+ vlc_preparser_Cancel( parser, this );
+ //wait for the callback call on cancel
+ d->m_preparseSem.acquire();
+ }
}
}
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -32,6 +32,7 @@
#include <vlc_es.h>
#include <vlc_cxx_helpers.hpp>
#include <vlc_vout.h>
+#include <vlc_preparser.h>
#include <QFile>
#include <QDir>
@@ -1973,10 +1974,13 @@ void PlayerController::requestArtUpdate( input_item_t *p_item, bool b_forced )
if ( status & ( ITEM_ART_NOTFOUND|ITEM_ART_FETCHED ) )
return;
}
- libvlc_MetadataRequest( vlc_object_instance(d->p_intf), p_item,
- (b_forced) ? META_REQUEST_OPTION_FETCH_ANY
- : META_REQUEST_OPTION_FETCH_LOCAL,
- &art_fetcher_cbs, d, 0, NULL );
+ vlc_preparser_t *parser = libvlc_GetMainPreparser( vlc_object_instance(d->p_intf) );
+ if (unlikely(parser == NULL))
+ return;
+ vlc_preparser_Push( parser, p_item,
+ (b_forced) ? META_REQUEST_OPTION_FETCH_ANY
+ : META_REQUEST_OPTION_FETCH_LOCAL,
+ &art_fetcher_cbs, d, 0, NULL );
}
}
=====================================
src/input/input.c
=====================================
@@ -294,12 +294,7 @@ input_thread_t * input_Create( vlc_object_t *p_parent, input_item_t *p_item,
if( !var_InheritBool( p_input, "interact" ) )
p_input->obj.no_interact = true;
else if( cfg->interact )
- {
- /* If true, this item was asked explicitly to interact with the user
- * (via libvlc_MetadataRequest). Sub items created from this input won't
- * have this flag and won't interact with the user */
p_input->obj.no_interact = false;
- }
vlc_mutex_unlock( &p_item->lock );
=====================================
src/libvlc.c
=====================================
@@ -454,54 +454,9 @@ 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 struct vlc_metadata_cbs *cbs,
- void *cbs_userdata,
- int timeout, void *id)
+vlc_preparser_t *
+libvlc_GetMainPreparser(libvlc_int_t *libvlc)
{
libvlc_priv_t *priv = libvlc_priv(libvlc);
-
- if (unlikely(priv->parser == NULL))
- return VLC_ENOMEM;
-
- return vlc_preparser_Push( priv->parser, item, i_options, cbs,
- cbs_userdata, timeout, id );
-}
-
-/**
- * Requests extraction of the meta data for an input item (a.k.a. preparsing).
- * The actual extraction is asynchronous. It can be cancelled with
- * libvlc_MetadataCancel()
- */
-int libvlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
- input_item_meta_request_option_t i_options,
- const struct vlc_metadata_cbs *cbs,
- void *cbs_userdata,
- int timeout, void *id)
-{
- libvlc_priv_t *priv = libvlc_priv(libvlc);
- assert(i_options & META_REQUEST_OPTION_SCOPE_ANY ||
- i_options & META_REQUEST_OPTION_FETCH_ANY);
-
- if (unlikely(priv->parser == NULL))
- return VLC_ENOMEM;
-
- return vlc_MetadataRequest(libvlc, item, i_options, cbs, cbs_userdata, timeout, id);
-}
-
-/**
- * Cancels extraction of the meta data for an input item.
- *
- * This does nothing if the input item is already processed or if it was not
- * added with libvlc_MetadataRequest()
- */
-void libvlc_MetadataCancel(libvlc_int_t *libvlc, void *id)
-{
- libvlc_priv_t *priv = libvlc_priv(libvlc);
-
- if (unlikely(priv->parser == NULL))
- return;
-
- vlc_preparser_Cancel(priv->parser, id);
+ return priv->parser;
}
=====================================
src/libvlc.h
=====================================
@@ -203,12 +203,6 @@ int intf_InsertItem(libvlc_int_t *, const char *mrl, unsigned optc,
const char * const *optv, unsigned flags);
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 struct vlc_metadata_cbs *cbs,
- void *cbs_userdata,
- int timeout, void *id);
-
/*
* Variables stuff
*/
=====================================
src/libvlccore.sym
=====================================
@@ -244,8 +244,6 @@ libvlc_InternalDestroy
libvlc_InternalInit
libvlc_Quit
libvlc_SetExitHandler
-libvlc_MetadataRequest
-libvlc_MetadataCancel
vlc_UrlParse
vlc_UrlParseFixup
vlc_UrlClean
@@ -1007,6 +1005,7 @@ vlc_playlist_Preparse
vlc_playlist_Export
vlc_playlist_SetMediaStoppedAction
vlc_intf_GetMainPlaylist
+libvlc_GetMainPreparser
vlc_media_source_Hold
vlc_media_source_Release
vlc_media_source_provider_Get
@@ -1026,7 +1025,6 @@ vlc_media_tree_Add
vlc_media_tree_Remove
vlc_media_tree_Find
vlc_media_tree_Preparse
-vlc_media_tree_PreparseCancel
vlc_viewpoint_to_4x4
vlc_viewpoint_from_orientation
vlc_video_context_Create
=====================================
src/media_source/media_tree.c
=====================================
@@ -30,6 +30,7 @@
#include <vlc_atomic.h>
#include <vlc_input_item.h>
#include <vlc_threads.h>
+#include <vlc_preparser.h>
#include "libvlc.h"
struct vlc_media_tree_listener_id
@@ -340,31 +341,19 @@ static const struct vlc_metadata_cbs preparser_callbacks = {
};
void
-vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
+vlc_media_tree_Preparse(vlc_media_tree_t *tree, vlc_preparser_t *parser,
input_item_t *media, void* id)
{
#ifdef TEST_MEDIA_SOURCE
VLC_UNUSED(tree);
- VLC_UNUSED(libvlc);
+ VLC_UNUSED(parser);
VLC_UNUSED(media);
VLC_UNUSED(id);
VLC_UNUSED(preparser_callbacks);
#else
- vlc_MetadataRequest(libvlc, media, META_REQUEST_OPTION_SCOPE_ANY |
- META_REQUEST_OPTION_DO_INTERACT |
- META_REQUEST_OPTION_PARSE_SUBITEMS,
- &preparser_callbacks, tree, 0, id);
-#endif
-}
-
-
-void
-vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id)
-{
-#ifdef TEST_MEDIA_SOURCE
- VLC_UNUSED(libvlc);
- VLC_UNUSED(id);
-#else
- libvlc_MetadataCancel(libvlc, id);
+ vlc_preparser_Push(parser, media, META_REQUEST_OPTION_SCOPE_ANY |
+ META_REQUEST_OPTION_DO_INTERACT |
+ META_REQUEST_OPTION_PARSE_SUBITEMS,
+ &preparser_callbacks, tree, 0, id);
#endif
}
=====================================
src/playlist/playlist.c
=====================================
@@ -37,6 +37,17 @@ vlc_playlist_New(vlc_object_t *parent)
if (unlikely(!playlist))
return NULL;
+#ifdef TEST_PLAYLIST
+ playlist->parser = NULL;
+#else
+ playlist->parser = libvlc_GetMainPreparser(vlc_object_instance(parent));
+ if (unlikely(playlist->parser == NULL))
+ {
+ free(playlist);
+ return NULL;
+ }
+#endif
+
bool ok = vlc_playlist_PlayerInit(playlist, parent);
if (unlikely(!ok))
{
@@ -56,11 +67,9 @@ vlc_playlist_New(vlc_object_t *parent)
playlist->idgen = 0;
playlist->recursive = VLC_PLAYLIST_RECURSIVE_COLLAPSE;
#ifdef TEST_PLAYLIST
- playlist->libvlc = NULL;
playlist->auto_preparse = false;
#else
assert(parent);
- playlist->libvlc = vlc_object_instance(parent);
playlist->auto_preparse = var_InheritBool(parent, "auto-preparse");
char *rec = var_InheritString(parent, "recursive");
=====================================
src/playlist/playlist.h
=====================================
@@ -23,6 +23,7 @@
#include <vlc_common.h>
#include <vlc_playlist.h>
+#include <vlc_preparser.h>
#include <vlc_vector.h>
#include "../player/player.h"
#include "randomizer.h"
@@ -54,6 +55,7 @@ enum vlc_playlist_recursive_parsing
struct vlc_playlist
{
vlc_player_t *player;
+ vlc_preparser_t *parser;
libvlc_int_t *libvlc;
enum vlc_playlist_media_stopped_action stopped_action;
bool auto_preparse;
=====================================
src/playlist/preparse.c
=====================================
@@ -28,7 +28,6 @@
#include "item.h"
#include "playlist.h"
#include "notify.h"
-#include "libvlc.h" /* for vlc_MetadataRequest() */
typedef struct VLC_VECTOR(input_item_t *) media_vector_t;
@@ -120,14 +119,15 @@ vlc_playlist_Preparse(vlc_playlist_t *playlist, input_item_t *input,
VLC_UNUSED(input);
VLC_UNUSED(preparser_callbacks);
#else
- /* vlc_MetadataRequest is not exported */
+ assert(playlist->parser != NULL);
+
input_item_meta_request_option_t options =
META_REQUEST_OPTION_SCOPE_LOCAL | META_REQUEST_OPTION_FETCH_LOCAL;
if (parse_subitems)
options |= META_REQUEST_OPTION_PARSE_SUBITEMS;
- vlc_MetadataRequest(playlist->libvlc, input, options,
- &preparser_callbacks, playlist, -1, NULL);
+ vlc_preparser_Push(playlist->parser, input, options,
+ &preparser_callbacks, playlist, -1, NULL);
#endif
}
=====================================
src/preparser/fetcher.h
=====================================
@@ -25,6 +25,7 @@
#define _INPUT_FETCHER_H 1
#include <vlc_input_item.h>
+#include <vlc_preparser.h>
/**
* Fetcher opaque structure.
=====================================
test/libvlc/media.c
=====================================
@@ -30,6 +30,7 @@
#include <vlc_threads.h>
#include <vlc_fs.h>
#include <vlc_input_item.h>
+#include <vlc_preparser.h>
static void media_parse_ended(const libvlc_event_t *event, void *user_data)
{
@@ -239,16 +240,18 @@ static void test_input_metadata_timeout(libvlc_instance_t *vlc, int timeout,
const struct vlc_metadata_cbs cbs = {
.on_preparse_ended = input_item_preparse_timeout,
};
- i_ret = libvlc_MetadataRequest(vlc->p_libvlc_int, p_item,
- META_REQUEST_OPTION_SCOPE_LOCAL |
- META_REQUEST_OPTION_FETCH_LOCAL,
- &cbs, &sem, timeout, vlc);
+ vlc_preparser_t *parser = libvlc_GetMainPreparser(vlc->p_libvlc_int);
+ assert(parser != NULL);
+ i_ret = vlc_preparser_Push(parser, p_item,
+ META_REQUEST_OPTION_SCOPE_LOCAL |
+ META_REQUEST_OPTION_FETCH_LOCAL,
+ &cbs, &sem, timeout, vlc);
assert(i_ret == 0);
if (wait_and_cancel > 0)
{
vlc_tick_sleep( VLC_TICK_FROM_MS(wait_and_cancel) );
- libvlc_MetadataCancel(vlc->p_libvlc_int, vlc);
+ vlc_preparser_Cancel(parser, vlc);
}
vlc_sem_wait(&sem);
@@ -463,7 +466,7 @@ int main(int i_argc, char *ppsz_argv[])
test_media_subitems (vlc);
test_media_tracks (vlc);
- /* Testing libvlc_MetadataRequest timeout and libvlc_MetadataCancel. For
+ /* Testing vlc_preparser_Push timeout and vlc_preparser_Cancel. For
* that, we need to create a local input_item_t based on a pipe. There is
* no way to do that with a libvlc_media_t, that's why we don't use
* libvlc_media_parse*() */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/07dab83c1dbe158d182dd9a6ca7de4b42ef741b6...d3c65e6bf788c0e0be63e8d3bea9eb0dfe63186f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/07dab83c1dbe158d182dd9a6ca7de4b42ef741b6...d3c65e6bf788c0e0be63e8d3bea9eb0dfe63186f
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