Doxygen Book
gsttensor_demux.c File Reference

GStreamer plugin to demux tensors (as a filter for other general neural network filters) More...

#include <string.h>
#include <gst/gst.h>
#include <glib.h>
#include <nnstreamer_util.h>
#include "gsttensor_demux.h"
Include dependency graph for gsttensor_demux.c:

Go to the source code of this file.

Macros

#define GST_CAT_DEFAULT   gst_tensor_demux_debug
 
#define CAPS_STRING_SINK   GST_TENSORS_CAP_MAKE ("{ static, flexible }")
 Default caps string for sink pad. More...
 
#define CAPS_STRING_SRC   GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_MAKE ("{ static, flexible }")
 Default caps string for src pad. More...
 
#define gst_tensor_demux_parent_class   parent_class
 

Enumerations

enum  { PROP_0, PROP_SILENT, PROP_TENSORPICK }
 

Functions

 GST_DEBUG_CATEGORY_STATIC (gst_tensor_demux_debug)
 
static GstFlowReturn gst_tensor_demux_chain (GstPad *pad, GstObject *parent, GstBuffer *buf)
 chain function for sink (gst element vmethod) More...
 
static gboolean gst_tensor_demux_event (GstPad *pad, GstObject *parent, GstEvent *event)
 event function for sink (gst element vmethod) More...
 
static GstStateChangeReturn gst_tensor_demux_change_state (GstElement *element, GstStateChange transition)
 change state (gst element vmethod) More...
 
static void gst_tensor_demux_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_demux_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_demux_dispose (GObject *object)
 dispose function for tensor demux (gst element vmethod) More...
 
 G_DEFINE_TYPE (GstTensorDemux, gst_tensor_demux, GST_TYPE_ELEMENT)
 
static void gst_tensor_demux_class_init (GstTensorDemuxClass *klass)
 initialize the tensor_demux's class More...
 
static void gst_tensor_demux_init (GstTensorDemux *tensor_demux)
 initialize the new element instantiate pads and add them to element set pad callback functions initialize instance structure More...
 
static void gst_tensor_demux_remove_src_pads (GstTensorDemux *tensor_demux)
 function to remove srcpad list More...
 
static gboolean gst_tensor_demux_parse_caps (GstTensorDemux *tensor_demux, GstCaps *caps)
 Parse caps and configure tensors info. More...
 
static gboolean gst_tensor_demux_get_tensor_config (GstTensorDemux *tensor_demux, GstTensorsConfig *config, const guint nth, const guint total)
 Get tensor config info from configured tensors. More...
 
static GstTensorPadgst_tensor_demux_get_tensor_pad (GstTensorDemux *tensor_demux, gboolean *created, const guint nth, const guint total)
 Checking if the source pad is created and if not, create TensorPad. More...
 
static GstFlowReturn gst_tensor_demux_combine_flows (GstTensorDemux *tensor_demux, GstTensorPad *pad, GstFlowReturn ret)
 Check the status among sources in demux. More...
 

Variables

static GstStaticPadTemplate src_templ
 the capabilities of the inputs and outputs. describe the real formats here. More...
 
static GstStaticPadTemplate sink_templ
 

Detailed Description

GStreamer plugin to demux tensors (as a filter for other general neural network filters)

GStreamer Copyright (C) 2005 Thomas Vander Stichele thoma.nosp@m.s@ap.nosp@m.estaa.nosp@m.rt.o.nosp@m.rg Copyright (C) 2005 Ronald S. Bultje rbult.nosp@m.je@r.nosp@m.onald.nosp@m..bit.nosp@m.freak.nosp@m..net Copyright (C) 2018 Jijoong Moon jijoo.nosp@m.ng.m.nosp@m.oon@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

Date
03 July 2018
See also
https://github.com/nnstreamer/nnstreamer
Author
Jijoong Moon jijoo.nosp@m.ng.m.nosp@m.oon@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m
Bug:
No known bugs except for NYI items

Definition in file gsttensor_demux.c.

Macro Definition Documentation

◆ CAPS_STRING_SINK

#define CAPS_STRING_SINK   GST_TENSORS_CAP_MAKE ("{ static, flexible }")

Default caps string for sink pad.

Definition at line 78 of file gsttensor_demux.c.

◆ CAPS_STRING_SRC

#define CAPS_STRING_SRC   GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_MAKE ("{ static, flexible }")

Default caps string for src pad.

Definition at line 83 of file gsttensor_demux.c.

◆ GST_CAT_DEFAULT

#define GST_CAT_DEFAULT   gst_tensor_demux_debug

Definition at line 73 of file gsttensor_demux.c.

◆ gst_tensor_demux_parent_class

#define gst_tensor_demux_parent_class   parent_class

Definition at line 119 of file gsttensor_demux.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_SILENT 
PROP_TENSORPICK 

Definition at line 85 of file gsttensor_demux.c.

Function Documentation

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( GstTensorDemux  ,
gst_tensor_demux  ,
GST_TYPE_ELEMENT   
)

◆ GST_DEBUG_CATEGORY_STATIC()

GST_DEBUG_CATEGORY_STATIC ( gst_tensor_demux_debug  )

