2007-06-17 18:24:49 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* media_descriptor.c: Libvlc API media descriport management
|
|
|
|
*****************************************************************************
|
|
|
|
* Copyright (C) 2007 the VideoLAN team
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Authors: Pierre d'Herbemont <pdherbemont@videolan.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <vlc/libvlc.h>
|
|
|
|
#include <vlc_input.h>
|
|
|
|
#include <vlc_meta.h>
|
|
|
|
|
|
|
|
#include "libvlc_internal.h"
|
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
static const vlc_meta_type_t libvlc_to_vlc_meta[] =
|
|
|
|
{
|
|
|
|
[libvlc_meta_Title] = vlc_meta_Title,
|
|
|
|
[libvlc_meta_Artist] = vlc_meta_Artist,
|
|
|
|
[libvlc_meta_Genre] = vlc_meta_Genre,
|
|
|
|
[libvlc_meta_Copyright] = vlc_meta_Copyright,
|
|
|
|
[libvlc_meta_Album] = vlc_meta_Album,
|
|
|
|
[libvlc_meta_TrackNumber] = vlc_meta_TrackNumber,
|
|
|
|
[libvlc_meta_Description] = vlc_meta_Description,
|
|
|
|
[libvlc_meta_Rating] = vlc_meta_Rating,
|
|
|
|
[libvlc_meta_Date] = vlc_meta_Date,
|
|
|
|
[libvlc_meta_Setting] = vlc_meta_Setting,
|
|
|
|
[libvlc_meta_URL] = vlc_meta_URL,
|
|
|
|
[libvlc_meta_Language] = vlc_meta_Language,
|
|
|
|
[libvlc_meta_NowPlaying] = vlc_meta_NowPlaying,
|
|
|
|
[libvlc_meta_Publisher] = vlc_meta_Publisher,
|
|
|
|
[libvlc_meta_EncodedBy] = vlc_meta_EncodedBy,
|
|
|
|
[libvlc_meta_ArtworkURL] = vlc_meta_ArtworkURL,
|
|
|
|
[libvlc_meta_TrackID] = vlc_meta_TrackID
|
|
|
|
};
|
|
|
|
|
|
|
|
static const libvlc_meta_t vlc_to_libvlc_meta[] =
|
|
|
|
{
|
|
|
|
[vlc_meta_Title] = libvlc_meta_Title,
|
|
|
|
[vlc_meta_Artist] = libvlc_meta_Artist,
|
|
|
|
[vlc_meta_Genre] = libvlc_meta_Genre,
|
|
|
|
[vlc_meta_Copyright] = libvlc_meta_Copyright,
|
|
|
|
[vlc_meta_Album] = libvlc_meta_Album,
|
|
|
|
[vlc_meta_TrackNumber] = libvlc_meta_TrackNumber,
|
|
|
|
[vlc_meta_Description] = libvlc_meta_Description,
|
|
|
|
[vlc_meta_Rating] = libvlc_meta_Rating,
|
|
|
|
[vlc_meta_Date] = libvlc_meta_Date,
|
|
|
|
[vlc_meta_Setting] = libvlc_meta_Setting,
|
|
|
|
[vlc_meta_URL] = libvlc_meta_URL,
|
|
|
|
[vlc_meta_Language] = libvlc_meta_Language,
|
|
|
|
[vlc_meta_NowPlaying] = libvlc_meta_NowPlaying,
|
|
|
|
[vlc_meta_Publisher] = libvlc_meta_Publisher,
|
|
|
|
[vlc_meta_EncodedBy] = libvlc_meta_EncodedBy,
|
|
|
|
[vlc_meta_ArtworkURL] = libvlc_meta_ArtworkURL,
|
|
|
|
[vlc_meta_TrackID] = libvlc_meta_TrackID
|
|
|
|
};
|
|
|
|
|
2007-08-16 20:05:07 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* input_item_subitem_added (Private) (vlc event Callback)
|
|
|
|
**************************************************************************/
|
|
|
|
static void input_item_subitem_added( const vlc_event_t *p_event,
|
2007-08-20 00:46:15 +02:00
|
|
|
void * user_data )
|
2007-08-16 20:05:07 +02:00
|
|
|
{
|
|
|
|
libvlc_media_descriptor_t * p_md = user_data;
|
|
|
|
libvlc_media_descriptor_t * p_md_child;
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
p_md_child = libvlc_media_descriptor_new_from_input_item(
|
|
|
|
p_md->p_libvlc_instance,
|
|
|
|
p_event->u.input_item_subitem_added.p_new_child, NULL );
|
|
|
|
|
|
|
|
/* Construct the event */
|
|
|
|
event.type = libvlc_MediaDescriptorSubItemAdded;
|
|
|
|
event.u.media_descriptor_subitem_added.new_child = p_md_child;
|
|
|
|
|
|
|
|
/* Send the event */
|
|
|
|
libvlc_event_send( p_md->p_event_manager, &event );
|
|
|
|
libvlc_media_descriptor_release( p_md_child );
|
|
|
|
}
|
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* input_item_meta_changed (Private) (vlc event Callback)
|
|
|
|
**************************************************************************/
|
|
|
|
static void input_item_meta_changed( const vlc_event_t *p_event,
|
|
|
|
void * user_data )
|
|
|
|
{
|
|
|
|
libvlc_media_descriptor_t * p_md = user_data;
|
|
|
|
libvlc_event_t event;
|
|
|
|
|
|
|
|
/* Construct the event */
|
|
|
|
event.type = libvlc_MediaDescriptorMetaChanged;
|
|
|
|
event.u.media_descriptor_meta_changed.meta_type =
|
|
|
|
vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
|
|
|
|
|
|
|
|
/* Send the event */
|
|
|
|
libvlc_event_send( p_md->p_event_manager, &event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Install event handler (Private)
|
|
|
|
**************************************************************************/
|
|
|
|
static void install_input_item_observer( libvlc_media_descriptor_t *p_md )
|
|
|
|
{
|
2007-08-16 20:05:07 +02:00
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemSubItemAdded,
|
|
|
|
input_item_subitem_added,
|
|
|
|
p_md );
|
2007-08-15 20:27:49 +02:00
|
|
|
vlc_event_attach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemMetaChanged,
|
|
|
|
input_item_meta_changed,
|
|
|
|
p_md );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Uninstall event handler (Private)
|
|
|
|
**************************************************************************/
|
|
|
|
static void uninstall_input_item_observer( libvlc_media_descriptor_t *p_md )
|
|
|
|
{
|
2007-08-16 20:05:07 +02:00
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemSubItemAdded,
|
|
|
|
input_item_subitem_added,
|
|
|
|
p_md );
|
2007-08-15 20:27:49 +02:00
|
|
|
vlc_event_detach( &p_md->p_input_item->event_manager,
|
|
|
|
vlc_InputItemMetaChanged,
|
|
|
|
input_item_meta_changed,
|
|
|
|
p_md );
|
|
|
|
}
|
2007-06-17 18:24:49 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
2007-06-17 19:51:40 +02:00
|
|
|
* Preparse if not already done (Private)
|
2007-06-17 18:24:49 +02:00
|
|
|
**************************************************************************/
|
2007-07-09 22:52:11 +02:00
|
|
|
static void preparse_if_needed( libvlc_media_descriptor_t *p_md )
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
|
|
|
/* XXX: need some locking here */
|
2007-07-09 22:52:11 +02:00
|
|
|
if (!p_md->b_preparsed)
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
2007-07-09 22:52:11 +02:00
|
|
|
input_Preparse( p_md->p_libvlc_instance->p_libvlc_int,
|
|
|
|
p_md->p_input_item );
|
|
|
|
p_md->b_preparsed = VLC_TRUE;
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2007-08-15 20:27:49 +02:00
|
|
|
* Create a new media descriptor object from an input_item
|
|
|
|
* (libvlc internal)
|
|
|
|
* That's the generic constructor
|
2007-06-17 18:24:49 +02:00
|
|
|
**************************************************************************/
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
|
2007-06-17 18:24:49 +02:00
|
|
|
libvlc_instance_t *p_instance,
|
2007-08-15 20:27:49 +02:00
|
|
|
input_item_t *p_input_item,
|
2007-06-17 18:24:49 +02:00
|
|
|
libvlc_exception_t *p_e )
|
|
|
|
{
|
2007-07-09 22:52:11 +02:00
|
|
|
libvlc_media_descriptor_t * p_md;
|
2007-06-17 18:24:49 +02:00
|
|
|
|
|
|
|
if (!p_input_item)
|
2007-06-24 13:19:48 +02:00
|
|
|
{
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_exception_raise( p_e, "No input item given" );
|
2007-06-24 13:19:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
p_md = malloc( sizeof(libvlc_media_descriptor_t) );
|
|
|
|
p_md->p_libvlc_instance = p_instance;
|
|
|
|
p_md->p_input_item = p_input_item;
|
2007-08-15 20:27:49 +02:00
|
|
|
p_md->b_preparsed = VLC_TRUE;
|
2007-08-08 23:12:02 +02:00
|
|
|
p_md->i_refcount = 1;
|
2007-08-16 20:05:07 +02:00
|
|
|
|
2007-08-20 00:46:15 +02:00
|
|
|
vlc_dictionary_init( &p_md->tags, 1 );
|
|
|
|
|
|
|
|
p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance, p_e );
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_event_manager_register_event_type( p_md->p_event_manager,
|
|
|
|
libvlc_MediaDescriptorMetaChanged, p_e );
|
2007-08-16 20:05:07 +02:00
|
|
|
libvlc_event_manager_register_event_type( p_md->p_event_manager,
|
|
|
|
libvlc_MediaDescriptorSubItemAdded, p_e );
|
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
vlc_gc_incref( p_md->p_input_item );
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
install_input_item_observer( p_md );
|
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
return p_md;
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
/**************************************************************************
|
2007-08-15 20:27:49 +02:00
|
|
|
* Create a new media descriptor object
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_media_descriptor_t * libvlc_media_descriptor_new(
|
2007-06-17 22:54:32 +02:00
|
|
|
libvlc_instance_t *p_instance,
|
2007-08-15 20:27:49 +02:00
|
|
|
const char * psz_mrl,
|
2007-06-24 13:31:57 +02:00
|
|
|
libvlc_exception_t *p_e )
|
2007-06-17 22:54:32 +02:00
|
|
|
{
|
2007-08-15 20:27:49 +02:00
|
|
|
input_item_t * p_input_item;
|
2007-07-09 22:52:11 +02:00
|
|
|
libvlc_media_descriptor_t * p_md;
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2007-08-19 23:52:45 +02:00
|
|
|
p_input_item = input_ItemNew( p_instance->p_libvlc_int, psz_mrl, NULL );
|
2007-08-15 20:27:49 +02:00
|
|
|
|
2007-06-17 22:54:32 +02:00
|
|
|
if (!p_input_item)
|
2007-06-24 13:19:48 +02:00
|
|
|
{
|
2007-08-15 20:27:49 +02:00
|
|
|
libvlc_exception_raise( p_e, "Can't create md's input_item" );
|
2007-06-24 13:19:48 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
p_md = libvlc_media_descriptor_new_from_input_item( p_instance,
|
|
|
|
p_input_item, p_e );
|
2007-06-17 22:54:32 +02:00
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
return p_md;
|
2007-06-17 22:54:32 +02:00
|
|
|
}
|
|
|
|
|
2007-06-17 18:24:49 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Delete a media descriptor object
|
|
|
|
**************************************************************************/
|
2007-08-08 23:12:02 +02:00
|
|
|
void libvlc_media_descriptor_release( libvlc_media_descriptor_t *p_md )
|
2007-06-17 18:24:49 +02:00
|
|
|
{
|
2007-08-20 00:46:15 +02:00
|
|
|
int i;
|
2007-06-17 22:54:32 +02:00
|
|
|
if (!p_md)
|
2007-06-17 18:24:49 +02:00
|
|
|
return;
|
|
|
|
|
2007-08-08 23:12:02 +02:00
|
|
|
p_md->i_refcount--;
|
|
|
|
|
|
|
|
if( p_md->i_refcount > 0 )
|
|
|
|
return;
|
2007-08-15 20:27:49 +02:00
|
|
|
|
|
|
|
uninstall_input_item_observer( p_md );
|
|
|
|
vlc_gc_decref( p_md->p_input_item );
|
|
|
|
|
2007-08-20 00:46:15 +02:00
|
|
|
char ** all_keys = vlc_dictionary_all_keys( &p_md->tags );
|
|
|
|
for( i = 0; all_keys[i]; i++ )
|
|
|
|
{
|
|
|
|
int j;
|
2007-08-20 03:40:03 +02:00
|
|
|
struct libvlc_tags_storage_t * p_ts = vlc_dictionary_value_for_key( &p_md->tags, all_keys[i] );
|
2007-08-20 00:46:15 +02:00
|
|
|
for( j = 0; j < p_ts->i_count; j++ )
|
|
|
|
{
|
|
|
|
free( p_ts->ppsz_tags[j] );
|
|
|
|
free( p_ts->ppsz_tags );
|
|
|
|
}
|
|
|
|
free( p_ts );
|
|
|
|
}
|
|
|
|
vlc_dictionary_clear( &p_md->tags );
|
2007-06-17 22:54:32 +02:00
|
|
|
free( p_md );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2007-08-08 23:12:02 +02:00
|
|
|
* Retain a media descriptor object
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_descriptor_retain( libvlc_media_descriptor_t *p_md )
|
|
|
|
{
|
|
|
|
if (!p_md)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p_md->i_refcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Duplicate a media descriptor object
|
2007-06-17 22:54:32 +02:00
|
|
|
**************************************************************************/
|
|
|
|
libvlc_media_descriptor_t *
|
|
|
|
libvlc_media_descriptor_duplicate( libvlc_media_descriptor_t *p_md_orig )
|
|
|
|
{
|
2007-08-15 19:56:00 +02:00
|
|
|
return libvlc_media_descriptor_new_from_input_item(
|
2007-08-15 20:27:49 +02:00
|
|
|
p_md_orig->p_libvlc_instance, p_md_orig->p_input_item, NULL );
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
|
|
|
|
2007-08-09 18:08:14 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Retain a media descriptor object
|
|
|
|
**************************************************************************/
|
|
|
|
char *
|
|
|
|
libvlc_media_descriptor_get_mrl( libvlc_media_descriptor_t * p_md,
|
|
|
|
libvlc_exception_t * p_e )
|
|
|
|
{
|
|
|
|
(void)p_e;
|
|
|
|
return strdup( p_md->p_input_item->psz_uri );
|
|
|
|
}
|
|
|
|
|
2007-06-17 18:24:49 +02:00
|
|
|
/**************************************************************************
|
2007-06-17 22:54:32 +02:00
|
|
|
* Getter for meta information
|
2007-06-17 18:24:49 +02:00
|
|
|
**************************************************************************/
|
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
char * libvlc_media_descriptor_get_meta( libvlc_media_descriptor_t *p_md,
|
2007-06-17 18:24:49 +02:00
|
|
|
libvlc_meta_t e_meta,
|
|
|
|
libvlc_exception_t *p_e )
|
|
|
|
{
|
2007-08-18 05:22:03 +02:00
|
|
|
char * psz_meta;
|
2007-06-17 18:24:49 +02:00
|
|
|
|
|
|
|
/* XXX: locking */
|
|
|
|
|
2007-07-09 22:52:11 +02:00
|
|
|
preparse_if_needed( p_md );
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2007-08-15 20:27:49 +02:00
|
|
|
psz_meta = input_item_GetMeta( p_md->p_input_item,
|
|
|
|
libvlc_to_vlc_meta[e_meta] );
|
2007-06-17 18:24:49 +02:00
|
|
|
|
2007-08-15 19:53:27 +02:00
|
|
|
/* Should be integrated in core */
|
|
|
|
if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name )
|
2007-08-18 05:22:03 +02:00
|
|
|
{
|
|
|
|
free( psz_meta );
|
2007-08-15 19:53:27 +02:00
|
|
|
return strdup( p_md->p_input_item->psz_name );
|
2007-08-18 05:22:03 +02:00
|
|
|
}
|
2007-08-15 19:53:27 +02:00
|
|
|
|
2007-08-18 05:22:03 +02:00
|
|
|
return psz_meta;
|
2007-06-17 18:24:49 +02:00
|
|
|
}
|
2007-07-09 22:52:11 +02:00
|
|
|
|
2007-08-19 23:52:45 +02:00
|
|
|
/**************************************************************************
|
2007-08-20 00:46:15 +02:00
|
|
|
* Add a tag
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_descriptor_add_tag( libvlc_media_descriptor_t *p_md,
|
|
|
|
const char * key,
|
|
|
|
const libvlc_tag_t tag,
|
|
|
|
libvlc_exception_t *p_e )
|
|
|
|
{
|
2007-08-20 03:40:03 +02:00
|
|
|
struct libvlc_tags_storage_t * p_ts;
|
2007-08-20 00:46:15 +02:00
|
|
|
|
|
|
|
if( !tag || !key )
|
|
|
|
return;
|
|
|
|
|
|
|
|
p_ts = vlc_dictionary_value_for_key( &p_md->tags, key );
|
|
|
|
|
|
|
|
if( !p_ts )
|
|
|
|
{
|
2007-08-20 03:40:03 +02:00
|
|
|
p_ts = malloc(sizeof(struct libvlc_tags_storage_t));
|
|
|
|
memset( p_ts, 0, sizeof(struct libvlc_tags_storage_t) );
|
2007-08-20 00:46:15 +02:00
|
|
|
}
|
|
|
|
p_ts->i_count++;
|
|
|
|
|
|
|
|
if( !p_ts->ppsz_tags )
|
|
|
|
p_ts->ppsz_tags = malloc(sizeof(char*)*(p_ts->i_count));
|
|
|
|
else
|
|
|
|
p_ts->ppsz_tags = realloc(p_ts->ppsz_tags, sizeof(char*)*(p_ts->i_count));
|
|
|
|
|
|
|
|
p_ts->ppsz_tags[p_ts->i_count-1] = strdup( tag );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Remove a tag
|
|
|
|
**************************************************************************/
|
|
|
|
void libvlc_media_descriptor_remove_tag( libvlc_media_descriptor_t *p_md,
|
|
|
|
const char * key,
|
|
|
|
const libvlc_tag_t tag,
|
|
|
|
libvlc_exception_t *p_e )
|
|
|
|
{
|
2007-08-20 03:40:03 +02:00
|
|
|
struct libvlc_tags_storage_t * p_ts;
|
2007-08-20 00:46:15 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if( !tag || !key )
|
|
|
|
return;
|
|
|
|
|
|
|
|
p_ts = vlc_dictionary_value_for_key( &p_md->tags, key );
|
|
|
|
|
|
|
|
if( !p_ts )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( i = 0; i < p_ts->i_count; i++ )
|
|
|
|
{
|
|
|
|
if( !strcmp( p_ts->ppsz_tags[i], tag ) )
|
|
|
|
{
|
|
|
|
free( p_ts->ppsz_tags[i] );
|
|
|
|
memcpy( p_ts->ppsz_tags + i + 1, p_ts->ppsz_tags + i, (p_ts->i_count - i - 2)*sizeof(char*) );
|
|
|
|
/* Don't dealloc, the memory will be regain if we add a new tag */
|
|
|
|
p_ts->i_count--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Get tags count
|
2007-08-19 23:52:45 +02:00
|
|
|
**************************************************************************/
|
2007-08-20 00:46:15 +02:00
|
|
|
int libvlc_media_descriptor_tags_count_for_key( libvlc_media_descriptor_t *p_md,
|
|
|
|
const char * key,
|
|
|
|
libvlc_exception_t *p_e )
|
2007-08-19 23:52:45 +02:00
|
|
|
{
|
2007-08-20 03:40:03 +02:00
|
|
|
struct libvlc_tags_storage_t * p_ts;
|
2007-08-20 00:46:15 +02:00
|
|
|
|
|
|
|
if( !key )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p_ts = vlc_dictionary_value_for_key( &p_md->tags, key );
|
|
|
|
|
|
|
|
if( !p_ts )
|
|
|
|
return 0;
|
|
|
|
return p_ts->i_count;
|
|
|
|
}
|
2007-08-19 23:52:45 +02:00
|
|
|
|
2007-08-20 00:46:15 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Get a tag
|
|
|
|
**************************************************************************/
|
|
|
|
libvlc_tag_t
|
|
|
|
libvlc_media_descriptor_tag_at_index_for_key( libvlc_media_descriptor_t *p_md,
|
|
|
|
int i,
|
|
|
|
const char * key,
|
|
|
|
libvlc_exception_t *p_e )
|
|
|
|
{
|
2007-08-20 03:40:03 +02:00
|
|
|
struct libvlc_tags_storage_t * p_ts;
|
2007-08-20 00:46:15 +02:00
|
|
|
|
|
|
|
if( !key )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
p_ts = vlc_dictionary_value_for_key( &p_md->tags, key );
|
|
|
|
|
|
|
|
if( !p_ts )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return strdup( p_ts->ppsz_tags[i] );
|
2007-08-19 23:52:45 +02:00
|
|
|
}
|
|
|
|
|