]> git.sesse.net Git - vlc/commitdiff
Merge 0.8.5-api changes
authorClément Stenac <zorglub@videolan.org>
Sun, 8 Jan 2006 16:32:33 +0000 (16:32 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 8 Jan 2006 16:32:33 +0000 (16:32 +0000)
Fix compilation

20 files changed:
Makefile.am
bindings/python/setup.py
bindings/python/vlcglue.h
include/libvlc_internal.h [new file with mode: 0644]
include/mediacontrol_internal.h [moved from include/vlc_control.h with 93% similarity]
include/vlc/libvlc.h [new file with mode: 0644]
include/vlc/mediacontrol.h [moved from include/vlc/control.h with 99% similarity]
include/vlc/mediacontrol_structures.h [moved from include/vlc/control_structures.h with 100% similarity]
include/vlc/vlc.h
include/vlc_common.h
src/control/core.c
src/control/input.c [new file with mode: 0644]
src/control/mediacontrol_audio_video.c [moved from src/control/audio_video.c with 99% similarity]
src/control/mediacontrol_core.c [new file with mode: 0644]
src/control/mediacontrol_init.c [moved from src/control/init.c with 97% similarity]
src/control/mediacontrol_plugin.c [moved from src/control/plugin.c with 88% similarity]
src/control/mediacontrol_util.c [moved from src/control/util.c with 99% similarity]
src/control/playlist.c [new file with mode: 0644]
src/misc/stats.c
test/libvlc_sample.c [new file with mode: 0644]

index d0444d8b29056e64b89ed9bbb61a5cbe552b163d..2d8b005ec9d35d7d00e04e3c939c7b9ebbe8e194 100644 (file)
@@ -63,14 +63,15 @@ pkgincludedir = $(includedir)/vlc
 
 dist_pkginclude_HEADERS = \
        include/vlc/vlc.h \
+       include/vlc/libvlc.h \
        include/vlc/aout.h \
        include/vlc/vout.h \
        include/vlc/sout.h \
        include/vlc/decoder.h \
        include/vlc/input.h \
        include/vlc/intf.h \
-       include/vlc/control.h \
-       include/vlc/control_structures.h \
+       include/vlc/mediacontrol.h \
+       include/vlc/mediacontrol_structures.h \
        $(NULL)
 
 noinst_HEADERS = $(HEADERS_include)
@@ -105,7 +106,6 @@ HEADERS_include = \
        include/vlc_codec.h \
        include/vlc_common.h \
        include/vlc_config.h \
-       include/vlc_control.h \
        include/vlc_cpu.h \
        include/vlc_demux.h \
        include/vlc_error.h \
@@ -137,6 +137,8 @@ HEADERS_include = \
        include/vlc_xml.h \
        include/vout_synchro.h \
        include/win32_specific.h \
+       include/libvlc_internal.h \
+       include/mediacontrol_internal.h
        $(NULL)
 
 src/misc/modules_builtin.h: Makefile src/misc/modules_builtin.h.in vlc-config
@@ -471,12 +473,15 @@ SOURCES_libvlc_common = \
        src/misc/version.c \
        src/extras/libc.c \
        src/control/core.c \
-       src/control/util.c \
-       src/control/audio_video.c \
+       src/control/playlist.c \
+       src/control/input.c \
+       src/control/mediacontrol_core.c \
+       src/control/mediacontrol_util.c \
+       src/control/mediacontrol_audio_video.c \
        $(NULL)
 
 # These should be distributed, but not compiled
-EXTRA_DIST += src/control/init.c src/control/plugin.c
+EXTRA_DIST += src/control/mediacontrol_init.c src/control/mediacontrol_plugin.c
 
 SOURCES_libvlc = \
        $(SOURCES_libvlc_common) \
index 943baba83bdf8aa15382959cf524b64199d68d7d..bf27e42548b65e1e6fb5a0b1a0bb8f337c2103a4 100644 (file)
@@ -48,7 +48,7 @@ def get_ldflags():
 # To compile in a local vlc tree
 vlclocal = Extension('vlc',
                 sources = ['vlcglue.c',
-                           '../../src/control/init.c'],
+                           '../../src/control/mediacontrol_init.c'],
                 include_dirs = ['../../include', '../../', '/usr/win32/include' ],
                 extra_objects = [ '../../lib/libvlc_pic.a' ],
                 extra_compile_args = get_cflags(),
index 61265412e2204860728435c63288daa0019a8a94..f2b719774f4004f09eba13cbe65979ae97fe8ac7 100644 (file)
@@ -29,8 +29,8 @@
 
 #include <stdio.h>
 #include <vlc/vlc.h>
-#include <vlc/control_structures.h>
-#include <vlc/control.h>
+#include <vlc/mediacontrol_structures.h>
+#include <vlc/mediacontrol.h>
 
 #define SELF ((MediaControl*)self)
 
diff --git a/include/libvlc_internal.h b/include/libvlc_internal.h
new file mode 100644 (file)
index 0000000..88d28a2
--- /dev/null
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * libvlc_internal.h : Definition of opaque structures for libvlc exported API
+ * Also contains some internal utility functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id: control_structures.h 13752 2005-12-15 10:14:42Z oaubert $
+ *
+ * Authors: Clément Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef _LIBVLC_INTERNAL_H
+#define _LIBVLC_INTERNAL_H 1
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+#include <vlc/vlc.h>
+
+struct libvlc_instance_t
+{
+    vlc_t *p_vlc;
+    playlist_t *p_playlist;
+    int    i_vlc_id;
+};
+
+struct libvlc_input_t
+{
+    int i_input_id;  ///< Input object id. We don't use a pointer to
+                     /// avoid any crash
+    struct libvlc_instance_t *p_instance; ///< Parent instance
+};
+
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
similarity index 93%
rename from include/vlc_control.h
rename to include/mediacontrol_internal.h
index 070c1b1cc9004ea4431a61bfb570ba1cb82af91c..8297f00557fc47259c38f3dbda1cd69202ff0006 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#ifndef _VLC_PRIVATE_CONTROL_H
-#define _VLC_PRIVATE_CONTROL_H 1
+#ifndef _VLC_MEDIACONTROL_INTERNAL_H
+#define _VLC_MEDIACONTROL_INTERNAL_H 1
 
 # ifdef __cplusplus
 extern "C" {
 # endif
 
 #include <vlc/vlc.h>
-#include "vlc/control_structures.h"
+#include "vlc/mediacontrol_structures.h"
 
 typedef struct {
     vlc_object_t  *p_vlc;
diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
new file mode 100644 (file)
index 0000000..210760c
--- /dev/null
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * libvlc.h:  libvlc_* new external API
+ *****************************************************************************
+ * Copyright (C) 1998-2005 the VideoLAN team
+ * $Id: vlc.h 13701 2005-12-12 17:58:56Z zorglub $
+ *
+ * Authors: Clément Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/**
+ * \defgroup libvlc Libvlc
+ * This is libvlc, the base library of the VLC program.
+ *
+ * @{
+ */
+
+
+#ifndef _LIBVLC_H
+#define _LIBVLC_H 1
+
+#include <vlc/vlc.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/*****************************************************************************
+ * Exception handling
+ *****************************************************************************/
+/** defgroup libvlc_exception Exceptions
+ * \ingroup libvlc
+ * LibVLC Exceptions handling
+ * @{
+ */
+
+struct libvlc_exception_t
+{
+    int b_raised;
+    char *psz_message;
+};
+typedef struct libvlc_exception_t libvlc_exception_t;
+
+/**
+ * Initialize an exception structure. This can be called several times to reuse
+ * an exception structure.
+ * \param p_exception the exception to initialize
+ */
+void libvlc_exception_init( libvlc_exception_t *p_exception );
+
+/**
+ * Has an exception been raised ?
+ * \param p_exception the exception to query
+ * \return 0 if no exception raised, 1 else
+ */
+int libvlc_exception_raised( libvlc_exception_t *p_exception );
+
+/**
+ * Get exception message
+ * \param p_exception the exception to query
+ * \return the exception message or NULL if not applicable (exception not raised
+ * for example)
+ */
+char* libvlc_exception_get_message( libvlc_exception_t *p_exception );
+
+
+
+/** @} */
+
+/*****************************************************************************
+ * Core handling
+ *****************************************************************************/
+
+/** defgroup libvlc_core Core
+ * \ingroup libvlc
+ * LibVLC Core
+ * @{
+ */
+
+/** This structure is opaque. It represents a libvlc instance */
+typedef struct libvlc_instance_t libvlc_instance_t;
+
+/**
+ * Create an initialized libvlc instance
+ * \param argc the number of arguments
+ * \param argv command-line-type arguments
+ * \param exception an initialized exception pointer
+ */
+libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
+
+/**
+ * Destroy a libvlc instance
+ * \param p_instance the instance to destroy
+ */
+void libvlc_destroy( libvlc_instance_t *);
+
+/** @}*/
+
+/*****************************************************************************
+ * Playlist
+ *****************************************************************************/
+/** defgroup libvlc_playlist Playlist
+ * \ingroup libvlc
+ * LibVLC Playlist handling
+ * @{
+ */
+
+/**
+ * Start playing. You can give some additionnal playlist item options
+ * that will be added to the item before playing it.
+ * \param p_instance the instance
+ * \param i_options the number of options to add to the item
+ * \param ppsz_options the options to add to the item
+ * \param p_exception an initialized exception
+ */
+void libvlc_playlist_play( libvlc_instance_t*, int, char **,
+                           libvlc_exception_t * );
+
+typedef struct libvlc_input_t libvlc_input_t;
+
+///\todo document me
+libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *,
+                                           libvlc_exception_t * );
+
+
+
+/** @}*/
+
+/*****************************************************************************
+ * Input
+ *****************************************************************************/
+/** defgroup libvlc_input Input
+ * \ingroup libvlc
+ * LibVLC Input handling
+ * @{
+ */
+
+/** Free an input object
+ * \param p_input the input to free
+ */
+void libvlc_input_free( libvlc_input_t * );
+
+/// \bug This might go away ... to be replaced by a broader system
+vlc_int64_t libvlc_input_get_length( libvlc_input_t *, libvlc_exception_t *);
+vlc_int64_t libvlc_input_get_time( libvlc_input_t *, libvlc_exception_t *);
+float libvlc_input_get_position( libvlc_input_t *, libvlc_exception_t *);
+
+/** @} */
+
+
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif /* <vlc/vlc_control.h> */
similarity index 99%
rename from include/vlc/control.h
rename to include/vlc/mediacontrol.h
index 803ec7db47b8a8b0ad5dcbd6b9c25d9be2092b64..c1f3f5ac5c60b7ec5c509f79f14f03932bffe2ec 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 #define WINDOWHANDLE int
 #endif
 
-#include <vlc/control_structures.h>
+#include <vlc/mediacontrol_structures.h>
 
 /************************************************************************
  * Position Object Manipulation
index ab298417e72aa31ddec0c3d5171aff7200f5a72d..e7667d3f29239c1323c20d3864b881072bd1be77 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * vlc.h: global header for vlc
+ * vlc.h: global header for libvlc (old-style)
  *****************************************************************************
  * Copyright (C) 1998-2004 the VideoLAN team
  * $Id$
@@ -25,8 +25,9 @@
  *****************************************************************************/
 
 /**
- * \defgroup libvlc Libvlc
+ * \defgroup libvlc_old Libvlc Old
  * This is libvlc, the base library of the VLC program.
+ * This is the legacy API. Please consider using the new libvlc API
  *
  * @{
  */
index c3def784f0283d878b5f80ea7a94f1918321e278..79569983c5ed1245cf891b91500ec83d6966aa11 100644 (file)
@@ -419,6 +419,7 @@ typedef struct vlc_meta_t    vlc_meta_t;
 typedef struct counter_t     counter_t;
 typedef struct counter_sample_t counter_sample_t;
 typedef struct stats_handler_t stats_handler_t;
+typedef struct input_stats_t input_stats_t;
 
 
 /*****************************************************************************
index 3e31fc2ebd5c1018382bf3bd22fc42a94de85990..25fa55f79494aaddffbf43ebe8422020c2bcb956 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
- * core.c: Core functions : init, playlist, stream management
+ * core.c: Core libvlc new API functions : initialization, exceptions handling
  *****************************************************************************
  * Copyright (C) 2005 the VideoLAN team
  * $Id$
  *
- * Authors: Olivier Aubert <olivier.aubert@liris.univ-lyon1.fr>
+ * Authors: Clément Stenac <zorglub@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
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <vlc_control.h>
-#include <vlc/control.h>
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
 
 #include <vlc/intf.h>
-#include <vlc/vout.h>
-#include <vlc/aout.h>
-#include <vlc_demux.h>
-
-#include <vlc_osd.h>
-
-#define HAS_SNAPSHOT 1
-
-#ifdef HAS_SNAPSHOT
-#include <snapshot.h>
-#endif
-
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
-
-#include <errno.h>                                                 /* ENOMEM */
-#include <stdio.h>
-#include <ctype.h>
-
-#ifdef HAVE_UNISTD_H
-#    include <unistd.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#    include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#endif
-
-#define RAISE( c, m )  exception->code = c; \
-                       exception->message = strdup(m);
 
 vlc_t * vlc_current_object( int );
 
-mediacontrol_Instance* mediacontrol_new_from_object( int vlc_object_id,
-                                                     mediacontrol_Exception *exception )
-{
-    mediacontrol_Instance* retval;
-    vlc_object_t *p_vlc;
-    vlc_object_t *p_object;
-
-    p_object = ( vlc_object_t* )vlc_current_object( vlc_object_id );
-    if( ! p_object )
-    {
-        RAISE( mediacontrol_InternalException, "Unable to find vlc object" );
-        return NULL;
-    }
-
-    p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT );
-    if( ! p_vlc )
-    {
-        RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );
-        return NULL;
-    }
-    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
-    retval->p_vlc = p_vlc;
-    retval->vlc_object_id = p_vlc->i_object_id;
-
-    /* We can keep references on these, which should not change. Is it true ? */
-    retval->p_playlist = vlc_object_find( p_vlc,
-                                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
-
-    if( ! retval->p_playlist || ! retval->p_intf )
-    {
-        RAISE( mediacontrol_InternalException, "No available interface" );
-        return NULL;
-    }
-    return retval;
-};
-
-
-/**************************************************************************
- * Playback management
- **************************************************************************/
-mediacontrol_Position*
-mediacontrol_get_media_position( mediacontrol_Instance *self,
-                                 const mediacontrol_PositionOrigin an_origin,
-                                 const mediacontrol_PositionKey a_key,
-                                 mediacontrol_Exception *exception )
-{
-    mediacontrol_Position* retval;
-    vlc_value_t val;
-    input_thread_t * p_input = self->p_playlist->p_input;
-
-    exception = mediacontrol_exception_init( exception );
-
-    retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
-    retval->origin = an_origin;
-    retval->key = a_key;
-
-    if( ! p_input )
-    {
-        RAISE( mediacontrol_InternalException, "No input thread." );
-        return NULL;
-    }
-
-    if(  an_origin != mediacontrol_AbsolutePosition )
-    {
-        /* Relative or ModuloPosition make no sense */
-        RAISE( mediacontrol_PositionOriginNotSupported, "Only absolute position is valid." );
-        return NULL;
-    }
-
-    /* We are asked for an AbsolutePosition. */
-    val.i_time = 0;
-    var_Get( p_input, "time", &val );
-    /* FIXME: check val.i_time > 0 */
-
-    retval->value = mediacontrol_unit_convert( p_input,
-                                               mediacontrol_MediaTime,
-                                               a_key,
-                                               val.i_time / 1000 );
-    return retval;
-}
-
-/* Sets the media position */
-void
-mediacontrol_set_media_position( mediacontrol_Instance *self,
-                                 const mediacontrol_Position * a_position,
-                                 mediacontrol_Exception *exception )
-{
-    vlc_value_t val;
-    input_thread_t * p_input = self->p_playlist->p_input;
-
-    exception=mediacontrol_exception_init( exception );
-    if( ! p_input )
-    {
-        RAISE( mediacontrol_InternalException, "No input thread." );
-        return;
-    }
-
-    if( !var_GetBool( p_input, "seekable" ) )
-    {
-        RAISE( mediacontrol_InvalidPosition, "Stream not seekable" );
-        return;
-    }
-
-    val.i_time = mediacontrol_position2microsecond( p_input, a_position );
-    var_Set( p_input, "time", val );
-    return;
-}
-
-/* Starts playing a stream */
-/*
- * Known issues: since moving in the playlist using playlist_Next
- * or playlist_Prev implies starting to play items, the a_position
- * argument will be only honored for the 1st item in the list.
- * 
- * XXX:FIXME split moving in the playlist and playing items two
- * different actions or make playlist_<Next|Prev> accept a time
- * value to start to play from.
- */
-void
-mediacontrol_start( mediacontrol_Instance *self,
-                    const mediacontrol_Position * a_position,
-                    mediacontrol_Exception *exception )
+/*************************************************************************
+ * Exceptions handling
+ *************************************************************************/
+inline void libvlc_exception_init( libvlc_exception_t *p_exception )
 {
-    playlist_t * p_playlist = self->p_playlist;
-
-    exception = mediacontrol_exception_init( exception );
-    if( ! p_playlist )
-    {
-        RAISE( mediacontrol_PlaylistException, "No available playlist" );
-        return;
-    }
-
-    vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_playlist->i_size )
-    {
-        int i_index;
-        int i_from;
-       char * psz_from = ( char * )malloc( 20 * sizeof( char ) );
-
-        i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;
-       
-        i_index = p_playlist->i_index;
-        if( i_index < 0 )
-        { 
-            /* We know that there is at least 1 element, since i_size != 0 */
-            i_index = 0;
-        }
-
-        /* Set start time */
-       snprintf( psz_from, 20, "start-time=%i", i_from );
-       playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from );
-       free( psz_from );
-
-        vlc_mutex_unlock( &p_playlist->object_lock );
-
-        playlist_Play( p_playlist );
-    }
-    else
-    {
-        RAISE( mediacontrol_PlaylistException, "Empty playlist." );
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
-
-    return;
+    p_exception->b_raised = 0;
+    p_exception->psz_message = NULL;
 }
 
