2005-06-02 00:19:03 +02:00
|
|
|
from distutils.core import setup, Extension
|
|
|
|
import os
|
2009-05-25 12:22:41 +02:00
|
|
|
import commands
|
2005-06-02 00:19:03 +02:00
|
|
|
|
2006-02-22 14:15:10 +01:00
|
|
|
# Get build variables (buildir, srcdir)
|
2008-05-21 19:48:11 +02:00
|
|
|
top_builddir = os.path.join( '..', '..' )
|
|
|
|
os.environ['top_builddir'] = top_builddir
|
2006-02-22 14:15:10 +01:00
|
|
|
|
2007-07-04 17:29:57 +02:00
|
|
|
# Determine the extra link args. Normally, vlc-config should take care
|
|
|
|
# of this and return the right path values, from a development tree or
|
|
|
|
# an installed version.
|
|
|
|
libtool=False
|
|
|
|
linkargs=[]
|
|
|
|
d=os.path.join(top_builddir, 'src', '.libs')
|
|
|
|
if os.path.exists(d):
|
|
|
|
# We are in a development tree, which was compiled with libtool
|
|
|
|
libtool=True
|
|
|
|
linkargs=[ '-L' + d ]
|
|
|
|
else:
|
|
|
|
d=os.path.join(top_builddir, 'src')
|
|
|
|
# We are in a development tree, which was compiled without libtool
|
|
|
|
if os.path.exists(d):
|
|
|
|
linkargs=[ '-L' + d ]
|
|
|
|
|
|
|
|
# For out-of-tree compilations
|
2008-05-21 19:48:11 +02:00
|
|
|
srcdir = '.'
|
2006-02-22 14:15:10 +01:00
|
|
|
|
2005-06-02 00:19:03 +02:00
|
|
|
def get_vlcconfig():
|
|
|
|
vlcconfig=None
|
|
|
|
for n in ( 'vlc-config',
|
2006-02-22 14:15:10 +01:00
|
|
|
os.path.join( top_builddir, 'vlc-config' )):
|
2005-06-02 00:19:03 +02:00
|
|
|
if os.path.exists(n):
|
|
|
|
vlcconfig=n
|
|
|
|
break
|
2009-05-25 12:22:41 +02:00
|
|
|
status, output = commands.getstatusoutput('pkg-config libvlc --exists')
|
|
|
|
if status == 0:
|
|
|
|
vlcconfig="pkg-config libvlc"
|
2005-06-02 00:19:03 +02:00
|
|
|
if vlcconfig is None:
|
2009-05-25 12:22:41 +02:00
|
|
|
print "*** Warning *** Cannot find vlc-config. Will try sane defaults."
|
2005-06-02 00:19:03 +02:00
|
|
|
elif os.sys.platform == 'win32':
|
|
|
|
# Win32 does not know how to invoke the shell itself.
|
|
|
|
vlcconfig="sh %s" % vlcconfig
|
|
|
|
return vlcconfig
|
|
|
|
|
2005-12-09 18:54:47 +01:00
|
|
|
def get_vlc_version():
|
|
|
|
vlcconfig=get_vlcconfig()
|
|
|
|
if vlcconfig is None:
|
|
|
|
return ""
|
|
|
|
else:
|
2009-05-25 12:22:41 +02:00
|
|
|
version=os.popen('%s --modversion' % vlcconfig, 'r').readline().strip()
|
2005-12-09 18:54:47 +01:00
|
|
|
return version
|
2009-05-25 12:22:41 +02:00
|
|
|
|
2005-06-02 00:19:03 +02:00
|
|
|
def get_cflags():
|
|
|
|
vlcconfig=get_vlcconfig()
|
|
|
|
if vlcconfig is None:
|
|
|
|
return []
|
|
|
|
else:
|
2009-05-25 12:22:41 +02:00
|
|
|
cflags=os.popen('%s --cflags ' % vlcconfig, 'r').readline().strip()
|
2005-06-02 00:19:03 +02:00
|
|
|
return cflags
|
|
|
|
|
|
|
|
def get_ldflags():
|
|
|
|
vlcconfig=get_vlcconfig()
|
|
|
|
if vlcconfig is None:
|
2008-05-15 18:40:44 +02:00
|
|
|
return [ '-lvlc' ]
|
2005-06-02 00:19:03 +02:00
|
|
|
else:
|
2005-12-19 15:23:25 +01:00
|
|
|
ldflags = []
|
|
|
|
if os.sys.platform == 'darwin':
|
|
|
|
ldflags = "-read_only_relocs warning".split()
|
2009-05-25 12:22:41 +02:00
|
|
|
ldflags.extend(os.popen('%s --libs ' % vlcconfig,
|
|
|
|
'r').readline().rstrip().split())
|
2005-12-19 15:23:25 +01:00
|
|
|
if os.sys.platform == 'darwin':
|
|
|
|
ldflags.append('-lstdc++')
|
2005-06-02 00:19:03 +02:00
|
|
|
return ldflags
|
|
|
|
|
2007-01-05 20:15:16 +01:00
|
|
|
#source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c',
|
2006-09-20 13:10:44 +02:00
|
|
|
# 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
|
|
|
|
source_files = [ 'vlc_module.c' ]
|
|
|
|
|
2005-06-02 00:19:03 +02:00
|
|
|
# To compile in a local vlc tree
|
|
|
|
vlclocal = Extension('vlc',
|
2009-05-25 12:22:41 +02:00
|
|
|
sources = [ os.path.join( srcdir, f ) for f in source_files ],
|
|
|
|
include_dirs = [ top_builddir,
|
|
|
|
srcdir ],
|
|
|
|
extra_objects = [ ],
|
|
|
|
extra_compile_args = get_cflags(),
|
|
|
|
extra_link_args = linkargs + get_ldflags(),
|
|
|
|
)
|
|
|
|
|
|
|
|
setup (name = 'python-vlc',
|
|
|
|
version = '1.0.0.90',
|
|
|
|
author='Olivier Aubert',
|
|
|
|
author_email='olivier.aubert@liris.cnrs.fr',
|
|
|
|
url='http://wiki.videolan.org/PythonBinding',
|
|
|
|
#scripts = [ os.path.join( srcdir, 'vlcwidget.py') ],
|
|
|
|
py_modules=['vlcwrapper'],
|
2005-12-09 18:54:47 +01:00
|
|
|
keywords = [ 'vlc', 'video' ],
|
2009-05-25 12:22:41 +02:00
|
|
|
license = "GPL",
|
|
|
|
description = "VLC bindings for python.",
|
|
|
|
long_description = """VLC bindings for python.
|
2005-06-02 00:19:03 +02:00
|
|
|
|
2006-09-20 13:10:44 +02:00
|
|
|
This module provides bindings for the native libvlc API of the VLC
|
2009-05-25 12:22:41 +02:00
|
|
|
video player. Documentation can be found on the VLC wiki :
|
|
|
|
http://wiki.videolan.org/ExternalAPI
|
2005-06-02 00:19:03 +02:00
|
|
|
|
2006-09-20 13:10:44 +02:00
|
|
|
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 :
|
2009-05-25 12:22:41 +02:00
|
|
|
http://wiki.videolan.org/PythonBinding
|
2005-12-09 18:54:47 +01:00
|
|
|
|
2009-05-25 12:22:41 +02:00
|
|
|
Example session (for the MediaControl API):
|
2005-06-02 00:19:03 +02:00
|
|
|
|
|
|
|
import vlc
|
|
|
|
mc=vlc.MediaControl(['--verbose', '1'])
|
|
|
|
mc.playlist_add_item('movie.mpg')
|
|
|
|
|
|
|
|
# Start the movie at 2000ms
|
|
|
|
p=vlc.Position()
|
|
|
|
p.origin=vlc.RelativePosition
|
|
|
|
p.key=vlc.MediaTime
|
|
|
|
p.value=2000
|
|
|
|
mc.start(p)
|
|
|
|
# which could be abbreviated as
|
|
|
|
# mc.start(2000)
|
|
|
|
# for the default conversion from int is to make a RelativePosition in MediaTime
|
|
|
|
|
|
|
|
# Display some text during 2000ms
|
|
|
|
mc.display_text('Some useless information', 0, 2000)
|
|
|
|
|
|
|
|
# Pause the video
|
|
|
|
mc.pause(0)
|
|
|
|
|
|
|
|
# Get status information
|
|
|
|
mc.get_stream_information()
|
|
|
|
""",
|
|
|
|
ext_modules = [ vlclocal ])
|