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;
}
============================================================================
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;
}
相关文章推荐
- Spring 4 MVC example with Maven - [Source Code Download]
- gstreamer source code compile and install
- C / ANSI-C examples (example source code) Organized by topic
- C / ANSI-C examples (example source code) Organized by topic
- Android source code architecture
- Source Code Formatter,一个不错的Windows Live Writer 插件
- Google Chrome Source Code 源码下载 Google Chrome Source Code 源码下载
- firebug sourcecode
- 【Android-Source】Install Git and repo to get android source code
- Learning English From Android Source Code:2 Ampersand
- Download/Attach source-code/java-docs with maven dependencies
- How to build and debug android source code
- VC++ MFC Tutorial: CListCtrl, InsertItem, Using List Control, SetImageList, Article with source code.
- DSS Source Code Analyse (10) - RTPSession::Run
- DSS Source Code Analyse (19) - Authentication
- Learning English From Android Source Code:2 Ampersand
- Shell if elif else Code Example
- BeansDB Source Code Reading (1)
- Revised Visualization Source Code
- Paint .NET 3.05 Source Code can be got now!