|
| 1 | +A GStreamer plugin that provides an `airplaysrc` element for receiving video |
| 2 | +streamed from Apple devices using the AirPlay protocol. Audio is currently not |
| 3 | +supported. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +See [below](#building) for build instructions. Once you have the file `libgstairplay.so`, |
| 8 | +you must let GStreamer find it. Possibilities include: |
| 9 | + |
| 10 | +* Placing the `libgstairplay.so` file in `~/.local/share/gstreamer-1.0/plugins`. |
| 11 | +* Using the `--gst-plugin-path` option with `gst-launch` (for example `gst-launch-1.0 --gst-plugin-path=~/my-gst-plugins` airplaysrc ! ...`, see below for complete pipelines). |
| 12 | +* Add the directory containing the plugin to the `GST_PLUGIN_PATH` environment variable. |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +The `airplaysrc` element can be used like other video sources in GStreamer |
| 17 | +pipelines. Examples are shown below. |
| 18 | + |
| 19 | +Typical use will require the following packages (tested on Ubuntu 20.04): |
| 20 | + |
| 21 | +``` |
| 22 | +gstreamer1.0-tools |
| 23 | +gstreamer1.0-plugins-good |
| 24 | +gstreamer1.0-plugins-bad |
| 25 | +gstreamer1.0-libav |
| 26 | +libavahi-compat-libdnssd1 |
| 27 | +libplist3 |
| 28 | +``` |
| 29 | + |
| 30 | +### Showing the video in a window |
| 31 | + |
| 32 | +The `gst-launch` tool can be used to run a pipeline that shows the video stream |
| 33 | +in a new window: |
| 34 | + |
| 35 | +``` |
| 36 | +gst-launch-1.0 airplaysrc ! queue ! h264parse ! avdec_h264 max-threads=1 ! autovideosink |
| 37 | +``` |
| 38 | + |
| 39 | +Explanation: the video stream is received in the H.264 format. The stream must |
| 40 | +be parsed (`h264parse`) and decoded (`avdec_h264`) before showing in a window |
| 41 | +(`autovideosink`). The `queue` element adds some buffering. The `max-threads=1` |
| 42 | +decoding option can help reduce latency. |
| 43 | + |
| 44 | +### Using as a source in OBS Studio |
| 45 | + |
| 46 | +The `airplaysrc` element can be used with the [OBS GStreamer |
| 47 | +plugin](https://github.com/fzwoch/obs-gstreamer) to configure an OBS source |
| 48 | +that shows the AirPlay video stream: |
| 49 | + |
| 50 | +1. Install the OBS Gstreamer plugin. After compiling, I put the file `obs-gstreamer.so` in the directory `~/.config/obs-studio/plugins/obs-gstreamer/bin/64bit/`. |
| 51 | +1. In your OBS scene, add a "GStreamer Source" |
| 52 | +1. Set the pipeline parameter, using `airplaysrc` as first element. I use the following: |
| 53 | + |
| 54 | + airplaysrc ! queue ! h264parse ! avdec_h264 max-threads=1 ! videoconvert ! videoscale ! video. |
| 55 | + |
| 56 | +1. For best results, set the canvas and output sizes to the resolution of the AirPlay stream. |
| 57 | + |
| 58 | +### Using as a Linux camera device |
| 59 | + |
| 60 | +Using the [v4l2loopback](https://github.com/umlaeute/v4l2loopback) kernel |
| 61 | +module, you can expose the AirPlay video stream as a camera device in Linux. |
| 62 | + |
| 63 | +1. Install the `v4l2loopback` module. Your distribution might have it as a package, for example `v4l2loopback-dkms` in Ubuntu 20.04. |
| 64 | +1. Load the module with appropriate options. I use the following: |
| 65 | + |
| 66 | + sudo modprobe v4l2loopback devices=1 video_nr=10 card_label="AirPlay Cam" exclusive_caps=1 max_buffers=3 |
| 67 | + |
| 68 | + This creates a virtual camera with name "AirPlay Cam" and device `/dev/video10`. |
| 69 | + |
| 70 | +1. Start a GStreamer pipeline that feeds the AirPlay stream to the video device: |
| 71 | + |
| 72 | + gst-launch-1.0 -v airplaysrc ! queue ! h264parse ! avdec_h264 max-threads=1 ! videoconvert ! videoscale ! v4l2sink device=/dev/video10 |
| 73 | + |
| 74 | +Once you start streaming from the Apple device, you should see "AirPlay Cam" in the list of cameras on your computer. |
| 75 | + |
| 76 | +## Troubleshooting |
| 77 | + |
| 78 | +Call `gst-inspect-1.0 libgstairplay.so` (giving the path where the |
| 79 | +`libgstairplay.so` file is located) to check for problems such as missing |
| 80 | +libraries. For example if it says `libplist.so.3: cannot open shared object |
| 81 | +file: No such file or directory`, you can fix it by installing the `libplist3` |
| 82 | +package (on Ubuntu 20.04 at least). |
| 83 | + |
| 84 | +If you get an uninformative error message such as `Could not load plugin file: |
| 85 | +File "libgstairplay.so" appears to be a GStreamer plugin, but it failed to |
| 86 | +initialize`, try running again with `GST_DEBUG=4 gst-inspect-1.0 |
| 87 | +build/libgstairplay.so`. |
| 88 | + |
| 89 | +## Building |
| 90 | + |
| 91 | +First install the build dependencies. The following packages are needed on |
| 92 | +Ubuntu 20.04: |
| 93 | + |
| 94 | +``` |
| 95 | +git |
| 96 | +gcc |
| 97 | +pkg-config |
| 98 | +cmake |
| 99 | +gstreamer1.0-tools |
| 100 | +libgstreamer1.0-dev |
| 101 | +libgstreamer-plugins-base1.0-dev |
| 102 | +libavahi-compat-libdnssd-dev |
| 103 | +libplist-dev |
| 104 | +libssl-dev |
| 105 | +meson |
| 106 | +ninja-build |
| 107 | +``` |
| 108 | + |
| 109 | +Then clone and build RPiPlay. The fork at https://github.com/knuesel/RPiPlay is |
| 110 | +currently required. I use the following commands: |
| 111 | + |
| 112 | +``` |
| 113 | +git clone https://github.com/knuesel/RPiPlay |
| 114 | +cd RPiPlay |
| 115 | +mkdir -p build install |
| 116 | +cd build |
| 117 | +cmake -DCMAKE_INSTALL_PREFIX=../install .. |
| 118 | +make install |
| 119 | +``` |
| 120 | + |
| 121 | +Then clone and build this project. I use the following: |
| 122 | + |
| 123 | +``` |
| 124 | +cd ../.. # Get out of the RPiPlay directory |
| 125 | +export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/RPiPlay/install/lib/pkgconfig |
| 126 | +git clone https://github.com/knuesel/gst-airplay |
| 127 | +cd gst-airplay |
| 128 | +meson build |
| 129 | +ninja -C build |
| 130 | +``` |
| 131 | + |
| 132 | +You should now have the compiled plugin `libgstairplay.so` in the `build` |
| 133 | +directory. To check that it is a valid GStreamer plugin, run: |
| 134 | + |
| 135 | +``` |
| 136 | +gst-inspect-1.0 build/libgstairplay.so |
| 137 | +``` |
| 138 | + |
| 139 | +This should display something such as |
| 140 | + |
| 141 | +``` |
| 142 | +Plugin Details: |
| 143 | + Name airplay |
| 144 | + Description receive video through Apple AirPlay |
| 145 | + Filename build/libgstairplay.so |
| 146 | + Version 0.1 |
| 147 | + License GPL |
| 148 | + Source module gst-airplay-plugin |
| 149 | + Binary package GStreamer airplay Plug-ins |
| 150 | + Origin URL https://github.com/knuesel/gst-airplay |
| 151 | +
|
| 152 | + airplaysrc: AirPlay source |
| 153 | +
|
| 154 | + 1 features: |
| 155 | + +-- 1 elements |
| 156 | +``` |
| 157 | + |
| 158 | +If you get an error message, see the [troubleshooting](#troubleshooting) section. |
| 159 | + |
| 160 | +## Credits |
| 161 | + |
| 162 | +The pluging code is based on |
| 163 | +[gst-template](https://gitlab.freedesktop.org/gstreamer/gst-template/) and uses |
| 164 | +the AirPlay implementation from [RPiPlay](https://github.com/FD-/RPiPlay). |
| 165 | + |
| 166 | +## License |
| 167 | + |
| 168 | +The plugin makes use of [RPiPlay](https://github.com/FD-/RPiPlay) so it is |
| 169 | +licensed under the GNU GPL 3.0. |
0 commit comments