Doxygen Book
gsttensor_mux.c File Reference

GStreamer plugin to mux 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_mux.h"
Include dependency graph for gsttensor_mux.c:

Go to the source code of this file.

Macros

#define GST_CAT_DEFAULT   gst_tensor_mux_debug
 
#define DBG   (!tensor_mux->silent)
 Macro for debug mode. More...
 
#define CAPS_STRING_SINK   GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_MAKE ("{ static, flexible }")
 Default caps string for sink pad. More...
 
#define CAPS_STRING_SRC   GST_TENSORS_CAP_MAKE ("{ static, flexible }")
 Default caps string for src pad. More...
 
#define gst_tensor_mux_parent_class   parent_class
 

Enumerations

enum  { PROP_0, PROP_SILENT, PROP_SYNC_MODE, PROP_SYNC_OPTION }
 

Functions

 GST_DEBUG_CATEGORY_STATIC (gst_tensor_mux_debug)
 
static gboolean gst_tensor_mux_src_event (GstPad *pad, GstObject *parent, GstEvent *event)
 src event vmethod More...
 
static GstPad * gst_tensor_mux_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *req_name, const GstCaps *caps)
 making new request pad (gst element vmethod) More...
 
static GstStateChangeReturn gst_tensor_mux_change_state (GstElement *element, GstStateChange transition)
 change state (gst element vmethod) More...
 
static gboolean gst_tensor_mux_sink_event (GstCollectPads *pads, GstCollectData *data, GstEvent *event, GstTensorMux *tensor_mux)
 sink event vmethod More...
 
static GstFlowReturn gst_tensor_mux_collected (GstCollectPads *pads, GstTensorMux *tensor_mux)
 Gst Collect Pads Function which is called once collect pads done. More...
 
static GstFlowReturn gst_tensor_mux_do_clip (GstCollectPads *pads, GstCollectData *data, GstBuffer *buffer, GstBuffer **out, GstTensorMux *tensor_mux)
 Gst Clip Pads Function which is called right after a buffer is received for each pad. More...
 
static void gst_tensor_mux_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_mux_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_mux_finalize (GObject *object)
 finalize vmethod More...
 
 G_DEFINE_TYPE (GstTensorMux, gst_tensor_mux, GST_TYPE_ELEMENT)
 
static void gst_tensor_mux_class_init (GstTensorMuxClass *klass)
 initialize the tensor_mux's class More...
 
static void gst_tensor_mux_init (GstTensorMux *tensor_mux)
 initialize the new element instantiate pads and add them to element set pad callback functions initialize instance structure More...
 
static void gst_tensor_mux_set_waiting (GstTensorMux *tensor_mux, gboolean waiting)
 set pads waiting property More...
 
static gboolean gst_tensor_mux_collect_buffer (GstTensorMux *tensor_mux, GstBuffer *tensors_buf, gboolean *is_eos)
 Looping to generete output buffer for srcpad. More...
 
static gboolean gst_tensor_mux_set_src_caps (GstTensorMux *tensor_mux)
 Set src pad caps if src pad is not negotiated. More...
 
static void gst_tensor_mux_send_segment_event (GstTensorMux *tensor_mux, GstClockTime pts, GstClockTime dts)
 Create a new segment event if necessary. More...
 
static GstBuffer * gst_tensor_mux_chain_flex_tensor (GstTensorMux *tensor_mux, GstBuffer *buf)
 Process flex tensor. More...
 
static void gst_tensor_mux_ready_to_paused (GstTensorMux *tensor_mux)
 Ready --> Pasuse State Change. 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 mux 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_mux.c.

Macro Definition Documentation

◆ CAPS_STRING_SINK

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

Default caps string for sink pad.

Definition at line 89 of file gsttensor_mux.c.

◆ CAPS_STRING_SRC

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

Default caps string for src pad.

Definition at line 94 of file gsttensor_mux.c.

◆ DBG

#define DBG   (!tensor_mux->silent)

Macro for debug mode.

Definition at line 75 of file gsttensor_mux.c.

◆ GST_CAT_DEFAULT

#define GST_CAT_DEFAULT   gst_tensor_mux_debug

Definition at line 69 of file gsttensor_mux.c.

◆ gst_tensor_mux_parent_class

#define gst_tensor_mux_parent_class   parent_class

Definition at line 132 of file gsttensor_mux.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_SILENT 
PROP_SYNC_MODE 
PROP_SYNC_OPTION 

Definition at line 78 of file gsttensor_mux.c.

Function Documentation

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( GstTensorMux  ,
gst_tensor_mux  ,
GST_TYPE_ELEMENT   
)

◆ GST_DEBUG_CATEGORY_STATIC()

GST_DEBUG_CATEGORY_STATIC ( gst_tensor_mux_debug  )

SECTION:element-tensormux

