]> git.sesse.net Git - vlc/blobdiff - bindings/python/vlc_internal.c
playlist: Handle vlc_InputItemErrorWhenReadingChanged events.
[vlc] / bindings / python / vlc_internal.c
index f19d6e3c81fa28d1b887d1e028b431e0841651f1..b84b94b78fd8a42f3226dd3d798f64b9017a62b3 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #include "vlc_internal.h"
+#include "../../src/libvlc.h"
 
 /**************************************************************************
  * VLC Module
@@ -122,7 +123,7 @@ static void
 vlcObject_dealloc( PyObject *self )
 {
     vlcObject_release( self, NULL );
-    PyMem_DEL( self );
+    PyObject_DEL( self );
 }
 
 static PyObject *
@@ -253,13 +254,40 @@ vlcObject_find_object( PyObject *self, PyObject *args )
     return ( PyObject * )p_retval;
 }
 
+static PyObject *
+vlcObject_find_name( PyObject *self, PyObject *args )
+{
+    vlcObject *p_retval;
+    vlc_object_t *p_obj;
+    char *psz_name;
+
+    if( !PyArg_ParseTuple( args, "s", &psz_name ) )
+        return NULL;
+
+    p_obj = vlc_object_find_name( VLCSELF->p_object, psz_name, FIND_ANYWHERE );
+
+    if( !p_obj )
+    {
+        Py_INCREF( Py_None );
+        return Py_None;
+    }
+
+    p_retval = PyObject_New( vlcObject, &vlcObject_Type );
+
+    p_retval->p_object = p_obj;
+
+    return ( PyObject * )p_retval;
+}
+
 static PyObject *
 vlcObject_info( PyObject *self, PyObject *args )
 {
     PyObject *p_retval;
     vlc_object_t *p_obj;
-
+    vlc_object_internals_t *p_priv;
+    
     p_obj = VLCSELF->p_object;
+    p_priv = vlc_internals( p_obj );
 
     /* Return information about the object as a dict. */
     p_retval = PyDict_New();
@@ -271,12 +299,11 @@ vlcObject_info( PyObject *self, PyObject *args )
     PyDict_SetItemString( p_retval, "object-name",
                           Py_BuildValue( "s", p_obj->psz_object_name ) );
     PyDict_SetItemString( p_retval, "thread",
-                          PyBool_FromLong( p_obj->b_thread ) );
+                          PyBool_FromLong( p_priv->b_thread ) );
     PyDict_SetItemString( p_retval, "thread-id",
-                          PyLong_FromLongLong( p_obj->thread_id ) );
+                          PyLong_FromLongLong( p_priv->thread_id ) );
     PyDict_SetItemString( p_retval, "refcount",
-                          PyInt_FromLong( p_obj->i_refcount ) );
-
+                          PyInt_FromLong( p_priv->i_refcount ) );
     return p_retval;
 }
 
@@ -501,14 +528,17 @@ vlcObject_var_list( PyObject *self, PyObject *args )
     PyObject *p_retval;
     Py_ssize_t i_size;
     Py_ssize_t i_index;
+    vlc_object_internals_t *p_priv;
 
-    i_size = VLCSELF->p_object->i_vars;
+    p_priv = vlc_internals( VLCSELF->p_object );
+    i_size = p_priv->i_vars;
     p_retval = PyTuple_New( i_size );
 
+
     for ( i_index = 0 ; i_index < i_size ; i_index++ )
     {
         PyTuple_SetItem( p_retval, i_index,
-                         Py_BuildValue( "s", VLCSELF->p_object->p_vars[i_index].psz_name ) );
+                         Py_BuildValue( "s", p_priv->p_vars[i_index].psz_name ) );
     }
 
     return p_retval;
@@ -657,6 +687,8 @@ static PyMethodDef vlcObject_methods[] =
       "find_object( str ) -> Object     Find the object of a given type.\n\nAvailable types are : aout, decoder, input, httpd, intf, playlist, root, vlc, vout"},
     { "find_id", vlcObject_find_id, METH_VARARGS,
       "find_id( int ) -> Object      Find an object by id" },
+    { "find_name", vlcObject_find_name, METH_VARARGS,
+      "find_name( str ) -> Object      Find an object by name" },
     { "info", vlcObject_info, METH_NOARGS,
        "info( ) -> dict    Return information about the object" },
     { "release", vlcObject_release, METH_NOARGS,
@@ -687,7 +719,7 @@ static PyTypeObject vlcObject_Type =
     0,                         /*tp_setattro*/
     0,                         /*tp_as_buffer*/
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "Expose VLC object infrastructure.\n\nConstructor: vlc.Object(object_id)",  /* tp_doc */
+    "Expose VLC object internal infrastructure.\n\nConstructor: vlc.Object(object_id)\n\nPLEASE BE AWARE that accessing internal features of VLC voids the guarantee for the product and is not advised except if you know what you are doing.",  /* tp_doc */
     0,                     /* tp_traverse */
     0,                     /* tp_clear */
     0,                     /* tp_richcompare */