-void
-mediacontrol_pause( mediacontrol_Instance *self,
-                    const mediacontrol_Position * a_position,
-                    mediacontrol_Exception *exception )
+inline int libvlc_exception_raised( libvlc_exception_t *p_exception )
 {
-    input_thread_t *p_input = self->p_playlist->p_input;
-
-    /* FIXME: use the a_position parameter */
-    exception=mediacontrol_exception_init( exception );
-    if( p_input != NULL )
-    {
-        var_SetInteger( p_input, "state", PAUSE_S );
-    }
-    else
-    {
-        RAISE( mediacontrol_InternalException, "No input" );
-    }
-
-    return;
+    return p_exception->b_raised;
 }
 
-void
-mediacontrol_resume( mediacontrol_Instance *self,
-                     const mediacontrol_Position * a_position,
-                     mediacontrol_Exception *exception )
+inline char* libvlc_exception_get_message( libvlc_exception_t *p_exception )
 {
-    input_thread_t *p_input = self->p_playlist->p_input;
-
-    /* FIXME: use the a_position parameter */
-    exception=mediacontrol_exception_init( exception );
-    if( p_input != NULL )
+    if( p_exception->b_raised == 1 && p_exception->psz_message )
     {
-        var_SetInteger( p_input, "state", PAUSE_S );
-    }
-    else
-    {
-        RAISE( mediacontrol_InternalException, "No input" );
+        return p_exception->psz_message;
     }
+    return NULL;
 }
 
