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

27 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 [new file with mode: 0644]
include/vlc/control.h [deleted file]
include/vlc/control_structures.h [deleted file]
include/vlc/libvlc.h [new file with mode: 0644]
include/vlc/mediacontrol.h [new file with mode: 0644]
include/vlc/mediacontrol_structures.h [new file with mode: 0644]
include/vlc/vlc.h
include/vlc_common.h
include/vlc_control.h [deleted file]
src/control/audio_video.c [deleted file]
src/control/core.c
src/control/init.c [deleted file]
src/control/input.c [new file with mode: 0644]
src/control/mediacontrol_audio_video.c [new file with mode: 0644]
src/control/mediacontrol_core.c [new file with mode: 0644]
src/control/mediacontrol_init.c [new file with mode: 0644]
src/control/mediacontrol_plugin.c [new file with mode: 0644]
src/control/mediacontrol_util.c [new file with mode: 0644]
src/control/playlist.c [new file with mode: 0644]
src/control/plugin.c [deleted file]
src/control/util.c [deleted file]
src/misc/stats.c
test/libvlc_sample.c [new file with mode: 0644]

index d0444d8..2d8b005 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 943baba..bf27e42 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 6126541..f2b7197 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
diff --git a/include/mediacontrol_internal.h b/include/mediacontrol_internal.h
new file mode 100644 (file)
index 0000000..8297f00
--- /dev/null
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * control.h: private header for mediacontrol
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id: vlc.h 10101 2005-03-02 16:47:31Z robux4 $
+ *
+ * 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.
+ *****************************************************************************/
+
+#ifndef _VLC_MEDIACONTROL_INTERNAL_H
+#define _VLC_MEDIACONTROL_INTERNAL_H 1
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+#include <vlc/vlc.h>
+#include "vlc/mediacontrol_structures.h"
+
+typedef struct {
+    vlc_object_t  *p_vlc;
+    playlist_t    *p_playlist;
+    intf_thread_t *p_intf;
+    int           vlc_object_id;
+} mediacontrol_Instance;
+
+vlc_int64_t mediacontrol_unit_convert( input_thread_t *p_input,
+                                       mediacontrol_PositionKey from,
+                                       mediacontrol_PositionKey to,
+                                       vlc_int64_t value );
+vlc_int64_t mediacontrol_position2microsecond(
+    input_thread_t *p_input,
+    const mediacontrol_Position *pos );
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
diff --git a/include/vlc/control.h b/include/vlc/control.h
deleted file mode 100644 (file)
index 803ec7d..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*****************************************************************************
- * control.h: global header for mediacontrol
- *****************************************************************************
- * 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.
- *****************************************************************************/
-
-#ifndef _VLC_CONTROL_H
-#define _VLC_CONTROL_H 1
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-#if defined( WIN32 )
-#define WINDOWHANDLE HWND
-#else
-#define WINDOWHANDLE int
-#endif
-
-#include <vlc/control_structures.h>
-
-/************************************************************************
- * Position Object Manipulation
- *************************************************************************/
-
-typedef struct {
-    int  width;
-    int  height;
-    long type;
-    vlc_int64_t date;
-    int  size;
-    char *data;
-} mediacontrol_RGBPicture;
-
-typedef struct {
-    int size;
-    char **data;
-} mediacontrol_PlaylistSeq;
-
-typedef struct {
-    int code;
-    char *message;
-} mediacontrol_Exception;
-
-/* Exception codes */
-#define mediacontrol_PositionKeyNotSupported    1
-#define mediacontrol_PositionOriginNotSupported 2
-#define mediacontrol_InvalidPosition            3
-#define mediacontrol_PlaylistException          4
-#define mediacontrol_InternalException          5
-
-typedef mediacontrol_Instance;
-
-/* Cf stream_control.h */
-enum mediacontrol_PlayerStatusList
-{
-    mediacontrol_PlayingStatus, mediacontrol_PauseStatus,
-    mediacontrol_ForwardStatus, mediacontrol_BackwardStatus,
-    mediacontrol_InitStatus,    mediacontrol_EndStatus,
-    mediacontrol_UndefinedStatus
-};
-typedef enum mediacontrol_PlayerStatusList mediacontrol_PlayerStatus;
-
-typedef struct {
-    mediacontrol_PlayerStatus streamstatus;
-    char *url;         /* The URL of the current media stream */
-    vlc_int64_t position;     /* actual location in the stream (in ms) */
-    vlc_int64_t length;         /* total length of the stream (in ms) */
-} mediacontrol_StreamInformation;
-
-/**************************************************************************
- *  Helper functions
- ***************************************************************************/
-
-mediacontrol_RGBPicture *mediacontrol_RGBPicture__alloc( int datasize );
-
-void mediacontrol_RGBPicture__free( mediacontrol_RGBPicture *pic );
-
-mediacontrol_RGBPicture *
-  _mediacontrol_createRGBPicture( int, int, long, vlc_int64_t l_date,
-                                  char *, int);
-
-mediacontrol_PlaylistSeq *mediacontrol_PlaylistSeq__alloc( int size );
-
-void mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq *ps );
-
-mediacontrol_Exception *
-  mediacontrol_exception_init( mediacontrol_Exception *exception );
-
-void mediacontrol_exception_free(mediacontrol_Exception *exception);
-
-/*****************************************************************************
- * Core functions
- *****************************************************************************/
-mediacontrol_Instance *
-  mediacontrol_new( char **args, mediacontrol_Exception *exception );
-
-mediacontrol_Instance *
-  mediacontrol_new_from_object( int vlc_object_id,
-                                mediacontrol_Exception *exception );
-
-mediacontrol_Position * mediacontrol_get_media_position(
-                         mediacontrol_Instance *self,
-                         const mediacontrol_PositionOrigin an_origin,
-                         const mediacontrol_PositionKey a_key,
-                         mediacontrol_Exception *exception );
-
-void mediacontrol_set_media_position( mediacontrol_Instance *self,
-                                      const mediacontrol_Position *a_position,
-                                      mediacontrol_Exception *exception );
-
-void mediacontrol_start( mediacontrol_Instance *self,
-                         const mediacontrol_Position *a_position,
-                         mediacontrol_Exception *exception );
-
-void mediacontrol_pause( mediacontrol_Instance *self,
-                         const mediacontrol_Position *a_position,
-                         mediacontrol_Exception *exception );
-
-void mediacontrol_resume( mediacontrol_Instance *self,
-                          const mediacontrol_Position *a_position,
-                          mediacontrol_Exception *exception );
-
-void mediacontrol_stop( mediacontrol_Instance *self,
-                        const mediacontrol_Position *a_position,
-                        mediacontrol_Exception *exception );
-
-void mediacontrol_exit( mediacontrol_Instance *self );
-
-void mediacontrol_playlist_add_item( mediacontrol_Instance *self,
-                                     const char* psz_file,
-                                     mediacontrol_Exception *exception );
-void mediacontrol_playlist_clear( mediacontrol_Instance *self,
-                                  mediacontrol_Exception *exception );
-mediacontrol_PlaylistSeq *
-  mediacontrol_playlist_get_list( mediacontrol_Instance *self,
-                                  mediacontrol_Exception *exception );
-
-
-/*****************************************************************************
- * A/V functions
- *****************************************************************************/
-mediacontrol_RGBPicture *
-  mediacontrol_snapshot( mediacontrol_Instance *self,
-                         const mediacontrol_Position *a_position,
-                         mediacontrol_Exception *exception );
-
-/* Return a NULL terminated list */
-mediacontrol_RGBPicture **
-  mediacontrol_all_snapshots( mediacontrol_Instance *self,
-                              mediacontrol_Exception *exception );
-
-/* Displays the message string, between "begin" and "end" positions */
-void mediacontrol_display_text( mediacontrol_Instance *self,
-                                const char *message,
-                                const mediacontrol_Position *begin,
-                                const mediacontrol_Position *end,
-                                mediacontrol_Exception *exception );
-
-mediacontrol_StreamInformation *
-  mediacontrol_get_stream_information( mediacontrol_Instance *self,
-                                       mediacontrol_PositionKey a_key,
-                                       mediacontrol_Exception *exception );
-
-unsigned short
-  mediacontrol_sound_get_volume( mediacontrol_Instance *self,
-                                 mediacontrol_Exception *exception );
-void mediacontrol_sound_set_volume( mediacontrol_Instance *self,
-                                    const unsigned short volume,
-                                    mediacontrol_Exception *exception );
-
-vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
-                                    WINDOWHANDLE visual_id,
-                                    mediacontrol_Exception *exception );
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
diff --git a/include/vlc/control_structures.h b/include/vlc/control_structures.h
deleted file mode 100644 (file)
index aea153c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
- * control_structures.h: global header for mediacontrol
- *****************************************************************************
- * 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.
- *****************************************************************************/
-
-#ifndef _VLC_CONTROL_STRUCTURES_H
-#define _VLC_CONTROL_STRUCTURES_H 1
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-typedef enum  {
-    mediacontrol_AbsolutePosition,
-    mediacontrol_RelativePosition,
-    mediacontrol_ModuloPosition
-} mediacontrol_PositionOrigin;
-
-typedef enum {
-    mediacontrol_ByteCount,
-    mediacontrol_SampleCount,
-    mediacontrol_MediaTime
-} mediacontrol_PositionKey;
-
-typedef struct {
-    mediacontrol_PositionOrigin origin;
-    mediacontrol_PositionKey key;
-    long value;
-} mediacontrol_Position;
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
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> */
diff --git a/include/vlc/mediacontrol.h b/include/vlc/mediacontrol.h
new file mode 100644 (file)
index 0000000..c1f3f5a
--- /dev/null
@@ -0,0 +1,197 @@
+/*****************************************************************************
+ * control.h: global header for mediacontrol
+ *****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+#ifndef _VLC_CONTROL_H
+#define _VLC_CONTROL_H 1
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+#if defined( WIN32 )
+#define WINDOWHANDLE HWND
+#else
+#define WINDOWHANDLE int
+#endif
+
+#include <vlc/mediacontrol_structures.h>
+
+/************************************************************************
+ * Position Object Manipulation
+ *************************************************************************/
+
+typedef struct {
+    int  width;
+    int  height;
+    long type;
+    vlc_int64_t date;
+    int  size;
+    char *data;
+} mediacontrol_RGBPicture;
+
+typedef struct {
+    int size;
+    char **data;
+} mediacontrol_PlaylistSeq;
+
+typedef struct {
+    int code;
+    char *message;
+} mediacontrol_Exception;
+
+/* Exception codes */
+#define mediacontrol_PositionKeyNotSupported    1
+#define mediacontrol_PositionOriginNotSupported 2
+#define mediacontrol_InvalidPosition            3
+#define mediacontrol_PlaylistException          4
+#define mediacontrol_InternalException          5
+
+typedef mediacontrol_Instance;
+
+/* Cf stream_control.h */
+enum mediacontrol_PlayerStatusList
+{
+    mediacontrol_PlayingStatus, mediacontrol_PauseStatus,
+    mediacontrol_ForwardStatus, mediacontrol_BackwardStatus,
+    mediacontrol_InitStatus,    mediacontrol_EndStatus,
+    mediacontrol_UndefinedStatus
+};
+typedef enum mediacontrol_PlayerStatusList mediacontrol_PlayerStatus;
+
+typedef struct {
+    mediacontrol_PlayerStatus streamstatus;
+    char *url;         /* The URL of the current media stream */
+    vlc_int64_t position;     /* actual location in the stream (in ms) */
+    vlc_int64_t length;         /* total length of the stream (in ms) */
+} mediacontrol_StreamInformation;
+
+/**************************************************************************
+ *  Helper functions
+ ***************************************************************************/
+
+mediacontrol_RGBPicture *mediacontrol_RGBPicture__alloc( int datasize );
+
+void mediacontrol_RGBPicture__free( mediacontrol_RGBPicture *pic );
+
+mediacontrol_RGBPicture *
+  _mediacontrol_createRGBPicture( int, int, long, vlc_int64_t l_date,
+                                  char *, int);
+
+mediacontrol_PlaylistSeq *mediacontrol_PlaylistSeq__alloc( int size );
+
+void mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq *ps );
+
+mediacontrol_Exception *
+  mediacontrol_exception_init( mediacontrol_Exception *exception );
+
+void mediacontrol_exception_free(mediacontrol_Exception *exception);
+
+/*****************************************************************************
+ * Core functions
+ *****************************************************************************/
+mediacontrol_Instance *
+  mediacontrol_new( char **args, mediacontrol_Exception *exception );
+
+mediacontrol_Instance *
+  mediacontrol_new_from_object( int vlc_object_id,
+                                mediacontrol_Exception *exception );
+
+mediacontrol_Position * mediacontrol_get_media_position(
+                         mediacontrol_Instance *self,
+                         const mediacontrol_PositionOrigin an_origin,
+                         const mediacontrol_PositionKey a_key,
+                         mediacontrol_Exception *exception );
+
+void mediacontrol_set_media_position( mediacontrol_Instance *self,
+                                      const mediacontrol_Position *a_position,
+                                      mediacontrol_Exception *exception );
+
+void mediacontrol_start( mediacontrol_Instance *self,
+                         const mediacontrol_Position *a_position,
+                         mediacontrol_Exception *exception );
+
+void mediacontrol_pause( mediacontrol_Instance *self,
+                         const mediacontrol_Position *a_position,
+                         mediacontrol_Exception *exception );
+
+void mediacontrol_resume( mediacontrol_Instance *self,
+                          const mediacontrol_Position *a_position,
+                          mediacontrol_Exception *exception );
+
+void mediacontrol_stop( mediacontrol_Instance *self,
+                        const mediacontrol_Position *a_position,
+                        mediacontrol_Exception *exception );
+
+void mediacontrol_exit( mediacontrol_Instance *self );
+
+void mediacontrol_playlist_add_item( mediacontrol_Instance *self,
+                                     const char* psz_file,
+                                     mediacontrol_Exception *exception );
+void mediacontrol_playlist_clear( mediacontrol_Instance *self,
+                                  mediacontrol_Exception *exception );
+mediacontrol_PlaylistSeq *
+  mediacontrol_playlist_get_list( mediacontrol_Instance *self,
+                                  mediacontrol_Exception *exception );
+
+
+/*****************************************************************************
+ * A/V functions
+ *****************************************************************************/
+mediacontrol_RGBPicture *
+  mediacontrol_snapshot( mediacontrol_Instance *self,
+                         const mediacontrol_Position *a_position,
+                         mediacontrol_Exception *exception );
+
+/* Return a NULL terminated list */
+mediacontrol_RGBPicture **
+  mediacontrol_all_snapshots( mediacontrol_Instance *self,
+                              mediacontrol_Exception *exception );
+
+/* Displays the message string, between "begin" and "end" positions */
+void mediacontrol_display_text( mediacontrol_Instance *self,
+                                const char *message,
+                                const mediacontrol_Position *begin,
+                                const mediacontrol_Position *end,
+                                mediacontrol_Exception *exception );
+
+mediacontrol_StreamInformation *
+  mediacontrol_get_stream_information( mediacontrol_Instance *self,
+                                       mediacontrol_PositionKey a_key,
+                                       mediacontrol_Exception *exception );
+
+unsigned short
+  mediacontrol_sound_get_volume( mediacontrol_Instance *self,
+                                 mediacontrol_Exception *exception );
+void mediacontrol_sound_set_volume( mediacontrol_Instance *self,
+                                    const unsigned short volume,
+                                    mediacontrol_Exception *exception );
+
+vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
+                                    WINDOWHANDLE visual_id,
+                                    mediacontrol_Exception *exception );
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
diff --git a/include/vlc/mediacontrol_structures.h b/include/vlc/mediacontrol_structures.h
new file mode 100644 (file)
index 0000000..aea153c
--- /dev/null
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * control_structures.h: global header for mediacontrol
+ *****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+#ifndef _VLC_CONTROL_STRUCTURES_H
+#define _VLC_CONTROL_STRUCTURES_H 1
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+typedef enum  {
+    mediacontrol_AbsolutePosition,
+    mediacontrol_RelativePosition,
+    mediacontrol_ModuloPosition
+} mediacontrol_PositionOrigin;
+
+typedef enum {
+    mediacontrol_ByteCount,
+    mediacontrol_SampleCount,
+    mediacontrol_MediaTime
+} mediacontrol_PositionKey;
+
+typedef struct {
+    mediacontrol_PositionOrigin origin;
+    mediacontrol_PositionKey key;
+    long value;
+} mediacontrol_Position;
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
index ab29841..e7667d3 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 c3def78..7956998 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;
 
 
 /*****************************************************************************
diff --git a/include/vlc_control.h b/include/vlc_control.h
deleted file mode 100644 (file)
index 070c1b1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
- * control.h: private header for mediacontrol
- *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
- * $Id: vlc.h 10101 2005-03-02 16:47:31Z robux4 $
- *
- * 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.
- *****************************************************************************/
-
-#ifndef _VLC_PRIVATE_CONTROL_H
-#define _VLC_PRIVATE_CONTROL_H 1
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-#include <vlc/vlc.h>
-#include "vlc/control_structures.h"
-
-typedef struct {
-    vlc_object_t  *p_vlc;
-    playlist_t    *p_playlist;
-    intf_thread_t *p_intf;
-    int           vlc_object_id;
-} mediacontrol_Instance;
-
-vlc_int64_t mediacontrol_unit_convert( input_thread_t *p_input,
-                                       mediacontrol_PositionKey from,
-                                       mediacontrol_PositionKey to,
-                                       vlc_int64_t value );
-vlc_int64_t mediacontrol_position2microsecond(
-    input_thread_t *p_input,
-    const mediacontrol_Position *pos );
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
diff --git a/src/control/audio_video.c b/src/control/audio_video.c
deleted file mode 100644 (file)
index c2dd457..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-/*****************************************************************************
- * audio_video.c: Audio/Video management : volume, snapshot, OSD
- *****************************************************************************
- * 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 <vlc_control.h>
-
-#include <vlc/control.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);
-
-mediacontrol_RGBPicture *
-mediacontrol_snapshot( mediacontrol_Instance *self,
-                       const mediacontrol_Position * a_position,
-                       mediacontrol_Exception *exception )
-{
-    mediacontrol_RGBPicture *retval = NULL;
-    input_thread_t* p_input = self->p_playlist->p_input;
-    vout_thread_t *p_vout = NULL;
-    int i_datasize;
-    snapshot_t **pointer;
-    vlc_value_t val;
-    int i_index;
-    snapshot_t *p_best_snapshot;
-    long searched_date;
-#ifdef HAS_SNAPSHOT
-    int i_cachesize;
-#endif
-
-    exception=mediacontrol_exception_init( exception );
-
-    /*
-       if( var_Get( self->p_vlc, "snapshot-id", &val ) == VLC_SUCCESS )
-       p_vout = vlc_object_get( self->p_vlc, val.i_int );
-    */
-
-    /* FIXME: if in p_libvlc, we cannot have multiple video outputs */
-    /* Once corrected, search for snapshot-id to modify all instances */
-    if( var_Get( p_input, "snapshot-id", &val ) != VLC_SUCCESS )
-    {
-        RAISE( mediacontrol_InternalException, "No snapshot-id in p_input" );
-        return NULL;
-    }
-    p_vout = vlc_object_get( self->p_vlc, val.i_int );
-
-    if( ! p_vout )
-    {
-        RAISE( mediacontrol_InternalException, "No snapshot module" );
-        return NULL;
-    }
-
-#ifdef HAS_SNAPSHOT
-    /* We test if the vout is a snapshot module. We cannot test
-       pvout_psz_object_name( which is NULL ). But we can check if
-       there are snapshot-specific variables */
-    if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
-    {
-        RAISE( mediacontrol_InternalException, "No snapshot module" );
-        vlc_object_release( p_vout );
-        return NULL;
-    }
-    i_datasize = val.i_int;
-
-    /* Handle the a_position parameter */
-    if( ! ( a_position->origin == mediacontrol_RelativePosition
-            && a_position->value == 0 ) )
-    {
-        /* The position is not the current one. Go to it. */
-        mediacontrol_set_media_position( self,
-                                         ( mediacontrol_Position* ) a_position,
-                                         exception );
-        if( exception->code )
-        {
-            vlc_object_release( p_vout );
-            return NULL;
-        }
-    }
-
-    /* FIXME: We should not go further until we got past the position
-       ( which means that we had the possibility to capture the right
-       picture ). */
-
-    vlc_mutex_lock( &p_vout->picture_lock );
-
-    searched_date = mediacontrol_position2microsecond( p_input,
-                                                       ( mediacontrol_Position * ) a_position );
-
-    var_Get( p_vout, "snapshot-cache-size", &val );
-    i_cachesize = val.i_int  ;
-
-    var_Get( p_vout, "snapshot-list-pointer", &val );
-    pointer = ( snapshot_t ** )val.p_address;
-
-    if( ! pointer )
-    {
-        RAISE( mediacontrol_InternalException, "No available snapshot" );
-
-        vlc_mutex_unlock( &p_vout->picture_lock );
-        vlc_object_release( p_vout );
-        return NULL;
-    }
-
-    /* Find the more appropriate picture, based on date */
-    p_best_snapshot = pointer[0];
-
-    for( i_index = 1 ; i_index < i_cachesize ; i_index++ )
-    {
-        long l_diff = pointer[i_index]->date - searched_date;
-        if( l_diff > 0 && l_diff < abs( p_best_snapshot->date - searched_date ))
-        {
-            /* This one is closer, and _after_ the requested position */
-            p_best_snapshot = pointer[i_index];
-        }
-    }
-
-    /* FIXME: add a test for the case that no picture matched the test
-       ( we have p_best_snapshot == pointer[0] */
-    retval = _mediacontrol_createRGBPicture( p_best_snapshot->i_width,
-                                             p_best_snapshot->i_height,
-                                             p_vout->output.i_chroma,
-                                             p_best_snapshot->date,
-                                             p_best_snapshot->p_data,
-                                             i_datasize );
-
-    vlc_mutex_unlock( &p_vout->picture_lock );
-    vlc_object_release( p_vout );
-
-#endif
-
-    return retval;
-}
-
-mediacontrol_RGBPicture **
-mediacontrol_all_snapshots( mediacontrol_Instance *self,
-                            mediacontrol_Exception *exception )
-{
-    mediacontrol_RGBPicture **retval = NULL;
-    vout_thread_t *p_vout = NULL;
-    int i_datasize;
-    int i_cachesize;
-    vlc_value_t val;
-    int i_index;
-#ifdef HAS_SNAPSHOT
-    snapshot_t **pointer;
-#endif
-
-    exception=mediacontrol_exception_init( exception );
-
-    if( var_Get( self->p_playlist->p_input, "snapshot-id", &val ) == VLC_SUCCESS )
-        p_vout = vlc_object_get( self->p_vlc, val.i_int );
-
-    if( ! p_vout )
-    {
-        RAISE( mediacontrol_InternalException, "No snapshot module" );
-        return NULL;
-    }
-#ifdef HAS_SNAPSHOT
-    /* We test if the vout is a snapshot module. We cannot test
-       pvout_psz_object_name( which is NULL ). But we can check if
-       there are snapshot-specific variables */
-    if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
-    {
-        RAISE( mediacontrol_InternalException, "No snapshot module" );
-        vlc_object_release( p_vout );
-        return NULL;
-    }
-    i_datasize = val.i_int;
-
-    vlc_mutex_lock( &p_vout->picture_lock );
-
-    var_Get( p_vout, "snapshot-cache-size", &val );
-    i_cachesize = val.i_int  ;
-
-    var_Get( p_vout, "snapshot-list-pointer", &val );
-    pointer = ( snapshot_t ** )val.p_address;
-
-    if( ! pointer )
-    {
-        RAISE( mediacontrol_InternalException, "No available picture" );
-
-        vlc_mutex_unlock( &p_vout->picture_lock );
-        vlc_object_release( p_vout );
-        return NULL;
-    }
-
-    retval = ( mediacontrol_RGBPicture** )malloc( (i_cachesize + 1 ) * sizeof( char* ));
-
-    for( i_index = 0 ; i_index < i_cachesize ; i_index++ )
-    {
-        snapshot_t *p_s = pointer[i_index];
-        mediacontrol_RGBPicture *p_rgb;
-
-        p_rgb = _mediacontrol_createRGBPicture( p_s->i_width,
-                                                p_s->i_height,
-                                                p_vout->output.i_chroma,
-                                                p_s->date,
-                                                p_s->p_data,
-                                                i_datasize );
-
-        retval[i_index] = p_rgb;
-    }
-
-    retval[i_cachesize] = NULL;
-
-    vlc_mutex_unlock( &p_vout->picture_lock );
-    vlc_object_release( p_vout );
-
-#endif
-
-    return retval;
-}
-
-int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
-                           char *psz_string, text_style_t *p_style,
-                           int i_flags, int i_hmargin, int i_vmargin,
-                           mtime_t i_start, mtime_t i_stop )
-{
-    subpicture_t *p_spu;
-    video_format_t fmt;
-
-    if( !psz_string ) return VLC_EGENERIC;
-
-    p_spu = spu_CreateSubpicture( p_vout->p_spu );
-    if( !p_spu ) return VLC_EGENERIC;
-
-    /* Create a new subpicture region */
-    memset( &fmt, 0, sizeof(video_format_t) );
-    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
-    fmt.i_aspect = 0;
-    fmt.i_width = fmt.i_height = 0;
-    fmt.i_x_offset = fmt.i_y_offset = 0;
-    p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_vout), &fmt );
-    if( !p_spu->p_region )
-    {
-        msg_Err( p_vout, "cannot allocate SPU region" );
-        spu_DestroySubpicture( p_vout->p_spu, p_spu );
-        return VLC_EGENERIC;
-    }
-
-    p_spu->p_region->psz_text = strdup( psz_string );
-    p_spu->i_start = i_start;
-    p_spu->i_stop = i_stop;
-    p_spu->b_ephemer = VLC_FALSE;
-    p_spu->b_absolute = VLC_FALSE;
-
-    p_spu->i_x = i_hmargin;
-    p_spu->i_y = i_vmargin;
-    p_spu->i_flags = i_flags;
-    p_spu->i_channel = i_channel;
-
-    spu_DisplaySubpicture( p_vout->p_spu, p_spu );
-
-    return VLC_SUCCESS;
-}
-
-
-void
-mediacontrol_display_text( mediacontrol_Instance *self,
-                           const char * message,
-                           const mediacontrol_Position * begin,
-                           const mediacontrol_Position * end,
-                           mediacontrol_Exception *exception )
-{
-    input_thread_t *p_input = NULL;
-    vout_thread_t *p_vout = NULL;
-    char* psz_message;
-
-    psz_message = strdup( message );
-    if( !psz_message )
-    {
-        RAISE( mediacontrol_InternalException, "No more memory" );
-        return;
-    }
-
-    p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
-    if( ! p_vout )
-    {
-        RAISE( mediacontrol_InternalException, "No video output" );
-        return;
-    }
-
-    if( begin->origin == mediacontrol_RelativePosition &&
-        begin->value == 0 &&
-        end->origin == mediacontrol_RelativePosition )
-    {
-        mtime_t i_duration = 0;
-       mtime_t i_now = mdate();
-
-        i_duration = 1000 * mediacontrol_unit_convert( self->p_playlist->p_input,
-                                                       end->key,
-                                                       mediacontrol_MediaTime,
-                                                       end->value );
-
-        mediacontrol_showtext( p_vout, DEFAULT_CHAN, psz_message, NULL,
-                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
-                               i_now, i_now + i_duration );
-    }
-    else
-    {
-        mtime_t i_debut, i_fin, i_now;
-
-        p_input = self->p_playlist->p_input;
-        if( ! p_input )
-        {
-            RAISE( mediacontrol_InternalException, "No input" );
-            vlc_object_release( p_vout );
-            return;
-        }
-
-        /* FIXME */
-        /* i_now = input_ClockGetTS( p_input, NULL, 0 ); */
-        i_now = mdate();
-        
-        i_debut = mediacontrol_position2microsecond( p_input,
-                                                     ( mediacontrol_Position* ) begin );
-        i_debut += i_now;
-
-        i_fin = mediacontrol_position2microsecond( p_input,
-                                                   ( mediacontrol_Position * ) end );
-        i_fin += i_now;
-
-        vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, psz_message, NULL,
-                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
-                               i_debut, i_fin );
-    }
-
-    vlc_object_release( p_vout );
-}
-
-unsigned short
-mediacontrol_sound_get_volume( mediacontrol_Instance *self,
-                               mediacontrol_Exception *exception )
-{
-    short retval;
-    audio_volume_t i_volume;
-
-    if( !self->p_intf )
-    {
-        RAISE( mediacontrol_InternalException, "No interface module" );
-        return 0;
-    }
-    aout_VolumeGet( self->p_intf, &i_volume );
-    retval = i_volume;
-    return retval;
-}
-
-void
-mediacontrol_sound_set_volume( mediacontrol_Instance *self,
-                               const unsigned short volume,
-                               mediacontrol_Exception *exception )
-{
-    if( !self->p_intf )
-    {
-        RAISE( mediacontrol_InternalException, "No interface module" );
-        return;
-    }
-    aout_VolumeSet( self->p_intf,( audio_volume_t )volume );
-}
-
-vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
-                                   WINDOWHANDLE visual_id,
-                                   mediacontrol_Exception *exception )
-{
-    vlc_value_t value;
-    int ret;
-
-    if( !self->p_vlc )
-    {
-        RAISE( mediacontrol_InternalException, "No vlc reference" );
-        return 0;
-    }
-    value.i_int=visual_id;
-    ret = var_Set(self->p_vlc, "drawable", value);
-    
-    return (ret == VLC_SUCCESS);
-}
index 3e31fc2..25fa55f 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/init.c b/src/control/init.c
deleted file mode 100644 (file)
index 0cdb3ab..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#define __VLC__
-#include <vlc_control.h>
-#include <vlc/control.h>
-
-mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
-{
-    mediacontrol_Instance* retval;
-    vlc_object_t *p_vlc;
-    int p_vlc_id;
-    char **ppsz_argv;
-    int i_count = 0;
-    int i_index;
-    char **p_tmp;
-
-    if( args )
-    {
-        for ( p_tmp = args ; *p_tmp != NULL ; p_tmp++ )
-            i_count++;
-    }
-
-    ppsz_argv = malloc( i_count + 2 );
-    if( ! ppsz_argv )
-    {
-        exception->code = mediacontrol_InternalException;
-        exception->message = "Out of memory";
-        return NULL;
-    }
-    ppsz_argv[0] = "vlc";
-    for ( i_index = 0; i_index < i_count; i_index++ )
-    {
-        ppsz_argv[i_index + 1] = strdup( args[i_index] );
-        if( ! ppsz_argv[i_index + 1] )
-        {
-            exception->code = mediacontrol_InternalException;
-            exception->message = "Out of memory";
-            return NULL;
-        }
-    }
-
-    ppsz_argv[i_count + 1] = NULL;
-
-    p_vlc_id = VLC_Create();
-  
-    p_vlc = ( vlc_object_t* )vlc_current_object( p_vlc_id );
-  
-    if( ! p_vlc )
-    {
-        exception->code = mediacontrol_InternalException;
-        exception->message = strdup( "Unable to initialize VLC" );
-        return NULL;
-    }
-    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
-    if( ! retval )
-    {
-        exception->code = mediacontrol_InternalException;
-        exception->message = strdup( "Out of memory" );
-        return NULL;
-    }
-
-    VLC_Init( p_vlc_id, i_count + 1, ppsz_argv );
-
-    retval->p_vlc = p_vlc;
-    retval->vlc_object_id = p_vlc_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 )
-    {
-        exception->code = mediacontrol_InternalException;
-        exception->message = strdup( "No available interface" );
-        return NULL;
-    }
-
-    
-    return retval;  
-};
-
-void
-mediacontrol_exit( mediacontrol_Instance *self )
-{
-  
-    vlc_object_release( (vlc_object_t* )self->p_playlist );
-    vlc_object_release( (vlc_object_t* )self->p_intf );
-    vlc_object_release( (vlc_object_t*)self->p_vlc );
-  
-    VLC_CleanUp( self->vlc_object_id );
-    VLC_Destroy( self->vlc_object_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;
+}
diff --git a/src/control/mediacontrol_audio_video.c b/src/control/mediacontrol_audio_video.c
new file mode 100644 (file)
index 0000000..1d02885
--- /dev/null
@@ -0,0 +1,425 @@
+/*****************************************************************************
+ * audio_video.c: Audio/Video management : volume, snapshot, OSD
+ *****************************************************************************
+ * 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);
+
+mediacontrol_RGBPicture *
+mediacontrol_snapshot( mediacontrol_Instance *self,
+                       const mediacontrol_Position * a_position,
+                       mediacontrol_Exception *exception )
+{
+    mediacontrol_RGBPicture *retval = NULL;
+    input_thread_t* p_input = self->p_playlist->p_input;
+    vout_thread_t *p_vout = NULL;
+    int i_datasize;
+    snapshot_t **pointer;
+    vlc_value_t val;
+    int i_index;
+    snapshot_t *p_best_snapshot;
+    long searched_date;
+#ifdef HAS_SNAPSHOT
+    int i_cachesize;
+#endif
+
+    exception=mediacontrol_exception_init( exception );
+
+    /*
+       if( var_Get( self->p_vlc, "snapshot-id", &val ) == VLC_SUCCESS )
+       p_vout = vlc_object_get( self->p_vlc, val.i_int );
+    */
+
+    /* FIXME: if in p_libvlc, we cannot have multiple video outputs */
+    /* Once corrected, search for snapshot-id to modify all instances */
+    if( var_Get( p_input, "snapshot-id", &val ) != VLC_SUCCESS )
+    {
+        RAISE( mediacontrol_InternalException, "No snapshot-id in p_input" );
+        return NULL;
+    }
+    p_vout = vlc_object_get( self->p_vlc, val.i_int );
+
+    if( ! p_vout )
+    {
+        RAISE( mediacontrol_InternalException, "No snapshot module" );
+        return NULL;
+    }
+
+#ifdef HAS_SNAPSHOT
+    /* We test if the vout is a snapshot module. We cannot test
+       pvout_psz_object_name( which is NULL ). But we can check if
+       there are snapshot-specific variables */
+    if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
+    {
+        RAISE( mediacontrol_InternalException, "No snapshot module" );
+        vlc_object_release( p_vout );
+        return NULL;
+    }
+    i_datasize = val.i_int;
+
+    /* Handle the a_position parameter */
+    if( ! ( a_position->origin == mediacontrol_RelativePosition
+            && a_position->value == 0 ) )
+    {
+        /* The position is not the current one. Go to it. */
+        mediacontrol_set_media_position( self,
+                                         ( mediacontrol_Position* ) a_position,
+                                         exception );
+        if( exception->code )
+        {
+            vlc_object_release( p_vout );
+            return NULL;
+        }
+    }
+
+    /* FIXME: We should not go further until we got past the position
+       ( which means that we had the possibility to capture the right
+       picture ). */
+
+    vlc_mutex_lock( &p_vout->picture_lock );
+
+    searched_date = mediacontrol_position2microsecond( p_input,
+                                                       ( mediacontrol_Position * ) a_position );
+
+    var_Get( p_vout, "snapshot-cache-size", &val );
+    i_cachesize = val.i_int  ;
+
+    var_Get( p_vout, "snapshot-list-pointer", &val );
+    pointer = ( snapshot_t ** )val.p_address;
+
+    if( ! pointer )
+    {
+        RAISE( mediacontrol_InternalException, "No available snapshot" );
+
+        vlc_mutex_unlock( &p_vout->picture_lock );
+        vlc_object_release( p_vout );
+        return NULL;
+    }
+
+    /* Find the more appropriate picture, based on date */
+    p_best_snapshot = pointer[0];
+
+    for( i_index = 1 ; i_index < i_cachesize ; i_index++ )
+    {
+        long l_diff = pointer[i_index]->date - searched_date;
+        if( l_diff > 0 && l_diff < abs( p_best_snapshot->date - searched_date ))
+        {
+            /* This one is closer, and _after_ the requested position */
+            p_best_snapshot = pointer[i_index];
+        }
+    }
+
+    /* FIXME: add a test for the case that no picture matched the test
+       ( we have p_best_snapshot == pointer[0] */
+    retval = _mediacontrol_createRGBPicture( p_best_snapshot->i_width,
+                                             p_best_snapshot->i_height,
+                                             p_vout->output.i_chroma,
+                                             p_best_snapshot->date,
+                                             p_best_snapshot->p_data,
+                                             i_datasize );
+
+    vlc_mutex_unlock( &p_vout->picture_lock );
+    vlc_object_release( p_vout );
+
+#endif
+
+    return retval;
+}
+
+mediacontrol_RGBPicture **
+mediacontrol_all_snapshots( mediacontrol_Instance *self,
+                            mediacontrol_Exception *exception )
+{
+    mediacontrol_RGBPicture **retval = NULL;
+    vout_thread_t *p_vout = NULL;
+    int i_datasize;
+    int i_cachesize;
+    vlc_value_t val;
+    int i_index;
+#ifdef HAS_SNAPSHOT
+    snapshot_t **pointer;
+#endif
+
+    exception=mediacontrol_exception_init( exception );
+
+    if( var_Get( self->p_playlist->p_input, "snapshot-id", &val ) == VLC_SUCCESS )
+        p_vout = vlc_object_get( self->p_vlc, val.i_int );
+
+    if( ! p_vout )
+    {
+        RAISE( mediacontrol_InternalException, "No snapshot module" );
+        return NULL;
+    }
+#ifdef HAS_SNAPSHOT
+    /* We test if the vout is a snapshot module. We cannot test
+       pvout_psz_object_name( which is NULL ). But we can check if
+       there are snapshot-specific variables */
+    if( var_Get( p_vout, "snapshot-datasize", &val ) != VLC_SUCCESS )
+    {
+        RAISE( mediacontrol_InternalException, "No snapshot module" );
+        vlc_object_release( p_vout );
+        return NULL;
+    }
+    i_datasize = val.i_int;
+
+    vlc_mutex_lock( &p_vout->picture_lock );
+
+    var_Get( p_vout, "snapshot-cache-size", &val );
+    i_cachesize = val.i_int  ;
+
+    var_Get( p_vout, "snapshot-list-pointer", &val );
+    pointer = ( snapshot_t ** )val.p_address;
+
+    if( ! pointer )
+    {
+        RAISE( mediacontrol_InternalException, "No available picture" );
+
+        vlc_mutex_unlock( &p_vout->picture_lock );
+        vlc_object_release( p_vout );
+        return NULL;
+    }
+
+    retval = ( mediacontrol_RGBPicture** )malloc( (i_cachesize + 1 ) * sizeof( char* ));
+
+    for( i_index = 0 ; i_index < i_cachesize ; i_index++ )
+    {
+        snapshot_t *p_s = pointer[i_index];
+        mediacontrol_RGBPicture *p_rgb;
+
+        p_rgb = _mediacontrol_createRGBPicture( p_s->i_width,
+                                                p_s->i_height,
+                                                p_vout->output.i_chroma,
+                                                p_s->date,
+                                                p_s->p_data,
+                                                i_datasize );
+
+        retval[i_index] = p_rgb;
+    }
+
+    retval[i_cachesize] = NULL;
+
+    vlc_mutex_unlock( &p_vout->picture_lock );
+    vlc_object_release( p_vout );
+
+#endif
+
+    return retval;
+}
+
+int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
+                           char *psz_string, text_style_t *p_style,
+                           int i_flags, int i_hmargin, int i_vmargin,
+                           mtime_t i_start, mtime_t i_stop )
+{
+    subpicture_t *p_spu;
+    video_format_t fmt;
+
+    if( !psz_string ) return VLC_EGENERIC;
+
+    p_spu = spu_CreateSubpicture( p_vout->p_spu );
+    if( !p_spu ) return VLC_EGENERIC;
+
+    /* Create a new subpicture region */
+    memset( &fmt, 0, sizeof(video_format_t) );
+    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
+    fmt.i_aspect = 0;
+    fmt.i_width = fmt.i_height = 0;
+    fmt.i_x_offset = fmt.i_y_offset = 0;
+    p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_vout), &fmt );
+    if( !p_spu->p_region )
+    {
+        msg_Err( p_vout, "cannot allocate SPU region" );
+        spu_DestroySubpicture( p_vout->p_spu, p_spu );
+        return VLC_EGENERIC;
+    }
+
+    p_spu->p_region->psz_text = strdup( psz_string );
+    p_spu->i_start = i_start;
+    p_spu->i_stop = i_stop;
+    p_spu->b_ephemer = VLC_FALSE;
+    p_spu->b_absolute = VLC_FALSE;
+
+    p_spu->i_x = i_hmargin;
+    p_spu->i_y = i_vmargin;
+    p_spu->i_flags = i_flags;
+    p_spu->i_channel = i_channel;
+
+    spu_DisplaySubpicture( p_vout->p_spu, p_spu );
+
+    return VLC_SUCCESS;
+}
+
+
+void
+mediacontrol_display_text( mediacontrol_Instance *self,
+                           const char * message,
+                           const mediacontrol_Position * begin,
+                           const mediacontrol_Position * end,
+                           mediacontrol_Exception *exception )
+{
+    input_thread_t *p_input = NULL;
+    vout_thread_t *p_vout = NULL;
+    char* psz_message;
+
+    psz_message = strdup( message );
+    if( !psz_message )
+    {
+        RAISE( mediacontrol_InternalException, "No more memory" );
+        return;
+    }
+
+    p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
+    if( ! p_vout )
+    {
+        RAISE( mediacontrol_InternalException, "No video output" );
+        return;
+    }
+
+    if( begin->origin == mediacontrol_RelativePosition &&
+        begin->value == 0 &&
+        end->origin == mediacontrol_RelativePosition )
+    {
+        mtime_t i_duration = 0;
+       mtime_t i_now = mdate();
+
+        i_duration = 1000 * mediacontrol_unit_convert( self->p_playlist->p_input,
+                                                       end->key,
+                                                       mediacontrol_MediaTime,
+                                                       end->value );
+
+        mediacontrol_showtext( p_vout, DEFAULT_CHAN, psz_message, NULL,
+                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
+                               i_now, i_now + i_duration );
+    }
+    else
+    {
+        mtime_t i_debut, i_fin, i_now;
+
+        p_input = self->p_playlist->p_input;
+        if( ! p_input )
+        {
+            RAISE( mediacontrol_InternalException, "No input" );
+            vlc_object_release( p_vout );
+            return;
+        }
+
+        /* FIXME */
+        /* i_now = input_ClockGetTS( p_input, NULL, 0 ); */
+        i_now = mdate();
+        
+        i_debut = mediacontrol_position2microsecond( p_input,
+                                                     ( mediacontrol_Position* ) begin );
+        i_debut += i_now;
+
+        i_fin = mediacontrol_position2microsecond( p_input,
+                                                   ( mediacontrol_Position * ) end );
+        i_fin += i_now;
+
+        vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, psz_message, NULL,
+                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
+                               i_debut, i_fin );
+    }
+
+    vlc_object_release( p_vout );
+}
+
+unsigned short
+mediacontrol_sound_get_volume( mediacontrol_Instance *self,
+                               mediacontrol_Exception *exception )
+{
+    short retval;
+    audio_volume_t i_volume;
+
+    if( !self->p_intf )
+    {
+        RAISE( mediacontrol_InternalException, "No interface module" );
+        return 0;
+    }
+    aout_VolumeGet( self->p_intf, &i_volume );
+    retval = i_volume;
+    return retval;
+}
+
+void
+mediacontrol_sound_set_volume( mediacontrol_Instance *self,
+                               const unsigned short volume,
+                               mediacontrol_Exception *exception )
+{
+    if( !self->p_intf )
+    {
+        RAISE( mediacontrol_InternalException, "No interface module" );
+        return;
+    }
+    aout_VolumeSet( self->p_intf,( audio_volume_t )volume );
+}
+
+vlc_bool_t mediacontrol_set_visual( mediacontrol_Instance *self,
+                                   WINDOWHANDLE visual_id,
+                                   mediacontrol_Exception *exception )
+{
+    vlc_value_t value;
+    int ret;
+
+    if( !self->p_vlc )
+    {
+        RAISE( mediacontrol_InternalException, "No vlc reference" );
+        return 0;
+    }
+    value.i_int=visual_id;
+    ret = var_Set(self->p_vlc, "drawable", value);
+    
+    return (ret == VLC_SUCCESS);
+}
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;
+}
diff --git a/src/control/mediacontrol_init.c b/src/control/mediacontrol_init.c
new file mode 100644 (file)
index 0000000..a9108e5
--- /dev/null
@@ -0,0 +1,91 @@
+#define __VLC__
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
+
+mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
+{
+    mediacontrol_Instance* retval;
+    vlc_object_t *p_vlc;
+    int p_vlc_id;
+    char **ppsz_argv;
+    int i_count = 0;
+    int i_index;
+    char **p_tmp;
+
+    if( args )
+    {
+        for ( p_tmp = args ; *p_tmp != NULL ; p_tmp++ )
+            i_count++;
+    }
+
+    ppsz_argv = malloc( i_count + 2 );
+    if( ! ppsz_argv )
+    {
+        exception->code = mediacontrol_InternalException;
+        exception->message = "Out of memory";
+        return NULL;
+    }
+    ppsz_argv[0] = "vlc";
+    for ( i_index = 0; i_index < i_count; i_index++ )
+    {
+        ppsz_argv[i_index + 1] = strdup( args[i_index] );
+        if( ! ppsz_argv[i_index + 1] )
+        {
+            exception->code = mediacontrol_InternalException;
+            exception->message = "Out of memory";
+            return NULL;
+        }
+    }
+
+    ppsz_argv[i_count + 1] = NULL;
+
+    p_vlc_id = VLC_Create();
+  
+    p_vlc = ( vlc_object_t* )vlc_current_object( p_vlc_id );
+  
+    if( ! p_vlc )
+    {
+        exception->code = mediacontrol_InternalException;
+        exception->message = strdup( "Unable to initialize VLC" );
+        return NULL;
+    }
+    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
+    if( ! retval )
+    {
+        exception->code = mediacontrol_InternalException;
+        exception->message = strdup( "Out of memory" );
+        return NULL;
+    }
+
+    VLC_Init( p_vlc_id, i_count + 1, ppsz_argv );
+
+    retval->p_vlc = p_vlc;
+    retval->vlc_object_id = p_vlc_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 )
+    {
+        exception->code = mediacontrol_InternalException;
+        exception->message = strdup( "No available interface" );
+        return NULL;
+    }
+
+    
+    return retval;  
+};
+
+void
+mediacontrol_exit( mediacontrol_Instance *self )
+{
+  
+    vlc_object_release( (vlc_object_t* )self->p_playlist );
+    vlc_object_release( (vlc_object_t* )self->p_intf );
+    vlc_object_release( (vlc_object_t*)self->p_vlc );
+  
+    VLC_CleanUp( self->vlc_object_id );
+    VLC_Destroy( self->vlc_object_id );
+}
diff --git a/src/control/mediacontrol_plugin.c b/src/control/mediacontrol_plugin.c
new file mode 100644 (file)
index 0000000..fa731b2
--- /dev/null
@@ -0,0 +1,18 @@
+#include <mediacontrol_internal.h>
+#include <vlc/mediacontrol.h>
+#include <vlc/intf.h>
+
+mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
+{
+    exception->code = mediacontrol_InternalException;
+    exception->message = strdup( "The mediacontrol extension was compiled for plugin use only." );
+    return NULL;
+};
+
+void
+mediacontrol_exit( mediacontrol_Instance *self )
+{
+    vlc_mutex_lock( &self->p_intf->change_lock );
+    self->p_intf->b_die = 1;
+    vlc_mutex_unlock( &self->p_intf->change_lock );
+}
diff --git a/src/control/mediacontrol_util.c b/src/control/mediacontrol_util.c
new file mode 100644 (file)
index 0000000..eba2d4c
--- /dev/null
@@ -0,0 +1,294 @@
+/*****************************************************************************
+ * util.c: Utility functions and exceptions 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_int64_t mediacontrol_unit_convert( input_thread_t *p_input,
+                                       mediacontrol_PositionKey from,
+                                       mediacontrol_PositionKey to,
+                                       vlc_int64_t value )
+{
+    if( to == from )
+        return value;
+
+    /* For all conversions, we need data from p_input */
+    if( !p_input )
+        return 0;
+
+    switch( from )
+    {
+    case mediacontrol_MediaTime:
+        if( to == mediacontrol_ByteCount )
+        {
+            /* FIXME */
+            /* vlc < 0.8 API */
+            /* return value * 50 * p_input->stream.i_mux_rate / 1000; */
+            return 0;
+        }
+        if( to == mediacontrol_SampleCount )
+        {
+            double f_fps;
+
+            if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
+                return 0;
+            else
+                return( value * f_fps / 1000.0 );
+        }
+        /* Cannot happen */
+        /* See http://catb.org/~esr/jargon/html/entry/can't-happen.html */
+        break;
+
+    case mediacontrol_SampleCount:
+    {
+        double f_fps;
+
+       if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
+            return 0;
+
+        if( to == mediacontrol_ByteCount )
+        {
+            /* FIXME */
+            /* vlc < 0.8 API */
+/*             return ( vlc_int64_t )( value * 50 * p_input->stream.i_mux_rate / f_fps ); */
+            return 0;
+        }
+
+        if( to == mediacontrol_MediaTime )
+            return( vlc_int64_t )( value * 1000.0 / ( double )f_fps );
+
+        /* Cannot happen */
+        break;
+    }
+    case mediacontrol_ByteCount:
+        /* FIXME */
+        return 0;
+/* vlc < 0.8 API: */
+
+//         if( p_input->stream.i_mux_rate == 0 )
+//             return 0;
+// 
+//         /* Convert an offset into milliseconds. Taken from input_ext-intf.c.
+//            The 50 hardcoded constant comes from the definition of i_mux_rate :
+//            i_mux_rate : the rate we read the stream (in units of 50 bytes/s) ;
+//            0 if undef */
+//         if( to == mediacontrol_MediaTime )
+//             return ( vlc_int64_t )( 1000 * value / 50 / p_input->stream.i_mux_rate );
+// 
+//         if( to == mediacontrol_SampleCount )
+//         {
+//             double f_fps;
+//             if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
+//                 return 0;
+//             else
+//                 return ( vlc_int64_t )( value * f_fps / 50 / p_input->stream.i_mux_rate );
+//         }
+        /* Cannot happen */
+        break;
+    }
+    /* Cannot happen */
+    return 0;
+}
+
+/* Converts a mediacontrol_Position into a time in microseconds in
+   movie clock time */
+vlc_int64_t
+mediacontrol_position2microsecond( input_thread_t* p_input, const mediacontrol_Position * pos )
+{
+    switch( pos->origin )
+    {
+    case mediacontrol_AbsolutePosition:
+        return ( 1000 * mediacontrol_unit_convert( p_input,
+                                                   pos->key, /* from */
+                                                   mediacontrol_MediaTime,  /* to */
+                                                   pos->value ) );
+        break;
+    case mediacontrol_RelativePosition:
+    {
+        vlc_int64_t l_pos;
+        vlc_value_t val;
+
+        val.i_time = 0;
+        if( p_input )
+        {
+            var_Get( p_input, "time", &val );
+        }
+
+        l_pos = 1000 * mediacontrol_unit_convert( p_input,
+                                                  pos->key,
+                                                  mediacontrol_MediaTime,
+                                                  pos->value );
+        return val.i_time + l_pos;
+        break;
+    }
+    case mediacontrol_ModuloPosition:
+    {
+        vlc_int64_t l_pos;
+        vlc_value_t val;
+
+        val.i_time = 0;
+        if( p_input )
+        {
+            var_Get( p_input, "length", &val );
+        }
+
+        if( val.i_time > 0)
+        {
+            l_pos = ( 1000 * mediacontrol_unit_convert( p_input,
+                                                        pos->key,
+                                                        mediacontrol_MediaTime,
+                                                        pos->value ) );
+        }
+        else
+            l_pos = 0;
+
+        return l_pos % val.i_time;
+        break;
+    }
+    }
+    return 0;
+}
+
+mediacontrol_RGBPicture*
+mediacontrol_RGBPicture__alloc( int datasize )
+{
+    mediacontrol_RGBPicture* pic;
+
+    pic = ( mediacontrol_RGBPicture * )malloc( sizeof( mediacontrol_RGBPicture ) );
+    if( ! pic )
+        return NULL;
+
+    pic->size = datasize;
+    pic->data = ( char* )malloc( datasize );
+    return pic;
+}
+
+void
+mediacontrol_RGBPicture__free( mediacontrol_RGBPicture* pic )
+{
+    if( pic )
+        free( pic->data );
+    free( pic );
+}
+
+mediacontrol_PlaylistSeq*
+mediacontrol_PlaylistSeq__alloc( int size )
+{
+    mediacontrol_PlaylistSeq* ps;
+
+    ps =( mediacontrol_PlaylistSeq* )malloc( sizeof( mediacontrol_PlaylistSeq ) );
+    if( ! ps )
+        return NULL;
+
+    ps->size = size;
+    ps->data = ( char** )malloc( size * sizeof( char* ) );
+    return ps;
+}
+
+void
+mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq* ps )
+{
+    if( ps )
+    {
+        int i;
+        for( i = 0 ; i < ps->size ; i++ )
+            free( ps->data[i] );
+    }
+    free( ps->data );
+    free( ps );
+}
+
+mediacontrol_Exception*
+mediacontrol_exception_init( mediacontrol_Exception *exception )
+{
+    if( exception == NULL )
+    {
+        exception = ( mediacontrol_Exception* )malloc( sizeof( mediacontrol_Exception ) );
+    }
+
+    exception->code = 0;
+    exception->message = NULL;
+    return exception;
+}
+
+void
+mediacontrol_exception_free( mediacontrol_Exception *exception )
+{
+    if( ! exception )
+        return;
+
+    free( exception->message );
+    free( exception );
+}
+
+mediacontrol_RGBPicture*
+_mediacontrol_createRGBPicture( int i_width, int i_height, long i_chroma, vlc_int64_t l_date,
+                                char* p_data, int i_datasize )
+{
+    mediacontrol_RGBPicture *retval;
+
+    retval = mediacontrol_RGBPicture__alloc( i_datasize );
+    if( retval )
+    {
+        retval->width  = i_width;
+        retval->height = i_height;
+        retval->type   = i_chroma;
+        retval->date   = l_date;
+        retval->size   = i_datasize;
+        memcpy( retval->data, p_data, i_datasize );
+    }
+    return retval;
+}
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;
+}
diff --git a/src/control/plugin.c b/src/control/plugin.c
deleted file mode 100644 (file)
index 85c6a93..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <vlc_control.h>
-#include <vlc/control.h>
-#include <vlc/intf.h>
-
-mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
-{
-    exception->code = mediacontrol_InternalException;
-    exception->message = strdup( "The mediacontrol extension was compiled for plugin use only." );
-    return NULL;
-};
-
-void
-mediacontrol_exit( mediacontrol_Instance *self )
-{
-    vlc_mutex_lock( &self->p_intf->change_lock );
-    self->p_intf->b_die = 1;
-    vlc_mutex_unlock( &self->p_intf->change_lock );
-}
diff --git a/src/control/util.c b/src/control/util.c
deleted file mode 100644 (file)
index e2d2d21..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*****************************************************************************
- * util.c: Utility functions and exceptions 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 <vlc_control.h>
-#include <vlc/control.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_int64_t mediacontrol_unit_convert( input_thread_t *p_input,
-                                       mediacontrol_PositionKey from,
-                                       mediacontrol_PositionKey to,
-                                       vlc_int64_t value )
-{
-    if( to == from )
-        return value;
-
-    /* For all conversions, we need data from p_input */
-    if( !p_input )
-        return 0;
-
-    switch( from )
-    {
-    case mediacontrol_MediaTime:
-        if( to == mediacontrol_ByteCount )
-        {
-            /* FIXME */
-            /* vlc < 0.8 API */
-            /* return value * 50 * p_input->stream.i_mux_rate / 1000; */
-            return 0;
-        }
-        if( to == mediacontrol_SampleCount )
-        {
-            double f_fps;
-
-            if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
-                return 0;
-            else
-                return( value * f_fps / 1000.0 );
-        }
-        /* Cannot happen */
-        /* See http://catb.org/~esr/jargon/html/entry/can't-happen.html */
-        break;
-
-    case mediacontrol_SampleCount:
-    {
-        double f_fps;
-
-       if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
-            return 0;
-
-        if( to == mediacontrol_ByteCount )
-        {
-            /* FIXME */
-            /* vlc < 0.8 API */
-/*             return ( vlc_int64_t )( value * 50 * p_input->stream.i_mux_rate / f_fps ); */
-            return 0;
-        }
-
-        if( to == mediacontrol_MediaTime )
-            return( vlc_int64_t )( value * 1000.0 / ( double )f_fps );
-
-        /* Cannot happen */
-        break;
-    }
-    case mediacontrol_ByteCount:
-        /* FIXME */
-        return 0;
-/* vlc < 0.8 API: */
-
-//         if( p_input->stream.i_mux_rate == 0 )
-//             return 0;
-// 
-//         /* Convert an offset into milliseconds. Taken from input_ext-intf.c.
-//            The 50 hardcoded constant comes from the definition of i_mux_rate :
-//            i_mux_rate : the rate we read the stream (in units of 50 bytes/s) ;
-//            0 if undef */
-//         if( to == mediacontrol_MediaTime )
-//             return ( vlc_int64_t )( 1000 * value / 50 / p_input->stream.i_mux_rate );
-// 
-//         if( to == mediacontrol_SampleCount )
-//         {
-//             double f_fps;
-//             if( demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
-//                 return 0;
-//             else
-//                 return ( vlc_int64_t )( value * f_fps / 50 / p_input->stream.i_mux_rate );
-//         }
-        /* Cannot happen */
-        break;
-    }
-    /* Cannot happen */
-    return 0;
-}
-
-/* Converts a mediacontrol_Position into a time in microseconds in
-   movie clock time */
-vlc_int64_t
-mediacontrol_position2microsecond( input_thread_t* p_input, const mediacontrol_Position * pos )
-{
-    switch( pos->origin )
-    {
-    case mediacontrol_AbsolutePosition:
-        return ( 1000 * mediacontrol_unit_convert( p_input,
-                                                   pos->key, /* from */
-                                                   mediacontrol_MediaTime,  /* to */
-                                                   pos->value ) );
-        break;
-    case mediacontrol_RelativePosition:
-    {
-        vlc_int64_t l_pos;
-        vlc_value_t val;
-
-        val.i_time = 0;
-        if( p_input )
-        {
-            var_Get( p_input, "time", &val );
-        }
-
-        l_pos = 1000 * mediacontrol_unit_convert( p_input,
-                                                  pos->key,
-                                                  mediacontrol_MediaTime,
-                                                  pos->value );
-        return val.i_time + l_pos;
-        break;
-    }
-    case mediacontrol_ModuloPosition:
-    {
-        vlc_int64_t l_pos;
-        vlc_value_t val;
-
-        val.i_time = 0;
-        if( p_input )
-        {
-            var_Get( p_input, "length", &val );
-        }
-
-        if( val.i_time > 0)
-        {
-            l_pos = ( 1000 * mediacontrol_unit_convert( p_input,
-                                                        pos->key,
-                                                        mediacontrol_MediaTime,
-                                                        pos->value ) );
-        }
-        else
-            l_pos = 0;
-
-        return l_pos % val.i_time;
-        break;
-    }
-    }
-    return 0;
-}
-
-mediacontrol_RGBPicture*
-mediacontrol_RGBPicture__alloc( int datasize )
-{
-    mediacontrol_RGBPicture* pic;
-
-    pic = ( mediacontrol_RGBPicture * )malloc( sizeof( mediacontrol_RGBPicture ) );
-    if( ! pic )
-        return NULL;
-
-    pic->size = datasize;
-    pic->data = ( char* )malloc( datasize );
-    return pic;
-}
-
-void
-mediacontrol_RGBPicture__free( mediacontrol_RGBPicture* pic )
-{
-    if( pic )
-        free( pic->data );
-    free( pic );
-}
-
-mediacontrol_PlaylistSeq*
-mediacontrol_PlaylistSeq__alloc( int size )
-{
-    mediacontrol_PlaylistSeq* ps;
-
-    ps =( mediacontrol_PlaylistSeq* )malloc( sizeof( mediacontrol_PlaylistSeq ) );
-    if( ! ps )
-        return NULL;
-
-    ps->size = size;
-    ps->data = ( char** )malloc( size * sizeof( char* ) );
-    return ps;
-}
-
-void
-mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq* ps )
-{
-    if( ps )
-    {
-        int i;
-        for( i = 0 ; i < ps->size ; i++ )
-            free( ps->data[i] );
-    }
-    free( ps->data );
-    free( ps );
-}
-
-mediacontrol_Exception*
-mediacontrol_exception_init( mediacontrol_Exception *exception )
-{
-    if( exception == NULL )
-    {
-        exception = ( mediacontrol_Exception* )malloc( sizeof( mediacontrol_Exception ) );
-    }
-
-    exception->code = 0;
-    exception->message = NULL;
-    return exception;
-}
-
-void
-mediacontrol_exception_free( mediacontrol_Exception *exception )
-{
-    if( ! exception )
-        return;
-
-    free( exception->message );
-    free( exception );
-}
-
-mediacontrol_RGBPicture*
-_mediacontrol_createRGBPicture( int i_width, int i_height, long i_chroma, vlc_int64_t l_date,
-                                char* p_data, int i_datasize )
-{
-    mediacontrol_RGBPicture *retval;
-
-    retval = mediacontrol_RGBPicture__alloc( i_datasize );
-    if( retval )
-    {
-        retval->width  = i_width;
-        retval->height = i_height;
-        retval->type   = i_chroma;
-        retval->date   = l_date;
-        retval->size   = i_datasize;
-        memcpy( retval->data, p_data, i_datasize );
-    }
-    return retval;
-}
index 0daa6cc..433f7a6 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;
+}