Commit 8239a932 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Libvlc: Start the implementation of the libvlc playlist. Still in progress.

parent 423ff245
......@@ -141,11 +141,10 @@ VLC_PUBLIC_API libvlc_media_descriptor_t * libvlc_media_descriptor_new(
const char * psz_mrl,
libvlc_exception_t *p_e );
/**
* Destroy a media descriptor object.
* \param p_meta_desc the md to destroy
*/
VLC_PUBLIC_API void libvlc_media_descriptor_destroy(
VLC_PUBLIC_API void libvlc_media_descriptor_retain(
libvlc_media_descriptor_t *p_meta_desc );
VLC_PUBLIC_API void libvlc_media_descriptor_release(
libvlc_media_descriptor_t *p_meta_desc );
/**
......@@ -321,6 +320,7 @@ VLC_PUBLIC_API libvlc_media_instance_t * libvlc_media_instance_new_from_media_de
* \param p_mi the Media Instance to free
*/
VLC_PUBLIC_API void libvlc_media_instance_release( libvlc_media_instance_t * );
VLC_PUBLIC_API void libvlc_media_instance_retain( libvlc_media_instance_t * );
/** Set the media descriptor that will be used by the media_instance. If any,
* previous md will be released.
......@@ -343,6 +343,7 @@ VLC_PUBLIC_API libvlc_event_manager_t * libvlc_media_instance_event_manager ( li
VLC_PUBLIC_API void libvlc_media_instance_play ( libvlc_media_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_media_instance_pause ( libvlc_media_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void libvlc_media_instance_stop ( libvlc_media_instance_t *, libvlc_exception_t * );
/// \bug This might go away ... to be replaced by a broader system
VLC_PUBLIC_API vlc_int64_t libvlc_media_instance_get_length ( libvlc_media_instance_t *, libvlc_exception_t *);
......@@ -364,6 +365,126 @@ VLC_PUBLIC_API vlc_bool_t libvlc_media_instance_has_vout( libvlc_media_instance
VLC_PUBLIC_API float libvlc_media_instance_get_fps( libvlc_media_instance_t *, libvlc_exception_t *);
/** @} */
/*****************************************************************************
* Tag Query
*****************************************************************************/
/** defgroup libvlc_tag_query Tag Query
* \ingroup libvlc
* LibVLC Tag query
* @{
*/
VLC_PUBLIC_API libvlc_tag_query_t *
libvlc_tag_query_new( libvlc_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_tag_query_release( libvlc_tag_query_t * );
VLC_PUBLIC_API void
libvlc_tag_query_retain( libvlc_tag_query_t * );
VLC_PUBLIC_API vlc_bool_t
libvlc_tag_query_match( libvlc_tag_query_t *, libvlc_media_descriptor_t *,
libvlc_exception_t * );
/** @} */
/*****************************************************************************
* Media List
*****************************************************************************/
/** defgroup libvlc_media_list MediaList
* \ingroup libvlc
* LibVLC Media List
* @{
*/
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_list_new( libvlc_instance_t *, libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_release( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_retain( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_add_media_descriptor( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_insert_media_descriptor( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
int,
libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_remove_index( libvlc_media_list_t *, int,
libvlc_exception_t * );
VLC_PUBLIC_API int
libvlc_media_list_count( libvlc_media_list_t * p_mlist,
libvlc_exception_t * p_e );
VLC_PUBLIC_API libvlc_media_descriptor_t *
libvlc_media_list_item_at_index( libvlc_media_list_t *, int,
libvlc_exception_t * );
VLC_PUBLIC_API int
libvlc_media_list_index_of_item( libvlc_media_list_t *,
libvlc_media_descriptor_t *,
libvlc_exception_t * );
VLC_PUBLIC_API void
libvlc_media_list_lock( libvlc_media_list_t * );
VLC_PUBLIC_API void
libvlc_media_list_unlock( libvlc_media_list_t * );
VLC_PUBLIC_API libvlc_event_manager_t *
libvlc_media_list_event_manager( libvlc_media_list_t *,
libvlc_exception_t * );
VLC_PUBLIC_API libvlc_media_list_t *
libvlc_media_list_dynamic_sublist( libvlc_media_list_t *,
libvlc_tag_query_t *,
libvlc_exception_t * );
/** @} */
/*****************************************************************************
* Media List Player
*****************************************************************************/
/** defgroup libvlc_media_list_player MediaListPlayer
* \ingroup libvlc
* LibVLC Media List Player
* @{
*/
VLC_PUBLIC_API libvlc_media_list_player_t *
libvlc_media_list_player_new( libvlc_instance_t * p_instance,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_release( libvlc_media_list_player_t * p_mlp );
VLC_PUBLIC_API void
libvlc_media_list_player_set_media_instance(
libvlc_media_list_player_t * p_mlp,
libvlc_media_instance_t * p_mi,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_set_media_list(
libvlc_media_list_player_t * p_mlp,
libvlc_media_list_t * p_mlist,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_play( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_stop( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
VLC_PUBLIC_API void
libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
/** @} */
/** defgroup libvlc_video Video
......
......@@ -52,6 +52,19 @@ typedef struct libvlc_exception_t
/**@} */
/*****************************************************************************
* Tag Query
*****************************************************************************/
/** defgroup libvlc_tag_query Tag Query
* \ingroup libvlc
* LibVLC Tag Query support in media descriptor
* @{
*/
typedef struct libvlc_tag_query_t libvlc_tag_query_t;
/**@} */
/*****************************************************************************
* Media Descriptor
*****************************************************************************/
......@@ -79,6 +92,7 @@ typedef struct libvlc_media_descriptor_t libvlc_media_descriptor_t;
/**@} */
/*****************************************************************************
* Media Instance
*****************************************************************************/
......@@ -92,6 +106,31 @@ typedef struct libvlc_media_instance_t libvlc_media_instance_t;
/**@} */
/*****************************************************************************
* Media List
*****************************************************************************/
/** defgroup libvlc_media_list MediaList
* \ingroup libvlc
* LibVLC Media List handling
* @{
*/
typedef struct libvlc_media_list_t libvlc_media_list_t;
/**@} */
/*****************************************************************************
* Media List Player
*****************************************************************************/
/** defgroup libvlc_media_list_player MediaListPlayer
* \ingroup libvlc
* LibVLC Media List Player handling
* @{
*/
typedef struct libvlc_media_list_player_t libvlc_media_list_player_t;
/**@} */
/*****************************************************************************
* Playlist
......@@ -188,6 +227,9 @@ typedef struct libvlc_log_message_t
typedef enum libvlc_event_type_t {
libvlc_MediaInstanceReachedEnd,
libvlc_MediaListItemAdded,
libvlc_MediaListItemDeleted,
libvlc_MediaListItemChanged,
} libvlc_event_type_t;
/**
......@@ -200,13 +242,24 @@ typedef enum libvlc_event_type_t {
typedef struct libvlc_event_t
{
libvlc_event_type_t type;
void * p_obj;
union
void * p_obj;
union event_type_specific
{
struct
{
int new_volume;
} volume_changed; /* Scheduled for deletion */
libvlc_media_descriptor_t * item;
int index;
} media_list_item_added;
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_item_deleted;
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_item_changed;
} u;
} libvlc_event_t;
......@@ -222,7 +275,7 @@ typedef struct libvlc_event_manager_t libvlc_event_manager_t;
* \param p_event the event triggering the callback
*/
typedef void ( *libvlc_callback_t )( const libvlc_event_t * );
typedef void ( *libvlc_callback_t )( const libvlc_event_t *, void * );
/**@} */
......
......@@ -141,7 +141,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
{
/* We found the group, now send every one the event */
FOREACH_ARRAY( listener, listeners_group->listeners )
listener->pf_callback( p_event );
listener->pf_callback( p_event, listener->p_user_data );
FOREACH_END()
break;
}
......
......@@ -67,9 +67,28 @@ struct libvlc_media_descriptor_t
{
int b_preparsed;
input_item_t *p_input_item;
int i_refcount;
libvlc_instance_t *p_libvlc_instance;
};
struct libvlc_tag_query_t
{
struct libvlc_instance_t *p_libvlc_instance; /* Parent instance */
int i_refcount;
};
struct libvlc_media_list_t
{
libvlc_event_manager_t * p_event_manager;
libvlc_instance_t * p_libvlc_instance;
int i_refcount;
vlc_mutex_t object_lock;
libvlc_media_list_t * p_media_provider; /* For dynamic sublist */
libvlc_tag_query_t * p_query; /* For dynamic sublist */
DECL_ARRAY(void *) items;
};
struct libvlc_media_instance_t
{
int i_refcount;
......@@ -81,6 +100,19 @@ struct libvlc_media_instance_t
libvlc_event_manager_t * p_event_manager;
};
struct libvlc_media_list_player_t
{
libvlc_event_manager_t * p_event_manager;
libvlc_instance_t * p_libvlc_instance;
int i_refcount;
vlc_mutex_t object_lock;
int i_current_playing_index;
libvlc_media_descriptor_t * p_current_playing_item;
libvlc_media_list_t * p_mlist;
libvlc_media_instance_t * p_mi;
};
/*
* Event Handling
......
......@@ -65,6 +65,7 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
p_md->p_libvlc_instance = p_instance;
p_md->p_input_item = p_input_item;
p_md->b_preparsed = VLC_FALSE;
p_md->i_refcount = 1;
vlc_gc_incref( p_md->p_input_item );
......@@ -92,6 +93,7 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
p_md->p_libvlc_instance = p_instance;
p_md->p_input_item = p_input_item;
p_md->b_preparsed = VLC_TRUE;
p_md->i_refcount = 1;
vlc_gc_incref( p_md->p_input_item );
......@@ -101,19 +103,38 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
/**************************************************************************
* Delete a media descriptor object
**************************************************************************/
void libvlc_media_descriptor_destroy( libvlc_media_descriptor_t *p_md )
void libvlc_media_descriptor_release( libvlc_media_descriptor_t *p_md )
{
if (!p_md)
return;
p_md->i_refcount--;
/* XXX: locking */
vlc_gc_decref( p_md->p_input_item );
if( p_md->i_refcount > 0 )
return;
free( p_md );
}
/**************************************************************************
* Delete a media descriptor object
* Retain a media descriptor object
**************************************************************************/
void libvlc_media_descriptor_retain( libvlc_media_descriptor_t *p_md )
{
if (!p_md)
return;
p_md->i_refcount++;
/* XXX: locking */
vlc_gc_incref( p_md->p_input_item );
}
/**************************************************************************
* Duplicate a media descriptor object
**************************************************************************/
libvlc_media_descriptor_t *
libvlc_media_descriptor_duplicate( libvlc_media_descriptor_t *p_md_orig )
......
......@@ -261,7 +261,7 @@ void libvlc_media_instance_destroy( libvlc_media_instance_t *p_mi )
input_DestroyThread( p_input_thread );
libvlc_media_descriptor_destroy( p_mi->p_md );
libvlc_media_descriptor_release( p_mi->p_md );
free( p_mi );
}
......@@ -278,24 +278,32 @@ void libvlc_media_instance_release( libvlc_media_instance_t *p_mi )
p_mi->i_refcount--;
/* We hold the mutex, as a waiter to make sure pending operations
* are finished. We can't hold it longer as the get_input_thread
* function holds a lock. */
vlc_mutex_unlock( &p_mi->object_lock );
if( p_mi->i_refcount > 0 )
{
vlc_mutex_unlock( &p_mi->object_lock );
return;
}
vlc_mutex_unlock( &p_mi->object_lock );
libvlc_event_manager_release( p_mi->p_event_manager );
release_input_thread( p_mi );
libvlc_media_descriptor_destroy( p_mi->p_md );
libvlc_media_descriptor_release( p_mi->p_md );
free( p_mi );
}
/**************************************************************************
* Retain a Media Instance object
**************************************************************************/
void libvlc_media_instance_retain( libvlc_media_instance_t *p_mi )
{
if( !p_mi )
return;
p_mi->i_refcount++;
}
/**************************************************************************
* Set the Media descriptor associated with the instance
**************************************************************************/
......@@ -313,7 +321,7 @@ void libvlc_media_instance_set_media_descriptor(
release_input_thread( p_mi );
libvlc_media_descriptor_destroy( p_mi->p_md );
libvlc_media_descriptor_release( p_mi->p_md );
if( !p_md )
{
......@@ -422,6 +430,15 @@ void libvlc_media_instance_pause( libvlc_media_instance_t *p_mi,
vlc_object_release( p_input_thread );
}
/**************************************************************************
* Stop
**************************************************************************/
void libvlc_media_instance_stop( libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e )
{
libvlc_exception_raise( p_mi, "Not implemented" );
}
/**************************************************************************
* Getters for stream information
**************************************************************************/
......
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
* tag_query.c: libvlc new API media tag query functions
*****************************************************************************
* 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 "libvlc_internal.h"
#include <vlc/libvlc.h>
#include "vlc_arrays.h"
/* XXX This API is in construction
*
* It's goal is to represent a meta tag query
* It should be also able to say if a query can be matched in a media
* descriptor through libvlc_query_match.
*/
/*
* Public libvlc functions
*/
/**************************************************************************
* libvlc_tag_query_new (Public)
*
* Init an object.
**************************************************************************/
libvlc_tag_query_t *
libvlc_tag_query_new( libvlc_instance_t * p_inst,
libvlc_exception_t * p_e )
{
(void)p_e;
libvlc_tag_query_t * p_q;
p_q = malloc(sizeof(libvlc_tag_query_t));
if( !p_q )
return NULL;
p_q->p_libvlc_instance = p_inst;
p_q->i_refcount = 1;
return p_q;
}
/**************************************************************************
* libvlc_media_list_release (Public)
*
* Release an object.
**************************************************************************/
void libvlc_tag_query_release( libvlc_tag_query_t * p_q )
{
p_q->i_refcount--;
if( p_q->i_refcount > 0 )
return;
free( p_q );
}
/**************************************************************************
* libvlc_media_list_retain (Public)
*
* Release an object.
**************************************************************************/
void libvlc_tag_query_retain( libvlc_tag_query_t * p_q )
{
p_q->i_refcount++;
}
/**************************************************************************
* libvlc_query_match (Public)
*
* Return true if the query p_q is matched in p_md
**************************************************************************/
vlc_bool_t
libvlc_tag_query_match( libvlc_tag_query_t * p_q,
libvlc_media_descriptor_t * p_md,
libvlc_exception_t * p_e )
{
(void)p_q;
(void)p_md;
(void)p_e;
/* In construction... */
return 1;
}
Markdown is supported
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