-void
-mediacontrol_stop( mediacontrol_Instance *self,
-                   const mediacontrol_Position * a_position,
-                   mediacontrol_Exception *exception )
+inline void libvlc_exception_raise( libvlc_exception_t *p_exception,
+                                    char *psz_message )
 {
-    /* FIXME: use the a_position parameter */
-    exception=mediacontrol_exception_init( exception );
-    if( !self->p_playlist )
-    {
-        RAISE( mediacontrol_PlaylistException, "No playlist" );
-        return;
-    }
-
-    playlist_Stop( self->p_playlist );
+    if( p_exception == NULL ) return;
+    p_exception->b_raised = 1;
+    p_exception->psz_message = strdup( psz_message );
 }
 
-/**************************************************************************
- * Playlist management
- **************************************************************************/
-
-void
-mediacontrol_playlist_add_item( mediacontrol_Instance *self,
-                                const char * psz_file,
-                                mediacontrol_Exception *exception )
-{
-    exception=mediacontrol_exception_init( exception );
-    if( !self->p_playlist )
-    {
-        RAISE( mediacontrol_InternalException, "No playlist" );
-        return;
-    }
-
-    playlist_Add( self->p_playlist, psz_file, psz_file , PLAYLIST_INSERT,
-                  PLAYLIST_END );
-}
 