SECTION:element-tensor_demux

A Demuxer that demux tensors stream to tensor(s) stream for NN frameworks. The output is always in the format of other/tensor or other/tensors.

<refsect2> <title>Example launch line</title> |[ gst-launch-1.0 tensor_mux name=mux ! tensor_demux name=demux \ filesrc location=testcase01_RGB_100x100.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_0 \ filesrc location=testcase01_RGB_100x100.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_1 \ filesrc location=testcase01_RGB_100x100.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_2 \ demux.src_0 ! queue ! filesink location=demux00.log \ demux.src_1 ! queue ! filesink location=demux01.log \ demux.src_2 ! queue ! filesink location=demux02.log ]|

|[ gst-launch-1.0 tensor_mux name=mux ! tensor_demux name=demux tensorpick=0,1:2,2+0 \ ... (tensor 0) ! mux.sink_0 \ ... (tensor 1) ! mux.sink_1 \ ... (tensor 2) ! mux.sink_2 \ demux.src_0 ! (tensor 0) ... demux.src_1 ! (tensor 1,2) ... demux.src_2 ! (tensor 2,0) ... ]|

</refsect2>

◆ gst_tensor_demux_chain()

static GstFlowReturn gst_tensor_demux_chain ( GstPad *  pad,
GstObject *  parent,
GstBuffer *  buf 
)
static

chain function for sink (gst element vmethod)

The number of tensors in the buffer: The number of tensors from caps and gst-buffer should be same when incoming buffer is static tensor. If given buffer is flexible tensor, we cannot get exact number of tensors from config.

Definition at line 476 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_change_state()

static GstStateChangeReturn gst_tensor_demux_change_state ( GstElement *  element,
GstStateChange  transition 
)
static

change state (gst element vmethod)

Definition at line 586 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_class_init()

static void gst_tensor_demux_class_init ( GstTensorDemuxClass klass)
static

initialize the tensor_demux's class

Definition at line 127 of file gsttensor_demux.c.

Here is the call graph for this function:

◆ gst_tensor_demux_combine_flows()

static GstFlowReturn gst_tensor_demux_combine_flows ( GstTensorDemux tensor_demux,
GstTensorPad pad,
GstFlowReturn  ret 
)
static

Check the status among sources in demux.

Parameters
tensor_demuxTensorDemux Object
TensorPadTensorpad
retreturn status of current pad
Returns
return status after check sources

Definition at line 453 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_dispose()

static void gst_tensor_demux_dispose ( GObject *  object)
static

dispose function for tensor demux (gst element vmethod)

Definition at line 219 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_event()

static gboolean gst_tensor_demux_event ( GstPad *  pad,
GstObject *  parent,
GstEvent *  event 
)
static

event function for sink (gst element vmethod)

Definition at line 252 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_get_property()

static void gst_tensor_demux_get_property ( GObject *  object,
guint  prop_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Get property (gst element vmethod)

Definition at line 652 of file gsttensor_demux.c.

Here is the caller graph for this function:

◆ gst_tensor_demux_get_tensor_config()

static gboolean gst_tensor_demux_get_tensor_config ( GstTensorDemux tensor_demux,
GstTensorsConfig config,
const guint  nth,
const guint  total 
)
static

Get tensor config info from configured tensors.

Parameters
tensor_demux"this" pointer
configtensor config to be filled
nthsource ordering
totalnumber of tensors
Returns
TRUE if successfully configured

Definition at line 290 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_get_tensor_pad()

static GstTensorPad* gst_tensor_demux_get_tensor_pad ( GstTensorDemux tensor_demux,
gboolean *  created,
const guint  nth,
const guint  total 
)
static

Checking if the source pad is created and if not, create TensorPad.

Parameters
tensor_demuxTensorDemux Object
[out]createdwill be updated in this function
nthsource ordering
totalnumber of tensors
Returns
TensorPad if pad is already created, then return created pad. If not return new pad after creation.

Definition at line 349 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_init()

static void gst_tensor_demux_init ( GstTensorDemux tensor_demux)
static

initialize the new element instantiate pads and add them to element set pad callback functions initialize instance structure

Definition at line 175 of file gsttensor_demux.c.

Here is the call graph for this function:

◆ gst_tensor_demux_parse_caps()

static gboolean gst_tensor_demux_parse_caps ( GstTensorDemux tensor_demux,
GstCaps *  caps 
)
static

Parse caps and configure tensors info.

Parameters
tensor_demuxGstTensorDemux object
capsincoming capability
Returns
TRUE/FALSE (if successfully configured, return TRUE)

Definition at line 235 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_remove_src_pads()

static void gst_tensor_demux_remove_src_pads ( GstTensorDemux tensor_demux)
static

function to remove srcpad list

Definition at line 199 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_demux_set_property()

static void gst_tensor_demux_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Get property (gst element vmethod)

Definition at line 615 of file gsttensor_demux.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sink_templ

GstStaticPadTemplate sink_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
)

Definition at line 102 of file gsttensor_demux.c.

◆ src_templ

GstStaticPadTemplate src_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
)

the capabilities of the inputs and outputs. describe the real formats here.

Definition at line 96 of file gsttensor_demux.c.