#include #include static GstPadProbeReturn cb_have_data (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstElement * sink; gchar* filename; struct timeval tp; time_t curtime; struct tm *t; gettimeofday(&tp, 0); curtime = tp.tv_sec; t = localtime(&curtime); filename = g_strdup_printf("%02d:%02d:%02d:%03ld.raw", t->tm_hour, t->tm_min, t->tm_sec, tp.tv_usec); sink = GST_ELEMENT(user_data); g_object_set(G_OBJECT(sink), "location", filename, NULL); g_free(filename); return GST_PAD_PROBE_OK; } int main (int argc, char *argv[]) { GstElement *pipeline, *sink; GstBus *bus; GstMessage *msg; GstPad *sinkpad; /* Initialize GStreamer */ gst_init (&argc, &argv); /* Build the pipeline */ pipeline = gst_parse_launch ("nvarguscamerasrc num-buffers=10 ! nvvidconv ! queue leaky=2 max-size-buffers=5 ! video/x-raw,width=1280,height=720,framerate=30/1 ! multifilesink name=sink", NULL); sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink"); sinkpad = gst_element_get_static_pad(sink, "sink"); gst_pad_add_probe(sinkpad,GST_PAD_PROBE_TYPE_BUFFER, (GstPadProbeCallback) cb_have_data, sink, NULL); /* Start playing */ gst_element_set_state (pipeline, GST_STATE_PLAYING); /* Wait until error or EOS */ bus = gst_element_get_bus (pipeline); msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); /* See next tutorial for proper error message handling/parsing */ if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { g_error ("An error occurred! Re-run with the GST_DEBUG=*:WARN environment " "variable set for more details."); } /* Free resources */ gst_message_unref (msg); gst_object_unref (bus); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; }