...
Provide easy-to-use streaming APIs for c3v platforms, helping users quickly develop stream-related applications like this sample.
Why use CM Streaming API?
...
For example, if need to get the YUV data from the sensor inside the program. In the GStreamer way, the developer should create elements, link them together, and then start it. The flow will be like this:
...
The main code will be like:
Code Block | ||
---|---|---|
| ||
#include <gst/gst.h>
static GstFlowReturn _src_new_sample(GstElement *ele, gpointer data){
GstElement *sample;
g_singal_emit_by_name(ele, "pull-sample", &sample);
if(sample){
GstBuffer *buffer = gst_sample_get_buffer(sample);
......
}
}
int main(int argc, char* argv[]){
gst_init(&argc, &argv);
GstElement* bin = gst_pipeline_new(NULL);
g_assert(bin);
GstElement* src = gst_element_factory_make("v4l2src", NULL);
g_assert(src);
g_object_set(src, "device", "/dev/video0", NULL);
GstElement* sink = gst_element_factory_make("appsink", NULL);
g_assert(sink);
g_object_set(sink, "emit-signals", TRUE, NULL);
gint signal = g_signal_connect(sink, G_CALLBACK(_src_new_sample), NULL);
gst_bin_add_many(bin, src, sink, NULL);
gst_element_link(src, sink);
gst_element_set_state(bin, GST_STATE_PLAYING);
......
gst_element_set_state(bin, GST_STATE_NULL);
g_signal_handler_disconnect(sink, signal);
gst_object_unref(bin);
gst_deinit();
} |
If now want to get data from another sensor, the developer needs to do the appeal process again. But in the CM Streaming API, the appeal process is packaged as API, users just need to call the API without caring about how it is implemented.
In the CM Streaming API way, the main code will be like this.
How to use CM Streaming API?
...