summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorNicola Murino <nicola.murino@gmail.com>2018-11-26 16:38:37 +0100
committerNicola Murino <nicola.murino@gmail.com>2018-12-14 18:43:49 +0100
commitef3da2787aa4c078b385df2a32d9dbc0f7a10e18 (patch)
treeadeaea971e56141cd5952c49ba7cfac7b3fbeda9 /gst
parentfa7da2fb16876993c95da3c3be14bb953754b85e (diff)
downloadgstreamer-plugins-bad-ef3da2787aa4c078b385df2a32d9dbc0f7a10e18.tar.gz
removesilence: add silent property to control bus message notifications
Closes #63
Diffstat (limited to 'gst')
-rw-r--r--gst/removesilence/gstremovesilence.c47
-rw-r--r--gst/removesilence/gstremovesilence.h1
2 files changed, 33 insertions, 15 deletions
diff --git a/gst/removesilence/gstremovesilence.c b/gst/removesilence/gstremovesilence.c
index a51038edf..e41c84622 100644
--- a/gst/removesilence/gstremovesilence.c
+++ b/gst/removesilence/gstremovesilence.c
@@ -59,7 +59,8 @@ enum
PROP_0,
PROP_REMOVE,
PROP_HYSTERESIS,
- PROP_SQUASH
+ PROP_SQUASH,
+ PROP_SILENT
};
@@ -128,6 +129,11 @@ gst_remove_silence_class_init (GstRemoveSilenceClass * klass)
"Set to true to retimestamp buffers when silence is removed and so avoid timestamp gap",
FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_SILENT,
+ g_param_spec_boolean ("silent", "Silent",
+ "Disable/enable bus message notifications for silent detected/finished",
+ TRUE, G_PARAM_READWRITE));
+
gst_element_class_set_static_metadata (gstelement_class,
"RemoveSilence",
"Filter/Effect/Audio",
@@ -156,6 +162,7 @@ gst_remove_silence_init (GstRemoveSilence * filter)
filter->squash = FALSE;
filter->ts_offset = 0;
filter->silence_detected = FALSE;
+ filter->silent = TRUE;
if (!filter->vad) {
GST_DEBUG ("Error initializing VAD !!");
@@ -190,6 +197,9 @@ gst_remove_silence_set_property (GObject * object, guint prop_id,
case PROP_SQUASH:
filter->squash = g_value_get_boolean (value);
break;
+ case PROP_SILENT:
+ filter->silent = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -212,6 +222,9 @@ gst_remove_silence_get_property (GObject * object, guint prop_id,
case PROP_SQUASH:
g_value_set_boolean (value, filter->squash);
break;
+ case PROP_SILENT:
+ g_value_set_boolean (value, filter->silent);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -235,13 +248,15 @@ gst_remove_silence_transform_ip (GstBaseTransform * trans, GstBuffer * inbuf)
if (frame_type == VAD_SILENCE) {
GST_DEBUG ("Silence detected");
if (!filter->silence_detected) {
- if (GST_BUFFER_PTS_IS_VALID (inbuf)) {
- GstStructure *s;
- GstMessage *m;
- s = gst_structure_new ("removesilence", "silence_detected",
- G_TYPE_UINT64, GST_BUFFER_PTS (inbuf) - filter->ts_offset, NULL);
- m = gst_message_new_element (GST_OBJECT (filter), s);
- gst_element_post_message (GST_ELEMENT (filter), m);
+ if (!filter->silent) {
+ if (GST_BUFFER_PTS_IS_VALID (inbuf)) {
+ GstStructure *s;
+ GstMessage *m;
+ s = gst_structure_new ("removesilence", "silence_detected",
+ G_TYPE_UINT64, GST_BUFFER_PTS (inbuf) - filter->ts_offset, NULL);
+ m = gst_message_new_element (GST_OBJECT (filter), s);
+ gst_element_post_message (GST_ELEMENT (filter), m);
+ }
}
filter->silence_detected = TRUE;
}
@@ -260,13 +275,15 @@ gst_remove_silence_transform_ip (GstBaseTransform * trans, GstBuffer * inbuf)
} else {
if (filter->silence_detected) {
- if (GST_BUFFER_PTS_IS_VALID (inbuf)) {
- GstStructure *s;
- GstMessage *m;
- s = gst_structure_new ("removesilence", "silence_finished",
- G_TYPE_UINT64, GST_BUFFER_PTS (inbuf) - filter->ts_offset, NULL);
- m = gst_message_new_element (GST_OBJECT (filter), s);
- gst_element_post_message (GST_ELEMENT (filter), m);
+ if (!filter->silent) {
+ if (GST_BUFFER_PTS_IS_VALID (inbuf)) {
+ GstStructure *s;
+ GstMessage *m;
+ s = gst_structure_new ("removesilence", "silence_finished",
+ G_TYPE_UINT64, GST_BUFFER_PTS (inbuf) - filter->ts_offset, NULL);
+ m = gst_message_new_element (GST_OBJECT (filter), s);
+ gst_element_post_message (GST_ELEMENT (filter), m);
+ }
}
filter->silence_detected = FALSE;
}
diff --git a/gst/removesilence/gstremovesilence.h b/gst/removesilence/gstremovesilence.h
index 1d1ef233f..ff44552ad 100644
--- a/gst/removesilence/gstremovesilence.h
+++ b/gst/removesilence/gstremovesilence.h
@@ -47,6 +47,7 @@ typedef struct _GstRemoveSilence {
gboolean squash;
guint64 ts_offset;
gboolean silence_detected;
+ gboolean silent;
} GstRemoveSilence;
typedef struct _GstRemoveSilenceClass {