deepstream_sinks.h 4.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
 *
 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
 * property and proprietary rights in and to this material, related
 * documentation and any modifications thereto. Any use, reproduction,
 * disclosure or distribution of this material and related documentation
 * without an express license agreement from NVIDIA CORPORATION or
 * its affiliates is strictly prohibited.
 */

#ifndef __NVGSTDS_SINKS_H__
#define __NVGSTDS_SINKS_H__

#ifdef __aarch64__
#define IS_TEGRA
#endif

#include <gst/gst.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum
{
  NV_DS_SINK_FAKE = 1,
#ifndef IS_TEGRA
  NV_DS_SINK_RENDER_EGL,
#else
  NV_DS_SINK_RENDER_3D,
#endif
  NV_DS_SINK_ENCODE_FILE,
  NV_DS_SINK_UDPSINK,
  NV_DS_SINK_RENDER_DRM,
  NV_DS_SINK_MSG_CONV_BROKER,
} NvDsSinkType;

typedef enum
{
  NV_DS_CONTAINER_MP4 = 1,
  NV_DS_CONTAINER_MKV
} NvDsContainerType;

typedef enum
{
  NV_DS_ENCODER_H264 = 1,
  NV_DS_ENCODER_H265,
  NV_DS_ENCODER_MPEG4
} NvDsEncoderType;

typedef enum
{
  NV_DS_ENCODER_TYPE_HW,
  NV_DS_ENCODER_TYPE_SW
} NvDsEncHwSwType;

typedef enum
{
    NV_DS_ENCODER_OUTPUT_IO_MODE_MMAP = 2,
    NV_DS_ENCODER_OUTPUT_IO_MODE_DMABUF_IMPORT = 5,
}NvDsEncOutputIOMode;

typedef struct
{
  NvDsSinkType type;
  NvDsContainerType container;
  NvDsEncoderType codec;
  NvDsEncHwSwType enc_type;
  guint compute_hw;
  gint bitrate;
  guint profile;
  gint sync;
  gchar *output_file_path;
  guint gpu_id;
  guint rtsp_port;
  guint udp_port;
  guint64 udp_buffer_size;
  guint iframeinterval;
  guint copy_meta;
  NvDsEncOutputIOMode output_io_mode;
  gint sw_preset;
} NvDsSinkEncoderConfig;

typedef struct
{
  NvDsSinkType type;
  gint width;
  gint height;
  gint sync;
  gboolean qos;
  gboolean qos_value_specified;
  guint gpu_id;
  guint nvbuf_memory_type;
  guint offset_x;
  guint offset_y;
  guint color_range;
  guint conn_id;
  guint plane_id;
  gboolean set_mode;
} NvDsSinkRenderConfig;

typedef struct
{
  gboolean enable;
  /** MsgConv settings */
  gchar*    config_file_path;
  guint     conv_payload_type;
  gchar*    conv_msg2p_lib;
  guint     conv_comp_id;
  gchar*    debug_payload_dir;
  gboolean  multiple_payloads;
  gboolean  conv_msg2p_new_api;
  guint     conv_frame_interval;
  gboolean  conv_dummy_payload;
  /** Broker settings */
  gchar*    proto_lib;
  gchar*    conn_str;
  gchar*    topic;
  gchar*    broker_config_file_path;
  guint     broker_comp_id;
  gboolean  disable_msgconv;
  gint sync;
  gboolean  new_api;
  guint broker_sleep_time;
} NvDsSinkMsgConvBrokerConfig;

typedef struct
{
  gboolean enable;
  guint source_id;
  gboolean link_to_demux;
  NvDsSinkType type;
  gint sync;
  NvDsSinkEncoderConfig encoder_config;
  NvDsSinkRenderConfig render_config;
  NvDsSinkMsgConvBrokerConfig msg_conv_broker_config;
} NvDsSinkSubBinConfig;

typedef struct
{
  GstElement *bin;
  GstElement *queue;
  GstElement *transform;
  GstElement *cap_filter;
  GstElement *enc_caps_filter;
  GstElement *encoder;
  GstElement *codecparse;
  GstElement *mux;
  GstElement *sink;
  GstElement *rtppay;
  gulong sink_buffer_probe;
} NvDsSinkBinSubBin;

typedef struct
{
  GstElement *bin;
  GstElement *queue;
  GstElement *tee;

  gint num_bins;
  NvDsSinkBinSubBin sub_bins[MAX_SINK_BINS];
} NvDsSinkBin;

/**
 * Initialize @ref NvDsSinkBin. It creates and adds sink and
 * other elements needed for processing to the bin.
 * It also sets properties mentioned in the configuration file under
 * group @ref CONFIG_GROUP_SINK
 *
 * @param[in] num_sub_bins number of sink elements.
 * @param[in] config_array array of pointers of type @ref NvDsSinkSubBinConfig
 *            parsed from configuration file.
 * @param[in] bin pointer to @ref NvDsSinkBin to be filled.
 * @param[in] index id of source element.
 *
 * @return true if bin created successfully.
 */
gboolean create_sink_bin (guint num_sub_bins,
    NvDsSinkSubBinConfig *config_array, NvDsSinkBin *bin, guint index);

void destroy_sink_bin (void);
gboolean create_demux_sink_bin (guint num_sub_bins,
    NvDsSinkSubBinConfig *config_array, NvDsSinkBin *bin, guint index);

void set_rtsp_udp_port_num (guint rtsp_port_num, guint udp_port_num);

#ifdef __cplusplus
}
#endif

#endif