您的位置:首页 > 其它

IMX6 GStreamer Source Code Example

2017-07-21 09:50 441 查看
/*

============================================================================

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Gstreamer Example imx6