Changeset a315f6348f5932244c9b395cd0330652faa9baeb

Show
Ignore:
Timestamp:
12/21/06 12:02:31 (2 years ago)
Author:
Olivier Aubert <olivier.aubert@liris.cnrs.fr>
git-committer:
Olivier Aubert <olivier.aubert@liris.cnrs.fr> 1166698951 +0000
git-parent:

[a77fdc28e0573179dd369475bb1cb58ce403b641]

git-author:
Olivier Aubert <olivier.aubert@liris.cnrs.fr> 1166698951 +0000
Message:

python bindings: completed libvlc bindings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bindings/python/vlc_input.c

    r53af664 ra315f63  
    163163} 
    164164 
     165static PyObject * 
     166vlcInput_audio_get_track( PyObject *self, PyObject *args ) 
     167{ 
     168    libvlc_exception_t ex; 
     169    int i_ret; 
     170 
     171    LIBVLC_TRY; 
     172    i_ret = libvlc_audio_get_track( LIBVLC_INPUT->p_input, &ex ); 
     173    LIBVLC_EXCEPT; 
     174    return Py_BuildValue( "i", i_ret ); 
     175} 
     176 
     177static PyObject * 
     178vlcInput_audio_set_track( PyObject *self, PyObject *args ) 
     179{ 
     180    libvlc_exception_t ex; 
     181    int i_track; 
     182 
     183    if( !PyArg_ParseTuple( args, "i", &i_track ) ) 
     184        return NULL; 
     185 
     186    LIBVLC_TRY; 
     187    libvlc_audio_set_track( LIBVLC_INPUT->p_input, i_track, &ex ); 
     188    LIBVLC_EXCEPT; 
     189    Py_INCREF( Py_None ); 
     190    return Py_None; 
     191} 
     192 
     193static PyObject * 
     194vlcInput_toggle_fullscreen( PyObject *self, PyObject *args ) 
     195{ 
     196    libvlc_exception_t ex; 
     197 
     198    LIBVLC_TRY; 
     199    libvlc_toggle_fullscreen( LIBVLC_INPUT->p_input, &ex); 
     200    LIBVLC_EXCEPT; 
     201    Py_INCREF( Py_None ); 
     202    return Py_None;     
     203} 
     204 
     205static PyObject * 
     206vlcInput_set_fullscreen( PyObject *self, PyObject *args ) 
     207{ 
     208    libvlc_exception_t ex; 
     209    int i_fullscreen; 
     210 
     211    if( !PyArg_ParseTuple( args, "i", &i_fullscreen ) ) 
     212        return NULL; 
     213 
     214    LIBVLC_TRY; 
     215    libvlc_set_fullscreen( LIBVLC_INPUT->p_input, i_fullscreen, &ex); 
     216    LIBVLC_EXCEPT; 
     217    Py_INCREF( Py_None ); 
     218    return Py_None; 
     219} 
     220 
     221static PyObject * 
     222vlcInput_get_fullscreen( PyObject *self, PyObject *args ) 
     223{ 
     224    libvlc_exception_t ex; 
     225    int i_ret; 
     226 
     227    LIBVLC_TRY; 
     228    i_ret = libvlc_get_fullscreen( LIBVLC_INPUT->p_input, &ex); 
     229    LIBVLC_EXCEPT; 
     230    return Py_BuildValue( "i", i_ret ); 
     231} 
     232 
     233static PyObject * 
     234vlcInput_get_height( PyObject *self, PyObject *args ) 
     235{ 
     236    libvlc_exception_t ex; 
     237    int i_ret; 
     238 
     239    LIBVLC_TRY; 
     240    i_ret = libvlc_video_get_height( LIBVLC_INPUT->p_input, &ex); 
     241    LIBVLC_EXCEPT; 
     242    return Py_BuildValue( "i", i_ret ); 
     243} 
     244 
     245static PyObject * 
     246vlcInput_get_width( PyObject *self, PyObject *args ) 
     247{ 
     248    libvlc_exception_t ex; 
     249    int i_ret; 
     250 
     251    LIBVLC_TRY; 
     252    i_ret = libvlc_video_get_width( LIBVLC_INPUT->p_input, &ex); 
     253    LIBVLC_EXCEPT; 
     254    return Py_BuildValue( "i", i_ret ); 
     255} 
     256 
     257static PyObject * 
     258vlcInput_get_aspect_ratio( PyObject *self, PyObject *args ) 
     259{ 
     260    libvlc_exception_t ex; 
     261    char* psz_ret; 
     262    PyObject* o_ret; 
     263 
     264    LIBVLC_TRY; 
     265    psz_ret = libvlc_video_get_aspect_ratio( LIBVLC_INPUT->p_input, &ex); 
     266    LIBVLC_EXCEPT; 
     267    o_ret=Py_BuildValue( "s", psz_ret ); 
     268    free( psz_ret ); 
     269    return o_ret; 
     270} 
     271 
     272static PyObject * 
     273vlcInput_set_aspect_ratio( PyObject *self, PyObject *args ) 
     274{ 
     275    libvlc_exception_t ex; 
     276    char* psz_ratio; 
     277 
     278    if( !PyArg_ParseTuple( args, "s", &psz_ratio ) ) 
     279        return NULL; 
     280 
     281    LIBVLC_TRY; 
     282    libvlc_video_set_aspect_ratio( LIBVLC_INPUT->p_input, psz_ratio, &ex); 
     283    LIBVLC_EXCEPT; 
     284    free( psz_ratio ); 
     285    Py_INCREF( Py_None ); 
     286    return Py_None; 
     287} 
     288 
     289static PyObject * 
     290vlcInput_video_take_snapshot( PyObject *self, PyObject *args ) 
     291{ 
     292    libvlc_exception_t ex; 
     293    char* psz_filename; 
     294 
     295    if( !PyArg_ParseTuple( args, "s", &psz_filename ) ) 
     296        return NULL; 
     297 
     298    LIBVLC_TRY; 
     299    libvlc_video_take_snapshot( LIBVLC_INPUT->p_input, psz_filename, &ex); 
     300    LIBVLC_EXCEPT; 
     301    Py_INCREF( Py_None ); 
     302    return Py_None; 
     303} 
     304 
     305static PyObject * 
     306vlcInput_video_resize( PyObject *self, PyObject *args ) 
     307{ 
     308    libvlc_exception_t ex; 
     309    int i_width; 
     310    int i_height; 
     311 
     312    if( !PyArg_ParseTuple( args, "ii", &i_width, &i_height ) ) 
     313        return NULL; 
     314 
     315    LIBVLC_TRY; 
     316    libvlc_video_resize( LIBVLC_INPUT->p_input, i_width, i_height, &ex); 
     317    LIBVLC_EXCEPT; 
     318    Py_INCREF( Py_None ); 
     319    return Py_None; 
     320} 
     321 
     322static PyObject * 
     323vlcInput_video_reparent( PyObject *self, PyObject *args ) 
     324{ 
     325    libvlc_exception_t ex; 
     326    WINDOWHANDLE i_visual; 
     327    int i_ret; 
     328 
     329    if( !PyArg_ParseTuple( args, "i", &i_visual ) ) 
     330        return NULL; 
     331 
     332    LIBVLC_TRY; 
     333    i_ret = libvlc_video_reparent( LIBVLC_INPUT->p_input, i_visual, &ex); 
     334    LIBVLC_EXCEPT; 
     335    return Py_BuildValue( "i", i_ret ); 
     336} 
     337 
    165338static PyMethodDef vlcInput_methods[] = 
    166339{ 
    167340    { "get_length", vlcInput_get_length, METH_VARARGS, 
    168       "get_length() -> long" }, 
     341      "get_length() -> long    " }, 
    169342    { "get_time", vlcInput_get_time, METH_VARARGS, 
    170343      "get_time() -> long" }, 
     
    187360    { "get_fps", vlcInput_get_fps, METH_VARARGS, 
    188361      "get_fps() -> float" }, 
     362    { "audio_get_track", vlcInput_audio_get_track, METH_VARARGS, 
     363      "audio_get_track() -> int    Get current audio track" }, 
     364    { "audio_set_track", vlcInput_audio_set_track, METH_VARARGS, 
     365      "audio_set_track(int)        Set current audio track" }, 
     366    { "toggle_fullscreen", vlcInput_toggle_fullscreen, METH_VARARGS, 
     367      "toggle_fullscreen()    Toggle fullscreen status on video output" }, 
     368    { "set_fullscreen", vlcInput_set_fullscreen, METH_VARARGS, 
     369      "set_fullscreen(bool)    Enable or disable fullscreen on a video output" }, 
     370    { "get_fullscreen", vlcInput_get_fullscreen, METH_VARARGS, 
     371      "get_fullscreen() -> bool    Get current fullscreen status" }, 
     372    { "get_height", vlcInput_get_height, METH_VARARGS, 
     373      "get_height() -> int           Get current video height" }, 
     374    { "get_width", vlcInput_get_width, METH_VARARGS, 
     375      "get_width() -> int           Get current video width" }, 
     376    { "get_aspect_ratio", vlcInput_get_aspect_ratio, METH_VARARGS, 
     377      "get_aspect_ratio() -> str    Get current video aspect ratio" }, 
     378    { "set_aspect_ratio", vlcInput_set_aspect_ratio, METH_VARARGS, 
     379      "set_aspect_ratio(str)        Set new video aspect ratio" }, 
     380    { "video_take_snapshot", vlcInput_video_take_snapshot, METH_VARARGS, 
     381      "video_take_snapshot(filename=str)        Take a snapshot of the current video window" }, 
     382    { "video_resize", vlcInput_video_resize, METH_VARARGS, 
     383      "video_resize(width=int, height=int)      Resize the current video output window" }, 
     384    { "video_reparent", vlcInput_video_reparent, METH_VARARGS, 
     385      "video_reparent(visual=int)               change the parent for the current video output" }, 
     386 
    189387    { NULL }  /* Sentinel */ 
    190388}; 
  • bindings/python/vlc_instance.c

    r53af664 ra315f63  
    124124} 
    125125 
     126/* Set loop variable */ 
     127static PyObject * 
     128vlcInstance_playlist_loop( PyObject *self, PyObject *args ) 
     129{ 
     130    libvlc_exception_t ex; 
     131    int i_loop = 0; 
     132 
     133    if( !PyArg_ParseTuple( args, "i", &i_loop ) ) 
     134        return NULL; 
     135 
     136    LIBVLC_TRY; 
     137    libvlc_playlist_loop( LIBVLC_INSTANCE->p_instance, i_loop, &ex ); 
     138    LIBVLC_EXCEPT; 
     139 
     140    Py_INCREF( Py_None ); 
     141    return Py_None; 
     142} 
     143 
    126144/* Playlist play. 2 parameters: i_id, the id to play 
    127145   l_options: a list of options */ 
     
    412430    LIBVLC_TRY; 
    413431    libvlc_audio_set_mute( LIBVLC_INSTANCE->p_instance, i_volume, &ex ); 
     432    LIBVLC_EXCEPT; 
     433    Py_INCREF( Py_None ); 
     434    return Py_None; 
     435} 
     436 
     437static PyObject * 
     438vlcInstance_audio_get_channel( PyObject *self, PyObject *args ) 
     439{ 
     440    libvlc_exception_t ex; 
     441    char* psz_ret; 
     442    PyObject* o_ret; 
     443 
     444    LIBVLC_TRY; 
     445    psz_ret = libvlc_audio_get_channel( LIBVLC_INSTANCE->p_instance, &ex ); 
     446    LIBVLC_EXCEPT; 
     447    o_ret=Py_BuildValue( "s", psz_ret ); 
     448    free( psz_ret ); 
     449    return o_ret; 
     450} 
     451 
     452static PyObject * 
     453vlcInstance_audio_set_channel( PyObject *self, PyObject *args ) 
     454{ 
     455    libvlc_exception_t ex; 
     456    char* psz_channel; 
     457 
     458    if( !PyArg_ParseTuple( args, "s", &psz_channel ) ) 
     459        return NULL; 
     460 
     461    LIBVLC_TRY; 
     462    libvlc_audio_set_channel( LIBVLC_INSTANCE->p_instance, psz_channel, &ex ); 
    414463    LIBVLC_EXCEPT; 
    415464    Py_INCREF( Py_None ); 
     
    596645    libvlc_exception_t ex; 
    597646    char* psz_name; 
    598      
     647 
    599648    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
    600649        return NULL; 
     
    621670    Py_INCREF( Py_None ); 
    622671    return Py_None; 
     672} 
     673 
     674static PyObject * 
     675vlcInstance_vlm_seek_media( PyObject *self, PyObject *args ) 
     676{ 
     677    libvlc_exception_t ex; 
     678    char* psz_name; 
     679    float f_percentage; 
     680     
     681    if( !PyArg_ParseTuple( args, "sf", &psz_name, &f_percentage ) ) 
     682        return NULL; 
     683 
     684    LIBVLC_TRY; 
     685    libvlc_vlm_seek_media( LIBVLC_INSTANCE->p_instance, psz_name, f_percentage, &ex); 
     686    LIBVLC_EXCEPT; 
     687    Py_INCREF( Py_None ); 
     688    return Py_None; 
     689} 
     690 
     691static PyObject * 
     692vlcInstance_vlm_show_media( PyObject *self, PyObject *args ) 
     693{ 
     694    libvlc_exception_t ex; 
     695    char* psz_name; 
     696    char* psz_ret; 
     697    PyObject* o_ret; 
     698 
     699    if( !PyArg_ParseTuple( args, "s", &psz_name ) ) 
     700        return NULL; 
     701    LIBVLC_TRY; 
     702    psz_ret = libvlc_vlm_show_media( LIBVLC_INSTANCE->p_instance, psz_name, &ex ); 
     703    LIBVLC_EXCEPT; 
     704    o_ret = Py_BuildValue( "s", psz_ret ); 
     705    free( psz_ret ); 
     706    return o_ret; 
    623707} 
    624708 
     
    628712    { "get_vlc_id", vlcInstance_get_vlc_id, METH_VARARGS, 
    629713      "get_vlc_id( ) -> int        Get the instance id."}, 
     714    { "playlist_loop", vlcInstance_playlist_loop, METH_VARARGS, 
     715      "playlist_loop(bool)         Set loop variable" }, 
    630716    { "playlist_play", vlcInstance_playlist_play, METH_VARARGS, 
    631717      "playlist_play(id=int, options=list)   Play the given playlist item (-1 for current item) with optional options (a list of strings)" }, 
     
    664750    { "audio_set_volume", vlcInstance_audio_set_volume, METH_VARARGS, 
    665751      "audio_set_volume(volume=int)       Set the audio volume"}, 
    666  
     752    { "audio_get_channel", vlcInstance_audio_get_channel, METH_VARARGS, 
     753      "audio_get_channel() -> int  Get current audio channel" }, 
     754    { "audio_set_channel", vlcInstance_audio_set_channel, METH_VARARGS, 
     755      "audio_set_channel(int)      Set current audio channel" }, 
    667756    { "vlm_add_broadcast", vlcInstance_vlm_add_broadcast, METH_VARARGS | METH_KEYWORDS, 
    668757      "vlm_add_broadcast(name=str, input=str, output=str, options=list, enable=int, loop=int)   Add a new broadcast" }, 
     
    680769      "vlm_change_media(name=str, input=str, output=str, options=list, enable=int, loop=int)   Change the broadcast parameters" }, 
    681770    { "vlm_play_media", vlcInstance_vlm_play_media, METH_VARARGS, 
    682       "vlm_play_media(name=str)" }, 
     771      "vlm_play_media(name=str)       Plays the named broadcast." }, 
    683772    { "vlm_stop_media", vlcInstance_vlm_stop_media, METH_VARARGS, 
    684       "vlm_stop_media(name=str)" }, 
     773      "vlm_stop_media(name=str)       Stops the named broadcast." }, 
    685774    { "vlm_pause_media", vlcInstance_vlm_pause_media, METH_VARARGS, 
    686       "vlm_pause_media(name=str)" }, 
     775      "vlm_pause_media(name=str)      Pauses the named broadcast." }, 
     776    { "vlm_seek_media", vlcInstance_vlm_seek_media, METH_VARARGS, 
     777      "vlm_seek_media(name=str, percentage=float)  Seeks in the named broadcast." }, 
     778    { "vlm_show_media", vlcInstance_vlm_show_media, METH_VARARGS, 
     779      "vlm_show_media(name=str)       Return information of the named broadcast." }, 
    687780 
    688781    { NULL, NULL, 0, NULL },