-void
-mediacontrol_playlist_next_item( mediacontrol_Instance *self,
-                                mediacontrol_Exception *exception )
+libvlc_instance_t * libvlc_new( int argc, char **argv,
+                                libvlc_exception_t *p_exception )
 {
-    exception=mediacontrol_exception_init( exception );
-    if ( !self->p_playlist )
-    {
-        RAISE( mediacontrol_InternalException, "No playlist" );
-        return;
-    }
+    int i_vlc_id;
+    libvlc_instance_t *p_new;
+    vlc_t *p_vlc;
 
-    playlist_Next( self->p_playlist );
+    i_vlc_id = VLC_Create();
+    p_vlc = (vlc_t* ) vlc_current_object( i_vlc_id );
 
-    return;
-}
-
-void
-mediacontrol_playlist_clear( mediacontrol_Instance *self,
-                             mediacontrol_Exception *exception )
-{
-    exception=mediacontrol_exception_init( exception );
-    if( !self->p_playlist )
+    if( !p_vlc )
     {
-        RAISE( mediacontrol_PlaylistException, "No playlist" );
-        return;
+        libvlc_exception_raise( p_exception, "VLC initialization failed" );
+        return NULL;
     }
+    p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) );
 
-    playlist_Clear( self->p_playlist );
+    /** \todo Look for interface settings. If we don't have any, add -I dummy */
+    /* Because we probably don't want a GUI by default */
 
