| 95 | {{{ |
| 96 | void WebCamDisplayVideo(int seconds) |
| 97 | { |
| 98 | GstElement* pipeline; |
| 99 | GstBus* bus; |
| 100 | GstMessage* msg; |
| 101 | |
| 102 | const char* cmd = "v4l2src device=/dev/video2 ! autovideosink"; |
| 103 | pipeline = gst_parse_launch(cmd, NULL); |
| 104 | gst_element_set_state (pipeline, GST_STATE_PLAYING); |
| 105 | |
| 106 | /* Wait until error or EOS */ |
| 107 | bus = gst_element_get_bus(pipeline); |
| 108 | msg = gst_bus_timed_pop_filtered(bus, seconds * 1000 * GST_MSECOND, (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)); |
| 109 | if(msg != NULL) { |
| 110 | gst_message_unref(msg); |
| 111 | } |
| 112 | gst_object_unref(bus); |
| 113 | gst_element_set_state(pipeline, GST_STATE_NULL); |
| 114 | gst_object_unref(pipeline); |
| 115 | } |
| 116 | |
| 117 | }}} |
| 118 | |
| 119 | |