IMX6 GStreamer Source Code Example

/*
============================================================================
Name
: Freescale Camera Viewer
Commandline Equiv: gst-launch mfw_v4lsrc device=/dev/video1 capture-mode=5 ! mfw_v4lsink
Author
: Mark Talbot:
Description : Gstreamer Example - no error handling
============================================================================
*/
#include <gst/gst.h>
#include <glib.h>
#include <stdio.h>
int
main (int argc,
char *argv[])
{
GstElement *pipeline, *source, *sink;
/* Initialisation */
gst_init (&argc, &argv);
/* Check input arguments */
if (argc != 2) {
g_printerr ("Usage: %s <input dev: eg: /dev/video0>\n", argv[0]);
return -1;
}

g_print ("Device to be used: %s \n", argv[1]);

/* Create gstreamer elements */
pipeline = gst_pipeline_new ("video-player");
source = gst_element_factory_make ("mfw_v4lsrc",
"video-source");
sink = gst_element_factory_make ("mfw_v4lsink", "fsl-v4lsink");
if (!pipeline || !source || !sink) {
g_printerr ("One element could not be created. Exiting.\n");
return -1;
}
/* Set up the pipeline */
/* we set the input filename to the source element */
g_object_set (G_OBJECT (source), "device", argv[1], "capture-mode", 4, NULL);
/* For Debug */
/* g_object_set (G_OBJECT (source), "device", "/dev/video1", "capture-mode", 5, NULL);*/
/* we add all elements into the pipeline */
/* file-source | video-output */
gst_bin_add_many (GST_BIN (pipeline),
source, sink, NULL);
/* we link the elements together */
/* file-source -> video-output */
gst_element_link_many (source, sink, NULL);
/* Set the pipeline to "playing" state*/
g_print ("Now playing: %s\n", argv[1]);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_print ("Running...\n");

/* When you press enter we will do a graceful exit */
printf ("**************Press ENTER to stop************************\n ");
while (1)
{
char c=getchar();
if (c=='\n' || c==EOF) break;
}
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值