Commit 203fc8a6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Remove CMML module.

No maintainer showed up. It is broken in many ways and there is virtually no streams using that...
parent 7c8b9f86
......@@ -103,6 +103,7 @@ Removed modules:
* opie, qte and qte_main
* opengllayer
* cddax. Use cdda instead
* cmml.
Changes between 1.0.2 and 1.0.3:
......
......@@ -3500,16 +3500,6 @@ AS_IF( [test "${enable_asademux}" = "yes"], [
])
])
dnl
dnl CMML plugin
dnl
AC_ARG_ENABLE(cmml,
[ --enable-cmml CMML support (default enabled)])
if test "${enable_cmml}" != "no"
then
VLC_ADD_PLUGIN([cmml])
fi
dnl
dnl kate decoder plugin
dnl
......@@ -5132,7 +5122,6 @@ AC_CONFIG_FILES([
modules/audio_output/Makefile
modules/codec/Makefile
modules/codec/avcodec/Makefile
modules/codec/cmml/Makefile
modules/codec/dmo/Makefile
modules/codec/shine/Makefile
modules/codec/subtitles/Makefile
......
......@@ -74,7 +74,6 @@ $Id$
* chorus_flanger: variable delay audio filter
* chroma_neon: ARM NEONv1 chroma conversion module
* clone: Clone video filter
* cmml: Continuous Media Markup Language annotations/hyperlinks decoder
* colorthres: Theshold color based on similarity to reference color Video filter
* converter_fixed: Fixed-point audio format conversions
* converter_float: Floating-point audio format conversions
......
SUBDIRS = cmml dmo avcodec shine subtitles spudec wmafixed
SUBDIRS = dmo avcodec shine subtitles spudec wmafixed
SOURCES_a52 = a52.c a52.h
SOURCES_dts = dts.c
SOURCES_flac = flac.c
......
What's CMML?
------------
This is an implementation of the Continuous Media Markup Language
(CMML) for VideoLAN. In short, CMML is a (XML) markup language for
time-continuous data, which of course includes multimedia such as
video and audio. It allows one to annotate a media file with both
structured and unstructured textual data, but one of its distinguishing
features--and what this code implements--is its support for embedding
hyperlinks in media files.
So, while viewing some media (e.g. a radio interview with a band),
you could provide a hyperlink to any URL, including a standard web
page or other media (e.g. the band's home page). The hyperlinks
are active only for specific intervals of time while the media is
playing, so for example during a radio interview, the hyperlinks
can change depending on what questions the interviewer is asking
and topic is being discussed.
For more general information on CMML and its role in the bigger
picture of extending the World Wide Web to properly support multimedia,
see <http://www.annodex.net/overview.html>. For specifications of
CMML, see <http://www.annodex.net/specifications.html>.
Usage
-----
Once you have hyperlinking capability, you take on some of the
capabilities of a web browser, in particular following hyperlinks,
and also maintaining a browsing history where you can go backwards
and forwards between pieces of media you've linked to. So, if you
are viewing a file with CMML markup:
* Hyperlinks are displayed as a subtitle track
* Hyperlinks are followed with the VLC "activate" hotkey (by default,
this is just the Enter key)
* Going back and forward are done with the "history-back" and
"history-forward" keys, by default Cmd-[ and Cmd-] on Mac OS X,
and Ctrl-[ and Ctrl-] on all other platforms.
Until the media browsing history features are made available outside
of the CMML plugin, you can only use the history features while
viewing a file that contains CMML markup: e.g. you cannot navigate
backwards or forward in the history while viewing a standard MPEG
video. This is a limitation which may be removed if the media
browsing code is merged into the VLC core.
Overview of the code
--------------------
First: a lot of this code could be implemented, or should be
implemented, in VLC's core (libvlc) rather than be part of a codec
plugin, either because it's something which really should belong
in the core (e.g. media browsing history, system-indepedent interface
to web browser) or a generally useful thing outside of the codec
plugin (e.g. XML parser, URL handling library). That's well and
good, but changes to libvlc are far-reaching and affect all of VLC,
rather than only affecting a single plugin. It's sensible to
gradually merge this stuff into libvlc on an as-needs basis, rather
than trying to refactor out huge amounts of code at once.
Here's a quick overview of what the files do:
* browser_open.[ch]: A very simple attempt to provide a way to
open the system's web browser.
* history.[ch]: Media browsing history (as described above in
"Usage").
* xstrcat.h: Simple wrapper around strcat(1) which performs a
realloc(1) if needed.
* xarray.[ch]: extensible (growable) array, similar to a Vector in
Java/C++. Could be replaced with a vlc_list_t from libvlc's
src/misc/objects.c if the vlc_list_t API were made public.
* xlist.[ch]: Yet Another Linked List implementation (sorry guys
:), only here because XTag (see below) uses it internally.
* xtag.[ch]: A very simple (but working!), lightweight XML
parser.
* xurl.[ch]: A small URL handling library.
* cmml.c: The actual 'codec' parser, which parses the CMML data
(demuxed from the incoming media stream, of course), and provides
two VLC vars ("psz-current-anchor-description" and
"psz-current-anchor-url") which enable intf plugins to display
the CMML data to the user and let them interact with it.
* intf.c: Enables media browsing functionality by displaying
hyperlinks as a subtitle track, and responding to user
keypresses for following hyperlinks and navigating the media
browsing history.
So, all the files except for cmml.c and intf.c could be made available
and re-used outside of this plugin, but currently are not (for the
reasons given above).
SOURCES_cmml = \
browser_open.c browser_open.h \
cmml.c \
history.c history.h \
intf.c \
xarray.c xarray.h \
xlist.c xlist.h \
xstrcat.h \
xtag.c xtag.h \
xurl.c xurl.h
/*****************************************************************************
* browser_open.c: platform-independent opening of a web browser
*****************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include "browser_open.h"
#if 0
int browser_Open( const char *psz_url )
{
#ifdef __APPLE__
char *psz_open_commandline;
int i_ret;
if( asprintf( &psz_open_commandline, "/usr/bin/open %s", psz_url ) == -1 )
return -1;
i_ret = system( psz_open_commandline );
free( psz_open_commandline );
return i_ret;
#elif defined( UNDER_CE )
return -1;
#elif defined( WIN32 )
char *psz_open_commandline;
int i_ret;
if( asprintf( &psz_open_commandline, "explorer %s", psz_url ) == -1 )
return -1;
i_ret = system( psz_open_commandline );
free( psz_open_commandline );
return i_ret;
#else
/* Assume we're on a UNIX of some sort */
char *psz_open_commandline;
int i_ret;
/* Debian uses www-browser */
if( asprintf( &psz_open_commandline, "www-browser %s", psz_url ) == -1 )
return -1;
i_ret = system( psz_open_commandline );
free( psz_open_commandline );
if( i_ret == 0 )
return 0;
/* Try mozilla */
if( asprintf( &psz_open_commandline, "mozilla %s", psz_url ) == -1 )
return -1;
i_ret = system( psz_open_commandline );
free( psz_open_commandline );
return i_ret;
#endif
}
#else
int browser_Open( const char *psz_url )
{
(void)psz_url;
return -1;
}
#endif
/*****************************************************************************
* browser_open.h: platform-independent opening of a web browser
*****************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __BROWSER_OPEN_H__
#define __BROWSER_OPEN_H__
int browser_Open( const char *psz_url );
#endif /* __BROWSER_OPEN_H__ */
/*****************************************************************************
* cmml.c : CMML annotations/metadata decoder
*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Author: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_codec.h>
#include <vlc_osd.h>
#include <vlc_charset.h>
#include <vlc_interface.h>
#include "xtag.h"
#undef CMML_DEBUG
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static void CloseDecoder ( vlc_object_t * );
static subpicture_t *DecodeBlock ( decoder_t *, block_t ** );
static void ParseText ( decoder_t *, block_t * );
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
decoder_sys_t *OpenIntf( vlc_object_t * );
void CloseIntf( decoder_sys_t * );
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
vlc_module_begin ()
set_description( N_("CMML annotations decoder") )
set_capability( "decoder", 50 )
set_callbacks( OpenDecoder, CloseDecoder )
add_shortcut( "cmml" )
add_submodule ()
set_capability( "interface", 0 )
set_callbacks( OpenIntf, CloseIntf )
add_shortcut( "cmml" )
vlc_module_end ()
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************
* Tries to launch a decoder and return score so that the interface is able
* to chose.
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
input_thread_t * p_input;
if( p_dec->fmt_in.i_codec != VLC_CODEC_CMML )
return VLC_EGENERIC;
p_dec->pf_decode_sub = DecodeBlock;
/* Let other interested modules know that we're a CMML decoder
* We have to set this variable on the input thread, because there's
* typically more than one decoder running so we can't find the CMML
* decoder succesfully with vlc_object_find. (Any hints on how to achieve
* this would be rather appreciated ;) */
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( p_input )
{
vlc_value_t val;
#ifdef CMML_DEBUG
msg_Dbg( p_dec, "p_input is at %p", p_input );
#endif
val.p_address = p_dec;
var_Create( p_input, "has-cmml-decoder",
VLC_VAR_ADDRESS|VLC_VAR_DOINHERIT );
if( var_Set( p_input, "has-cmml-decoder", val ) != VLC_SUCCESS )
msg_Dbg( p_dec, "var_Set of has-cmml-decoder failed" );
vlc_object_release( p_input );
}
/* initialise the CMML responder interface */
p_dec->p_sys = OpenIntf( VLC_OBJECT(p_dec) );
p_dec->fmt_out.i_cat = SPU_ES;
p_dec->fmt_out.i_codec = 0;
return VLC_SUCCESS;
}
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************
* This function must be fed with complete subtitles units.
****************************************************************************/
static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
subpicture_t *p_spu;
if( !pp_block || *pp_block == NULL )
{
return NULL;
}
ParseText( p_dec, *pp_block );
block_Release( *pp_block );
*pp_block = NULL;
/* allocate an empty subpicture to return. the actual subpicture
* displaying is done in the DisplayAnchor function in intf.c (called from
* DisplayPendingAnchor, which in turn is called from the main RunIntf
* loop). */
p_spu = decoder_NewSubpicture( p_dec );
if( !p_spu )
{
msg_Dbg( p_dec, "couldn't allocate new subpicture" );
return NULL;
}
return p_spu;
}
/*****************************************************************************
* CloseDecoder: clean up the decoder
*****************************************************************************/
static void CloseDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *)p_this;
CloseIntf( p_dec->p_sys );
}
/*****************************************************************************
* ParseText: parse an text subtitle packet and send it to the video output
*****************************************************************************/
static void ParseText( decoder_t *p_dec, block_t *p_block )
{
char *psz_subtitle, *psz_cmml, *psz_url;
XTag *p_clip_parser, *p_anchor;
vlc_value_t val;
/* We cannot display a subpicture with no date */
if( p_block->i_pts == 0 )
{
msg_Warn( p_dec, "subtitle without a date" );
return;
}
/* Check validity of packet data */
if( p_block->i_buffer <= 1 || p_block->p_buffer[0] == '\0' )
{
msg_Warn( p_dec, "empty subtitle" );
return;
}
/* get anchor text from CMML */
/* Copy the whole CMML tag into our own buffer:
allocate i_buffer bytes + 1 for the terminating \0 */
if( (psz_cmml = malloc( p_block->i_buffer + 1 )) == NULL )
return;
memcpy( psz_cmml, p_block->p_buffer, p_block->i_buffer );
psz_cmml[p_block->i_buffer] = '\0'; /* terminate the string */
#ifdef CMML_DEBUG
msg_Dbg( p_dec, "psz_cmml is \"%s\"", psz_cmml );
#endif
/* Parse the <clip> part of the CMML */
p_clip_parser = xtag_new_parse( psz_cmml, p_block->i_buffer );
if( !p_clip_parser )
{
msg_Warn( p_dec, "couldn't initialise <clip> parser" );
free( psz_cmml );
return;
}
/* Parse the anchor tag and get its contents */
p_anchor = xtag_first_child( p_clip_parser, "a" );
if( p_anchor != NULL )
{
psz_subtitle = xtag_get_pcdata( p_anchor );
}
else
{
psz_subtitle = strdup( " " );
}
#ifdef CMML_DEBUG
msg_Dbg( p_dec, "psz_subtitle is \"%s\"", psz_subtitle );
#endif
/* get URL from the current clip, if one exists */
psz_url = xtag_get_attribute( p_anchor, "href" );
#ifdef CMML_DEBUG
msg_Dbg( p_dec, "psz_url is \"%s\"", psz_url );
#endif
if( psz_url )
{
char *psz_tmp = strdup( psz_url );
val.p_address = psz_tmp;
if( var_Set( p_dec, "psz-current-anchor-url", val ) != VLC_SUCCESS )
{
var_Create( p_dec, "psz-current-anchor-url",
VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
msg_Dbg( p_dec, "creating psz-current-anchor-url" );
if( var_Set( p_dec, "psz-current-anchor-url", val ) != VLC_SUCCESS )
msg_Dbg( p_dec, "var_Set of psz-current-anchor-url failed" );
}
}
if( psz_subtitle )
{
char *psz_tmp = strdup( psz_subtitle );
val.p_address = psz_tmp;
if( var_Set( p_dec, "psz-current-anchor-description", val ) != VLC_SUCCESS )
{
var_Create( p_dec, "psz-current-anchor-description",
VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
msg_Dbg( p_dec, "creating psz-current-anchor-description" );
if( var_Set( p_dec, "psz-current-anchor-description", val ) != VLC_SUCCESS )
msg_Dbg( p_dec, "var_Set of psz-current-anchor-description failed" );
}
}
free( psz_subtitle );
free( psz_cmml );
free( p_anchor );
free( p_clip_parser );
free( psz_url );
}
/*****************************************************************************
* history.c: vlc_history_t (web-browser-like back/forward history) handling
*****************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_input.h>
#include "history.h"
#include "xarray.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h> /* malloc() */
#endif
#undef HISTORY_DEBUG
/*****************************************************************************
* Local prototypes
*****************************************************************************/
#ifdef HISTORY_DEBUG
static void history_Dump( history_t *p_history );
#endif
/*****************************************************************************
* Local structure lock
*****************************************************************************/
/*****************************************************************************
* Actual history code
*****************************************************************************/
history_t *history_New( void )
{
history_t *p_new_history;
p_new_history = calloc( 1, sizeof( struct history_t ) );
if( p_new_history == NULL ) return NULL;
p_new_history->p_xarray = xarray_New( 0 );
if( p_new_history->p_xarray == NULL )
{
free( p_new_history );
return NULL;
}
return p_new_history;
}
bool history_GoBackSavingCurrentItem ( history_t *p_history,
history_item_t *p_item )
{
history_PruneAndInsert( p_history, p_item );
/* PruneAndInsert will increment the index, so we need to go
* back one position to reset the index to the place we were at
* before saving the current state, and then go back one more to
* actually go back */
p_history->i_index -= 2;
#ifdef HISTORY_DEBUG
history_Dump( p_history );
#endif
return true;
}
#ifdef HISTORY_DEBUG
static void history_Dump( history_t *p_history )
{
unsigned int i_count;
int i;
if( xarray_Count( p_history->p_xarray, &i_count ) != XARRAY_SUCCESS )
return;
for (i = 0; i < (int) i_count; i++)
{
history_item_t *p_item;
void *pv_item;
xarray_ObjectAtIndex( p_history->p_xarray, i, &pv_item );
p_item = (history_item_t *) pv_item;
if( p_item == NULL )
fprintf( stderr, "HISTORY: [%d] NULL\n", i );
else
{
fprintf( stderr, "HISTORY: [%d] %p (%p->%s)\n", i, p_item,
p_item->psz_uri, p_item->psz_uri );
}
}
}
#endif
bool history_GoForwardSavingCurrentItem ( history_t *p_history,
history_item_t *p_item )
{
#ifdef HISTORY_DEBUG
history_Dump( p_history );
#endif
if( xarray_ReplaceObject( p_history->p_xarray, p_history->i_index, p_item )
== XARRAY_SUCCESS )
{
p_history->i_index++;
return true;
}
else
{
return false;
}
}
bool history_CanGoBack( history_t *p_history )
{
if( p_history->i_index > 0 )
return true;
else
return false;
}
bool history_CanGoForward( history_t *p_history )
{
unsigned int i_count;
if( xarray_Count( p_history->p_xarray, &i_count ) != XARRAY_SUCCESS )
return false;
if( p_history->i_index < i_count )
return true;
else
return false;
}
history_item_t *history_Item( history_t *p_history )
{
history_item_t *p_item;
void *pv_item;
if( xarray_ObjectAtIndex( p_history->p_xarray, p_history->i_index,
&pv_item )
== XARRAY_SUCCESS )
{
p_item = (history_item_t *) pv_item;
return p_item;
}
else
{
return NULL;
}
}
void history_Prune( history_t *p_history )
{
xarray_RemoveObjectsAfter( p_history->p_xarray, p_history->i_index );
xarray_RemoveObject( p_history->p_xarray, p_history->i_index );
}
void history_PruneAndInsert( history_t *p_history, history_item_t *p_item )
{
unsigned int i_count;
xarray_Count( p_history->p_xarray, &i_count );
if( i_count == 0 )
{
xarray_InsertObject( p_history->p_xarray, p_item, 0 );
p_history->i_index = 1;
}
else
{
history_Prune( p_history );
xarray_InsertObject( p_history->p_xarray, p_item, p_history->i_index );
p_history->i_index++;
}
}
unsigned int history_Count( history_t *p_history )
{
unsigned int i_count;
xarray_Count( p_history->p_xarray, &i_count );
return i_count;
}
unsigned int history_Index( history_t *p_history )
{
return p_history->i_index;
}
history_item_t * historyItem_New( char *psz_name, char *psz_uri )
{
history_item_t *p_history_item = NULL;
p_history_item = (history_item_t *) malloc( sizeof(history_item_t) );
if( !p_history_item ) return NULL;
p_history_item->psz_uri = strdup( psz_uri );
p_history_item->psz_name = strdup( psz_name );
return p_history_item;
}
/*****************************************************************************
* history.h: vlc_history_t (web-browser-like back/forward history) handling
*****************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __VLC_HISTORY_H__
#define __VLC_HISTORY_H__
#include "xarray.h"
struct history_item_t
{
char * psz_name;
char * psz_uri;
};
struct history_t
{
unsigned int i_index; /* current index into history */
XArray * p_xarray;
};
typedef struct history_item_t history_item_t;
typedef struct history_t history_t;
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
history_t * history_New ( void );
bool history_GoBackSavingCurrentItem ( history_t *,
history_item_t * );
bool history_GoForwardSavingCurrentItem ( history_t *,
history_item_t * );
bool history_CanGoBack ( history_t * );
bool history_CanGoForward ( history_t * );
history_item_t * history_Item ( history_t * );
void history_Prune ( history_t * );
void history_PruneAndInsert ( history_t *,
history_item_t * );
unsigned int history_Count ( history_t * );
unsigned int history_Index ( history_t * );
history_item_t * historyItem_New ( char *, char * );
#endif /* __VLC_HISTORY_H__ */
This diff is collapsed.
/*************************************************************************
* xarray.c: Mutable (dynamically growable) array
*************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "xarray.h"
#include <vlc_memory.h>
/* local prototypes */
XArray * xarray_New (unsigned int);
#define XARRAY_ASSERT_NOT_NULL(xarray) \
{ \
if (xarray == NULL) return XARRAY_ENULLPOINTER; \
}
#define XARRAY_BOUNDS_CHECK(xarray, index) \
{ \
if (xarray->last_valid_element != -1 && \
(int) index > xarray->last_valid_element) \
return XARRAY_EINDEXTOOLARGE; \
}
#define XARRAY_GROW_ARRAY(xarray) \
{ \
xarray->array = realloc_or_free (xarray->array, xarray->size * 2); \
if (xarray->array == NULL) return XARRAY_ENOMEM; \
}
XArray * xarray_New (unsigned int initial_size_hint)
{
XArray *new_xarray = NULL;
void *inner_array;
unsigned int initial_size;
new_xarray = (XArray *) malloc (sizeof(XArray));
if (new_xarray == NULL) return NULL;
if (initial_size_hint == 0)
initial_size = XARRAY_DEFAULT_SIZE;
else
initial_size = initial_size_hint;
inner_array = calloc (initial_size, sizeof(void *));
new_xarray->last_valid_element = -1;
new_xarray->size = initial_size;
new_xarray->last_error = 0;
if (inner_array == NULL)
{
free (new_xarray);
return NULL;
}
new_xarray->array = inner_array;
return new_xarray;
}
int xarray_ObjectAtIndex (XArray *xarray, unsigned int index,
void **out_object)
{
XARRAY_ASSERT_NOT_NULL (xarray);
XARRAY_BOUNDS_CHECK (xarray, index);
*out_object = xarray->array[index];
return XARRAY_SUCCESS;
}
int xarray_AddObject (XArray *xarray, void *object)
{
XARRAY_ASSERT_NOT_NULL (xarray);
++xarray->last_valid_element;
if (xarray->last_valid_element >= (int) xarray->size)
{
XARRAY_GROW_ARRAY (xarray);
}
xarray->array[xarray->last_valid_element] = object;
return XARRAY_SUCCESS;
}
int xarray_InsertObject (XArray *xarray, void *object,
unsigned int at_index)
{
XARRAY_ASSERT_NOT_NULL (xarray);
++xarray->last_valid_element;
XARRAY_BOUNDS_CHECK (xarray, at_index);
if (xarray->last_valid_element >= (int) xarray->size)
{
XARRAY_GROW_ARRAY (xarray);
}
/* Shift everything from a[i] onward one pointer forward */
if ((int) at_index < xarray->last_valid_element)
{
(void) memmove (&xarray->array[at_index + 1],
&xarray->array[at_index],
(xarray->last_valid_element - at_index) *
sizeof(void *));
}
xarray->array[at_index] = object;
return XARRAY_SUCCESS;
}
int xarray_RemoveLastObject (XArray *xarray)
{
XARRAY_ASSERT_NOT_NULL (xarray);
if (xarray->last_valid_element == -1)
return XARRAY_EEMPTYARRAY;
xarray->array[xarray->last_valid_element] = NULL;
--xarray->last_valid_element;
return XARRAY_SUCCESS;
}
int xarray_RemoveObject (XArray *xarray, unsigned int at_index)
{
XARRAY_ASSERT_NOT_NULL (xarray);
XARRAY_BOUNDS_CHECK (xarray, at_index);
/* Shift everything from a[i] onward one pointer backward */
if ((int) at_index < xarray->last_valid_element)
{
(void) memmove (&xarray->array[at_index],
&xarray->array[at_index + 1],
(xarray->last_valid_element - at_index) *
sizeof(void *));
}
xarray->array[xarray->last_valid_element] = NULL;
--xarray->last_valid_element;
return XARRAY_SUCCESS;
}
int xarray_RemoveObjects (XArray *xarray, unsigned int at_index,
int count)
{
int i;
XARRAY_ASSERT_NOT_NULL (xarray);
XARRAY_BOUNDS_CHECK (xarray, at_index);
if (count == 0) return XARRAY_SUCCESS;
if ((int) at_index + (count - 1) > xarray->last_valid_element)
return XARRAY_ECOUNTOUTOFBOUNDS;
for (i = 0; i < count; i++)
{
int e = xarray_RemoveObject (xarray, at_index);
if (e != XARRAY_SUCCESS) return e;
}
return XARRAY_SUCCESS;
}
int xarray_RemoveObjectsAfter (XArray *xarray, unsigned int index)
{
XARRAY_ASSERT_NOT_NULL (xarray);
XARRAY_BOUNDS_CHECK (xarray, index);
index++;
while ((int) index <= xarray->last_valid_element)
{
int e = xarray_RemoveObject (xarray, index);
if (e != XARRAY_SUCCESS) return e;
}
return XARRAY_SUCCESS;
}
int xarray_ReplaceObject (XArray *xarray, unsigned int index,
void *new_object)
{
XARRAY_ASSERT_NOT_NULL (xarray);
XARRAY_BOUNDS_CHECK (xarray, index);
xarray->array[index] = new_object;
return XARRAY_SUCCESS;
}
int xarray_Count (XArray *xarray, unsigned int *out_count)
{
XARRAY_ASSERT_NOT_NULL (xarray);
*out_count = xarray->last_valid_element + 1;
return XARRAY_SUCCESS;
}
#undef XARRAY_ASSERT_NOT_NULL
#undef XARRAY_BOUNDS_CHECK
#undef XARRAY_GROW_ARRAY
/*************************************************************************
* xarray.h: Mutable (dynamically growable) array (header file)
*************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
************************************************************************/
#ifndef __XARRAY_H__
#define __XARRAY_H__
#define XARRAY_DEFAULT_SIZE 69
/* Error codes */
enum xarray_errors
{
XARRAY_SUCCESS, XARRAY_ENULLPOINTER, XARRAY_ENEGATIVEINDEX,
XARRAY_EINDEXTOOLARGE, XARRAY_ENOMEM, XARRAY_EEMPTYARRAY,
XARRAY_ECOUNTOUTOFBOUNDS
};
typedef struct
{
void **array;
int last_valid_element;
unsigned int size;
unsigned int last_error;
}
XArray;
/* Mutable methods */
int xarray_AddObject (XArray *xarray, void *object);
int xarray_InsertObject (XArray *xarray, void *object,
unsigned int at_index);
int xarray_RemoveLastObject (XArray *xarray);
int xarray_RemoveObject (XArray *xarray, unsigned int at_index);
int xarray_RemoveObjects (XArray *xarray, unsigned int at_index,
int count);
int xarray_RemoveObjectsAfter (XArray *xarray, unsigned int index);
int xarray_ReplaceObject (XArray *xarray, unsigned int index,
void *new_object);
/* Immutable methods */
XArray * xarray_New ();
int xarray_ObjectAtIndex (XArray *xarray, unsigned int index,
void **out_object);
int xarray_Count (XArray *xarray, unsigned int *out_count);
#endif /* __XARRAY_H__ */
/*****************************************************************************
* xlist.c : a simple doubly linked list in C
*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2000-2004 the VideoLAN team
*
* $Id$
*
* Authors: Conrad Parker <Conrad.Parker@csiro.au>
* Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include "xlist.h"
static XList *
xlist_node_new (void * data)
{
XList * l;
l = (XList *) malloc (sizeof (XList));
l->prev = l->next = NULL;
l->data = data;
return l;
}
XList *
xlist_new (void)
{
return NULL;
}
XList *
xlist_clone (XList * list)
{
XList * l, * new_list;
if (list == NULL) return NULL;
new_list = xlist_new ();
for (l = list; l; l = l->next) {
new_list = xlist_append (new_list, l->data);
}
return new_list;
}
XList *
xlist_clone_with (XList * list, XCloneFunc clone)
{
XList * l, * new_list;
void * new_data;
if (list == NULL) return NULL;
if (clone == NULL) return xlist_clone (list);
new_list = xlist_new ();
for (l = list; l; l = l->next) {
new_data = clone (l->data);
new_list = xlist_append (new_list, new_data);
}
return new_list;
}
XList *
xlist_tail (XList * list)
{
XList * l;
for (l = list; l; l = l->next)
if (l->next == NULL) return l;
return NULL;
}
XList *
xlist_prepend (XList * list, void * data)
{
XList * l = xlist_node_new (data);
if (list == NULL) return l;
l->next = list;
list->prev = l;
return l;
}
XList *
xlist_append (XList * list, void * data)
{
XList * l = xlist_node_new (data);
XList * last;
if (list == NULL) return l;
last = xlist_tail (list);
last->next = l;
l->prev = last;
return list;
}
XList *
xlist_add_before (XList * list, void * data, XList * node)
{
XList * l, * p;
if (list == NULL) return xlist_node_new (data);
if (node == NULL) return xlist_append (list, data);
if (node == list) return xlist_prepend (list, data);
l = xlist_node_new (data);
p = node->prev;
l->prev = p;
l->next = node;
if (p) p->next = l;
node->prev = l;
return list;
}
XList *
xlist_add_after (XList * list, void * data, XList * node)
{
XList * l, * n;
if (node == NULL) return xlist_prepend (list, data);
l = xlist_node_new (data);
n = node->next;
l->prev = node;
l->next = n;
if (n) n->prev = l;
node->next = l;
return list;
}
XList *
xlist_find (XList * list, void * data)
{
XList * l;
for (l = list; l; l = l->next)
if (l->data == data) return l;
return NULL;
}
XList *
xlist_remove (XList * list, XList * node)
{
if (node == NULL) return list;
if (node->prev) node->prev->next = node->next;
if (node->next) node->next->prev = node->prev;
if (node == list) return list->next;
else return list;
}
int
xlist_length (XList * list)
{
XList * l;
int c = 0;
for (l = list; l; l = l->next)
c++;
return c;
}
int
xlist_is_empty (XList * list)
{
return (list == NULL);
}
int
xlist_is_singleton (XList * list)
{
if (list == NULL) return 0;
if (list->next == NULL) return 1;
else return 0;
}
/*
* xlist_free_with (list, free_func)
*
* Step through list 'list', freeing each node using free_func(), and
* also free the list structure itself.
*/
XList *
xlist_free_with (XList * list, XFreeFunc free_func)
{
XList * l, * ln;
for (l = list; l; l = ln) {
ln = l->next;
free_func (l->data);
free (l);
}
return NULL;
}
/*
* xlist_free (list)
*
* Free the list structure 'list', but not its nodes.
*/
XList *
xlist_free (XList * list)
{
XList * l, * ln;
for (l = list; l; l = ln) {
ln = l->next;
free (l);
}
return NULL;
}
/*****************************************************************************
* xlist.h : a simple doubly linked list in C (header file)
*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2000-2004 the VideoLAN team
*
* $Id$
*
* Authors: Conrad Parker <Conrad.Parker@csiro.au>
* Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __XLIST__
#define __XLIST__
/**
* A doubly linked list
*/
typedef struct _XList XList;
struct _XList {
XList * prev;
XList * next;
void * data;
};
/**
* Signature of a cloning function.
*/
typedef void * (*XCloneFunc) (void * data);
/**
* Signature of a freeing function.
*/
typedef void * (*XFreeFunc) (void * data);
/** Create a new list
* \return a new list
*/
XList * xlist_new (void);
/**
* Clone a list using the default clone function
* \param list the list to clone
* \returns a newly cloned list
*/
XList * xlist_clone (XList * list);
/**
* Clone a list using a custom clone function
* \param list the list to clone
* \param clone the function to use to clone a list item
* \returns a newly cloned list
*/
XList * xlist_clone_with (XList * list, XCloneFunc clone);
/**
* Return the tail element of a list
* \param list the list
* \returns the tail element
*/
XList * xlist_tail (XList * list);
/**
* Prepend a new node to a list containing given data
* \param list the list
* \param data the data element of the newly created node
* \returns the new list head
*/
XList * xlist_prepend (XList * list, void * data);
/**
* Append a new node to a list containing given data
* \param list the list
* \param data the data element of the newly created node
* \returns the head of the list
*/
XList * xlist_append (XList * list, void * data);
/**
* Add a new node containing given data before a given node
* \param list the list
* \param data the data element of the newly created node
* \param node the node before which to add the newly created node
* \returns the head of the list (which may have changed)
*/
XList * xlist_add_before (XList * list, void * data, XList * node);
/**
* Add a new node containing given data after a given node
* \param list the list
* \param data the data element of the newly created node
* \param node the node after which to add the newly created node
* \returns the head of the list
*/
XList * xlist_add_after (XList * list, void * data, XList * node);
/**
* Find the first node containing given data in a list
* \param list the list
* \param data the data element to find
* \returns the first node containing given data, or NULL if it is not found
*/
XList * xlist_find (XList * list, void * data);
/**
* Remove a node from a list
* \param list the list
* \param node the node to remove
* \returns the head of the list (which may have changed)
*/
XList * xlist_remove (XList * list, XList * node);
/**
* Query the number of items in a list
* \param list the list
* \returns the number of nodes in the list
*/
int xlist_length (XList * list);
/**
* Query if a list is empty, ie. contains no items
* \param list the list
* \returns 1 if the list is empty, 0 otherwise
*/
int xlist_is_empty (XList * list);
/**
* Query if the list is singleton, ie. contains exactly one item
* \param list the list
* \returns 1 if the list is singleton, 0 otherwise
*/
int xlist_is_singleton (XList * list);
/**
* Free a list, using a given function to free each data element
* \param list the list
* \param free_func a function to free each data element
* \returns NULL on success
*/
XList * xlist_free_with (XList * list, XFreeFunc free_func);
/**
* Free a list, using anx_free() to free each data element
* \param list the list
* \returns NULL on success
*/
XList * xlist_free (XList * list);
#endif /* __XLIST__ */
/*****************************************************************************
* xstrcat.h: strcat with realloc
*****************************************************************************
* Copyright (C) 2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __XSTRCAT_H__
#define __XSTRCAT_H__
# include <string.h>
# include <stdlib.h>
/* like strcat, but realloc's enough memory for the new string too */
static inline
char *xstrcat( char *psz_string, const char *psz_to_append )
{
size_t i_new_string_length = strlen( psz_string ) +
strlen( psz_to_append ) + 1;
psz_string = (char *) realloc( psz_string, i_new_string_length );
return strcat( psz_string, psz_to_append );
}
#endif /* __XSTRCAT_H__ */
This diff is collapsed.
/*****************************************************************************
* xlist.h : a trivial parser for XML-like tags (header file)
*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2000-2004 the VideoLAN team
*
* $Id$
*
* Authors: Conrad Parker <Conrad.Parker@csiro.au>
* Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __XTAG_H__
#define __XTAG_H__
typedef void XTag;
XTag * xtag_new_parse (const char * s, int n);
char * xtag_get_name (XTag * xtag);
char * xtag_get_pcdata (XTag * xtag);
char * xtag_get_attribute (XTag * xtag, const char * attribute);
XTag * xtag_first_child (XTag * xtag, const char * name);
XTag * xtag_next_child (XTag * xtag, char * name);
XTag * xtag_free (XTag * xtag);
int xtag_snprint (char * buf, int n, XTag * xtag);
#endif /* __XTAG_H__ */
This diff is collapsed.
/*****************************************************************************
* xurl.h: URL manipulation functions (header file)
*****************************************************************************
* Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
* Organisation (CSIRO) Australia
* Copyright (C) 2004-2008 the VideoLAN team
*
* $Id$
*
* Authors: Andre Pang <Andre.Pang@csiro.au>
*
* 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.
*****************************************************************************/
#ifndef __XURL_H__
#define __XURL_H__
#include <vlc_common.h>
/* Use DOS/Windows path separators? */
#ifdef WIN32
# define XURL_WIN32_PATHING
#else
# undef XURL_WIN32_PATHING
#endif
/* Debugging */
#undef XURL_DEBUG
char* XURL_Join ( char *psz_url1, char *psz_url2 );
char* XURL_Concat ( char *psz_url, char *psz_append );
bool XURL_IsAbsolute ( char *psz_url );
bool XURL_HasAbsolutePath ( char *psz_url );
bool XURL_IsFileURL ( char *psz_url );
bool XURL_HasFragment ( char *psz_url );
char* XURL_GetHostname ( char *psz_url );
char* XURL_GetSchemeAndHostname ( char *psz_url );
char* XURL_GetScheme ( char *psz_url );
char* XURL_GetPath ( char *psz_url );
char* XURL_GetWithoutFragment ( char *psz_url );
char* XURL_GetHead ( const char *psz_path );
#endif /* __XURL_H__ */
......@@ -372,21 +372,6 @@ modules/codec/avcodec/video.c
modules/codec/cc.c
modules/codec/cc.h
modules/codec/cdg.c
modules/codec/cmml/browser_open.c
modules/codec/cmml/browser_open.h
modules/codec/cmml/cmml.c
modules/codec/cmml/history.c
modules/codec/cmml/history.h
modules/codec/cmml/intf.c
modules/codec/cmml/xarray.c
modules/codec/cmml/xarray.h
modules/codec/cmml/xlist.c
modules/codec/cmml/xlist.h
modules/codec/cmml/xstrcat.h
modules/codec/cmml/xtag.c
modules/codec/cmml/xtag.h
modules/codec/cmml/xurl.c
modules/codec/cmml/xurl.h
modules/codec/cvdsub.c
modules/codec/dirac.c
modules/codec/dmo/buffer.c
......
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