-    return;
-}
-
-mediacontrol_PlaylistSeq *
-mediacontrol_playlist_get_list( mediacontrol_Instance *self,
-                                mediacontrol_Exception *exception )
-{
-    mediacontrol_PlaylistSeq *retval;
-    int i_index;
-    playlist_t * p_playlist = self->p_playlist;
-    int i_playlist_size;
-
-    exception=mediacontrol_exception_init( exception );
-    if( !p_playlist )
+    if( !p_new )
     {
-        RAISE( mediacontrol_PlaylistException, "No playlist" );
+        libvlc_exception_raise( p_exception, "Out of memory" );
         return NULL;
     }
 
-    vlc_mutex_lock( &p_playlist->object_lock );
-    i_playlist_size = p_playlist->i_size;
+    VLC_Init( i_vlc_id, argc, argv );
 
-    retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );
+    p_new->p_vlc = p_vlc;
+    p_new->p_playlist = (playlist_t *)vlc_object_find( p_new->p_vlc,
+                                VLC_OBJECT_PLAYLIST, FIND_CHILD );
 
-    for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
+    if( !p_new->p_playlist )
     {
-        retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->input.psz_uri );
+        libvlc_exception_raise( p_exception, "Playlist creation failed" );
+        return NULL;
     }
-    vlc_mutex_unlock( &p_playlist->object_lock );
+    p_new->i_vlc_id = i_vlc_id;
 
-    return retval;
+    return p_new;
 }
 
-/***************************************************************************
- * Status feedback
- ***************************************************************************/
-
-mediacontrol_StreamInformation *
-mediacontrol_get_stream_information( mediacontrol_Instance *self,
-                                     mediacontrol_PositionKey a_key,
-                                     mediacontrol_Exception *exception )
+void libvlc_destroy( libvlc_instance_t *p_instance )
 {
-    mediacontrol_StreamInformation *retval;
-    input_thread_t *p_input = self->p_playlist->p_input;
-    vlc_value_t val;
-
-    retval = ( mediacontrol_StreamInformation* )malloc( sizeof( mediacontrol_StreamInformation ) );
-    if( ! retval )
-    {
-        RAISE( mediacontrol_InternalException, "Out of memory" );
-        return NULL;
-    }
-
-    if( ! p_input )
-    {
-        /* No p_input defined */
-        retval->streamstatus = mediacontrol_UndefinedStatus;
-        retval->url          = strdup( "None" );
-        retval->position     = 0;
-        retval->length       = 0;
-    }
-    else
-    {
-        switch( var_GetInteger( p_input, "state" ) )
-        {
-        case PLAYING_S     :
-            retval->streamstatus = mediacontrol_PlayingStatus;
-            break;
-        case PAUSE_S       :
-            retval->streamstatus = mediacontrol_PauseStatus;
-            break;
-        case INIT_S        :
-            retval->streamstatus = mediacontrol_InitStatus;
-            break;
-        case END_S         :
-            retval->streamstatus = mediacontrol_EndStatus;
-            break;
-        default :
-            retval->streamstatus = mediacontrol_UndefinedStatus;
-            break;
-        }
-
-        retval->url = strdup( p_input->input.p_item->psz_uri );
-
-        /* TIME and LENGTH are in microseconds. We want them in ms */
-        var_Get( p_input, "time", &val);
-        retval->position = val.i_time / 1000;
-
-        var_Get( p_input, "length", &val);
-        retval->length = val.i_time / 1000;
-
-        retval->position = mediacontrol_unit_convert( p_input,
-                                                      mediacontrol_MediaTime, a_key,
-                                                      retval->position );
-        retval->length   = mediacontrol_unit_convert( p_input,
-                                                      mediacontrol_MediaTime, a_key,
-                                                      retval->length );
-    }
-    return retval;
+    if( p_instance->p_playlist )
+        vlc_object_release( p_instance->p_playlist );
+    vlc_object_release( p_instance->p_vlc );
+    VLC_CleanUp( p_instance->i_vlc_id );
+    VLC_Destroy( p_instance->i_vlc_id );
 }
diff --git a/src/control/input.c b/src/control/input.c
new file mode 100644 (file)
index 0000000..eb762e1
--- /dev/null
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * input.c: Libvlc new API input management functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/intf.h>
+
+void libvlc_input_free( libvlc_input_t *p_input )
+{
+    if( p_input )
+        free( p_input );
+}
+
+/**************************************************************************
+ * Getters for stream information
+ **************************************************************************/
+vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
+                             libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                                 p_input->p_instance->p_vlc,
+                                 p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1;
+    }
+    var_Get( p_input_thread, "length", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.i_time / 1000;
+}
+
+vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
+                           libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                                 p_input->p_instance->p_vlc,
+                                 p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1;
+    }
+    var_Get( p_input_thread , "time", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.i_time / 1000;
+}
+
+float libvlc_input_get_position( libvlc_input_t *p_input,
+                                 libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                            p_input->p_instance->p_vlc,
+                            p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1.0;
+    }
+    var_Get( p_input_thread, "position", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.f_float;
+}
similarity index 99%
rename from src/control/audio_video.c
rename to src/control/mediacontrol_audio_video.c
index c2dd457fabc617ee4e16bb307ac42e6cf3b7fcd8..1d0288533d013e5fbcdaf40cbb67cb0f0c10c968 100644 (file)
@@ -21,9 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <vlc_control.h>
+#include <mediacontrol_internal.h>
 
-#include <vlc/control.h>
+#include <vlc/mediacontrol.h>
 
 #include <vlc/intf.h>
 #include <vlc/vout.h>
