VLC_PUBLIC_API void
libvlc_tag_query_retain( libvlc_tag_query_t * );
+VLC_PUBLIC_API void
+ libvlc_tag_query_set_match_tag_and_key( libvlc_tag_query_t * p_q,
+ libvlc_tag_t tag,
+ char * psz_tag_key,
+ libvlc_exception_t * );
+
VLC_PUBLIC_API vlc_bool_t
libvlc_tag_query_match( libvlc_tag_query_t *, libvlc_media_descriptor_t *,
libvlc_exception_t * );
struct libvlc_callback_entry_list_t *p_callback_list;
};
+struct libvlc_tags_storage_t
+{
+ char ** ppsz_tags;
+ int i_count;
+};
+
struct libvlc_media_descriptor_t
{
libvlc_event_manager_t * p_event_manager;
{
struct libvlc_instance_t *p_libvlc_instance; /* Parent instance */
int i_refcount;
+ libvlc_tag_t tag;
+ char * psz_tag_key;
};
struct libvlc_tree_t
[vlc_meta_TrackID] = libvlc_meta_TrackID
};
-struct tag_storage
-{
- char ** ppsz_tags;
- int i_count;
-};
-
/**************************************************************************
* input_item_subitem_added (Private) (vlc event Callback)
**************************************************************************/
for( i = 0; all_keys[i]; i++ )
{
int j;
- struct tag_storage * p_ts = vlc_dictionary_value_for_key( &p_md->tags, all_keys[i] );
+ struct libvlc_tags_storage_t * p_ts = vlc_dictionary_value_for_key( &p_md->tags, all_keys[i] );
for( j = 0; j < p_ts->i_count; j++ )
{
free( p_ts->ppsz_tags[j] );
const libvlc_tag_t tag,
libvlc_exception_t *p_e )
{
- struct tag_storage * p_ts;
+ struct libvlc_tags_storage_t * p_ts;
if( !tag || !key )
return;
if( !p_ts )
{
- p_ts = malloc(sizeof(struct tag_storage));
- memset( p_ts, 0, sizeof(struct tag_storage) );
+ p_ts = malloc(sizeof(struct libvlc_tags_storage_t));
+ memset( p_ts, 0, sizeof(struct libvlc_tags_storage_t) );
}
p_ts->i_count++;
const libvlc_tag_t tag,
libvlc_exception_t *p_e )
{
- struct tag_storage * p_ts;
+ struct libvlc_tags_storage_t * p_ts;
int i;
if( !tag || !key )
const char * key,
libvlc_exception_t *p_e )
{
- struct tag_storage * p_ts;
+ struct libvlc_tags_storage_t * p_ts;
if( !key )
return 0;
const char * key,
libvlc_exception_t *p_e )
{
- struct tag_storage * p_ts;
+ struct libvlc_tags_storage_t * p_ts;
if( !key )
return NULL;
*/
/**************************************************************************
- * libvlc_tag_query_new (Public)
+ * new (Public)
*
* Init an object.
**************************************************************************/
p_q->p_libvlc_instance = p_inst;
p_q->i_refcount = 1;
+ p_q->tag = NULL;
+ p_q->psz_tag_key = NULL;
return p_q;
}
/**************************************************************************
- * libvlc_media_list_release (Public)
+ * release (Public)
*
* Release an object.
**************************************************************************/
if( p_q->i_refcount > 0 )
return;
+ free( p_q->tag );
+ free( p_q->psz_tag_key );
+
free( p_q );
}
/**************************************************************************
- * libvlc_media_list_retain (Public)
+ * retain (Public)
*
* Release an object.
**************************************************************************/
p_q->i_refcount++;
}
+/**************************************************************************
+ * set_match_tag_and_key (Public)
+ **************************************************************************/
+void libvlc_tag_query_set_match_tag_and_key( libvlc_tag_query_t * p_q,
+ libvlc_tag_t tag,
+ char * psz_tag_key,
+ libvlc_exception_t * p_e )
+{
+ (void)p_e;
+
+ p_q->tag = strdup( tag );
+ p_q->psz_tag_key = strdup( psz_tag_key );
+}
/**************************************************************************
- * libvlc_query_match (Public)
+ * match (Public)
*
* Return true if the query p_q is matched in p_md
**************************************************************************/
libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e )
{
- (void)p_q;
- (void)p_md;
- (void)p_e;
+ int i;
+ struct libvlc_tags_storage_t * p_ts;
+ (void)p_e;
+ if( !p_q->psz_tag_key )
+ return 1;
+
+ p_ts = vlc_dictionary_value_for_key( &p_md->tags, p_q->psz_tag_key );
+ if( !p_q->tag )
+ return p_ts->i_count > 0;
+
+ for( i = 0; i < p_ts->i_count; i++ )
+ {
+ if( !strcmp( p_ts->ppsz_tags[i], p_q->tag ) )
+ return 1;
+ }
+
/* In construction... */
- return 1;
+ return 0;
}