forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alan Jeffrey
committed
Nov 25, 2019
1 parent
a562808
commit 69acec1
Showing
11 changed files
with
1,079 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "servo-gst-plugin" | ||
description = "A GStreamer plugin that provides servosrc" | ||
version = "0.0.1" | ||
authors = ["The Servo Project Developers"] | ||
license = "MPL-2.0" | ||
edition = "2018" | ||
build = "build.rs" | ||
repository = "https://github.com/servo/servo/" | ||
publish = false | ||
|
||
[lib] | ||
name = "gstservoplugin" | ||
crate-type = ["cdylib"] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
crossbeam-channel = "0.3" | ||
euclid = "0.20" | ||
gleam = "0.6" | ||
glib = { version = "0.8", features = ["subclassing"] } | ||
gstreamer = { version = "0.14", features = ["subclassing"] } | ||
gstreamer-base = { version = "0.14", features = ["subclassing"] } | ||
gstreamer-gl = { version = "0.14", features = ["v1_16"] } | ||
gstreamer-video = { version = "0.14", features = ["subclassing"] } | ||
log = "0.4" | ||
lazy_static = "1.4" | ||
libservo = {path = "../../components/servo"} | ||
servo-media = {git = "https://github.com/servo/media"} | ||
sparkle = "0.1" | ||
# NOTE: the sm-angle-default feature only enables angle on windows, not other platforms! | ||
surfman = { version = "0.1", features = ["sm-angle-default", "sm-osmesa"] } | ||
surfman-chains-api = "0.2" | ||
surfman-chains = "0.2.1" | ||
|
||
[build-dependencies] | ||
gst-plugin-version-helper = "0.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# A GStreamer plugin which runs servo | ||
|
||
## Build | ||
|
||
``` | ||
./mach build -r -p servo-gst-plugin | ||
``` | ||
|
||
## Install | ||
|
||
By default, gstreamer's plugin finder will complain about any libraries it finds that aren't | ||
gstreamer plugins, so we need to have a directory just for plugins: | ||
``` | ||
mkdir target/gstplugins | ||
``` | ||
|
||
To install: | ||
``` | ||
cp target/release/libgstservoplugin.* target/gstplugins | ||
``` | ||
## Run | ||
|
||
To run locally: | ||
``` | ||
GST_PLUGIN_PATH=target/gstplugins \ | ||
gst-launch-1.0 servosrc \ | ||
! queue \ | ||
! video/x-raw,framerate=25/1,width=512,height=512 \ | ||
! videoflip video-direction=vert \ | ||
! autovideosink | ||
``` | ||
|
||
To stream over the network: | ||
``` | ||
GST_PLUGIN_PATH=target/gstplugins \ | ||
gst-launch-1.0 servosrc \ | ||
! queue \ | ||
! video/x-raw,framerate=25/1,width=512,height=512 \ | ||
! videoconvert \ | ||
! videoflip video-direction=vert \ | ||
! theoraenc \ | ||
! oggmux \ | ||
! tcpserversink host=127.0.0.1 port=8080 | ||
``` | ||
|
||
To save to a file: | ||
``` | ||
GST_PLUGIN_PATH=target/gstplugins \ | ||
gst-launch-1.0 servosrc num-buffers=2000 \ | ||
! queue \ | ||
! video/x-raw,framerate=25/1,width=512,height=512 \ | ||
! videoconvert \ | ||
! videoflip video-direction=vert \ | ||
! theoraenc \ | ||
! oggmux \ | ||
! filesink location=test.ogg | ||
``` | ||
|
||
*Note*: killing the gstreamer pipeline with control-C sometimes locks up macOS to the point | ||
of needing a power cycle. Killing the pipeline by closing the window seems to work. | ||
|
||
## Troubleshooting building the plugin | ||
|
||
You may need to make sure rust picks up the right gstreamer, for example: | ||
``` | ||
PKG_CONFIG_PATH=$PWD/support/linux/gstreamer/gst/lib \ | ||
LD_LIBRARY_PATH=$PWD/support/linux/gstreamer/gst/lib \ | ||
./mach build -r -p servo-gst-plugin | ||
``` | ||
|
||
## Troubleshooting running the plugin | ||
|
||
*Currently x11 support is broken!* | ||
|
||
First try: | ||
``` | ||
GST_PLUGIN_PATH=target/gstplugins \ | ||
gst-inspect-1.0 servosrc | ||
``` | ||
|
||
If that doesn't work, try: | ||
``` | ||
GST_PLUGIN_PATH=target/gstplugins \ | ||
gst-in2spect-1.0 target/gstplugins/libgstservoplugin.so | ||
``` | ||
|
||
If you get reports about the plugin being blacklisted, remove the (global!) gstreamer cache, e.g. under Linux: | ||
``` | ||
rm -r ~/.cache/gstreamer-1.0 | ||
``` | ||
|
||
If you get complaints about not being able to find libraries, set `LD_LIBRARY_PATH`, e.g. to use Servo's Linux gstreamer: | ||
``` | ||
LD_LIBRARY_PATH=$PWD/support/linux/gstreamer/gst/lib | ||
``` | ||
|
||
If you get complaints `cannot allocate memory in static TLS block` this is caused by gstreamer initializing threads using | ||
the system alloc, which causes problems if those threads run Rust code that uses jemalloc. The fix is to preload the plugin: | ||
``` | ||
LD_PRELOAD=$PWD/target/gstplugins/libgstservoplugin.so | ||
``` | ||
|
||
You may need to set `GST_PLUGIN_SCANNER`, e.g. to use Servo's: | ||
``` | ||
GST_PLUGIN_SCANNER=$PWD/support/linux/gstreamer/gst/libexec/gstreamer-1.0/gst-plugin-scanner | ||
``` | ||
|
||
You may need to include other directories on the plugin search path, e.g. Servo's gstreamer: | ||
``` | ||
GST_PLUGIN_PATH=$PWD/target/gstplugins/:$PWD/support/linux/gstreamer/gst/lib | ||
``` | ||
|
||
Under X11 you may get complaints about X11 threads not being initialized: | ||
``` | ||
GST_GL_XINITTHREADS=1 | ||
``` | ||
|
||
Under x11 you may get a frozen display from `autovideosink`, try `ximagesink` instead. | ||
|
||
Putting that all together: | ||
``` | ||
GST_GL_XINITTHREADS=1 \ | ||
GST_PLUGIN_PATH=$PWD/target/gstplugins/:$PWD/support/linux/gstreamer/gst/lib \ | ||
GST_PLUGIN_SCANNER=$PWD/support/linux/gstreamer/gst/libexec/gstreamer-1.0/gst-plugin-scanner \ | ||
LD_LIBRARY_PATH=$PWD/support/linux/gstreamer/gst/lib \ | ||
LD_PRELOAD=$PWD/target/gstplugins/libgstservoplugin.so \ | ||
gst-launch-1.0 servosrc \ | ||
! queue \ | ||
! videoflip video-direction=vert \ | ||
! ximagesink | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
fn main() { | ||
gst_plugin_version_helper::get_info() | ||
} |
Oops, something went wrong.