diff --git a/src/control/mediacontrol_core.c b/src/control/mediacontrol_core.c
new file mode 100644 (file)
index 0000000..6854970
--- /dev/null
@@ -0,0 +1,433 @@
+/*****************************************************************************
+ * core.c: Core functions : init, playlist, stream management
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Olivier Aubert <olivier.aubert@liris.univ-lyon1.fr>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
+
+#include <vlc/intf.h>
+#include <vlc/vout.h>
+#include <vlc/aout.h>
+#include <vlc_demux.h>
+
+#include <vlc_osd.h>
+
+#define HAS_SNAPSHOT 1
+
+#ifdef HAS_SNAPSHOT
+#include <snapshot.h>
+#endif
+
+#include <stdlib.h>                                      /* malloc(), free() */
+#include <string.h>
+
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef HAVE_UNISTD_H
+#    include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#    include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#    include <sys/types.h>
+#endif
+
+#define RAISE( c, m )  exception->code = c; \
+                       exception->message = strdup(m);
+
+vlc_t * vlc_current_object( int );
+
+mediacontrol_Instance* mediacontrol_new_from_object( int vlc_object_id,
+                                                     mediacontrol_Exception *exception )
+{
+    mediacontrol_Instance* retval;
+    vlc_object_t *p_vlc;
+    vlc_object_t *p_object;
+
+    p_object = ( vlc_object_t* )vlc_current_object( vlc_object_id );
+    if( ! p_object )
+    {
+        RAISE( mediacontrol_InternalException, "Unable to find vlc object" );
+        return NULL;
+    }
+
+    p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT );
+    if( ! p_vlc )
+    {
+        RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );
+        return NULL;
+    }
+    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
+    retval->p_vlc = p_vlc;
+    retval->vlc_object_id = p_vlc->i_object_id;
+
+    /* We can keep references on these, which should not change. Is it true ? */
+    retval->p_playlist = vlc_object_find( p_vlc,
+                                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
+
+    if( ! retval->p_playlist || ! retval->p_intf )
+    {
+        RAISE( mediacontrol_InternalException, "No available interface" );
+        return NULL;
+    }
+    return retval;
+};
+
+
+/**************************************************************************
+ * Playback management
+ **************************************************************************/
+mediacontrol_Position*
+mediacontrol_get_media_position( mediacontrol_Instance *self,
+                                 const mediacontrol_PositionOrigin an_origin,
+                                 const mediacontrol_PositionKey a_key,
+                                 mediacontrol_Exception *exception )
+{
+    mediacontrol_Position* retval;
+    vlc_value_t val;
+    input_thread_t * p_input = self->p_playlist->p_input;
+
+    exception = mediacontrol_exception_init( exception );
+
+    retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
+    retval->origin = an_origin;
+    retval->key = a_key;
+
+    if( ! p_input )
+    {
+        RAISE( mediacontrol_InternalException, "No input thread." );
+        return NULL;
+    }
+
+    if(  an_origin != mediacontrol_AbsolutePosition )
+    {
+        /* Relative or ModuloPosition make no sense */
+        RAISE( mediacontrol_PositionOriginNotSupported, "Only absolute position is valid." );
+        return NULL;
+    }
+
+    /* We are asked for an AbsolutePosition. */
+    val.i_time = 0;
+    var_Get( p_input, "time", &val );
+    /* FIXME: check val.i_time > 0 */
+
+    retval->value = mediacontrol_unit_convert( p_input,
+                                               mediacontrol_MediaTime,
+                                               a_key,
+                                               val.i_time / 1000 );
+    return retval;
+}
+
+/* Sets the media position */
+void
+mediacontrol_set_media_position( mediacontrol_Instance *self,
+                                 const mediacontrol_Position * a_position,
+                                 mediacontrol_Exception *exception )
+{
+    vlc_value_t val;
+    input_thread_t * p_input = self->p_playlist->p_input;
+
+    exception=mediacontrol_exception_init( exception );
+    if( ! p_input )
+    {
+        RAISE( mediacontrol_InternalException, "No input thread." );
+        return;
+    }
+
+    if( !var_GetBool( p_input, "seekable" ) )
+    {
+        RAISE( mediacontrol_InvalidPosition, "Stream not seekable" );
+        return;
+    }
+
+    val.i_time = mediacontrol_position2microsecond( p_input, a_position );
+    var_Set( p_input, "time", val );
+    return;
+}
+
+/* Starts playing a stream */
+/*
+ * Known issues: since moving in the playlist using playlist_Next
+ * or playlist_Prev implies starting to play items, the a_position
+ * argument will be only honored for the 1st item in the list.
+ * 
+ * XXX:FIXME split moving in the playlist and playing items two
+ * different actions or make playlist_<Next|Prev> accept a time
+ * value to start to play from.
+ */
+void
+mediacontrol_start( mediacontrol_Instance *self,
+                    const mediacontrol_Position * a_position,
+                    mediacontrol_Exception *exception )
+{
+    playlist_t * p_playlist = self->p_playlist;
+
+    exception = mediacontrol_exception_init( exception );
+    if( ! p_playlist )
+    {
+        RAISE( mediacontrol_PlaylistException, "No available playlist" );
+        return;
+    }
+
+    vlc_mutex_lock( &p_playlist->object_lock );
+    if( p_playlist->i_size )
+    {
+        int i_index;
+        int i_from;
+       char * psz_from = ( char * )malloc( 20 * sizeof( char ) );
+
+        i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;
+       
+        i_index = p_playlist->i_index;
+        if( i_index < 0 )
+        { 
+            /* We know that there is at least 1 element, since i_size != 0 */
+            i_index = 0;
+        }
+
+        /* Set start time */
+       snprintf( psz_from, 20, "start-time=%i", i_from );
+       playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from );
+       free( psz_from );
+
+        vlc_mutex_unlock( &p_playlist->object_lock );
+
+        playlist_Play( p_playlist );
+    }
+    else
+    {
+        RAISE( mediacontrol_PlaylistException, "Empty playlist." );
+        vlc_mutex_unlock( &p_playlist->object_lock );
+    }
+
+    return;
+}
+
+void
+mediacontrol_pause( mediacontrol_Instance *self,
+                    const mediacontrol_Position * a_position,
+                    mediacontrol_Exception *exception )
+{
+    input_thread_t *p_input = self->p_playlist->p_input;
+
+    /* FIXME: use the a_position parameter */
+    exception=mediacontrol_exception_init( exception );
+    if( p_input != NULL )
+    {
+        var_SetInteger( p_input, "state", PAUSE_S );
+    }
+    else
+    {
+        RAISE( mediacontrol_InternalException, "No input" );
+    }
+
+    return;
+}
+
+void
+mediacontrol_resume( mediacontrol_Instance *self,
+                     const mediacontrol_Position * a_position,
+                     mediacontrol_Exception *exception )
+{
+    input_thread_t *p_input = self->p_playlist->p_input;
+
+    /* FIXME: use the a_position parameter */
+    exception=mediacontrol_exception_init( exception );
+    if( p_input != NULL )
+    {
+        var_SetInteger( p_input, "state", PAUSE_S );
+    }
+    else
+    {
+        RAISE( mediacontrol_InternalException, "No input" );
+    }
+}
+
+void
+mediacontrol_stop( mediacontrol_Instance *self,
+                   const mediacontrol_Position * a_position,
+                   mediacontrol_Exception *exception )
+{
+    /* FIXME: use the a_position parameter */
+    exception=mediacontrol_exception_init( exception );
+    if( !self->p_playlist )
+    {
+        RAISE( mediacontrol_PlaylistException, "No playlist" );
+        return;
+    }
+
+    playlist_Stop( self->p_playlist );
+}
+
+/**************************************************************************
+ * Playlist management
+ **************************************************************************/
+
+void
+mediacontrol_playlist_add_item( mediacontrol_Instance *self,
+                                const char * psz_file,
+                                mediacontrol_Exception *exception )
+{
+    exception=mediacontrol_exception_init( exception );
+    if( !self->p_playlist )
+    {
+        RAISE( mediacontrol_InternalException, "No playlist" );
+        return;
+    }
+
+    playlist_Add( self->p_playlist, psz_file, psz_file , PLAYLIST_INSERT,
+                  PLAYLIST_END );
+}
+
+void
+mediacontrol_playlist_next_item( mediacontrol_Instance *self,
+                                mediacontrol_Exception *exception )
+{
+    exception=mediacontrol_exception_init( exception );
+    if ( !self->p_playlist )
+    {
+        RAISE( mediacontrol_InternalException, "No playlist" );
+        return;
+    }
+
+    playlist_Next( self->p_playlist );
+
+    return;
+}
+
+void
+mediacontrol_playlist_clear( mediacontrol_Instance *self,
+                             mediacontrol_Exception *exception )
+{
+    exception=mediacontrol_exception_init( exception );
+    if( !self->p_playlist )
+    {
+        RAISE( mediacontrol_PlaylistException, "No playlist" );
+        return;
+    }
+
+    playlist_Clear( self->p_playlist );
+
+    return;
+}
+
+mediacontrol_PlaylistSeq *
+mediacontrol_playlist_get_list( mediacontrol_Instance *self,
+                                mediacontrol_Exception *exception )
+{
+    mediacontrol_PlaylistSeq *retval;
+    int i_index;
+    playlist_t * p_playlist = self->p_playlist;
+    int i_playlist_size;
+
+    exception=mediacontrol_exception_init( exception );
+    if( !p_playlist )
+    {
+        RAISE( mediacontrol_PlaylistException, "No playlist" );
+        return NULL;
+    }
+
+    vlc_mutex_lock( &p_playlist->object_lock );
+    i_playlist_size = p_playlist->i_size;
+
+    retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );
+
+    for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
+    {
+        retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->input.psz_uri );
+    }
+    vlc_mutex_unlock( &p_playlist->object_lock );
+
+    return retval;
+}
+
+/***************************************************************************
+ * Status feedback
+ ***************************************************************************/
+
+mediacontrol_StreamInformation *
+mediacontrol_get_stream_information( mediacontrol_Instance *self,
+                                     mediacontrol_PositionKey a_key,
+                                     mediacontrol_Exception *exception )
+{
+    mediacontrol_StreamInformation *retval;
+    input_thread_t *p_input = self->p_playlist->p_input;
+    vlc_value_t val;
+
+    retval = ( mediacontrol_StreamInformation* )malloc( sizeof( mediacontrol_StreamInformation ) );
+    if( ! retval )
+    {
+        RAISE( mediacontrol_InternalException, "Out of memory" );
+        return NULL;
+    }
+
+    if( ! p_input )
+    {
+        /* No p_input defined */
+        retval->streamstatus = mediacontrol_UndefinedStatus;
+        retval->url          = strdup( "None" );
+        retval->position     = 0;
+        retval->length       = 0;
+    }
+    else
+    {
+        switch( var_GetInteger( p_input, "state" ) )
+        {
+        case PLAYING_S     :
+            retval->streamstatus = mediacontrol_PlayingStatus;
+            break;
+        case PAUSE_S       :
+            retval->streamstatus = mediacontrol_PauseStatus;
+            break;
+        case INIT_S        :
+            retval->streamstatus = mediacontrol_InitStatus;
+            break;
+        case END_S         :
+            retval->streamstatus = mediacontrol_EndStatus;
+            break;
+        default :
+            retval->streamstatus = mediacontrol_UndefinedStatus;
+            break;
+        }
+
+        retval->url = strdup( p_input->input.p_item->psz_uri );
+
+        /* TIME and LENGTH are in microseconds. We want them in ms */
+        var_Get( p_input, "time", &val);
+        retval->position = val.i_time / 1000;
+
+        var_Get( p_input, "length", &val);
+        retval->length = val.i_time / 1000;
+
+        retval->position = mediacontrol_unit_convert( p_input,
+                                                      mediacontrol_MediaTime, a_key,
+                                                      retval->position );
+        retval->length   = mediacontrol_unit_convert( p_input,
+                                                      mediacontrol_MediaTime, a_key,
+                                                      retval->length );
+    }
+    return retval;
+}
similarity index 97%
rename from src/control/init.c
rename to src/control/mediacontrol_init.c
index 0cdb3ab4ecfb7ca76db9e9a98dcdb87249554825..a9108e54b8de5e6662a2dc097f5cd64fd1ffbf9d 100644 (file)
@@ -1,6 +1,6 @@
 #define __VLC__
