gst-examples を試す

# gst-examples

[1.10のリリースノート](https://gstreamer.freedesktop.org/releases/1.10/)の中に`gst-examples`というサンプルアプリが含まれていました。今回はコレをビルド・実行してみようと思います。

# ビルドには meson を使う

gst-examplesをcloneするとわかるのですが、gst-examplesにはmakefileが含まれていません。

```shell-session
$ git clone git://anongit.freedesktop.org/gstreamer/gst-examples
$ find gst-examples/ | grep -i makefile || echo not found.
not found.
```

ビルドには[meson](https://github.com/mesonbuild/meson)を使います。`meson`は`apt`でも`pip`でもインストールできます。

```shell-session
$ apt-get install meson
$ which meson
/usr/bin/meson
```

mesonの使い方は簡単です。

1. プロジェクトのルートディレクトリにビルド用ディレクトリ用意
1. プロジェクトのルートディレクトリで、`meson <ビルド用ディレクトリ>`を実行
1. プロジェクトのビルド用ディレクトリ内で、`ninja`を実行

だけです。やってみると↓こんな感じ。

```shell-session
$ cd gst-examples
$ mkdir build
$ meson build/
the meson build system
version: 0.36.0
source dir: /home/shotam/src/gst/gst-examples
build dir: /home/shotam/src/gst/gst-examples/build
build type: native build
project name: gst-examples
native c compiler: cc (gcc 6.2.1)
build machine cpu family: x86_64
build machine cpu: x86_64
found pkg-config: /usr/bin/pkg-config (0.29)
native dependency gstreamer-1.0 found: yes 1.10.2
native dependency gstreamer-player-1.0 found: yes 1.10.2
library m found: yes
native dependency glib-2.0 found: yes 2.50.2
native dependency gobject-2.0 found: yes 2.50.2
native dependency gmodule-2.0 found: yes 2.50.2
native dependency gstreamer-tag-1.0 found: yes 1.10.2
native dependency gtk+-3.0 found: yes 3.22.5
native dependency x11 found: yes 1.6.4
native dependency glib-2.0 found: yes 2.50.2
warning: glib compiled dependencies do not work reliably with
the current version of glib. see the following upstream issue: https://bugzilla.gnome.org/show_bug.cgi?id=774368
xmllint not set and xmllint not found in path; skipping xml preprocessing.
native dependency gio-2.0 found: yes 2.50.2
build targets in project: 5
$ cd build/
$ ninja
[1/11] 'generating gtk-play-resources_h with a custom command.'
xmllint not set and xmllint not found in path; skipping xml preprocessing.
[2/11] 'generating gtk-play-resources_c with a custom command.'
xmllint not set and xmllint not found in path; skipping xml preprocessing.
[10/11] compiling c object 'playback/player/gtk/gtk-play@exe/gtk-play.c.o'
../playback/player/gtk/gtk-play.c: in function ‘gtk_player_popup_menu_create’:
../playback/player/gtk/gtk-play.c:1266:3: warning: ‘gtk_menu_popup’ is deprecated: use '(gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)' instead [-wdeprecated-declarations]
   gtk_menu_popup (gtk_menu (menu), null, null, null, null,
   ^~~~~~~~~~~~~~
in file included from /usr/include/gtk-3.0/gtk/gtklabel.h:34:0,
                 from /usr/include/gtk-3.0/gtk/gtkaccellabel.h:35,
                 from /usr/include/gtk-3.0/gtk/gtk.h:33,
                 from ../playback/player/gtk/gtk-play.c:38:
/usr/include/gtk-3.0/gtk/gtkmenu.h:138:9: note: declared here
 void    gtk_menu_popup    (gtkmenu        *menu,
         ^~~~~~~~~~~~~~
[11/11] linking target playback/player/gtk/gtk-play
```

ビルドすると`build`ディレクトリはこのようになります。

```
build
|-- build.ninja
|-- compile_commands.json
|-- meson-logs
|   `-- meson-log.txt
|-- meson-private
|   |-- build.dat
|   |-- coredata.dat
|   |-- install.dat
|   |-- meson_benchmark_setup.dat
```shell-session
|   |-- meson_test_setup.dat
|   |-- sanitycheckc.c
|   `-- sanitycheckc.exe
|-- network
|   `-- http-launch
|       |-- http-launch
|       `-- http-launch@exe
|           `-- http-launch.c.o
`-- playback
    `-- player
        |-- gst-play
        |   |-- gst-play
        |   `-- gst-play@exe
        |       |-- gst-play-kb.c.o
        |       `-- gst-play.c.o
        `-- gtk
            |-- gtk-play
            |-- gtk-play-resources.c
            |-- gtk-play-resources.h
            `-- gtk-play@exe
                |-- gtk-play.c.o
                |-- gtk-video-renderer.c.o
                `-- playback_player_gtk_gtk-play-resources.c.o
```

ちなみに、mesonはビルドに必要なものが足りないものがある場合、これを報告してくれます。

```shell-session
$ meson build/
the meson build system
version: 0.36.0
source dir: /home/shotam/src/gst/gst-examples
build dir: /home/shotam/src/gst/gst-examples/build
build type: native build
project name: gst-examples
native c compiler: cc (gcc 6.2.1)
build machine cpu family: x86_64
build machine cpu: x86_64
found pkg-config: /usr/bin/pkg-config (0.29)
native dependency gstreamer-1.0 found: yes 1.10.2
native dependency gstreamer-player-1.0 found: yes 1.10.2
library m found: yes
native dependency glib-2.0 found: yes 2.50.2
native dependency gobject-2.0 found: yes 2.50.2
native dependency gmodule-2.0 found: yes 2.50.2
native dependency gstreamer-tag-1.0 found: yes 1.10.2

meson encountered an error in file playback/player/gtk/meson.build, line 7, column 0:
native dependency gtk+-3.0 not found.
```

# ビルドした gtk-play を実行する

試しに gtk-play を実行してみます。

```shell-session
$ build/playback/player/gtk/gtk-play neko.avi
```

![Screenshot from 2016-12-11 21-46-51.png](https://qiita-image-store.s3.amazonaws.com/0/97187/e3e545df-83d3-00ad-90bc-6331f2bf49c3.png)

# まとめ

今回は gst-examples を触ってみました。gst-examples は今後より増えていく予定です。
アプリを作る時にはこういったサンプルを見てから作るのが良さそうですね。