A Muxer that merge tensor stream to tensors stream for NN frameworks. The output is always in the format of other/tensors

<refsect2> <title>Example launch line</title> |[ gst-launch -v -m \ filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_0 \ filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_1 \ filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! mux.sink_2 \ tensor_mux name=mux ! fakesink ]|

|[ gst-launch -v -m \ multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! mux.sink_0 \ multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! mux.sink_1 \ multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! mux.sink_2 \ tensor_mux name=mux ! filesink location=mux.log ]| </refsect2>

◆ gst_tensor_mux_chain_flex_tensor()

static GstBuffer* gst_tensor_mux_chain_flex_tensor ( GstTensorMux tensor_mux,
GstBuffer *  buf 
)
static

Process flex tensor.

Definition at line 446 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_change_state()

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

change state (gst element vmethod)

Definition at line 584 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_class_init()

static void gst_tensor_mux_class_init ( GstTensorMuxClass klass)
static

initialize the tensor_mux's class

Definition at line 139 of file gsttensor_mux.c.

Here is the call graph for this function:

◆ gst_tensor_mux_collect_buffer()

static gboolean gst_tensor_mux_collect_buffer ( GstTensorMux tensor_mux,
GstBuffer *  tensors_buf,
gboolean *  is_eos 
)
static

Looping to generete output buffer for srcpad.

Parameters
tensor_muxtensor muxer
tensors_bufoutput buffer for srcpad
is_eosboolean EOS ( End of Stream )
Returns
TRUE to push buffer to src pad

Definition at line 368 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_collected()

static GstFlowReturn gst_tensor_mux_collected ( GstCollectPads *  pads,
GstTensorMux tensor_mux 
)
static

Gst Collect Pads Function which is called once collect pads done.

Parameters
padsGstCollectPads
tensor_muxMuxer
Returns
GstFlowReturn

Cannot use gst-pad util to get stream ID (multiple sink pads). Create stream ID using first sink pad.

Definition at line 486 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_do_clip()

static GstFlowReturn gst_tensor_mux_do_clip ( GstCollectPads *  pads,
GstCollectData *  data,
GstBuffer *  buffer,
GstBuffer **  out,
GstTensorMux tensor_mux 
)
static

Gst Clip Pads Function which is called right after a buffer is received for each pad.

Definition at line 558 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_finalize()

static void gst_tensor_mux_finalize ( GObject *  object)
static

finalize vmethod

Definition at line 227 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_get_property()

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

Get property (gst element vmethod)

Definition at line 650 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_init()

static void gst_tensor_mux_init ( GstTensorMux tensor_mux)
static

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

Definition at line 193 of file gsttensor_mux.c.

Here is the call graph for this function:

◆ gst_tensor_mux_ready_to_paused()

static void gst_tensor_mux_ready_to_paused ( GstTensorMux tensor_mux)
static

Ready --> Pasuse State Change.

Definition at line 572 of file gsttensor_mux.c.

Here is the caller graph for this function:

◆ gst_tensor_mux_request_new_pad()

static GstPad * gst_tensor_mux_request_new_pad ( GstElement *  element,
GstPadTemplate *  templ,
const gchar *  name,
const GstCaps *  caps 
)
static

making new request pad (gst element vmethod)

Definition at line 253 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_send_segment_event()

static void gst_tensor_mux_send_segment_event ( GstTensorMux tensor_mux,
GstClockTime  pts,
GstClockTime  dts 
)
static

Create a new segment event if necessary.

Definition at line 422 of file gsttensor_mux.c.

Here is the caller graph for this function:

◆ gst_tensor_mux_set_property()

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

Get property (gst element vmethod)

Definition at line 617 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_set_src_caps()

static gboolean gst_tensor_mux_set_src_caps ( GstTensorMux tensor_mux)
static

Set src pad caps if src pad is not negotiated.

Definition at line 393 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_set_waiting()

static void gst_tensor_mux_set_waiting ( GstTensorMux tensor_mux,
gboolean  waiting 
)
static

set pads waiting property

Definition at line 322 of file gsttensor_mux.c.

Here is the caller graph for this function:

◆ gst_tensor_mux_sink_event()

static gboolean gst_tensor_mux_sink_event ( GstCollectPads *  pads,
GstCollectData *  data,
GstEvent *  event,
GstTensorMux tensor_mux 
)
static

sink event vmethod

Definition at line 339 of file gsttensor_mux.c.

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

◆ gst_tensor_mux_src_event()

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

src event vmethod

Definition at line 303 of file gsttensor_mux.c.

Here is the caller graph for this function:

Variable Documentation

◆ sink_templ

GstStaticPadTemplate sink_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
)

Definition at line 106 of file gsttensor_mux.c.

◆ src_templ

GstStaticPadTemplate src_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
)

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

Definition at line 100 of file gsttensor_mux.c.