-#include <vlc_control.h>
-#include <vlc/control.h>
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
 
 mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
 {
similarity index 88%
rename from src/control/plugin.c
rename to src/control/mediacontrol_plugin.c
index 85c6a938fb315669696339b4e4a51f41b3a94746..fa731b23d35d08ebbc2cca1be5bf564529c9ec8a 100644 (file)
@@ -1,5 +1,5 @@
-#include <vlc_control.h>
-#include <vlc/control.h>
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
 #include <vlc/intf.h>
 
 mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
similarity index 99%
rename from src/control/util.c
rename to src/control/mediacontrol_util.c
index e2d2d21c2777a9e5e7e6c86b812da24e33ac0fee..eba2d4cf29a09f949b9eae2fc08e82c7e536c364 100644 (file)
@@ -21,8 +21,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <vlc_control.h>
-#include <vlc/control.h>
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
 
 #include <vlc/intf.h>
 #include <vlc/vout.h>
diff --git a/src/control/playlist.c b/src/control/playlist.c
new file mode 100644 (file)
index 0000000..db597b6
--- /dev/null
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * playlist.c: libvlc new API playlist handling functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/intf.h>
+
+void libvlc_playlist_play( libvlc_instance_t *p_instance,
+                           int i_options, char **ppsz_options,
+                           libvlc_exception_t *p_exception )
+{
+    ///\todo Handle additionnal options
+
+    if( p_instance->p_playlist->i_size == 0 )
+    {
+        libvlc_exception_raise( p_exception, "Empty playlist" );
+        return;
+    }
+    playlist_Play( p_instance->p_playlist );
+}
+
+libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
+                                            libvlc_exception_t *p_exception )
+{
+    libvlc_input_t *p_input;
+
+    vlc_mutex_lock( &p_instance->p_playlist->object_lock );
+    if( p_instance->p_playlist->p_input == NULL )
+    {
+        libvlc_exception_raise( p_exception, "No active input" );
+        vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+        return;
+    }
+    p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
+
+    p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
+    p_input->p_instance = p_instance;
+    vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+
+    return p_input;
+}
index 0daa6cc21309f1d0c45ef1d0250383bf400d8153..433f7a6d6b126a95fdbcc17b94499e55394e6460 100644 (file)
@@ -96,7 +96,7 @@ static int stats_CounterUpdate( stats_handler_t *p_handler,
     {
     case STATS_LAST:
     case STATS_MIN:
-    case STATS_LAST:
+    case STATS_MAX:
         if( p_counter->i_samples > 1)
         {
             msg_Err( p_handler, "LAST counter has several samples !" );
@@ -249,7 +249,7 @@ void stats_ComputeInputStats( input_thread_t *p_input,
 {
     int i;
     /* read_packets and read_bytes are common to all streams */
-    p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );
-    p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );
+    //p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );
+    // p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );
 
 }
diff --git a/test/libvlc_sample.c b/test/libvlc_sample.c
new file mode 100644 (file)
index 0000000..4455c21
--- /dev/null
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <time.h>
+#include <vlc/libvlc.h>
+
+int main(int argc, char **argv)
+{
+    libvlc_instance_t *p_instance1;
+    libvlc_exception_t exception;
+    libvlc_input_t    *p_input;
+    int b_started = 0;
+
+    libvlc_exception_init( &exception );
+    
+    p_instance1 = libvlc_new( argc,argv, &exception );
+
+    if( libvlc_exception_raised( &exception ) )
+    {
+        fprintf( stderr, "FATAL: %s\n",
+                        libvlc_exception_get_message( &exception ) );
+        return 0; 
+    }
+
+    libvlc_playlist_play( p_instance1, 0,NULL, NULL );
+
+    while( 1 )
+    {
+        sleep( 1 );
+        libvlc_exception_init( &exception );
+        p_input = libvlc_playlist_get_input( p_instance1, &exception );
+
+        if( libvlc_exception_raised( &exception ) )
+        {
+           if( b_started == 1 )
+               break;
+           else
+               continue;
+        }
+        else
+        {
+            b_started = 1;
+        }
+        
+        fprintf( stderr, "Length %lli - Time %lli\n", 
+                              libvlc_input_get_length( p_input, NULL ),
+                              libvlc_input_get_time( p_input, NULL ) );
+        libvlc_input_free( p_input );
+    }
+
+    libvlc_destroy( p_instance1 );
+       
+    return 0;
+}