gstreamer plug-knowledge summary
1.gstreamer plug internal structure and function summary
(1) define plug-in properties and the signal
enum
{
/* FILL ME */
SIGNAL_DETECTED,
LAST_SIGNAL
};
(2) the gasket defines the type of data transmitted and received
static GstStaticPadTemplate sink_factory...
(3) elements and attributes initialization signal
gst_human_detection_class_init()
Attribute initialization sample:
g_object_class_install_property (gobject_class, PROP_PICTUREPATH,
g_param_spec_string ("picturePath", "picturePath", "output picturePath",
"NULL", (GParamFlags)(G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)));
Sample initialization signal:
gst_human_detection_signals[SIGNAL_DETECTED] =
g_signal_new ("detected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstHumanDetectionClass, detected), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
(4) element is initialized (initialization when loading or element)
gst_human_detection_init()
Stored in a function such as loading only loaded once without loading the cycle times and events networks.
(5) Function Set Properties
gst_human_detection_set_property()
(6) property getters
gst_human_detection_get_property()
(7) a main function operation (video stream goes through each frame of the image processing function)
gst_human_detection_chain()
2. Internal plug-in uses knowledge
(1) the use of locks
pthread_mutex_t threadMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&threadMutex);
pthread_mutex_unlock(&threadMutex);
(2) an initialization signal
static guint gst_human_detection_signals[LAST_SIGNAL] = { 0 };
(3) obtaining resolution video stream
int width, height;
GstCaps *caps;
caps = gst_pad_get_current_caps (pad);
GstStructure* structure = gst_caps_get_structure(caps, 0);
gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height);
...
gst_caps_unref (caps);
(4) obtaining a video image of each frame
GstMapInfo map;
gst_buffer_map(buf, &map, GST_MAP_READ);
v = Mat(Size(width,height),CV_8UC4,(char *)map.data);
...
memcpy(map.data, v.data, map.size);
gst_buffer_unmap (buf, &map);