⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vlcglue.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/***************************************************************************** * vlcglue.c: VLC Module ***************************************************************************** * Copyright (C) 1998-2004 the VideoLAN team * $Id: vlcglue.c 16647 2006-09-14 14:58:57Z hartman $ * * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr> *          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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/#include "vlcglue.h"/************************************************************************** * VLC Module **************************************************************************/#ifndef vlcMODINIT_FUNC /* declarations for DLL import/export */#define vlcMODINIT_FUNC void#endifstatic PyMethodDef vlc_methods[] = {    { NULL }  /* Sentinel */};/* Module globals */PyObject* MediaControl_InternalException          = NULL;PyObject* MediaControl_PositionKeyNotSupported    = NULL;PyObject *MediaControl_PositionOriginNotSupported = NULL;PyObject* MediaControl_InvalidPosition            = NULL;PyObject *MediaControl_PlaylistException          = NULL;vlcMODINIT_FUNCinitvlc( void ){    PyObject* p_module;    PyPosition_Type.tp_new = PyType_GenericNew;    PyPosition_Type.tp_alloc = PyType_GenericAlloc;    p_module = Py_InitModule3( "vlc", vlc_methods,                               "VLC media player embedding module." );    if( !p_module )      return;    if( PyType_Ready( &PyPosition_Type ) < 0 )        return;    if( PyType_Ready( &MediaControl_Type ) < 0 )        return;    if( PyType_Ready( &vlcObject_Type ) < 0 )        return;    /* Exceptions */    MediaControl_InternalException =            PyErr_NewException( "vlc.InternalException", NULL, NULL );    Py_INCREF( MediaControl_InternalException );    PyModule_AddObject( p_module, "InternalException",                        MediaControl_InternalException );    MediaControl_PositionKeyNotSupported =            PyErr_NewException( "vlc.PositionKeyNotSupported", NULL, NULL );    Py_INCREF( MediaControl_PositionKeyNotSupported );    PyModule_AddObject( p_module, "PositionKeyNotSupported",                        MediaControl_PositionKeyNotSupported );    MediaControl_PositionOriginNotSupported=            PyErr_NewException( "vlc.InvalidPosition", NULL, NULL );    Py_INCREF( MediaControl_PositionOriginNotSupported );    PyModule_AddObject( p_module, "PositionOriginNotSupported",                        MediaControl_PositionOriginNotSupported );    MediaControl_InvalidPosition =            PyErr_NewException( "vlc.InvalidPosition", NULL, NULL );    Py_INCREF( MediaControl_InvalidPosition );    PyModule_AddObject( p_module, "InvalidPosition",                        MediaControl_InvalidPosition );    MediaControl_PlaylistException =            PyErr_NewException( "vlc.PlaylistException", NULL, NULL );    Py_INCREF( MediaControl_PlaylistException );    PyModule_AddObject( p_module, "PlaylistException",                        MediaControl_PlaylistException );    /* Types */    Py_INCREF( &PyPosition_Type );    PyModule_AddObject( p_module, "Position",                        ( PyObject * )&PyPosition_Type );    Py_INCREF( &MediaControl_Type );    PyModule_AddObject( p_module, "MediaControl",                        ( PyObject * )&MediaControl_Type );    Py_INCREF( &vlcObject_Type );    PyModule_AddObject( p_module, "Object",                        ( PyObject * )&vlcObject_Type );    /* Constants */    PyModule_AddIntConstant( p_module, "AbsolutePosition",                             mediacontrol_AbsolutePosition );    PyModule_AddIntConstant( p_module, "RelativePosition",                             mediacontrol_RelativePosition );    PyModule_AddIntConstant( p_module, "ModuloPosition",                             mediacontrol_ModuloPosition );    PyModule_AddIntConstant( p_module, "ByteCount",                             mediacontrol_ByteCount );    PyModule_AddIntConstant( p_module, "SampleCount",                             mediacontrol_SampleCount );    PyModule_AddIntConstant( p_module, "MediaTime",                             mediacontrol_MediaTime );    PyModule_AddIntConstant( p_module, "PlayingStatus",                             mediacontrol_PlayingStatus );    PyModule_AddIntConstant( p_module, "PauseStatus",                             mediacontrol_PauseStatus );    PyModule_AddIntConstant( p_module, "ForwardStatus",                             mediacontrol_ForwardStatus );    PyModule_AddIntConstant( p_module, "BackwardStatus",                             mediacontrol_BackwardStatus );    PyModule_AddIntConstant( p_module, "InitStatus",                             mediacontrol_InitStatus );    PyModule_AddIntConstant( p_module, "EndStatus",                             mediacontrol_EndStatus );    PyModule_AddIntConstant( p_module, "UndefinedStatus",                             mediacontrol_UndefinedStatus );}/* Make libpostproc happy... */void * fast_memcpy( void * to, const void * from, size_t len ){  return memcpy( to, from, len );}/***************************************************************************** * VLCObject implementation *****************************************************************************/static PyObject*vlcObject_new( PyTypeObject *p_type, PyObject *p_args, PyObject *p_kwds ){    vlcObject *self;    vlc_object_t *p_object;    int i_id;    self = PyObject_New( vlcObject, &vlcObject_Type );    if( !PyArg_ParseTuple( p_args, "i", &i_id ) )      return NULL;    /* Maybe we were already initialized */    p_object = ( vlc_object_t* )vlc_current_object( i_id );    if( !p_object )    {        /* Try to initialize */        i_id = VLC_Create();	if( i_id < 0 )         {            PyErr_SetString( PyExc_StandardError, "Unable to create a VLC instance." );            return NULL;                    }        p_object = ( vlc_object_t* )vlc_current_object( i_id );    }    if( !p_object )    {        PyErr_SetString( PyExc_StandardError, "Unable to get object." );        return NULL;    }    self->p_object = p_object;    self->b_released = 0;    Py_INCREF(  self ); /* Ah bon ? */    return ( PyObject * )self;}static PyObject *vlcObject_release(  PyObject *self, PyObject *p_args ){    if( VLCSELF->b_released == 0 )    {        vlc_object_release( VLCSELF->p_object );        VLCSELF->b_released = 1;    }    Py_INCREF(  Py_None );    return Py_None;}static voidvlcObject_dealloc( PyObject *self ){    vlcObject_release( self, NULL );    PyMem_DEL( self );}static PyObject *vlcObject_find_object( PyObject *self, PyObject *args ){    vlcObject *p_retval;    vlc_object_t *p_obj;    char *psz_name;    int i_object_type;    if( !PyArg_ParseTuple( args, "s", &psz_name ) )        return NULL;    /* psz_name is in       ( aout, decoder, input, httpd, intf, playlist, root, vlc, vout )    */    switch ( psz_name[0] )    {        case 'a':            i_object_type = VLC_OBJECT_AOUT;            break;        case 'd':            i_object_type = VLC_OBJECT_DECODER;            break;        case 'h':            i_object_type = VLC_OBJECT_HTTPD;            break;        case 'i':            if( strlen( psz_name ) < 3 )                    i_object_type = VLC_OBJECT_INTF;            else if( psz_name[2] == 't' )                    i_object_type = VLC_OBJECT_INTF;            else                    i_object_type = VLC_OBJECT_INPUT;            break;        case 'p':            i_object_type = VLC_OBJECT_PLAYLIST;            break;        case 'r':            i_object_type = VLC_OBJECT_ROOT;            break;        case 'v':            if( strlen( psz_name ) < 3 )                    i_object_type = VLC_OBJECT_VLC;            else if( psz_name[1] == 'l' )                    i_object_type = VLC_OBJECT_VLC;            else                    i_object_type = VLC_OBJECT_VOUT;            break;        default:            /* FIXME: raise an exception ? */            return Py_None;    }    p_obj = vlc_object_find( VLCSELF->p_object, i_object_type, 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;    p_obj = VLCSELF->p_object;    /* Return information about the object as a dict. */    p_retval = PyDict_New();    PyDict_SetItemString( p_retval, "object-id",                          Py_BuildValue( "l", p_obj->i_object_id ) );    PyDict_SetItemString( p_retval, "object-type",                          Py_BuildValue( "s", p_obj->psz_object_type ) );    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 ) );    PyDict_SetItemString( p_retval, "thread-id",                          PyLong_FromLongLong( p_obj->thread_id ) );    PyDict_SetItemString( p_retval, "refcount",                          PyInt_FromLong( p_obj->i_refcount ) );    return p_retval;}static PyObject *vlcObject_find_id( PyObject *self, PyObject *args ){    vlcObject *p_retval;    vlc_object_t* p_object;    int i_id;    if( !PyArg_ParseTuple( args, "i", &i_id ) )        return NULL;    p_object = ( vlc_object_t* )vlc_current_object( i_id );    if( !p_object )    {        Py_INCREF( Py_None );        return Py_None;    }    p_retval = PyObject_NEW( vlcObject, &vlcObject_Type );    p_retval->p_object = p_object;    return ( PyObject * )p_retval;}/* Do a var_Get call on the object. Parameter: the variable name. */static PyObject *vlcObject_var_get( PyObject *self, PyObject *args ){    PyObject *p_retval;    vlc_value_t value;    char *psz_name;    int i_type;    if( !PyArg_ParseTuple( args, "s", &psz_name ) )        return NULL;    if( var_Get( VLCSELF->p_object, psz_name, &value ) != VLC_SUCCESS )    {        PyErr_SetString( PyExc_StandardError,                         "Error: variable does not exist.\n" );        return NULL;    }    i_type = var_Type ( VLCSELF->p_object, psz_name );    switch ( i_type )    {    case VLC_VAR_VOID      :        p_retval = PyString_FromString( "A void variable" );        break;    case VLC_VAR_BOOL      :        p_retval = PyBool_FromLong( value.b_bool );        break;    case VLC_VAR_INTEGER   :        p_retval = PyInt_FromLong( ( long )value.i_int );        break;    case VLC_VAR_HOTKEY    :        p_retval = PyString_FromFormat( "A hotkey variable ( %d )", value.i_int );        break;    case VLC_VAR_FILE      :    case VLC_VAR_STRING    :    case VLC_VAR_DIRECTORY :    case VLC_VAR_VARIABLE  :        p_retval = PyString_FromString( value.psz_string );        break;    case VLC_VAR_MODULE   :        p_retval = ( PyObject* )PyObject_New( vlcObject, &vlcObject_Type );        ( ( vlcObject* )p_retval )->p_object = value.p_object;        break;    case VLC_VAR_FLOAT     :        p_retval = PyFloat_FromDouble( ( double )value.f_float );        break;    case VLC_VAR_TIME      :        p_retval = PyLong_FromLongLong( value.i_time );        break;    case VLC_VAR_ADDRESS   :        p_retval = PyString_FromString( "A VLC address ( not handled yet )" );        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -