openwrt gstreamer執行個體學習筆記(一.初始化gstreamer)

來源:互聯網
上載者:User

標籤:

GStreamer 是一個非常強大而且通用的流媒體應用程式架構。 GStreamer所具備的很多優點來源於其架構的模組化: GStreamer能夠無縫的合并新的外掛程式。 但是, 由於追求模組化和高效率, 使得GStreamer在整個架構上變的複雜, 也同時因為複雜度的提高, 使得開發一個新的應用程式顯得不是那麼的簡單。

由於工作需求,因此筆者開啟了gstreamer構建音頻播放器之路!

 

首先openwrt下面make menuconfig 要選擇gstreamer必要的外掛程式庫,由於openwrt下面已經很好地支援了gstreamer的大部分外掛程式,因此使得openwrt下面基於gstreamer開發變得輕鬆一點。

 

第一步:寫程式

當我們準備寫一個GStreamer應用程式時,你僅需要通過包含標頭檔gst/gst.h 來訪問庫函數。除此之外,不要忘記初始化GStreamer庫。

#include <stdio.h>
#include <glib.h>
#include <gst/gst.h>

int main (int   argc,   char *argv[])
{
  const gchar *nano_str;
  guint major, minor, micro, nano;

  gst_init (&argc, &argv);

  gst_version (&major, &minor, &micro, &nano);

  if (nano == 1)
    nano_str = "(CVS)";
  else if (nano == 2)
    nano_str = "(Prerelease)";
  else
    nano_str = "";

  printf("This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str);

  return 0;
}

以上程式是初始gstreamer,並列印gstreamer的版本號碼!

第二歩:

編寫openwrt 下面makefile

 

include $(TOPDIR)/rules.mk

#LIB_GS=/home/xuyonghong/share/ffmpeg/car_radio_firmware/trunk/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/lib
PKG_NAME:=gst-test
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/gst-test
    SECTION:=multimedia
    CATEGORY:=Multimedia
    DEPENDS:=+gstreamer1* +glib2    +libpthread
    TITLE:=gstreamer test demo
endef


define Package/gst-test/description
    If you can‘t figure out what this program does, you‘re probably
    brain-dead and need immediate medical attention.
endef

TARGET_CPPFLAGS:= \
    -I$(STAGING_DIR)/usr/include/gstreamer-1.0 \
    $(TARGET_CPPFLAGS)


TARGET_CPPFLAGS:= \
    -I$(STAGING_DIR)/usr/include/glib-2.0 \
    $(TARGET_CPPFLAGS)


MAKE_FLAGS += \
    CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(PKG_CONFIGS) -ffunction-sections -fdata-sections" \
    LDFLAGS="$(TARGET_LDFLAGS) $(PKG_CONFIGS) -Wl,--gc-sections" \

    PKG_CONFIGS:= \
        `pkg-config --cflags --libs glib-2.0 gthread-2.0  gstreamer-1.0`

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef


define Package/gst-test/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/gst-test $(1)/bin/

#   
#$(CP) $(LIB_GS)/libgstreamer*  $(1)/bin

endef

$(eval $(call BuildPackage,gst-test))

第三步:make編譯

第四步;測試之

[email protected]:/#
[email protected]:/# chmod +x gst-test
[email protected]:/# ./gst-test
This program is linked against GStreamer 1.2.3
[email protected]:/#
[email protected]:/#

openwrt gstreamer執行個體學習筆記(一.初始化gstreamer)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.