[vlc-devel] [PATCHv3 1/7] input_item: add an owner placeholder
Thomas Guillem
thomas at gllm.fr
Tue Sep 22 14:09:52 CEST 2020
This will be used by libvlc_media to store the media instance into an
input_item. This will allow to get the media corresponding to an item
when propagating media events.
---
include/vlc_input_item.h | 18 +++++++++++-------
modules/demux/playlist/asx.c | 3 ++-
modules/demux/playlist/m3u.c | 2 +-
modules/lua/libs/sd.c | 2 +-
modules/lua/vlc.c | 2 +-
modules/misc/medialibrary/entities.cpp | 2 +-
modules/services_discovery/udev.c | 3 ++-
modules/services_discovery/upnp.cpp | 2 +-
modules/services_discovery/xcb_apps.c | 2 +-
src/input/item.c | 10 ++++++----
10 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 8e5ffc98eca..48d8e488b9d 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -120,6 +120,9 @@ struct input_item_t
bool b_preparse_interact; /**< Force interaction with the user when
preparsing.*/
+
+ void *owner_data; /**< Private data that can only be set by
+ the owner (one calling New()) */
};
#define INPUT_ITEM_URI_NOP "vlc://nop" /* dummy URI for node/directory items */
@@ -340,25 +343,26 @@ VLC_API void input_item_MergeInfos( input_item_t *, info_category_t * );
VLC_API input_item_t * input_item_NewExt( const char *psz_uri,
const char *psz_name,
vlc_tick_t i_duration, enum input_item_type_e i_type,
- enum input_item_net_type i_net ) VLC_USED;
+ enum input_item_net_type i_net,
+ void *owner_data) VLC_USED;
#define input_item_New( psz_uri, psz_name ) \
- input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
+ input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN, NULL )
#define input_item_NewCard( psz_uri, psz_name ) \
- input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_INDEFINITE, ITEM_TYPE_CARD, ITEM_LOCAL )
+ input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_INDEFINITE, ITEM_TYPE_CARD, ITEM_LOCAL, NULL )
#define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
- input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
+ input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL, NULL )
#define input_item_NewStream( psz_uri, psz_name, i_duration ) \
- input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
+ input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET, NULL )
#define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
- input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_DIRECTORY, i_net )
+ input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_DIRECTORY, i_net, NULL )
#define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
- input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
+ input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net, NULL )
/**
* This function creates a new input_item_t as a copy of another.
diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index e17be85e96b..825b48f657e 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -310,7 +310,8 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader,
/* Create the input item */
p_entry = input_item_NewExt( psz_mrl, psz_name, i_duration,
- ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN );
+ ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN,
+ NULL );
if( p_entry == NULL )
goto end;
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index af743b75da9..4da1926236e 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -250,7 +250,7 @@ static int CreateEntry( input_item_node_t *p_node, const struct entry_meta_s *me
input_item_t *p_input =
input_item_NewExt( meta->psz_mrl, meta->psz_name, meta->i_duration,
- ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN );
+ ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN, NULL );
if( !p_input )
return VLC_EGENERIC;
diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index 7068ec8f90a..369848adda2 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -295,7 +295,7 @@ static input_item_t *vlclua_sd_create_node( services_discovery_t *p_sd,
input_item_t *p_input = input_item_NewExt( INPUT_ITEM_URI_NOP, psz_name,
INPUT_DURATION_INDEFINITE,
ITEM_TYPE_NODE,
- ITEM_NET_UNKNOWN );
+ ITEM_NET_UNKNOWN, NULL );
lua_pop( L, 1 );
if( unlikely(p_input == NULL) )
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index dfb39988afe..61a5827ce52 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -483,7 +483,7 @@ input_item_t *vlclua_read_input_item(vlc_object_t *obj, lua_State *L)
/* Create input item */
input_item_t *item = input_item_NewExt(path, name, duration,
ITEM_TYPE_UNKNOWN,
- ITEM_NET_UNKNOWN);
+ ITEM_NET_UNKNOWN, NULL);
if (unlikely(item == NULL))
goto out;
diff --git a/modules/misc/medialibrary/entities.cpp b/modules/misc/medialibrary/entities.cpp
index 02c106e4e17..25e46603bcf 100644
--- a/modules/misc/medialibrary/entities.cpp
+++ b/modules/misc/medialibrary/entities.cpp
@@ -465,7 +465,7 @@ input_item_t* MediaToInputItem( const medialibrary::IMedia* media )
auto inputItem = vlc::wrap_cptr<input_item_t>(
input_item_NewExt( mrl.c_str(), media->fileName().c_str(),
VLC_TICK_FROM_MS( media->duration() ),
- ITEM_TYPE_FILE, ITEM_NET_UNKNOWN ),
+ ITEM_TYPE_FILE, ITEM_NET_UNKNOWN, NULL ),
&input_item_Release );
auto thumbnailStatus = media->thumbnailStatus( medialibrary::ThumbnailSizeType::Thumbnail );
if ( thumbnailStatus == medialibrary::ThumbnailStatus::Missing )
diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index cda59f37741..38b24cd90c4 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -170,7 +170,8 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev)
char *name = p_sys->subsys->get_name (dev);
input_item_t *item = input_item_NewExt (mrl, name ? name : mrl,
INPUT_DURATION_INDEFINITE,
- p_sys->subsys->item_type, ITEM_LOCAL);
+ p_sys->subsys->item_type, ITEM_LOCAL,
+ NULL);
msg_Dbg (sd, "adding %s (%s)", mrl, name);
free (name);
free (mrl);
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 054a5d19103..b9147ed7304 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -980,7 +980,7 @@ namespace
i_seconds );
}
return input_item_NewExt( psz_resource_url, title, i_duration,
- ITEM_TYPE_FILE, ITEM_NET );
+ ITEM_TYPE_FILE, ITEM_NET, NULL );
}
input_item_t *createNewContainerItem( const char* psz_root )
diff --git a/modules/services_discovery/xcb_apps.c b/modules/services_discovery/xcb_apps.c
index d22ea63933b..54086f37a35 100644
--- a/modules/services_discovery/xcb_apps.c
+++ b/modules/services_discovery/xcb_apps.c
@@ -171,7 +171,7 @@ static int Open (vlc_object_t *obj)
p_sys->apps = NULL;
p_sys->apps_root = input_item_NewExt(INPUT_ITEM_URI_NOP, _("Applications"),
INPUT_DURATION_INDEFINITE,
- ITEM_TYPE_NODE, ITEM_LOCAL);
+ ITEM_TYPE_NODE, ITEM_LOCAL, NULL);
if (likely(p_sys->apps_root != NULL))
services_discovery_AddItem(sd, p_sys->apps_root);
diff --git a/src/input/item.c b/src/input/item.c
index 1c03af739b7..a347d26f36f 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1051,7 +1051,8 @@ void input_item_SetEpgOffline( input_item_t *p_item )
input_item_t *
input_item_NewExt( const char *psz_uri, const char *psz_name,
- vlc_tick_t duration, enum input_item_type_e type, enum input_item_net_type i_net )
+ vlc_tick_t duration, enum input_item_type_e type,
+ enum input_item_net_type i_net, void *owner_data )
{
input_item_owner_t *owner = calloc( 1, sizeof( *owner ) );
if( unlikely(owner == NULL) )
@@ -1060,6 +1061,7 @@ input_item_NewExt( const char *psz_uri, const char *psz_name,
vlc_atomic_rc_init( &owner->rc );
input_item_t *p_input = &owner->item;
+ p_input->owner_data = owner_data;
vlc_event_manager_t * p_em = &p_input->event_manager;
vlc_mutex_init( &p_input->lock );
@@ -1111,7 +1113,7 @@ input_item_t *input_item_Copy( input_item_t *p_input )
item = input_item_NewExt( p_input->psz_uri, p_input->psz_name,
p_input->i_duration, p_input->i_type,
- ITEM_NET_UNKNOWN );
+ ITEM_NET_UNKNOWN, NULL );
if( likely(item != NULL) && p_input->p_meta != NULL )
{
meta = vlc_meta_New();
@@ -1768,7 +1770,7 @@ static int rdh_unflatten(struct vlc_readdir_helper *p_rdh,
input_item_t *p_item =
input_item_NewExt(INPUT_ITEM_URI_NOP, psz_subpathname, INPUT_DURATION_UNSET,
- ITEM_TYPE_DIRECTORY, i_net);
+ ITEM_TYPE_DIRECTORY, i_net, NULL);
if (p_item == NULL)
{
free(p_rdh_dir);
@@ -1908,7 +1910,7 @@ int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
}
input_item_t *p_item = input_item_NewExt(psz_uri, psz_filename, INPUT_DURATION_UNSET, i_type,
- i_net);
+ i_net, NULL);
if (p_item == NULL)
return VLC_ENOMEM;
--
2.28.0
More information about the vlc-devel
mailing list