Skip to content

Commit

Permalink
Added support for VLC 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nurupo committed Feb 10, 2018
1 parent b62b5f8 commit bd37df6
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 183 deletions.
65 changes: 41 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
sudo: required

dist: trusty

language: c
language: generic

compiler:
- gcc
sudo: required

services:
- docker

env:
- TARGET=LINUX VLC_VERSION=2.1
- TARGET=LINUX VLC_VERSION=2.2
- TARGET=WINDOWS VLC_VERSION=2.1
- TARGET=WINDOWS VLC_VERSION=2.2

before_script:
- if [ "$TARGET" = "LINUX" ] && [ "$VLC_VERSION" = "2.2" ]; then sudo add-apt-repository ppa:mc3man/trusty-media -y; fi
- sudo apt-get update -qq
- if [ "$TARGET" = "LINUX" ]; then sudo apt-get install vlc pkg-config libvlccore-dev -qq; fi
- if [ "$TARGET" = "WINDOWS" ]; then sudo apt-get install tree -qq; fi
- if [ "$TARGET" = "WINDOWS" ]; then sudo docker build -t vlc-pause-click-plugin-windows-build docker ; fi
matrix:
include:
- os: linux
env: TARGET=Linux VLC_VERSION=2.1 DEBIAN=wheezy-backports
- os: linux
env: TARGET=Linux VLC_VERSION=2.2 DEBIAN=stretch
- os: linux
env: TARGET=Linux VLC_VERSION=3.0 DEBIAN=experimental
- os: linux
env: TARGET=Windows VLC_VERSION=2.1
- os: linux
env: TARGET=Windows VLC_VERSION=2.2
- os: linux
env: TARGET=Windows VLC_VERSION=3.0
- os: osx
env: TARGET=macOS VLC_VERSION=2.1
language: c
osx_image: xcode7.3
- os: osx
env: TARGET=macOS VLC_VERSION=2.2
language: c
osx_image: xcode7.3
- os: osx
env: TARGET=macOS VLC_VERSION=3.0
language: c
osx_image: xcode7.3

script:
- if [ "$TARGET" = "LINUX" ]; then sudo make install; fi
- if [ "$TARGET" = "WINDOWS" ]; then sudo docker run --rm -v `pwd`:/repo -v `pwd`/build:/build vlc-pause-click-plugin-windows-build $VLC_VERSION i686; fi
- if [ "$TARGET" = "WINDOWS" ]; then sudo docker run --rm -v `pwd`:/repo -v `pwd`/build:/build vlc-pause-click-plugin-windows-build $VLC_VERSION x86_64; fi
- if [ "$TARGET" = "WINDOWS" ]; then tree build -s --si --du; fi
- if [ "$TARGET" = "WINDOWS" ] && [ $(find ./build -name "*.dll" | wc -l) != "2" ]; then false; fi
- ./.travis/script.sh

deploy:
provider: releases
api_key:
secure: BEBtgDclwqKqi1NWY26Af/5DalWJYFlxV36QMEC6EKajA5tv2GBR0nyjIpzG+wNeuqZitqYQaOG60F/UPD1xjbN1ZXdN4byuSaMKRUseO2H/7r3StMlTL3knVce4giIwaEe7Q05QtiV+3zLTcAxsEmzehQJZZpnYK0KXGqRyC/U=
file: vlc-*-macosx.zip
file_glob: true
skip_cleanup: true
on:
condition: $TARGET == macOS
repo: nurupo/vlc-pause-click-plugin
tags: true
70 changes: 70 additions & 0 deletions .travis/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
set -euxo pipefail

