Skip to content

Commit

Permalink
#970:
Browse files Browse the repository at this point in the history
* move the gstreamer path setup to the loader class, so we can run with either version and even try one then the other
* bundle gstreamer 1.0 plugins
* include the gi bindings (by hand since py2app doesn't do it)
* refactor platform checks in gstreamer util class, improve outpout layout

git-svn-id: https://xpra.org/svn/Xpra/trunk@11074 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 28, 2015
1 parent 1790091 commit dde2730
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 59 deletions.
3 changes: 1 addition & 2 deletions osx/Helpers/PythonExecWrapper
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
export PANGO_LIBDIR="$bundle_lib"
export PANGO_SYSCONFDIR="$bundle_etc"

export GST_PLUGIN_PATH="$bundle_lib/gstreamer-0.10"
export GST_PLUGIN_SCANNER="$bundle_contents/Helpers/gst-plugin-scanner"
export GST_BUNDLE_CONTENTS="$bundle_contents"

#Set $PYTHON to point inside the bundle
#This is not the real "python" but a copy of it named "$APPNAME"
Expand Down
14 changes: 10 additions & 4 deletions osx/Xpra.bundle
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,21 @@
<binary>
${prefix}/lib/gstreamer-0.10/*.so
</binary>
<binary>
${prefix}/lib/gstreamer-1.0/*.so
</binary>

<binary dest="${bundle}/Contents/Helpers/gst-plugin-scanner-0.10">
${prefix}/libexec/gstreamer-0.10/gst-plugin-scanner
</binary>
<binary dest="${bundle}/Contents/Helpers/gst-plugin-scanner-1.0">
${prefix}/libexec/gstreamer-1.0/gst-plugin-scanner
</binary>

<data dest="${bundle}/Contents/Resources/">
${project}/dist/Xpra.app/Contents/Resources/
</data>

<binary dest="${bundle}/Contents/Helpers/gst-plugin-scanner">
${prefix}/libexec/gstreamer-0.10/gst-plugin-scanner
</binary>

<data>
${prefix}/lib/pygtk/2.0/
</data>
Expand Down
58 changes: 30 additions & 28 deletions osx/make-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ echo "**************************************************************************
echo "Hacks"
#HACKS
#no idea why I have to do this by hand
#add gtk .so
echo " * add gtk .so"
rsync -rpl $PYTHON_PACKAGES/gtk-2.0/* $LIBDIR/
#add pygtk .py
PYGTK_LIBDIR="$LIBDIR/pygtk/2.0/"
rsync -rpl $PYTHON_PACKAGES/pygtk* $PYGTK_LIBDIR
rsync -rpl $PYTHON_PACKAGES/cairo $PYGTK_LIBDIR
#opengl: just take everything:
echo " * add all OpenGL"
rsync -rpl $PYTHON_PACKAGES/OpenGL* $LIBDIR/python/
#then remove what we know we don't need:
pushd $LIBDIR/python/OpenGL
Expand All @@ -188,7 +188,9 @@ for x in GLE Tk EGL GLES3 GLUT WGL GLX GLES1 GLES2; do
rm -fr ./raw/$x
done
popd
#remove numpy bits:
echo " * add gobject-introspection (py2app refuses to do it)"
rsync -rpl $PYTHON_PACKAGES/gi $LIBDIR/python/
echo " * trim numpy"
pushd $LIBDIR/python/numpy
rm -fr ./f2py/docs
for x in core distutils f2py lib linalg ma matrixlib oldnumeric polynomial random testing; do
Expand All @@ -201,34 +203,34 @@ pushd ${CONTENTS_DIR}
ln -sf Resources/lib Frameworks
pushd Resources/lib
echo "removing extra gstreamer dylib deps:"
for x in basevideo cdda \
check netbuffer photography \
rtp rtsp sdp signalprocessor \
video \
; do
for x in basevideo cdda check netbuffer photography rtp rtsp sdp signalprocessor; do
echo "* removing "$x
rm libgst${x}*
done
#only needed with gstreamer 1.x by gstpbutils, get rid of the 0.10 one:
rm libgstvideo-0.10.*
echo "removing extra gstreamer plugins:"
GST_PLUGIN_DIR=./gstreamer-0.10
KEEP=./gstreamer-0.10.keep
mkdir ${KEEP}
for x in app audio coreelements \
faac faad \
flac lame mad mpegaudioparse \
python \
ogg oss osxaudio speex gdp \
volume vorbis \
wav; do
echo "* keeping "$x
mv ${GST_PLUGIN_DIR}/libgst${x}* ${KEEP}/
for GST_VERSION in "0.10" "1.0"; do
echo " * GStreamer $GST_VERSION"
GST_PLUGIN_DIR="./gstreamer-$GST_VERSION"
KEEP="./gstreamer-$GST_VERSION.keep"
mkdir ${KEEP}
PLUGINS="app audio coreelements faac faad flac ogg oss osxaudio speex gdp volume vorbis wav"
if [ $GST_VERSION == "0.10" ]; then
#only found in 0.10:
PLUGINS="$PLUGINS lame mad mpegaudioparse python"
fi
for x in $PLUGINS; do
echo "* keeping "$x
mv ${GST_PLUGIN_DIR}/libgst${x}* ${KEEP}/
done
rm -fr ${GST_PLUGIN_DIR}
mv ${KEEP} ${GST_PLUGIN_DIR}
echo -n "GStreamer $GST_VERSION plugins shipped: "
ls ${GST_PLUGIN_DIR} | xargs
done
rm -fr ${GST_PLUGIN_DIR}
mv ${KEEP} ${GST_PLUGIN_DIR}
echo -n "GST Plugins shipped: "
ls ${GST_PLUGIN_DIR} | xargs
popd
popd
popd #${CONTENTS_DIR}
popd #"Resources/lib"

echo
echo "*******************************************************************************"
Expand All @@ -250,7 +252,7 @@ echo
echo "*******************************************************************************"
echo "De-duplicate dylibs"
pushd $LIBDIR
for x in `ls *dylib | sed 's+[0-9\.]*\.dylib++g' | sed 's+-$++g' | sort -u`; do
for x in `ls *dylib | grep -v libgst | sed 's+[0-9\.]*\.dylib++g' | sed 's+-$++g' | sort -u`; do
COUNT=`ls *dylib | grep $x | wc -l`
if [ "${COUNT}" -gt "1" ]; then
FIRST=`ls $x* | sort -n | head -n 1`
Expand All @@ -270,7 +272,7 @@ popd
echo
echo "*******************************************************************************"
echo "copying application image to Desktop"
rsync -rplogt "${IMAGE_DIR}" ~/Desktop/
rsync --delete -rplogt "${IMAGE_DIR}" ~/Desktop/
echo "Done"
echo "*******************************************************************************"
echo
2 changes: 2 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,8 @@ def run(self):
PYGTK_PACKAGES += ["gdk-2.0", "gtk+-2.0"]
add_packages("xpra.platform.darwin")
remove_packages("xpra.platform.win32", "xpra.platform.xposix")
#to support GStreamer 1.x we need this:
modules.append("importlib")
else:
PYGTK_PACKAGES += ["gdk-x11-2.0", "gtk+-x11-2.0"]
add_packages("xpra.platform.xposix")
Expand Down
64 changes: 39 additions & 25 deletions src/xpra/sound/gstreamer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import os

from xpra.util import csv
from xpra.log import Logger
log = Logger("sound")

Expand All @@ -27,8 +28,11 @@ def get_queue_time(default_value=450, prefix=""):
return queue_time


WIN32 = sys.platform.startswith("win")
OSX = sys.platform.startswith("darwin")

ALLOW_SOUND_LOOP = os.environ.get("XPRA_ALLOW_SOUND_LOOP", "0")=="1"
DEFAULT_GSTREAMER1 = not sys.platform.startswith("win") and not sys.platform.startswith("darwin")
DEFAULT_GSTREAMER1 = not WIN32 and not OSX
GSTREAMER1 = os.environ.get("XPRA_GSTREAMER1", str(int(DEFAULT_GSTREAMER1)))=="1"
MONITOR_DEVICE_NAME = os.environ.get("XPRA_MONITOR_DEVICE_NAME", "")
def force_enabled(codec_name):
Expand Down Expand Up @@ -215,34 +219,42 @@ def import_gst0_10():
return gst


def get_version_str(version):
if version==1:
return "1.0"
else:
return "0.10"

def import_gst():
global gst, has_gst, gst_vinfo, gst_major_version
if has_gst is not None:
return gst
#ugly win32 hack to make it find the gstreamer plugins:
if sys.platform.startswith("win") and hasattr(sys, "frozen") and sys.frozen in ("windows_exe", "console_exe", True):
from xpra.platform.paths import get_app_dir
if sys.version_info[0]<3:
#gstreamer-0.10
v = (0, 10)
else:
#gstreamer-1.0
v = (1, 0)
os.environ["GST_PLUGIN_PATH"] = os.path.join(get_app_dir(), "gstreamer-%s" % (".".join([str(x) for x in v])))

from xpra.gtk_common.gobject_compat import is_gtk3
if is_gtk3():
imports = [ (import_gst1, 1, "1.x") ]
imports = [ (import_gst1, 1) ]
else:
imports = [
(import_gst0_10, 0, "0.10"),
(import_gst1, 1, "1.x"),
]
(import_gst0_10, 0),
(import_gst1, 1),
]
if GSTREAMER1:
imports.reverse() #try gst1 first:
errs = {}
for import_function, MV, vinfo in imports:
for import_function, MV in imports:
vstr = get_version_str(MV)
#hacks to locate gstreamer plugins on win32 and osx:
if WIN32 and hasattr(sys, "frozen") and sys.frozen in ("windows_exe", "console_exe", True):
from xpra.platform.paths import get_app_dir
os.environ["GST_PLUGIN_PATH"] = os.path.join(get_app_dir(), "gstreamer-%s" % vstr)
elif OSX:
bundle_contents = os.environ.get("GST_BUNDLE_CONTENTS")
if "GST_PLUGIN_PATH" not in os.environ and bundle_contents:
os.environ["GST_PLUGIN_PATH"] = os.path.join(bundle_contents, "Resources", "lib", "gstreamer-%s" % vstr)
os.environ["GST_PLUGIN_SCANNER"] = os.path.join(bundle_contents, "Helpers", "gst-plugin-scanner-%s" % vstr)

try:
log("trying to import GStreamer %s using %s", get_version_str(MV), import_function)
_gst = import_function()
v = _gst.version()
if v[-1]==0:
Expand All @@ -252,14 +264,14 @@ def import_gst():
gst = _gst
break
except Exception as e:
log("failed to import GStreamer %s: %s", vinfo, e)
errs[vinfo] = e
log("failed to import GStreamer %s: %s", vstr, e)
errs[vstr] = e
if gst:
log("Python GStreamer version %s for Python %s.%s", gst_vinfo, sys.version_info[0], sys.version_info[1])
else:
log.warn("Warning: failed to import GStreamer:")
for vinfo,e in errs.items():
log.warn(" %s failed with: %s", vinfo, e)
for vstr,e in errs.items():
log.warn(" %s failed with: %s", vstr, e)
has_gst = gst is not None
return gst

Expand Down Expand Up @@ -314,7 +326,7 @@ def get_codecs():
log.info("sound codec %s force enabled", encoding)
elif encoding==FLAC:
#flac problems:
if sys.platform.startswith("win") and gst_major_version==0 and encoding==FLAC:
if WIN32 and gst_major_version==0 and encoding==FLAC:
#the gstreamer 0.10 builds on win32 use the outdated oss build,
#which includes outdated flac libraries with known CVEs,
#so avoid using those:
Expand All @@ -334,7 +346,9 @@ def get_codecs():
CODECS[encoding] = (encoder, muxer, decoder, demuxer)
log("initialized sound codecs:")
for k in [x for x in CODEC_ORDER if x in CODECS]:
log("* %s : %s", k, CODECS[k])
def ci(v):
return "%-12s" % v
log("* %-10s : %s", k, csv([ci(v) for v in CODECS[k]]))
return CODECS

def get_muxers():
Expand Down Expand Up @@ -410,9 +424,9 @@ def get_source_plugins():
if has_pa():
sources.append("pulsesrc")
sources.append("autoaudiosrc")
if sys.platform.startswith("darwin"):
if OSX:
sources.append("osxaudiosrc")
elif sys.platform.startswith("win"):
elif WIN32:
sources.append("directsoundsrc")
if os.name=="posix":
sources += ["alsasrc", "jackaudiosrc",
Expand Down Expand Up @@ -571,7 +585,7 @@ def parse_sound_source(all_plugins, sound_source_plugin, remote):


def sound_option_or_all(name, options, all_values):
from xpra.util import engs, csv
from xpra.util import engs
if not options:
v = all_values #not specified on command line: use default
else:
Expand Down
Loading

0 comments on commit dde2730

Please sign in to comment.