| 1 |
from distutils.core import setup, Extension |
|---|
| 2 |
import os |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
top_builddir = os.path.join( '..', '..' ) |
|---|
| 6 |
os.environ['top_builddir'] = top_builddir |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
libtool=False |
|---|
| 12 |
linkargs=[] |
|---|
| 13 |
d=os.path.join(top_builddir, 'src', '.libs') |
|---|
| 14 |
if os.path.exists(d): |
|---|
| 15 |
|
|---|
| 16 |
libtool=True |
|---|
| 17 |
linkargs=[ '-L' + d ] |
|---|
| 18 |
else: |
|---|
| 19 |
d=os.path.join(top_builddir, 'src') |
|---|
| 20 |
|
|---|
| 21 |
if os.path.exists(d): |
|---|
| 22 |
linkargs=[ '-L' + d ] |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
srcdir = '.' |
|---|
| 26 |
|
|---|
| 27 |
def get_vlcconfig(): |
|---|
| 28 |
vlcconfig=None |
|---|
| 29 |
for n in ( 'vlc-config', |
|---|
| 30 |
os.path.join( top_builddir, 'vlc-config' )): |
|---|
| 31 |
if os.path.exists(n): |
|---|
| 32 |
vlcconfig=n |
|---|
| 33 |
break |
|---|
| 34 |
if vlcconfig is None: |
|---|
| 35 |
print "*** Warning *** Cannot find vlc-config" |
|---|
| 36 |
elif os.sys.platform == 'win32': |
|---|
| 37 |
|
|---|
| 38 |
vlcconfig="sh %s" % vlcconfig |
|---|
| 39 |
return vlcconfig |
|---|
| 40 |
|
|---|
| 41 |
def get_vlc_version(): |
|---|
| 42 |
vlcconfig=get_vlcconfig() |
|---|
| 43 |
if vlcconfig is None: |
|---|
| 44 |
return "" |
|---|
| 45 |
else: |
|---|
| 46 |
version=os.popen('%s --version' % vlcconfig, 'r').readline().strip() |
|---|
| 47 |
return version |
|---|
| 48 |
|
|---|
| 49 |
def get_cflags(): |
|---|
| 50 |
vlcconfig=get_vlcconfig() |
|---|
| 51 |
if vlcconfig is None: |
|---|
| 52 |
return [] |
|---|
| 53 |
else: |
|---|
| 54 |
cflags=os.popen('%s --cflags vlc' % vlcconfig, 'r').readline().rstrip().split() |
|---|
| 55 |
return cflags |
|---|
| 56 |
|
|---|
| 57 |
def get_ldflags(): |
|---|
| 58 |
vlcconfig=get_vlcconfig() |
|---|
| 59 |
if vlcconfig is None: |
|---|
| 60 |
return [ '-lvlc' ] |
|---|
| 61 |
else: |
|---|
| 62 |
ldflags = [] |
|---|
| 63 |
if os.sys.platform == 'darwin': |
|---|
| 64 |
ldflags = "-read_only_relocs warning".split() |
|---|
| 65 |
ldflags.extend(os.popen('%s --libs external' % vlcconfig, |
|---|
| 66 |
'r').readline().rstrip().split()) |
|---|
| 67 |
if os.sys.platform == 'darwin': |
|---|
| 68 |
ldflags.append('-lstdc++') |
|---|
| 69 |
if not libtool: |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
ldflags.remove('-lvlc') |
|---|
| 73 |
return ldflags |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
source_files = [ 'vlc_module.c' ] |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
vlclocal = Extension('vlc', |
|---|
| 81 |
sources = [ os.path.join( srcdir, f ) for f in source_files ], |
|---|
| 82 |
include_dirs = [ top_builddir, |
|---|
| 83 |
os.path.join( srcdir, '..', '..', 'include' ), |
|---|
| 84 |
srcdir, |
|---|
| 85 |
'/usr/win32/include' ], |
|---|
| 86 |
extra_objects = [ ], |
|---|
| 87 |
extra_compile_args = get_cflags(), |
|---|
| 88 |
extra_link_args = linkargs + get_ldflags(), |
|---|
| 89 |
) |
|---|
| 90 |
|
|---|
| 91 |
setup (name = 'VLC Bindings', |
|---|
| 92 |
version = get_vlc_version(), |
|---|
| 93 |
|
|---|
| 94 |
keywords = [ 'vlc', 'video' ], |
|---|
| 95 |
license = "GPL", |
|---|
| 96 |
description = """VLC bindings for python. |
|---|
| 97 |
|
|---|
| 98 |
This module provides bindings for the native libvlc API of the VLC |
|---|
| 99 |
video player. Documentation can be found on the VLC wiki : |
|---|
| 100 |
http://wiki.videolan.org/index.php/ExternalAPI |
|---|
| 101 |
|
|---|
| 102 |
This module also provides a MediaControl object, which implements an |
|---|
| 103 |
API inspired from the OMG Audio/Video Stream 1.0 specification. |
|---|
| 104 |
Documentation can be found on the VLC wiki : |
|---|
| 105 |
http://wiki.videolan.org/index.php/PythonBinding |
|---|
| 106 |
|
|---|
| 107 |
Example session: |
|---|
| 108 |
|
|---|
| 109 |
import vlc |
|---|
| 110 |
mc=vlc.MediaControl(['--verbose', '1']) |
|---|
| 111 |
mc.playlist_add_item('movie.mpg') |
|---|
| 112 |
|
|---|
| 113 |
# Start the movie at 2000ms |
|---|
| 114 |
p=vlc.Position() |
|---|
| 115 |
p.origin=vlc.RelativePosition |
|---|
| 116 |
p.key=vlc.MediaTime |
|---|
| 117 |
p.value=2000 |
|---|
| 118 |
mc.start(p) |
|---|
| 119 |
# which could be abbreviated as |
|---|
| 120 |
# mc.start(2000) |
|---|
| 121 |
# for the default conversion from int is to make a RelativePosition in MediaTime |
|---|
| 122 |
|
|---|
| 123 |
# Display some text during 2000ms |
|---|
| 124 |
mc.display_text('Some useless information', 0, 2000) |
|---|
| 125 |
|
|---|
| 126 |
# Pause the video |
|---|
| 127 |
mc.pause(0) |
|---|
| 128 |
|
|---|
| 129 |
# Get status information |
|---|
| 130 |
mc.get_stream_information() |
|---|
| 131 |
""", |
|---|
| 132 |
ext_modules = [ vlclocal ]) |
|---|