if [ "$TARGET" = "Linux" ]; then
# start a docker container of a specific version of Debian
# different Debian versions have different VLC versions packaged: 2.1, 2.2 and 3.0
sudo docker run -it -d --name ci -v ${PWD}:/repo debian:$DEBIAN /bin/bash
# runs a command in the started continer
RUN() {
sudo docker exec ci "$@"
}
RUN apt-get update
# for some reason apt is having issues with verifying packages due to old/missing keys?
RUN apt-get install -y gnupg
RUN apt-key update
RUN apt-get install -y -t $DEBIAN build-essential pkg-config libvlccore-dev libvlc-dev
# print the version before testing it as we won't see which version it is if the test fails
RUN pkg-config --modversion libvlc
RUN pkg-config --modversion libvlc | grep "^$VLC_VERSION"
RUN pkg-config --modversion vlc-plugin
RUN pkg-config --modversion vlc-plugin | grep "^$VLC_VERSION"
if [ "$DEBIAN" = "wheezy-backports" ]; then
# gcc on wheezy-backports doesn't support c11
RUN sed -i 's/gnu11/gnu99/g' /repo/Makefile
fi
RUN make -C /repo install
elif [ "$TARGET" = "Windows" ]; then
sudo apt-get install -y tree
# use our own docker image for testing building of Windows binaries
# makes sure that our docker image is not broken too
sudo docker build -t vlc-pause-click-plugin-windows-build docker
sudo docker run --rm -v `pwd`:/repo -v `pwd`/build:/build vlc-pause-click-plugin-windows-build $VLC_VERSION 32
sudo docker run --rm -v `pwd`:/repo -v `pwd`/build:/build vlc-pause-click-plugin-windows-build $VLC_VERSION 64
tree build -s --si --du
# there should be exactly two dlls built, one for 32-bit VLC and another for 64-bit
[ $(find ./build -name "*.dll" | wc -l) = "2" ] || false
elif [ "$TARGET" = "macOS" ]; then
brew update
brew install p7zip
mkdir -p tmp/tmp
cd tmp/tmp
wget https://download.videolan.org/pub/videolan/vlc/$VLC_VERSION.0/macosx/vlc-$VLC_VERSION.0.dmg
# extracting contents of a .dmg file using 7-zip is more of a hack, and while it works 7z exits with an error code we want to supress
7z x "*.dmg" "*/VLC.app/Contents/MacOS" || true
mv */VLC.app/Contents/MacOS/lib ..
mv */VLC.app/Contents/MacOS/include ..
rm -rf ./*
cd ..
rm -rf ./tmp
# in contrast to Windows VLC including a very nice and complete sdk directory,
# macOS VLC doesn't package .pc files, plugin headers and in 2.1.0 libvlc_version.h is not generated off libvlc_version.h.in.
# it just packags libvlc.dylib, libvlccore.dylib and libvlc headers.
# honestly, wtf VLC team, get your game together.
# we grab the missing pieces from the Windows VLC, there shouldn't be anything platform-specific in those so it should work
wget https://download.videolan.org/pub/videolan/vlc/$VLC_VERSION.0/win32/vlc-$VLC_VERSION.0-win32.7z -O vlc-$VLC_VERSION.0-win32.7z
7z x "*.7z" -o* "*/sdk"
mv vlc-$VLC_VERSION.0-win32/*/sdk/include/vlc/libvlc_version.h include/vlc/
mv vlc-$VLC_VERSION.0-win32/*/sdk/include/vlc/plugins include/vlc/plugins
mv vlc-$VLC_VERSION.0-win32/*/sdk/lib/pkgconfig lib/pkgconfig
rm -rf ./vlc-$VLC_VERSION.0-win32
# fix paths in .pc files
sed -i "" "s|^prefix=.*|prefix=$PWD|g" lib/pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/lib/pkgconfig"
cd lib
# fix library symlink
ln -sf libvlccore.*.dylib libvlccore.dylib
cd ../..
make OS=macOS
zip -j vlc-$VLC_VERSION-macosx.zip libpause_click_plugin.dylib
fi
85 changes: 55 additions & 30 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,81 @@

If instead of using [the precompiled plugin binaries](https://github.com/nurupo/vlc-pause-click-plugin/releases) you want to build them yourself, you can follow these instructions on building the plugin.

These instructions describe out of the tree building of the plugin, since this is the easiest way to build it.

### Prerequisites

The prerequisite for building is having the VLC sdk corresponding to the version of VLC you are building the plugin for.

Specifically, you will need:
- `vlccore` library.
- Pkg-config file `vlc-plugin.pc`.
- Set of `libvlccore` headers. `vlc_filter.h` is one of those plugin headers.
- Set of `libvlc` headers. `libvlc_version.h` is one of those headers.

The way you get the VLC sdk varies from platform to platform.

On Windows there is a `sdk` directory included with your VLC installation that includes everything you need.
Note that [there is a Dockerfile](./docker) that fully automates building for Windows described in these instructions.
This is what I use to produce the Windows plugin binaries.
That Docker container is what I use to produce the Windows plugin binaries.

Also, if you want to build the plugin for Debian Linux or its derivatives, you can make your life easier if you follow the Debian installation instructions provided in [README](/README.md) instead of following this building guide.
On macOS `vlccore` library and `libvlc` headers are included in the VLC `.dmg` file, but there are `libvlccore` headers and `vlc-plugin.pc` in there.
You will have to get the missing pieces from the `sdk` directory of Windows VLC `.zip` archive of the same version as your `.dmg` VLC.

### Building
On Linux you generally just install the packages that contain the mentioned files and you are good to go.
If you have manually built VLC instead of getting it pre-built from the packages, you should probably already have the VLC libraries and headers installed.

What we want to do is to build VLC with the plugin integrated into its source tree and build system, so that the plugin would be built together with VLC.
If you want to build the plugin for Debian Linux or its derivatives, there are simpler instructions provided in [README](/README.md).

Git clone VLC:
### Fixing pkg-config

Make sure `pkg-config --cflags vlc-plugin` and `pkg-config --libs vlc-plugin` commands print the correct include and library paths.
If they do, you should skip this part and go to building.

Here is an example of how you would fix this for a Windows build (assuming you are on Linux and have Windows VLC sdk)

```sh
git clone git://git.videolan.org/vlc.git
```
cd sdk
# Set the prefix path to $PWD in vlc-plugin.pc
# It's hardcoded to the path VLC developer installed his VLC to and this is not the path you want
sed -i "s|^prefix=.*|prefix=$PWD|g" lib/pkgconfig/*.pc
# Make pkg-config aware of vlc-plugin.pc
export PKG_CONFIG_PATH="${PWD}/lib/pkgconfig"
```

After this `pkg-config --cflags vlc-plugin` and `pkg-config --libs vlc-plugin` commands should print the correct paths to the `vlccore` library and the headers.

Checkout the git tag that matches version of VLC that you want to build the plugin for. You can use `git tag` to get a list of all tags available. For example, for 2.2.0 you would do:
### Building

Once you get pkg-config to find the dependencies, the building is as easy as

```sh
cd vlc
git checkout 2.2.0-git
make CC=your-compiler LD=your-linked OS=your-target-os
```

Add the plugin into the VLC build system by copying `pause_click.c`, `vlc_interface-2.1.0-git.h` and `vlc_interface-2.2.0-git.h` into `modules/video_filter/`.

If you are building VLC 2.1.0, add
For example, to build 32-bit Windows binaries you would do

```sh
make CC=i686-w64-mingw32-gcc LD=i686-w64-mingw32-ld OS=Windows
```
libpause_click_plugin_la_SOURCES = pause_click.c
libpause_click_plugin_la_CFLAGS = $(AM_CFLAGS)
libpause_click_plugin_la_LIBADD = $(AM_LIBADD)
libvlc_LTLIBRARIES += libpause_click_plugin.la

Makefile defaults to Linux, so for Linux

```sh
make
```

to the end of `modules/video_filter/Modules.am` file.
would be enough.

If you are building VLC 2.2.0, add
For macOS

```
libpause_click_plugin_la_SOURCES = pause_click.c
libpause_click_plugin_la_CFLAGS = $(AM_CFLAGS)
libpause_click_plugin_la_LIBADD = $(AM_LIBADD)
video_filter_LTLIBRARIES += libpause_click_plugin.la
make OS=macOS
```

to the end of `modules/video_filter/Modules.am` file for VLC 2.2.0.
should be enough.

Build VLC the way you would usually do so.
There should be some instructions on VLC's wiki on how to build it for your target system, you should be able to easily google them.
Note that we don't really care if VLC fails to compile as long as we manage to compile our plugin, so if something fails the build and there is an option to disable that thing that is failing from being built -- there is no harm in doing so.
In fact, you will likely want to disable as many build options as possible so that there would be less things to fail the build.
`OS` is used to set the correct shared library extension.

After the build is done, you should have `libpause_click_plugin.dll` (Windows) or `libpause_click_plugin.so` (Linux) or `libpause_click_plugin.dylib` (macOS) somewhere in the subdirectories of `modules/` of the build tree.
That's the plugin binary that you want.
After running make you should see `libpause_click_plugin.[dll|so|dylib]` generated, which is the plugin binary ready for use.
You might want to strip it to shave some kilobytes off.
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
LD = ld
CC = cc
OS = Linux
DESTDIR =
INSTALL = install
CFLAGS = -g0 -O3 -Wall -Wextra
LDFLAGS =
Expand All @@ -8,39 +10,48 @@ VLC_PLUGIN_LIBS := $(shell pkg-config --libs vlc-plugin)

plugindir := $(shell pkg-config vlc-plugin --variable=pluginsdir)

override CC += -std=gnu99
override CC += -std=gnu11
override CPPFLAGS += -DPIC -I. -Isrc
override CFLAGS += -fPIC
override LDFLAGS += -Wl,-no-undefined,-z,defs

override CPPFLAGS += -DMODULE_STRING=\"pause_click\"
override CFLAGS += $(VLC_PLUGIN_CFLAGS)
override LDFLAGS += $(VLC_PLUGIN_LIBS)

TARGETS = libpause_click_plugin.so
ifeq ($(OS),Linux)
EXT := so
else ifeq ($(OS),Windows)
EXT := dll
else ifeq ($(OS),macOS)
EXT := dylib
else
$(error Unknown OS specified, please set OS to either Linux, Windows or macOS)
endif

all: libpause_click_plugin.so
TARGETS = libpause_click_plugin.$(EXT)

all: libpause_click_plugin.$(EXT)

install: all
mkdir -p -- $(DESTDIR)$(plugindir)/video_filter
$(INSTALL) --mode 0755 libpause_click_plugin.so $(DESTDIR)$(plugindir)/video_filter
$(INSTALL) --mode 0755 libpause_click_plugin.$(EXT) $(DESTDIR)$(plugindir)/video_filter

install-strip:
$(MAKE) install INSTALL="$(INSTALL) -s"

uninstall:
rm -f $(plugindir)/video_filter/libpause_click_plugin.so
rm -f $(DESTDIR)$(plugindir)/video_filter/libpause_click_plugin.$(EXT)

clean:
rm -f -- libpause_click_plugin.so pause_click.o
rm -f -- libpause_click_plugin.$(EXT) pause_click.o

mostlyclean: clean

SOURCES = pause_click.c

$(SOURCES:%.c=%.o): %: pause_click.c

libpause_click_plugin.so: $(SOURCES:%.c=%.o)
libpause_click_plugin.$(EXT): $(SOURCES:%.c=%.o)
$(CC) -shared -o $@ $^ $(LDFLAGS)

.PHONY: all install install-strip uninstall clean mostlyclean
Loading

0 comments on commit bd37df6

Please sign in to comment.