LoginSignup
8
10

More than 5 years have passed since last update.

GStreamer プラグイン開発のスタートアップ

Posted at

アドベントカレンダー13日目です。

はじめに

私がこれまでに書いてきたアドベントカレンダーの記事は主に、「ツールを使って簡単にマルチメディアアプリが書ける GStreamer」という内容でした。
ですが、12/6 ~ 12/12 の6日間は yashi さんが「ライブラリとしての GStreamer 」書いていただけました。
この流れに乗って、これからは「GStreamer のプラグインを作る」というのを書いていこうと思います。

GStreamer のプラグインを「使う側」だったのが「作る側」に回るわけです。

また、これから扱う内容は Plugin writer's guide (pwg) を翻訳した内容、かみ砕いた内容になるかもしれません。。。(私が勉強中なので)

環境

  • Windows 10 (64bit)
  • Visual Studio 2015
  • GStreamer 1.6.1 (64bit)

ゴール

Boilerplate のコードをビルドする

Chapter 3. Constructing the Boilerplate: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-boiler.html
Boilerplate: https://en.wikipedia.org/wiki/Boilerplate_code

手順

  1. Visual Studio プロジェクトの設定
    1. ターゲットを x64 にする
    2. プロパティシートの適用
    3. Randomized Base Address を No にする
    4. Configuration Type を dll にする
  2. Boilerplate をダウンロード
  3. Boilerplate のコードだけ取り込む
  4. Boilerplate のコードを修正
  5. ビルド

詳細

Visual Studio プロジェクトの設定

お察しの通り、プロジェクトの設定は Day 12 から1つ増えただけです。

なので、まずは Day 12 の内容を参照しプロジェクトの設定を行ってください。
その後、"Configuration Type を dll にする" を行ってください。

Configuration Type を dll にする

これ↓だけです。でも、重要です。

prp.png

Boilerplate のコードをダウンロード

MinGW でも、Windows Git でも、なんでもいいのでコードを落としてきます。

$ git clone git://anongit.freedesktop.org/gstreamer/gst-template.git

Boilerplate のコードだけ取り込む

コピーするのは2つだけです。

  • gstplugin.c
  • gstplugin.h

どちらも "Source Files" のフォルダに取り込みます。

dad.png

Boilerplate のコードを修正

VERSION が見つかりません。」と怒られてしまうので、以下をgstplugin.cに追加しておきましょう。

#ifndef VERSION
#define VERSION "1.6.1"
#endif

本来はここでべた書きする内容じゃなかったような...? (調べておきます)

ビルド

ビルドすると {ソリューションのディレクトリ}/x64/Debug/{プロジェクト名}.dll が作成されます。

{ソリューションのディレクトリ}/x64/Debug/に移動しgst-inspect を使ってビルドしたプラグインの情報を見てみましょう。

※コマンドプロンプトの場合

> set GST_PLUGIN_PATH=.& gst-inspect-1.0 | grep plug
plugin:  plugin: Plugin
debug:  testsink: Test plugin
Total count: 168 plugins, 1213 features

GST_PLUGIN_PATHを指定することで見つけてくれました。

> set GST_PLUGIN_PATH=.& gst-inspect-1.0 plugin
Factory Details:
  Rank                     none (0)
  Long-name                Plugin
  Klass                    FIXME:Generic
  Description              FIXME:Generic Template Element
  Author                   AUTHOR_NAME AUTHOR_EMAIL

Plugin Details:
  Name                     plugin
  Description              Template plugin
  Filename                 .\13_PluginsOnWindows.dll
  Version                  1.6.1
  License                  LGPL
  Source module            myfirstplugin
  Binary package           GStreamer
  Origin URL               http://gstreamer.net/

GObject
 +----GInitiallyUnowned
       +----GstObject
             +----GstElement

しっかりと自分でビルドしたプラグインであることが確認できます :)

これで、GStreamerのプラグイン開発の Hello world ができました!!

8
10
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10