Created
September 17, 2014 20:08
-
-
Save jampekka/d9aac995f6e414da76cd to your computer and use it in GitHub Desktop.
v4l2src hangs on Gstreamer 1.0 but works on 0.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Hangs after two frames with gstreamer 1.0: | |
gcc -o v4l2_hang1.0 `pkg-config gstreamer-1.0 --cflags --libs` v4l2_hang.c && ./v4l2_hang1.0 | |
Works fine with 0.10 | |
gcc -o v4l2_hang0.10 `pkg-config gstreamer-0.10 --cflags --libs` v4l2_hang.c && ./v4l2_hang0.10 | |
*/ | |
#include <gst/gst.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
gst_init(&argc, &argv); | |
GError *error = NULL; | |
GstElement *pipeline = gst_parse_launch( | |
"v4l2src device=/dev/video0 ! " | |
"appsink sync=false max-buffers=1 drop=true name=sink emit-signals=true", | |
&error); | |
if(!pipeline) { | |
printf("Pipeline construction failed: %s\n", error->message); | |
return 1; | |
} | |
GstElement *sink = gst_bin_get_by_name((GstBin *)pipeline, "sink"); | |
if(!sink) { | |
puts("Gouldn't get the sink"); | |
return 1; | |
} | |
gst_element_set_state(pipeline, GST_STATE_PLAYING); | |
#if GST_VERSION_MAJOR == (1) | |
GstSample *sample; | |
for(;;) { | |
printf("Pulling sample\n"); | |
g_signal_emit_by_name(sink, "pull-sample", &sample, NULL); | |
} | |
#endif | |
GstBuffer *buffer; | |
for(;;) { | |
printf("Pulling buffer\n"); | |
g_signal_emit_by_name(sink, "pull-buffer", &buffer, NULL); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment