Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
4e88f3b2
Commit
4e88f3b2
authored
Sep 20, 2006
by
Olivier Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python bindings: add support for the new libvlc API
parent
c340ebcb
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
2616 additions
and
31 deletions
+2616
-31
bindings/mediacontrol-python/Makefile.am
bindings/mediacontrol-python/Makefile.am
+4
-1
bindings/mediacontrol-python/README
bindings/mediacontrol-python/README
+22
-0
bindings/mediacontrol-python/setup.py
bindings/mediacontrol-python/setup.py
+25
-23
bindings/mediacontrol-python/vlc_input.c
bindings/mediacontrol-python/vlc_input.c
+234
-0
bindings/mediacontrol-python/vlc_instance.c
bindings/mediacontrol-python/vlc_instance.c
+644
-0
bindings/mediacontrol-python/vlc_mediacontrol.c
bindings/mediacontrol-python/vlc_mediacontrol.c
+660
-0
bindings/mediacontrol-python/vlc_module.c
bindings/mediacontrol-python/vlc_module.c
+182
-0
bindings/mediacontrol-python/vlc_object.c
bindings/mediacontrol-python/vlc_object.c
+616
-0
bindings/mediacontrol-python/vlc_position.c
bindings/mediacontrol-python/vlc_position.c
+188
-0
bindings/mediacontrol-python/vlcglue.h
bindings/mediacontrol-python/vlcglue.h
+41
-7
No files found.
bindings/mediacontrol-python/Makefile.am
View file @
4e88f3b2
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
# Building the Python binding
# Building the Python binding
###############################################################################
###############################################################################
EXTRA_DIST
=
vlcglue.c vlcglue.h setup.py vlcwrapper.py
EXTRA_DIST
=
vlcglue.h setup.py vlcwrapper.py
\
vlc_module.c vlc_object.c
\
vlc_mediacontrol.c vlc_position.c
\
vlc_instance.c vlc_input.c
if
BUILD_PYTHON
if
BUILD_PYTHON
...
...
bindings/mediacontrol-python/README
0 → 100644
View file @
4e88f3b2
* Compilation
* Testing
If you try to compile the bindings from a development tree, you will
have to specify the path for VLC modules, which cannot be guessed by
the extension module.
For vlc.MediaControl:
mc=vlc.MediaControl('--plugin-path /path/to/vlc/directory'.split())
For vlc.Instance:
i=vlc.Instance('--plugin-path /path/to/vlc/directory'.split())
* Skeleton generation :
** For method bindings:
perl -n -e 'print "static PyObject *\nvlcInput_$2( PyObject *self, PyObject *args )\n{\n libvlc_exception_t ex;\n LIBVLC_TRY;\n $1_$2( self->p_input, &ex); LIBVLC_EXCEPT;\n Py_INCREF( Py_None );\n return Py_None;\n}\n\n" if /(libvlc_input)_(\w+)/ and ($2 ne "t")' ../../include/vlc/libvlc.h
** For method table:
perl -n -e 'print " { \"$2\", $1_$2, METH_VARARGS,\n \"$2()\" },\n" if /^(vlcInput)_(\w+)/' vlc_instance.c
bindings/mediacontrol-python/setup.py
View file @
4e88f3b2
...
@@ -21,15 +21,8 @@ except KeyError:
...
@@ -21,15 +21,8 @@ except KeyError:
if
not
srcdir
:
if
not
srcdir
:
srcdir
=
'.'
srcdir
=
'.'
#if os.sys.platform in ('win32', 'darwin'):
vlclib
=
"-lvlc"
# Do not use PIC version on win32 and Mac OS X
picflag
=
''
if
True
:
# PIC version seems to be disabled on all platforms
vlclib
=
os
.
path
.
join
(
top_builddir
,
'src'
,
'libvlc.a'
)
picflag
=
''
else
:
vlclib
=
os
.
path
.
join
(
top_builddir
,
'src'
,
'libvlc_pic.a'
)
picflag
=
'pic'
def
get_vlcconfig
():
def
get_vlcconfig
():
vlcconfig
=
None
vlcconfig
=
None
...
@@ -69,38 +62,46 @@ def get_ldflags():
...
@@ -69,38 +62,46 @@ def get_ldflags():
ldflags
=
[]
ldflags
=
[]
if
os
.
sys
.
platform
==
'darwin'
:
if
os
.
sys
.
platform
==
'darwin'
:
ldflags
=
"-read_only_relocs warning"
.
split
()
ldflags
=
"-read_only_relocs warning"
.
split
()
ldflags
.
extend
(
os
.
popen
(
'%s --libs vlc %s
builtin
'
%
(
vlcconfig
,
ldflags
.
extend
(
os
.
popen
(
'%s --libs vlc %s'
%
(
vlcconfig
,
picflag
),
picflag
),
'r'
).
readline
().
rstrip
().
split
())
'r'
).
readline
().
rstrip
().
split
())
if
os
.
sys
.
platform
==
'darwin'
:
if
os
.
sys
.
platform
==
'darwin'
:
ldflags
.
append
(
'-lstdc++'
)
ldflags
.
append
(
'-lstdc++'
)
return
ldflags
return
ldflags
#source_files = [ 'vlc_module.c', 'vlc_object.c', 'vlc_mediacontrol.c',
# 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
source_files
=
[
'vlc_module.c'
]
# To compile in a local vlc tree
# To compile in a local vlc tree
vlclocal
=
Extension
(
'vlc'
,
vlclocal
=
Extension
(
'vlc'
,
sources
=
[
os
.
path
.
join
(
srcdir
,
'vlcglue.c'
),
sources
=
[
os
.
path
.
join
(
srcdir
,
f
)
for
f
in
source_files
]
+
os
.
path
.
join
(
srcdir
,
'../../src/control/mediacontrol_init.c'
)
],
[
os
.
path
.
join
(
top_builddir
,
'src/control/mediacontrol_init.c'
)
],
include_dirs
=
[
top_builddir
,
include_dirs
=
[
top_builddir
,
os
.
path
.
join
(
srcdir
,
'../../include'
),
os
.
path
.
join
(
top_builddir
,
'include'
),
os
.
path
.
join
(
srcdir
,
'../../'
,
'/usr/win32/include'
)
]
,
srcdir
,
'/usr/win32/include'
],
extra_objects
=
[
vlclib
],
extra_objects
=
[
vlclib
],
extra_compile_args
=
get_cflags
(),
extra_compile_args
=
get_cflags
(),
extra_link_args
=
[
'-L'
+
top_builddir
]
+
get_ldflags
(),
extra_link_args
=
[
'-L'
+
top_builddir
]
+
get_ldflags
(),
)
)
setup
(
name
=
'
MediaControl
'
,
setup
(
name
=
'
VLC Bindings
'
,
version
=
get_vlc_version
(),
version
=
get_vlc_version
(),
scripts
=
[
os
.
path
.
join
(
srcdir
,
'vlcwrapper.py'
)
],
#
scripts = [ os.path.join( srcdir, 'vlcwrapper.py') ],
keywords
=
[
'vlc'
,
'video'
],
keywords
=
[
'vlc'
,
'video'
],
license
=
"GPL"
,
license
=
"GPL"
,
description
=
"""VLC bindings for python.
description
=
"""VLC bindings for python.
This module provides a MediaControl object, which implements an API
This module provides bindings for the native libvlc API of the VLC
inspired from the OMG Audio/Video Stream 1.0 specification. Moreover,
video player. Documentation can be found on the VLC wiki :
the module provides a Object type, which gives a low-level access to
http://wiki.videolan.org/index.php/ExternalAPI
the vlc objects and their variables.
The module also provides a Object type, which gives a low-level access
to the vlc objects and their variables.
This module also provides a MediaControl object, which implements an
API inspired from the OMG Audio/Video Stream 1.0 specification.
Documentation can be found on the VLC wiki :
Documentation can be found on the VLC wiki :
http://wiki.videolan.org/index.php/PythonBinding
http://wiki.videolan.org/index.php/PythonBinding
...
@@ -135,5 +136,6 @@ o.info()
...
@@ -135,5 +136,6 @@ o.info()
i=o.find_object('input')
i=o.find_object('input')
i.list()
i.list()
i.get('time')
i.get('time')
"""
,
"""
,
ext_modules
=
[
vlclocal
])
ext_modules
=
[
vlclocal
])
bindings/mediacontrol-python/vlc_input.c
0 → 100644
View file @
4e88f3b2
/*****************************************************************************
* vlc_input.c: vlc.Input binding
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: $
*
* Authors: Olivier Aubert <oaubert at bat710.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "vlcglue.h"
/***********************************************************************
* vlc.Input
***********************************************************************/
static
PyObject
*
vlcInput_get_length
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
vlc_int64_t
i_ret
;
LIBVLC_TRY
;
i_ret
=
libvlc_input_get_length
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"L"
,
i_ret
);
}
static
PyObject
*
vlcInput_get_time
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
vlc_int64_t
i_ret
;
LIBVLC_TRY
;
i_ret
=
libvlc_input_get_time
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"L"
,
i_ret
);
}
static
PyObject
*
vlcInput_set_time
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
vlc_int64_t
i_time
;
if
(
!
PyArg_ParseTuple
(
args
,
"L"
,
&
i_time
)
)
return
NULL
;
LIBVLC_TRY
;
libvlc_input_set_time
(
LIBVLC_INPUT
->
p_input
,
i_time
,
&
ex
);
LIBVLC_EXCEPT
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
vlcInput_get_position
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
float
f_ret
;
LIBVLC_TRY
;
f_ret
=
libvlc_input_get_position
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"f"
,
f_ret
);
}
static
PyObject
*
vlcInput_set_position
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
float
f_pos
;
if
(
!
PyArg_ParseTuple
(
args
,
"f"
,
&
f_pos
)
)
return
NULL
;
LIBVLC_TRY
;
libvlc_input_set_position
(
LIBVLC_INPUT
->
p_input
,
f_pos
,
&
ex
);
LIBVLC_EXCEPT
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
vlcInput_will_play
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
int
i_ret
;
LIBVLC_TRY
;
i_ret
=
libvlc_input_will_play
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"i"
,
i_ret
);
}
static
PyObject
*
vlcInput_get_rate
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
float
f_ret
;
LIBVLC_TRY
;
f_ret
=
libvlc_input_get_rate
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"f"
,
f_ret
);
}
static
PyObject
*
vlcInput_set_rate
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
float
f_rate
;
if
(
!
PyArg_ParseTuple
(
args
,
"f"
,
&
f_rate
)
)
return
NULL
;
LIBVLC_TRY
;
libvlc_input_set_rate
(
LIBVLC_INPUT
->
p_input
,
f_rate
,
&
ex
);
LIBVLC_EXCEPT
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
vlcInput_get_state
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
int
i_ret
;
LIBVLC_TRY
;
i_ret
=
libvlc_input_get_state
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"i"
,
i_ret
);
}
static
PyObject
*
vlcInput_has_vout
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
int
i_ret
;
LIBVLC_TRY
;
i_ret
=
libvlc_input_has_vout
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"i"
,
i_ret
);
}
static
PyObject
*
vlcInput_get_fps
(
PyObject
*
self
,
PyObject
*
args
)
{
libvlc_exception_t
ex
;
float
f_ret
;
LIBVLC_TRY
;
f_ret
=
libvlc_input_get_fps
(
LIBVLC_INPUT
->
p_input
,
&
ex
);
LIBVLC_EXCEPT
;
return
Py_BuildValue
(
"f"
,
f_ret
);
}
static
PyMethodDef
vlcInput_methods
[]
=
{
{
"get_length"
,
vlcInput_get_length
,
METH_VARARGS
,
"get_length() -> long"
},
{
"get_time"
,
vlcInput_get_time
,
METH_VARARGS
,
"get_time() -> long"
},
{
"set_time"
,
vlcInput_set_time
,
METH_VARARGS
,
"set_time(long)"
},
{
"get_position"
,
vlcInput_get_position
,
METH_VARARGS
,
"get_position() -> float"
},
{
"set_position"
,
vlcInput_set_position
,
METH_VARARGS
,
"set_position(float)"
},
{
"will_play"
,
vlcInput_will_play
,
METH_VARARGS
,
"will_play() -> int"
},
{
"get_rate"
,
vlcInput_get_rate
,
METH_VARARGS
,
"get_rate() -> float"
},
{
"set_rate"
,
vlcInput_set_rate
,
METH_VARARGS
,
"set_rate(float)"
},
{
"get_state"
,
vlcInput_get_state
,
METH_VARARGS
,
"get_state() -> int"
},
{
"has_vout"
,
vlcInput_has_vout
,
METH_VARARGS
,
"has_vout() -> int"
},
{
"get_fps"
,
vlcInput_get_fps
,
METH_VARARGS
,
"get_fps() -> float"
},
{
NULL
}
/* Sentinel */
};
static
PyTypeObject
vlcInput_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
/*ob_size*/
"vlc.Input"
,
/*tp_name*/
sizeof
(
vlcInput_Type
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
0
,
/*tp_dealloc*/
0
,
/*tp_print*/
0
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash */
0
,
/*tp_call*/
0
,
/*tp_str*/
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/*tp_flags*/
"vlc.Input object"
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
vlcInput_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
};
bindings/mediacontrol-python/vlc_instance.c
0 → 100644
View file @
4e88f3b2
This diff is collapsed.
Click to expand it.
bindings/mediacontrol-python/vlc
glue
.c
→
bindings/mediacontrol-python/vlc
_mediacontrol
.c
View file @
4e88f3b2
This diff is collapsed.
Click to expand it.
bindings/mediacontrol-python/vlc_module.c
0 → 100644
View file @
4e88f3b2
/*****************************************************************************
* vlc_module.c: vlc python binding module
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: $
*
* Authors: Olivier Aubert <oaubert at bat710.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* We need to access some internal features of VLC (for vlc_object) */
#define __VLC__
#include "vlcglue.h"
/**************************************************************************
* VLC Module
**************************************************************************/
#ifndef vlcMODINIT_FUNC
/* declarations for DLL import/export */
#define vlcMODINIT_FUNC void
#endif
static
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_FUNC
initvlc
(
void
)
{
PyObject
*
p_module
;
PyPosition_Type
.
tp_new
=
PyType_GenericNew
;
PyPosition_Type
.
tp_alloc
=
PyType_GenericAlloc
;
vlcInput_Type
.
tp_new
=
PyType_GenericNew
;
vlcInput_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
;
if
(
PyType_Ready
(
&
vlcInstance_Type
)
<
0
)
return
;
if
(
PyType_Ready
(
&
vlcInput_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
);
/* Exceptions */
vlcInstance_Exception
=
PyErr_NewException
(
"vlc.InstanceException"
,
NULL
,
NULL
);
Py_INCREF
(
vlcInstance_Exception
);
PyModule_AddObject
(
p_module
,
"InstanceException"
,
vlcInstance_Exception
);
/* 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
);
Py_INCREF
(
&
vlcInstance_Type
);
PyModule_AddObject
(
p_module
,
"Instance"
,
(
PyObject
*
)
&
vlcInstance_Type
);
Py_INCREF
(
&
vlcInput_Type
);
PyModule_AddObject
(
p_module
,
"Input"
,
(
PyObject
*
)
&
vlcInput_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
);
}
/* Horrible hack... Please do not look. Temporary workaround for the
forward declaration mess of python types (cf vlcglue.h). If we do a
separate compilation, we have to declare some types as extern. But
the recommended way to forward declare types in python is
static... I am sorting the mess but in the meantime, this will
produce a working python module.
*/
#include "vlc_mediacontrol.c"
#include "vlc_position.c"
#include "vlc_instance.c"
#include "vlc_input.c"
#include "vlc_object.c"
bindings/mediacontrol-python/vlc_object.c
0 → 100644
View file @
4e88f3b2
This diff is collapsed.
Click to expand it.
bindings/mediacontrol-python/vlc_position.c
0 → 100644
View file @
4e88f3b2
/*****************************************************************************
* vlc_position.c: vlc.Position binding
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: $
*
* Authors: Olivier Aubert <oaubert at bat710.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "vlcglue.h"
/***********************************************************************
* Position
***********************************************************************/
static
int
PyPosition_init
(
PyPosition
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
self
->
origin
=
mediacontrol_AbsolutePosition
;
self
->
key
=
mediacontrol_MediaTime
;
self
->
value
=
0
;
return
0
;
}
mediacontrol_PositionKey
positionKey_py_to_c
(
PyObject
*
py_key
)
{
mediacontrol_PositionKey
key_position
=
mediacontrol_MediaTime
;
int
key
;
if
(
!
PyArg_Parse
(
py_key
,
"i"
,
&
key
)
)
{
PyErr_SetString
(
MediaControl_InternalException
,
"Invalid key value"
);
return
key_position
;
}
switch
(
key
)
{
case
0
:
key
=
mediacontrol_ByteCount
;
break
;
case
1
:
key
=
mediacontrol_SampleCount
;
break
;
case
2
:
key
=
mediacontrol_MediaTime
;
break
;
}
return
key_position
;
}
mediacontrol_PositionOrigin
positionOrigin_py_to_c
(
PyObject
*
py_origin
)
{
mediacontrol_PositionOrigin
origin_position
=
mediacontrol_AbsolutePosition
;
int
origin
;
if
(
!
PyArg_Parse
(
py_origin
,
"i"
,
&
origin
)
)
{
PyErr_SetString
(
MediaControl_InternalException
,
"Invalid origin value"
);
return
origin_position
;
}
switch
(
origin
)
{
case
0
:
origin_position
=
mediacontrol_AbsolutePosition
;
break
;
case
1
:
origin_position
=
mediacontrol_RelativePosition
;
break
;
case
2
:
origin_position
=
mediacontrol_ModuloPosition
;
break
;
}
return
origin_position
;
}
/* Methods for transforming the Position Python object to Position structure*/
mediacontrol_Position
*
position_py_to_c
(
PyObject
*
py_position
)
{
mediacontrol_Position
*
a_position
=
NULL
;
PyPosition
*
pos
=
(
PyPosition
*
)
py_position
;
a_position
=
(
mediacontrol_Position
*
)
malloc
(
sizeof
(
mediacontrol_Position
)
);
if
(
!
a_position
)
{
PyErr_SetString
(
PyExc_MemoryError
,
"Out of memory"
);
return
NULL
;
}
if
(
!
py_position
)
{
/* If we give a NULL value, it will be considered as
a 0 relative position in mediatime */
a_position
->
origin
=
mediacontrol_RelativePosition
;
a_position
->
key
=
mediacontrol_MediaTime
;
a_position
->
value
=
0
;
}
else
if
(
PyObject_IsInstance
(
py_position
,
(
PyObject
*
)
&
PyPosition_Type
)
)
{
a_position
->
origin
=
pos
->
origin
;
a_position
->
key
=
pos
->
key
;
a_position
->
value
=
ntohll
(
pos
->
value
);
}
else
{
/* Feature: if we give an integer, it will be considered as
a relative position in mediatime */
a_position
->
origin
=
mediacontrol_RelativePosition
;
a_position
->
key
=
mediacontrol_MediaTime
;
a_position
->
value
=
PyLong_AsLongLong
(
py_position
);
}
return
a_position
;
}
PyPosition
*
position_c_to_py
(
mediacontrol_Position
*
position
)
{
PyPosition
*
py_retval
;
py_retval
=
PyObject_New
(
PyPosition
,
&
PyPosition_Type
);
py_retval
->
origin
=
position
->
origin
;
py_retval
->
key
=
position
->
key
;
py_retval
->
value
=
position
->
value
;
return
py_retval
;
}
static
PyMethodDef
PyPosition_methods
[]
=
{
{
NULL
}
/* Sentinel */
};
static
PyMemberDef
PyPosition_members
[]
=
{
{
"origin"
,
T_INT
,
offsetof
(
PyPosition
,
origin
),
0
,
"Position origin"
},
{
"key"
,
T_INT
,
offsetof
(
PyPosition
,
key
),
0
,
"Position key"
},
{
"value"
,
T_ULONG
,
offsetof
(
PyPosition
,
value
),
0
,
"Position value"
},
{
NULL
}
/* Sentinel */
};
static
PyTypeObject
PyPosition_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
/*ob_size*/
"vlc.Position"
,
/*tp_name*/
sizeof
(
PyPosition_Type
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
0
,
/*tp_dealloc*/
0
,
/*tp_print*/
0
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash */
0
,
/*tp_call*/
0
,
/*tp_str*/
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/*tp_flags*/
"Represent a Position with origin, key and value"
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
PyPosition_methods
,
/* tp_methods */
PyPosition_members
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
(
initproc
)
PyPosition_init
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
};
bindings/mediacontrol-python/vlcglue.h
View file @
4e88f3b2
...
@@ -21,14 +21,15 @@
...
@@ -21,14 +21,15 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*****************************************************************************/
#ifndef _VLCGLUE_H
#define _VLCGLUE_H 1
#include <Python.h>
#include <Python.h>
#include "structmember.h"
#include "structmember.h"
#define __VLC__
#include <stdio.h>
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/vlc.h>
#include <vlc/libvlc.h>
#include <vlc/mediacontrol_structures.h>
#include <vlc/mediacontrol_structures.h>
#include <vlc/mediacontrol.h>
#include <vlc/mediacontrol.h>
...
@@ -70,6 +71,7 @@ PyObject *MediaControl_PositionKeyNotSupported;
...
@@ -70,6 +71,7 @@ PyObject *MediaControl_PositionKeyNotSupported;
PyObject
*
MediaControl_PositionOriginNotSupported
;
PyObject
*
MediaControl_PositionOriginNotSupported
;
PyObject
*
MediaControl_InvalidPosition
;
PyObject
*
MediaControl_InvalidPosition
;
PyObject
*
MediaControl_PlaylistException
;
PyObject
*
MediaControl_PlaylistException
;
PyObject
*
vlcInstance_Exception
;
/**********************************************************************
/**********************************************************************
* VLC Object
* VLC Object
...
@@ -86,8 +88,6 @@ typedef struct
...
@@ -86,8 +88,6 @@ typedef struct
int
b_released
;
int
b_released
;
}
vlcObject
;
}
vlcObject
;
staticforward
PyTypeObject
vlcObject_Type
;
/**********************************************************************
/**********************************************************************
* MediaControl Object
* MediaControl Object
**********************************************************************/
**********************************************************************/
...
@@ -95,9 +95,7 @@ typedef struct
...
@@ -95,9 +95,7 @@ typedef struct
{
{
PyObject_HEAD
PyObject_HEAD
mediacontrol_Instance
*
mc
;
mediacontrol_Instance
*
mc
;
}
MediaControl
;
}
MediaControl
;
staticforward
PyTypeObject
MediaControl_Type
;
/**********************************************************************
/**********************************************************************
* Position Object
* Position Object
...
@@ -110,7 +108,42 @@ typedef struct
...
@@ -110,7 +108,42 @@ typedef struct
PY_LONG_LONG
value
;
PY_LONG_LONG
value
;
}
PyPosition
;
}
PyPosition
;
/**********************************************************************
* vlc.Instance Object
**********************************************************************/
typedef
struct
{
PyObject_HEAD
libvlc_instance_t
*
p_instance
;
}
vlcInstance
;
#define LIBVLC_INSTANCE ((vlcInstance*)self)
/**********************************************************************
* vlc.Input Object
**********************************************************************/
typedef
struct
{
PyObject_HEAD
libvlc_input_t
*
p_input
;
}
vlcInput
;
/* Forward declarations */
staticforward
PyTypeObject
vlcObject_Type
;
staticforward
PyTypeObject
MediaControl_Type
;
staticforward
PyTypeObject
PyPosition_Type
;
staticforward
PyTypeObject
PyPosition_Type
;
staticforward
PyTypeObject
vlcInstance_Type
;
staticforward
PyTypeObject
vlcInput_Type
;
#define LIBVLC_INPUT ((vlcInput*)self)
#define LIBVLC_TRY libvlc_exception_init( &ex );
#define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \
PyObject *py_exc = vlcInstance_Exception; \
PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \
return NULL; \
}
mediacontrol_PositionKey
positionKey_py_to_c
(
PyObject
*
py_key
);
mediacontrol_PositionKey
positionKey_py_to_c
(
PyObject
*
py_key
);
mediacontrol_PositionOrigin
positionOrigin_py_to_c
(
PyObject
*
py_origin
);
mediacontrol_PositionOrigin
positionOrigin_py_to_c
(
PyObject
*
py_origin
);
...
@@ -124,3 +157,4 @@ PyPosition * position_c_to_py( mediacontrol_Position * position );
...
@@ -124,3 +157,4 @@ PyPosition * position_c_to_py( mediacontrol_Position * position );
#define ntohll(x) (x)
#define ntohll(x) (x)
#endif
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment