Commit c784e8ce authored by Romain Vimont's avatar Romain Vimont Committed by Thomas Guillem
Browse files

core: Move preparser out of the playlist



The preparser was implemented in playlist code, but it was (already)
independant of the playlist.

Therefore, move the implementation to a separate folder and rename the
functions.
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent fba6da91
......@@ -212,23 +212,23 @@ libvlccore_la_SOURCES = \
interface/dialog.c \
interface/interface.c \
playlist/playlist_internal.h \
playlist/art.c \
playlist/art.h \
playlist/aout.c \
playlist/thread.c \
playlist/control.c \
playlist/engine.c \
playlist/fetcher.c \
playlist/fetcher.h \
playlist/sort.c \
playlist/loadsave.c \
playlist/preparser.c \
playlist/preparser.h \
playlist/tree.c \
playlist/item.c \
playlist/search.c \
playlist/services_discovery.c \
playlist/renderer.c \
preparser/art.c \
preparser/art.h \
preparser/fetcher.c \
preparser/fetcher.h \
preparser/preparser.c \
preparser/preparser.h \
input/item.c \
input/access.c \
clock/clock_internal.c \
......
......@@ -36,7 +36,7 @@
#include <vlc_charset.h>
#include "input_internal.h"
#include "../playlist/art.h"
#include "../preparser/art.h"
struct vlc_meta_t
{
......@@ -212,7 +212,7 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input,
{ /* XXX Weird, we should not end up with attachment:// art URL
* unless there is a race condition */
msg_Warn( p_input, "art already fetched" );
if( likely(playlist_FindArtInCache( p_item ) == VLC_SUCCESS) )
if( likely(input_FindArtInCache( p_item ) == VLC_SUCCESS) )
return;
}
......@@ -248,8 +248,8 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input,
else if( !strcmp( p_attachment->psz_mime, "image/x-pict" ) )
psz_type = ".pct";
playlist_SaveArt( VLC_OBJECT(p_input), p_item,
p_attachment->p_data, p_attachment->i_data, psz_type );
input_SaveArt( VLC_OBJECT(p_input), p_item,
p_attachment->p_data, p_attachment->i_data, psz_type );
vlc_input_attachment_Delete( p_attachment );
}
......
......@@ -42,7 +42,7 @@
#include "modules/modules.h"
#include "config/configuration.h"
#include "playlist/preparser.h"
#include "preparser/preparser.h"
#include <stdio.h> /* sprintf() */
#include <string.h>
......@@ -226,7 +226,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/*
* Meta data handling
*/
priv->parser = playlist_preparser_New(VLC_OBJECT(p_libvlc));
priv->parser = input_preparser_New(VLC_OBJECT(p_libvlc));
if( !priv->parser )
goto error;
......@@ -357,7 +357,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
libvlc_priv_t *priv = libvlc_priv (p_libvlc);
if (priv->parser != NULL)
playlist_preparser_Deactivate(priv->parser);
input_preparser_Deactivate(priv->parser);
/* Ask the interfaces to stop and destroy them */
msg_Dbg( p_libvlc, "removing all interfaces" );
......@@ -387,7 +387,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
#endif
if (priv->parser != NULL)
playlist_preparser_Delete(priv->parser);
input_preparser_Delete(priv->parser);
libvlc_InternalActionsClean( p_libvlc );
......@@ -479,7 +479,7 @@ int libvlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
if( i_options & META_REQUEST_OPTION_DO_INTERACT )
item->b_preparse_interact = true;
vlc_mutex_unlock( &item->lock );
playlist_preparser_Push( priv->parser, item, i_options, timeout, id );
input_preparser_Push( priv->parser, item, i_options, timeout, id );
return VLC_SUCCESS;
}
......@@ -495,7 +495,7 @@ int libvlc_ArtRequest(libvlc_int_t *libvlc, input_item_t *item,
if (unlikely(priv->parser == NULL))
return VLC_ENOMEM;
playlist_preparser_fetcher_Push(priv->parser, item, i_options);
input_preparser_fetcher_Push(priv->parser, item, i_options);
return VLC_SUCCESS;
}
......@@ -512,5 +512,5 @@ void libvlc_MetadataCancel(libvlc_int_t *libvlc, void *id)
if (unlikely(priv->parser == NULL))
return;
playlist_preparser_Cancel(priv->parser, id);
input_preparser_Cancel(priv->parser, id);
}
......@@ -183,7 +183,7 @@ typedef struct libvlc_priv_t
vlc_dialog_provider *p_dialog_provider; ///< dialog provider
vlc_keystore *p_memory_keystore; ///< memory keystore
struct playlist_t *playlist; ///< Playlist for interfaces
struct playlist_preparser_t *parser; ///< Input item meta data handler
struct input_preparser_t *parser; ///< Input item meta data handler
vlc_actions_t *actions; ///< Hotkeys handler
/* Exit callback */
......
......@@ -37,8 +37,7 @@
#include "input/input_interface.h"
#include <assert.h>
#include "art.h"
#include "preparser.h"
#include "preparser/preparser.h"
void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist );
......
......@@ -159,7 +159,7 @@ end:
}
/* */
int playlist_FindArtInCache( input_item_t *p_item )
int input_FindArtInCache( input_item_t *p_item )
{
char *psz_path = ArtCachePath( p_item );
......@@ -228,7 +228,7 @@ static char * GetFileByItemUID( char *psz_dir, const char *psz_type )
return psz_file;
}
int playlist_FindArtInCacheUsingItemUID( input_item_t *p_item )
int input_FindArtInCacheUsingItemUID( input_item_t *p_item )
{
char *uid = input_item_GetInfo( p_item, "uid", "md5" );
if ( ! *uid )
......@@ -265,8 +265,8 @@ int playlist_FindArtInCacheUsingItemUID( input_item_t *p_item )
}
/* */
int playlist_SaveArt( vlc_object_t *obj, input_item_t *p_item,
const void *data, size_t length, const char *psz_type )
int input_SaveArt( vlc_object_t *obj, input_item_t *p_item,
const void *data, size_t length, const char *psz_type )
{
char *psz_filename = ArtCacheName( p_item, psz_type );
......
/*****************************************************************************
* art.h:
* art.h
*****************************************************************************
* Copyright (C) 1999-2008 VLC authors and VideoLAN
* $Id$
......@@ -22,14 +22,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _PLAYLIST_ART_H
#define _PLAYLIST_ART_H 1
#ifndef _INPUT_ART_H
#define _INPUT_ART_H 1
int playlist_FindArtInCache( input_item_t * );
int playlist_FindArtInCacheUsingItemUID( input_item_t * );
int input_FindArtInCache( input_item_t * );
int input_FindArtInCacheUsingItemUID( input_item_t * );
int playlist_SaveArt( vlc_object_t *, input_item_t *,
const void *, size_t, const char *psz_type );
int input_SaveArt( vlc_object_t *, input_item_t *,
const void *, size_t, const char *psz_type );
#endif
......@@ -41,7 +41,7 @@
#include "misc/background_worker.h"
#include "misc/interrupt.h"
struct playlist_fetcher_t {
struct input_fetcher_t {
struct background_worker* local;
struct background_worker* network;
struct background_worker* downloader;
......@@ -59,11 +59,11 @@ struct fetcher_request {
};
struct fetcher_thread {
void (*pf_worker)( playlist_fetcher_t*, struct fetcher_request* );
void (*pf_worker)( input_fetcher_t*, struct fetcher_request* );
struct background_worker* worker;
struct fetcher_request* req;
playlist_fetcher_t* fetcher;
input_fetcher_t* fetcher;
vlc_interrupt_t interrupt;
vlc_thread_t thread;
......@@ -104,7 +104,7 @@ static void FreeCacheEntry( void* data, void* obj )
VLC_UNUSED( obj );
}
static int ReadAlbumCache( playlist_fetcher_t* fetcher, input_item_t* item )
static int ReadAlbumCache( input_fetcher_t* fetcher, input_item_t* item )
{
char* key = CreateCacheKey( item );
......@@ -122,8 +122,8 @@ static int ReadAlbumCache( playlist_fetcher_t* fetcher, input_item_t* item )
return art ? VLC_SUCCESS : VLC_EGENERIC;
}
static void AddAlbumCache( playlist_fetcher_t* fetcher, input_item_t* item,
bool overwrite )
static void AddAlbumCache( input_fetcher_t* fetcher, input_item_t* item,
bool overwrite )
{
char* art = input_item_GetArtURL( item );
char* key = CreateCacheKey( item );
......@@ -143,7 +143,7 @@ static void AddAlbumCache( playlist_fetcher_t* fetcher, input_item_t* item,
free( key );
}
static int InvokeModule( playlist_fetcher_t* fetcher, input_item_t* item,
static int InvokeModule( input_fetcher_t* fetcher, input_item_t* item,
int scope, char const* type )
{
meta_fetcher_t* mf = vlc_custom_create( fetcher->owner,
......@@ -184,13 +184,13 @@ static int CheckArt( input_item_t* item )
return error;
}
static int SearchArt( playlist_fetcher_t* fetcher, input_item_t* item, int scope)
static int SearchArt( input_fetcher_t* fetcher, input_item_t* item, int scope)
{
InvokeModule( fetcher, item, scope, "art finder" );
return CheckArt( item );
}
static int SearchByScope( playlist_fetcher_t* fetcher,
static int SearchByScope( input_fetcher_t* fetcher,
struct fetcher_request* req, int scope )
{
input_item_t* item = req->item;
......@@ -201,10 +201,10 @@ static int SearchByScope( playlist_fetcher_t* fetcher,
return VLC_EGENERIC;
}
if( ! CheckArt( item ) ||
! ReadAlbumCache( fetcher, item ) ||
! playlist_FindArtInCacheUsingItemUID( item ) ||
! playlist_FindArtInCache( item ) ||
if( ! CheckArt( item ) ||
! ReadAlbumCache( fetcher, item ) ||
! input_FindArtInCacheUsingItemUID( item ) ||
! input_FindArtInCache( item ) ||
! SearchArt( fetcher, item, scope ) )
{
AddAlbumCache( fetcher, req->item, false );
......@@ -224,7 +224,7 @@ static void SetPreparsed( struct fetcher_request* req )
}
}
static void Downloader( playlist_fetcher_t* fetcher,
static void Downloader( input_fetcher_t* fetcher,
struct fetcher_request* req )
{
ReadAlbumCache( fetcher, req->item );
......@@ -268,8 +268,8 @@ static void Downloader( playlist_fetcher_t* fetcher,
goto error;
}
playlist_SaveArt( fetcher->owner, req->item, output_stream.ptr,
output_stream.length, NULL );
input_SaveArt( fetcher->owner, req->item, output_stream.ptr,
output_stream.length, NULL );
free( output_stream.ptr );
AddAlbumCache( fetcher, req->item, true );
......@@ -290,7 +290,7 @@ error:
goto out;
}
static void SearchLocal( playlist_fetcher_t* fetcher, struct fetcher_request* req )
static void SearchLocal( input_fetcher_t* fetcher, struct fetcher_request* req )
{
if( SearchByScope( fetcher, req, FETCHER_SCOPE_LOCAL ) == VLC_SUCCESS )
return; /* done */
......@@ -308,7 +308,7 @@ static void SearchLocal( playlist_fetcher_t* fetcher, struct fetcher_request* re
}
}
static void SearchNetwork( playlist_fetcher_t* fetcher, struct fetcher_request* req )
static void SearchNetwork( input_fetcher_t* fetcher, struct fetcher_request* req )
{
if( SearchByScope( fetcher, req, FETCHER_SCOPE_NETWORK ) )
{
......@@ -346,8 +346,8 @@ static void* FetcherThread( void* handle )
return NULL;
}
static int StartWorker( playlist_fetcher_t* fetcher,
void( *pf_worker )( playlist_fetcher_t*, struct fetcher_request* ),
static int StartWorker( input_fetcher_t* fetcher,
void( *pf_worker )( input_fetcher_t*, struct fetcher_request* ),
struct background_worker* bg, struct fetcher_request* req, void** handle )
{
struct fetcher_thread* th = malloc( sizeof *th );
......@@ -393,14 +393,14 @@ static void CloseWorker( void* fetcher_, void* th_ )
#define DEF_STARTER(name, worker) \
static int Start ## name( void* fetcher_, void* req_, void** out ) { \
playlist_fetcher_t* fetcher = fetcher_; \
input_fetcher_t* fetcher = fetcher_; \
return StartWorker( fetcher, name, worker, req_, out ); }
DEF_STARTER( SearchLocal, fetcher->local )
DEF_STARTER(SearchNetwork, fetcher->network )
DEF_STARTER( Downloader, fetcher->downloader )
static void WorkerInit( playlist_fetcher_t* fetcher,
static void WorkerInit( input_fetcher_t* fetcher,
struct background_worker** worker, int( *starter )( void*, void*, void** ) )
{
struct background_worker_config conf = {
......@@ -414,9 +414,9 @@ static void WorkerInit( playlist_fetcher_t* fetcher,
*worker = background_worker_New( fetcher, &conf );
}
playlist_fetcher_t* playlist_fetcher_New( vlc_object_t* owner )
input_fetcher_t* input_fetcher_New( vlc_object_t* owner )
{
playlist_fetcher_t* fetcher = malloc( sizeof( *fetcher ) );
input_fetcher_t* fetcher = malloc( sizeof( *fetcher ) );
if( unlikely( !fetcher ) )
return NULL;
......@@ -448,7 +448,7 @@ playlist_fetcher_t* playlist_fetcher_New( vlc_object_t* owner )
return fetcher;
}
int playlist_fetcher_Push( playlist_fetcher_t* fetcher, input_item_t* item,
int input_fetcher_Push( input_fetcher_t* fetcher, input_item_t* item,
input_item_meta_request_option_t options, int preparse_status )
{
struct fetcher_request* req = malloc( sizeof *req );
......@@ -470,7 +470,7 @@ int playlist_fetcher_Push( playlist_fetcher_t* fetcher, input_item_t* item,
return VLC_SUCCESS;
}
void playlist_fetcher_Delete( playlist_fetcher_t* fetcher )
void input_fetcher_Delete( input_fetcher_t* fetcher )
{
background_worker_Delete( fetcher->local );
background_worker_Delete( fetcher->network );
......
/*****************************************************************************
* playlist_fetcher.h:
* fetcher.h
*****************************************************************************
* Copyright (C) 1999-2008 VLC authors and VideoLAN
* $Id$
......@@ -22,8 +22,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _PLAYLIST_FETCHER_H
#define _PLAYLIST_FETCHER_H 1
#ifndef _INPUT_FETCHER_H
#define _INPUT_FETCHER_H 1
#include <vlc_input_item.h>
......@@ -33,12 +33,12 @@
* The fetcher object will retrieve the art album data for any given input
* item in an asynchronous way.
*/
typedef struct playlist_fetcher_t playlist_fetcher_t;
typedef struct input_fetcher_t input_fetcher_t;
/**
* This function creates the fetcher object and thread.
*/
playlist_fetcher_t *playlist_fetcher_New( vlc_object_t * );
input_fetcher_t *input_fetcher_New( vlc_object_t * );
/**
* This function enqueues the provided item to be art fetched.
......@@ -46,15 +46,15 @@ playlist_fetcher_t *playlist_fetcher_New( vlc_object_t * );
* The input item is retained until the art fetching is done or until the
* fetcher object is destroyed.
*/
int playlist_fetcher_Push( playlist_fetcher_t *, input_item_t *,
input_item_meta_request_option_t, int );
int input_fetcher_Push( input_fetcher_t *, input_item_t *,
input_item_meta_request_option_t, int );
/**
* This function destroys the fetcher object and thread.
*
* All pending input items will be released.
*/
void playlist_fetcher_Delete( playlist_fetcher_t * );
void input_fetcher_Delete( input_fetcher_t * );
#endif
......@@ -31,10 +31,10 @@
#include "preparser.h"
#include "fetcher.h"
struct playlist_preparser_t
struct input_preparser_t
{
vlc_object_t* owner;
playlist_fetcher_t* fetcher;
input_fetcher_t* fetcher;
struct background_worker* worker;
atomic_bool deactivated;
};
......@@ -52,7 +52,7 @@ static int InputEvent( vlc_object_t* obj, const char* varname,
static int PreparserOpenInput( void* preparser_, void* item_, void** out )
{
playlist_preparser_t* preparser = preparser_;
input_preparser_t* preparser = preparser_;
input_thread_t* input = input_CreatePreparser( preparser->owner, item_ );
if( !input )
......@@ -83,7 +83,7 @@ static int PreparserProbeInput( void* preparser_, void* input_ )
static void PreparserCloseInput( void* preparser_, void* input_ )
{
playlist_preparser_t* preparser = preparser_;
input_preparser_t* preparser = preparser_;
input_thread_t* input = input_;
input_item_t* item = input_priv(input)->p_item;
......@@ -107,7 +107,7 @@ static void PreparserCloseInput( void* preparser_, void* input_ )
if( preparser->fetcher )
{
if( !playlist_fetcher_Push( preparser->fetcher, item, 0, status ) )
if( !input_fetcher_Push( preparser->fetcher, item, 0, status ) )
return;
}
......@@ -118,9 +118,9 @@ static void PreparserCloseInput( void* preparser_, void* input_ )
static void InputItemRelease( void* item ) { input_item_Release( item ); }
static void InputItemHold( void* item ) { input_item_Hold( item ); }
playlist_preparser_t* playlist_preparser_New( vlc_object_t *parent )
input_preparser_t* input_preparser_New( vlc_object_t *parent )
{
playlist_preparser_t* preparser = malloc( sizeof *preparser );
input_preparser_t* preparser = malloc( sizeof *preparser );
struct background_worker_config conf = {
.default_timeout = var_InheritInteger( parent, "preparse-timeout" ),
......@@ -141,7 +141,7 @@ playlist_preparser_t* playlist_preparser_New( vlc_object_t *parent )
}
preparser->owner = parent;
preparser->fetcher = playlist_fetcher_New( parent );
preparser->fetcher = input_fetcher_New( parent );
atomic_init( &preparser->deactivated, false );
if( unlikely( !preparser->fetcher ) )
......@@ -150,7 +150,7 @@ playlist_preparser_t* playlist_preparser_New( vlc_object_t *parent )
return preparser;
}
void playlist_preparser_Push( playlist_preparser_t *preparser,
void input_preparser_Push( input_preparser_t *preparser,
input_item_t *item, input_item_meta_request_option_t i_options,
int timeout, void *id )
{
......@@ -180,30 +180,30 @@ void playlist_preparser_Push( playlist_preparser_t *preparser,
input_item_SignalPreparseEnded( item, ITEM_PREPARSE_FAILED );
}
void playlist_preparser_fetcher_Push( playlist_preparser_t *preparser,
void input_preparser_fetcher_Push( input_preparser_t *preparser,
input_item_t *item, input_item_meta_request_option_t options )
{
if( preparser->fetcher )
playlist_fetcher_Push( preparser->fetcher, item, options, -1 );
input_fetcher_Push( preparser->fetcher, item, options, -1 );
}
void playlist_preparser_Cancel( playlist_preparser_t *preparser, void *id )
void input_preparser_Cancel( input_preparser_t *preparser, void *id )
{
background_worker_Cancel( preparser->worker, id );
}
void playlist_preparser_Deactivate( playlist_preparser_t* preparser )
void input_preparser_Deactivate( input_preparser_t* preparser )
{
atomic_store( &preparser->deactivated, true );
background_worker_Cancel( preparser->worker, NULL );
}
void playlist_preparser_Delete( playlist_preparser_t *preparser )
void input_preparser_Delete( input_preparser_t *preparser )
{
background_worker_Delete( preparser->worker );
if( preparser->fetcher )
playlist_fetcher_Delete( preparser->fetcher );
input_fetcher_Delete( preparser->fetcher );
free( preparser );
}
/*****************************************************************************
* playlist_preparser.h:
* preparser.h
*****************************************************************************
* Copyright (C) 1999-2008 VLC authors and VideoLAN
* $Id$
......@@ -22,8 +22,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _PLAYLIST_PREPARSER_H
#define _PLAYLIST_PREPARSER_H 1
#ifndef _INPUT_PREPARSER_H
#define _INPUT_PREPARSER_H 1
#include <vlc_input_item.h>
/**
......@@ -33,12 +33,12 @@
* an asynchronous way.
* It will also issue art fetching requests.
*/
typedef struct playlist_preparser_t playlist_preparser_t;
typedef struct input_preparser_t input_preparser_t;
/**
* This function creates the preparser object and thread.
*/
playlist_preparser_t *playlist_preparser_New( vlc_object_t * );
input_preparser_t *input_preparser_New( vlc_object_t * );
/**
* This function enqueues the provided item to be preparsed.
......@@ -52,28 +52,28 @@ playlist_preparser_t *playlist_preparser_New( vlc_object_t * );
* "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 playlist_preparser_Cancel()
* the request with input_preparser_Cancel()
*/
void playlist_preparser_Push( playlist_preparser_t *, input_item_t *,
input_item_meta_request_option_t,
int timeout, void *id );
void input_preparser_Push( input_preparser_t *, input_item_t *,
input_item_meta_request_option_t,
int timeout, void *id );
void playlist_preparser_fetcher_Push( playlist_preparser_t *, input_item_t *,
input_item_meta_request_option_t );
void input_preparser_fetcher_Push( input_preparser_t *, input_item_t *,
input_item_meta_request_option_t );
/**
* This function cancel all preparsing requests for a given id
*
* @param id unique id given to playlist_preparser_Push()
* @param id unique id given to input_preparser_Push()
*/
void playlist_preparser_Cancel( playlist_preparser_t *, void *id );
void input_preparser_Cancel( input_preparser_t *, void *id );
/**
* This function destroys the preparser object and thread.
*
* All pending input items will be released.
*/
void playlist_preparser_Delete( playlist_preparser_t * );
void input_preparser_Delete( input_preparser_t * );
/**
* This function deactivates the preparser
......@@ -81,7 +81,7 @@ void playlist_preparser_Delete( playlist_preparser_t * );
* All pending requests will be removed, and it will block until the currently
* running entity has finished (if any).
*/
void playlist_preparser_Deactivate( playlist_preparser_t * );
void input_preparser_Deactivate( input_preparser_t * );
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment