No, I mean to remove the uridecodebin
, which will cause errors to be incorrectly passed in the pipeline.
Build a source bin similar to the following, Avoid errors passed to bus_callback
.
souphttpsrc location=xxxx --> caps --> queue --> nvjpegdec
OK, the following patch is my example, I have tested it and it works .
Add mjpeg-over-http=1
in [sourcex] group.
For apps-common
diff --git a/sources/apps/apps-common/includes/deepstream_config_file_parser.h b/sources/apps/apps-common/includes/deepstream_config_file_parser.h
index e219563..3967b88 100644
--- a/sources/apps/apps-common/includes/deepstream_config_file_parser.h
+++ b/sources/apps/apps-common/includes/deepstream_config_file_parser.h
@@ -112,6 +112,7 @@ extern "C"
#define CONFIG_GROUP_SOURCE_SMART_RECORD_DEFAULT_DURATION "smart-rec-default-duration"
#define CONFIG_GROUP_SOURCE_SMART_RECORD_DURATION "smart-rec-duration"
#define CONFIG_GROUP_SOURCE_SMART_RECORD_INTERVAL "smart-rec-interval"
+#define CONFIG_GROUP_SOURCE_MJPEG_OVER_HTTP "mjpeg-over-http"
/**
* Function to parse class label file. Parses the labels into a 2D-array of
diff --git a/sources/apps/apps-common/includes/deepstream_sources.h b/sources/apps/apps-common/includes/deepstream_sources.h
index 0416d05..a94d363 100644
--- a/sources/apps/apps-common/includes/deepstream_sources.h
+++ b/sources/apps/apps-common/includes/deepstream_sources.h
@@ -83,6 +83,7 @@ typedef struct
gchar* alsa_device;
/** Video format to be applied at nvvideoconvert source pad. */
gchar* video_format;
+ gboolean mjpeg_over_http;
} NvDsSourceConfig;
typedef struct NvDsSrcParentBin NvDsSrcParentBin;
diff --git a/sources/apps/apps-common/src/deepstream_config_file_parser.c b/sources/apps/apps-common/src/deepstream_config_file_parser.c
index 5d99503..c20fdff 100644
--- a/sources/apps/apps-common/src/deepstream_config_file_parser.c
+++ b/sources/apps/apps-common/src/deepstream_config_file_parser.c
@@ -402,6 +402,7 @@ parse_source (NvDsSourceConfig * config, GKeyFile * key_file, gchar * group,
gchar **key = NULL;
GError *error = NULL;
static GList *camera_id_list = NULL;
+ config->mjpeg_over_http = false;
if (g_strcmp0 (group, CONFIG_GROUP_SOURCE_ALL)) {
if (g_key_file_get_integer (key_file, group,
@@ -656,6 +657,11 @@ parse_source (NvDsSourceConfig * config, GKeyFile * key_file, gchar * group,
g_key_file_get_integer(key_file, CONFIG_GROUP_SOURCE,
CONFIG_GROUP_SOURCE_EXTRACT_SEI_TYPE5_DATA, &error);
CHECK_ERROR(error);
+ } else if (!g_strcmp0(*key, CONFIG_GROUP_SOURCE_MJPEG_OVER_HTTP)) {
+ config->mjpeg_over_http =
+ g_key_file_get_integer(key_file, group,
+ CONFIG_GROUP_SOURCE_MJPEG_OVER_HTTP, &error);
+ CHECK_ERROR(error);
}
else {
NVGSTDS_WARN_MSG_V ("Unknown key '%s' for group [%s]", *key, group);
diff --git a/sources/apps/apps-common/src/deepstream_source_bin.c b/sources/apps/apps-common/src/deepstream_source_bin.c
index 002d2ee..8c5dae3 100644
--- a/sources/apps/apps-common/src/deepstream_source_bin.c
+++ b/sources/apps/apps-common/src/deepstream_source_bin.c
@@ -652,7 +652,8 @@ check_rtsp_reconnection_attempts (NvDsSrcBin * src_bin)
gboolean remove_probe = TRUE;
guint i = 0;
for (i = 0; i < src_bin->parent_bin->num_bins; i++) {
- if (src_bin->parent_bin->sub_bins[i].config->type != NV_DS_SOURCE_RTSP)
+ if (src_bin->parent_bin->sub_bins[i].config->type != NV_DS_SOURCE_RTSP ||
+ src_bin->parent_bin->sub_bins[i].config->type != NV_DS_SOURCE_URI)
continue;
if (src_bin->parent_bin->sub_bins[i].have_eos &&
(src_bin->parent_bin->sub_bins[i].rtsp_reconnect_interval_sec == 0 ||
@@ -1292,42 +1293,87 @@ create_uridecode_src_bin (NvDsSourceConfig * config, NvDsSrcBin * bin)
GstCaps *caps = NULL;
GstCapsFeatures *feature = NULL;
bin->config = config;
+ GstElement *jpegparse = NULL;
+ GstElement *v4l2dec = NULL;
+ GstElement *filter = NULL;
- bin->src_elem = gst_element_factory_make (NVDS_ELEM_SRC_URI, "src_elem");
- if (!bin->src_elem) {
- NVGSTDS_ERR_MSG_V ("Could not create element 'src_elem'");
- goto done;
- }
+ bin->rtsp_reconnect_interval_sec = config->rtsp_reconnect_interval_sec;
+ bin->rtsp_reconnect_attempts = config->rtsp_reconnect_attempts;
- if (config->dewarper_config.enable) {
- if (!create_dewarper_bin (&config->dewarper_config, &bin->dewarper_bin)) {
- g_print ("Creating Dewarper bin failed \n");
+ if (config->mjpeg_over_http) {
+ bin->src_elem = gst_element_factory_make ("souphttpsrc", "src_elem");
+ if (!bin->src_elem) {
+ NVGSTDS_ERR_MSG_V ("Could not create element 'src_elem'");
goto done;
}
- }
- bin->latency = config->latency;
- bin->udp_buffer_size = config->udp_buffer_size;
+ g_object_set (G_OBJECT (bin->src_elem), "location", config->uri, NULL);
+ GstCaps *caps = gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, 15, 1, NULL);
+ filter = gst_element_factory_make (NVDS_ELEM_CAPS_FILTER, "filter0");
+ if (!filter) {
+ NVGSTDS_ERR_MSG_V ("Could not create 'filter'");
+ goto done;
+ }
+ g_object_set (G_OBJECT (filter), "caps", caps, NULL);
+ gst_caps_unref (caps);
- if (g_strrstr (config->uri, "file:/")) {
- config->live_source = FALSE;
- }
- if (g_strrstr (config->uri, "rtsp://") == config->uri) {
- configure_source_for_ntp_sync (bin->src_elem);
+ jpegparse = gst_element_factory_make ("jpegparse", "jpegparse");
+ if (!jpegparse) {
+ NVGSTDS_ERR_MSG_V ("Could not create element 'jpegparse'");
+ goto done;
+ }
+ v4l2dec = gst_element_factory_make ("nvv4l2decoder", "nvv4l2decoder");
+ if (!v4l2dec) {
+ NVGSTDS_ERR_MSG_V ("Could not create element 'nvv4l2decoder'");
+ goto done;
+ }
+ g_object_set (G_OBJECT (v4l2dec), "mjpeg", true, NULL);
+ } else {
+ bin->src_elem = gst_element_factory_make (NVDS_ELEM_SRC_URI, "src_elem");
+ if (!bin->src_elem) {
+ NVGSTDS_ERR_MSG_V ("Could not create element 'src_elem'");
+ goto done;
+ }
+
+ if (config->dewarper_config.enable) {
+ if (!create_dewarper_bin (&config->dewarper_config, &bin->dewarper_bin)) {
+ g_print ("Creating Dewarper bin failed \n");
+ goto done;
+ }
+ }
+ bin->latency = config->latency;
+ bin->udp_buffer_size = config->udp_buffer_size;
+
+ if (g_strrstr (config->uri, "file:/")) {
+ config->live_source = FALSE;
+ }
+ if (g_strrstr (config->uri, "rtsp://") == config->uri) {
+ configure_source_for_ntp_sync (bin->src_elem);
+ }
+
+ g_object_set (G_OBJECT (bin->src_elem), "uri", config->uri, NULL);
+ g_signal_connect (G_OBJECT (bin->src_elem), "pad-added",
+ G_CALLBACK (cb_newpad), bin);
+ g_signal_connect (G_OBJECT (bin->src_elem), "child-added",
+ G_CALLBACK (decodebin_child_added), bin);
+ g_signal_connect (G_OBJECT (bin->src_elem), "source-setup",
+ G_CALLBACK (cb_sourcesetup), bin);
}
- g_object_set (G_OBJECT (bin->src_elem), "uri", config->uri, NULL);
- g_signal_connect (G_OBJECT (bin->src_elem), "pad-added",
- G_CALLBACK (cb_newpad), bin);
- g_signal_connect (G_OBJECT (bin->src_elem), "child-added",
- G_CALLBACK (decodebin_child_added), bin);
- g_signal_connect (G_OBJECT (bin->src_elem), "source-setup",
- G_CALLBACK (cb_sourcesetup), bin);
bin->cap_filter = gst_element_factory_make (NVDS_ELEM_QUEUE, "queue");
if (!bin->cap_filter) {
NVGSTDS_ERR_MSG_V ("Could not create 'queue'");
goto done;
}
+ if (bin->rtsp_reconnect_interval_sec > 0) {
+ NVGSTDS_ELEM_ADD_PROBE(bin->rtspsrc_monitor_probe, bin->cap_filter, "sink", rtspsrc_monitor_probe_func, GST_PAD_PROBE_TYPE_BUFFER, bin);
+ install_mux_eosmonitor_probe = TRUE;
+ } else {
+ NVGSTDS_ELEM_ADD_PROBE (bin->rtspsrc_monitor_probe, bin->cap_filter,
+ "sink", rtspsrc_monitor_probe_func,
+ GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, bin);
+ }
+
bin->nvvidconv =
gst_element_factory_make (NVDS_ELEM_VIDEO_CONV, "nvvidconv_elem");
if (!bin->nvvidconv) {
@@ -1358,8 +1404,17 @@ create_uridecode_src_bin (NvDsSourceConfig * config, NvDsSrcBin * bin)
g_object_set_data (G_OBJECT (bin->cap_filter), SRC_CONFIG_KEY, config);
- gst_bin_add_many (GST_BIN (bin->bin), bin->src_elem, bin->cap_filter,
- bin->nvvidconv, bin->cap_filter1, NULL);
+ if (config->mjpeg_over_http) {
+ gst_bin_add_many (GST_BIN (bin->bin), bin->src_elem, filter, jpegparse, v4l2dec, bin->cap_filter,
+ bin->nvvidconv, bin->cap_filter1, NULL);
+ NVGSTDS_LINK_ELEMENT (bin->src_elem, filter);
+ NVGSTDS_LINK_ELEMENT (filter, jpegparse);
+ NVGSTDS_LINK_ELEMENT (jpegparse, v4l2dec);
+ NVGSTDS_LINK_ELEMENT (v4l2dec, bin->cap_filter);
+ } else {
+ gst_bin_add_many (GST_BIN (bin->bin), bin->src_elem, bin->cap_filter,
+ bin->nvvidconv, bin->cap_filter1, NULL);
+ }
NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->cap_filter1, "src");
@@ -1402,6 +1457,8 @@ create_uridecode_src_bin (NvDsSourceConfig * config, NvDsSrcBin * bin)
ret = TRUE;
+ g_timeout_add (1000, watch_source_status, bin);
+
GST_CAT_DEBUG (NVDS_APP,
"Decode bin created. Waiting for a new pad from decodebin to link");
For deepstream-app.c
diff --git a/sources/apps/sample_apps/deepstream-app/deepstream_app.c b/sources/apps/sample_apps/deepstream-app/deepstream_app.c
index 044cfbc..98a9a83 100644
--- a/sources/apps/sample_apps/deepstream-app/deepstream_app.c
+++ b/sources/apps/sample_apps/deepstream-app/deepstream_app.c
@@ -236,14 +236,15 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
}
if ((i != bin->num_bins) &&
- (appCtx->config.multi_source_config[0].type == NV_DS_SOURCE_RTSP)) {
+ ((appCtx->config.multi_source_config[0].type == NV_DS_SOURCE_RTSP) ||
+ (appCtx->config.multi_source_config[0].type == NV_DS_SOURCE_URI))) {
// Error from one of RTSP source.
NvDsSrcBin *subBin = &bin->sub_bins[i];
if (!subBin->reconfiguring ||
g_strrstr (debuginfo, "500 (Internal Server Error)")) {
subBin->reconfiguring = TRUE;
- g_timeout_add (0, reset_source_pipeline, subBin);
+ g_timeout_add (10000, reset_source_pipeline, subBin);
}
g_error_free (error);
g_free (debuginfo);