mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
Re-indent to Gst style
This commit is contained in:
parent
d89e80f1c9
commit
22b1337ed7
8 changed files with 324 additions and 350 deletions
|
@ -26,6 +26,4 @@ plugin_init (GstPlugin * plugin)
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
GST_VERSION_MINOR,
|
GST_VERSION_MINOR,
|
||||||
"dtmf",
|
"dtmf", "DTMF plugins", plugin_init, "0.1", "LGPL", "DTMF", "");
|
||||||
"DTMF plugins",
|
|
||||||
plugin_init, "0.1" , "LGPL", "DTMF", "");
|
|
||||||
|
|
|
@ -157,7 +157,8 @@
|
||||||
#define MIN_DUTY_CYCLE (MIN_INTER_DIGIT_INTERVAL + MIN_PULSE_DURATION)
|
#define MIN_DUTY_CYCLE (MIN_INTER_DIGIT_INTERVAL + MIN_PULSE_DURATION)
|
||||||
|
|
||||||
|
|
||||||
typedef struct st_dtmf_key {
|
typedef struct st_dtmf_key
|
||||||
|
{
|
||||||
char *event_name;
|
char *event_name;
|
||||||
int event_encoding;
|
int event_encoding;
|
||||||
float low_frequency;
|
float low_frequency;
|
||||||
|
@ -185,7 +186,8 @@ static const DTMF_KEY DTMF_KEYS[] = {
|
||||||
|
|
||||||
#define MAX_DTMF_EVENTS 16
|
#define MAX_DTMF_EVENTS 16
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
DTMF_KEY_EVENT_1 = 1,
|
DTMF_KEY_EVENT_1 = 1,
|
||||||
DTMF_KEY_EVENT_2 = 2,
|
DTMF_KEY_EVENT_2 = 2,
|
||||||
DTMF_KEY_EVENT_3 = 3,
|
DTMF_KEY_EVENT_3 = 3,
|
||||||
|
@ -228,9 +230,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"width = (int) 16, "
|
"width = (int) 16, "
|
||||||
"depth = (int) 16, "
|
"depth = (int) 16, "
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
||||||
"signed = (bool) true, "
|
"signed = (bool) true, " "rate = (int) 8000, " "channels = (int) 1")
|
||||||
"rate = (int) 8000, "
|
|
||||||
"channels = (int) 1")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstDTMFSrc, gst_dtmf_src, GstBaseSrc, GST_TYPE_BASE_SRC);
|
GST_BOILERPLATE (GstDTMFSrc, gst_dtmf_src, GstBaseSrc, GST_TYPE_BASE_SRC);
|
||||||
|
@ -260,8 +260,7 @@ gst_dtmf_src_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_dtmf_src_debug,
|
GST_DEBUG_CATEGORY_INIT (gst_dtmf_src_debug, "dtmfsrc", 0, "dtmfsrc element");
|
||||||
"dtmfsrc", 0, "dtmfsrc element");
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_dtmf_src_template));
|
gst_static_pad_template_get (&gst_dtmf_src_template));
|
||||||
|
@ -282,10 +281,8 @@ gst_dtmf_src_class_init (GstDTMFSrcClass * klass)
|
||||||
|
|
||||||
|
|
||||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_dtmf_src_finalize);
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_dtmf_src_finalize);
|
||||||
gobject_class->set_property =
|
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_dtmf_src_set_property);
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_set_property);
|
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_dtmf_src_get_property);
|
||||||
gobject_class->get_property =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_get_property);
|
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INTERVAL,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INTERVAL,
|
||||||
g_param_spec_uint ("interval", "Interval between tone packets",
|
g_param_spec_uint ("interval", "Interval between tone packets",
|
||||||
|
@ -294,17 +291,12 @@ gst_dtmf_src_class_init (GstDTMFSrcClass * klass)
|
||||||
|
|
||||||
gstelement_class->change_state =
|
gstelement_class->change_state =
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_change_state);
|
GST_DEBUG_FUNCPTR (gst_dtmf_src_change_state);
|
||||||
gstbasesrc_class->unlock =
|
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_dtmf_src_unlock);
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_unlock);
|
gstbasesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_dtmf_src_unlock_stop);
|
||||||
gstbasesrc_class->unlock_stop =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_unlock_stop);
|
|
||||||
|
|
||||||
gstbasesrc_class->event =
|
gstbasesrc_class->event = GST_DEBUG_FUNCPTR (gst_dtmf_src_handle_event);
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_handle_event);
|
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_dtmf_src_create);
|
||||||
gstbasesrc_class->create =
|
gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_dtmf_src_negotiate);
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_create);
|
|
||||||
gstbasesrc_class->negotiate =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_dtmf_src_negotiate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -383,8 +375,7 @@ failure:
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_dtmf_src_handle_custom_upstream (GstDTMFSrc *dtmfsrc,
|
gst_dtmf_src_handle_custom_upstream (GstDTMFSrc * dtmfsrc, GstEvent * event)
|
||||||
GstEvent * event)
|
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
const GstStructure *structure;
|
const GstStructure *structure;
|
||||||
|
@ -540,8 +531,8 @@ gst_dtmf_src_generate_silence(GstBuffer * buffer, float duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration,
|
gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key,
|
||||||
GstBuffer * buffer, gint sample_rate)
|
float duration, GstBuffer * buffer, gint sample_rate)
|
||||||
{
|
{
|
||||||
gint16 *p;
|
gint16 *p;
|
||||||
gint tone_size;
|
gint tone_size;
|
||||||
|
@ -753,7 +744,8 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
|
||||||
|
|
||||||
buf = gst_dtmf_src_create_next_tone_packet (dtmfsrc, dtmfsrc->last_event);
|
buf = gst_dtmf_src_create_next_tone_packet (dtmfsrc, dtmfsrc->last_event);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "Created buffer of size %d", GST_BUFFER_SIZE (buf));
|
GST_DEBUG_OBJECT (dtmfsrc, "Created buffer of size %d",
|
||||||
|
GST_BUFFER_SIZE (buf));
|
||||||
*buffer = buf;
|
*buffer = buf;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "returning a buffer");
|
GST_DEBUG_OBJECT (dtmfsrc, "returning a buffer");
|
||||||
|
@ -777,7 +769,8 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_dtmf_src_unlock (GstBaseSrc *src) {
|
gst_dtmf_src_unlock (GstBaseSrc * src)
|
||||||
|
{
|
||||||
GstDTMFSrc *dtmfsrc = GST_DTMF_SRC (src);
|
GstDTMFSrc *dtmfsrc = GST_DTMF_SRC (src);
|
||||||
GstDTMFSrcEvent *event = NULL;
|
GstDTMFSrcEvent *event = NULL;
|
||||||
|
|
||||||
|
@ -800,7 +793,8 @@ gst_dtmf_src_unlock (GstBaseSrc *src) {
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_dtmf_src_unlock_stop (GstBaseSrc *src) {
|
gst_dtmf_src_unlock_stop (GstBaseSrc * src)
|
||||||
|
{
|
||||||
GstDTMFSrc *dtmfsrc = GST_DTMF_SRC (src);
|
GstDTMFSrc *dtmfsrc = GST_DTMF_SRC (src);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "Unlock stopped");
|
GST_DEBUG_OBJECT (dtmfsrc, "Unlock stopped");
|
||||||
|
@ -824,17 +818,14 @@ gst_dtmf_src_negotiate (GstBaseSrc * basesrc)
|
||||||
"width", G_TYPE_INT, 16,
|
"width", G_TYPE_INT, 16,
|
||||||
"depth", G_TYPE_INT, 16,
|
"depth", G_TYPE_INT, 16,
|
||||||
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
"signed", G_TYPE_BOOLEAN, TRUE, "channels", G_TYPE_INT, 1, NULL);
|
||||||
"channels", G_TYPE_INT, 1,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
|
peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
|
||||||
|
|
||||||
if (peercaps == NULL) {
|
if (peercaps == NULL) {
|
||||||
/* no peer caps, just add the other properties */
|
/* no peer caps, just add the other properties */
|
||||||
gst_caps_set_simple (srccaps,
|
gst_caps_set_simple (srccaps,
|
||||||
"rate", G_TYPE_INT, dtmfsrc->sample_rate,
|
"rate", G_TYPE_INT, dtmfsrc->sample_rate, NULL);
|
||||||
NULL);
|
|
||||||
} else {
|
} else {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
gint sample_rate;
|
gint sample_rate;
|
||||||
|
@ -864,17 +855,13 @@ gst_dtmf_src_negotiate (GstBaseSrc * basesrc)
|
||||||
/* get first structure */
|
/* get first structure */
|
||||||
s = gst_caps_get_structure (srccaps, 0);
|
s = gst_caps_get_structure (srccaps, 0);
|
||||||
|
|
||||||
if (gst_structure_get_int (s, "rate", &sample_rate))
|
if (gst_structure_get_int (s, "rate", &sample_rate)) {
|
||||||
{
|
|
||||||
dtmfsrc->sample_rate = sample_rate;
|
dtmfsrc->sample_rate = sample_rate;
|
||||||
GST_LOG_OBJECT (dtmfsrc, "using rate from caps %d",
|
GST_LOG_OBJECT (dtmfsrc, "using rate from caps %d", dtmfsrc->sample_rate);
|
||||||
dtmfsrc->sample_rate);
|
|
||||||
} else {
|
} else {
|
||||||
GST_LOG_OBJECT (dtmfsrc, "using existing rate %d",
|
GST_LOG_OBJECT (dtmfsrc, "using existing rate %d", dtmfsrc->sample_rate);
|
||||||
dtmfsrc->sample_rate);
|
|
||||||
}
|
}
|
||||||
gst_structure_set (s, "rate", G_TYPE_INT, dtmfsrc->sample_rate,
|
gst_structure_set (s, "rate", G_TYPE_INT, dtmfsrc->sample_rate, NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), srccaps);
|
ret = gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), srccaps);
|
||||||
|
@ -952,4 +939,3 @@ gst_dtmf_src_plugin_init (GstPlugin * plugin)
|
||||||
return gst_element_register (plugin, "dtmfsrc",
|
return gst_element_register (plugin, "dtmfsrc",
|
||||||
GST_RANK_NONE, GST_TYPE_DTMF_SRC);
|
GST_RANK_NONE, GST_TYPE_DTMF_SRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <gst/base/gstbasesrc.h>
|
#include <gst/base/gstbasesrc.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_DTMF_SRC (gst_dtmf_src_get_type())
|
#define GST_TYPE_DTMF_SRC (gst_dtmf_src_get_type())
|
||||||
#define GST_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DTMF_SRC,GstDTMFSrc))
|
#define GST_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DTMF_SRC,GstDTMFSrc))
|
||||||
#define GST_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DTMF_SRC,GstDTMFSrcClass))
|
#define GST_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DTMF_SRC,GstDTMFSrcClass))
|
||||||
|
@ -40,7 +39,6 @@ G_BEGIN_DECLS
|
||||||
#define GST_IS_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DTMF_SRC))
|
#define GST_IS_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DTMF_SRC))
|
||||||
#define GST_IS_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DTMF_SRC))
|
#define GST_IS_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DTMF_SRC))
|
||||||
#define GST_DTMF_SRC_CAST(obj) ((GstDTMFSrc *)(obj))
|
#define GST_DTMF_SRC_CAST(obj) ((GstDTMFSrc *)(obj))
|
||||||
|
|
||||||
typedef struct _GstDTMFSrc GstDTMFSrc;
|
typedef struct _GstDTMFSrc GstDTMFSrc;
|
||||||
typedef struct _GstDTMFSrcClass GstDTMFSrcClass;
|
typedef struct _GstDTMFSrcClass GstDTMFSrcClass;
|
||||||
|
|
||||||
|
@ -51,7 +49,8 @@ typedef struct _GstDTMFSrcClass GstDTMFSrcClass;
|
||||||
* The opaque #GstDTMFSrc data structure.
|
* The opaque #GstDTMFSrc data structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum _GstDTMFEventType {
|
enum _GstDTMFEventType
|
||||||
|
{
|
||||||
DTMF_EVENT_TYPE_START,
|
DTMF_EVENT_TYPE_START,
|
||||||
DTMF_EVENT_TYPE_STOP,
|
DTMF_EVENT_TYPE_STOP,
|
||||||
DTMF_EVENT_TYPE_PAUSE_TASK
|
DTMF_EVENT_TYPE_PAUSE_TASK
|
||||||
|
@ -59,7 +58,8 @@ enum _GstDTMFEventType {
|
||||||
|
|
||||||
typedef enum _GstDTMFEventType GstDTMFEventType;
|
typedef enum _GstDTMFEventType GstDTMFEventType;
|
||||||
|
|
||||||
struct _GstDTMFSrcEvent {
|
struct _GstDTMFSrcEvent
|
||||||
|
{
|
||||||
GstDTMFEventType event_type;
|
GstDTMFEventType event_type;
|
||||||
double sample;
|
double sample;
|
||||||
guint16 event_number;
|
guint16 event_number;
|
||||||
|
@ -69,7 +69,8 @@ struct _GstDTMFSrcEvent {
|
||||||
|
|
||||||
typedef struct _GstDTMFSrcEvent GstDTMFSrcEvent;
|
typedef struct _GstDTMFSrcEvent GstDTMFSrcEvent;
|
||||||
|
|
||||||
struct _GstDTMFSrc {
|
struct _GstDTMFSrc
|
||||||
|
{
|
||||||
GstBaseSrc parent;
|
GstBaseSrc parent;
|
||||||
GAsyncQueue *event_queue;
|
GAsyncQueue *event_queue;
|
||||||
GstDTMFSrcEvent *last_event;
|
GstDTMFSrcEvent *last_event;
|
||||||
|
@ -84,7 +85,8 @@ struct _GstDTMFSrc {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct _GstDTMFSrcClass {
|
struct _GstDTMFSrcClass
|
||||||
|
{
|
||||||
GstBaseSrcClass parent_class;
|
GstBaseSrcClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,5 +95,4 @@ GType gst_dtmf_src_get_type (void);
|
||||||
gboolean gst_dtmf_src_plugin_init (GstPlugin * plugin);
|
gboolean gst_dtmf_src_plugin_init (GstPlugin * plugin);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_DTMF_SRC_H__ */
|
#endif /* __GST_DTMF_SRC_H__ */
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#define __GST_RTP_DTMF_COMMON_H__
|
#define __GST_RTP_DTMF_COMMON_H__
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
unsigned event:8; /* Current DTMF event */
|
unsigned event:8; /* Current DTMF event */
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
unsigned volume:6; /* power level of the tone, in dBm0 */
|
unsigned volume:6; /* power level of the tone, in dBm0 */
|
||||||
|
|
|
@ -55,7 +55,8 @@
|
||||||
|
|
||||||
#define DEFAULT_MAX_DURATION 0
|
#define DEFAULT_MAX_DURATION 0
|
||||||
|
|
||||||
typedef struct st_dtmf_key {
|
typedef struct st_dtmf_key
|
||||||
|
{
|
||||||
char *event_name;
|
char *event_name;
|
||||||
int event_encoding;
|
int event_encoding;
|
||||||
float low_frequency;
|
float low_frequency;
|
||||||
|
@ -83,7 +84,8 @@ static const DTMF_KEY DTMF_KEYS[] = {
|
||||||
|
|
||||||
#define MAX_DTMF_EVENTS 16
|
#define MAX_DTMF_EVENTS 16
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
DTMF_KEY_EVENT_1 = 1,
|
DTMF_KEY_EVENT_1 = 1,
|
||||||
DTMF_KEY_EVENT_2 = 2,
|
DTMF_KEY_EVENT_2 = 2,
|
||||||
DTMF_KEY_EVENT_3 = 3,
|
DTMF_KEY_EVENT_3 = 3,
|
||||||
|
@ -141,8 +143,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"depth = (int) 16, "
|
"depth = (int) 16, "
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
||||||
"signed = (boolean) true, "
|
"signed = (boolean) true, "
|
||||||
"rate = (int) [0, MAX], "
|
"rate = (int) [0, MAX], " "channels = (int) 1")
|
||||||
"channels = (int) 1")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_dtmf_depay_sink_template =
|
static GstStaticPadTemplate gst_rtp_dtmf_depay_sink_template =
|
||||||
|
@ -204,8 +205,8 @@ gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass)
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_UNIT_TIME,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_UNIT_TIME,
|
||||||
g_param_spec_uint ("unit-time", "Duration unittime",
|
g_param_spec_uint ("unit-time", "Duration unittime",
|
||||||
"The smallest unit (ms) the duration must be a multiple of (0 disables it)", MIN_UNIT_TIME,
|
"The smallest unit (ms) the duration must be a multiple of (0 disables it)",
|
||||||
MAX_UNIT_TIME, DEFAULT_UNIT_TIME, G_PARAM_READWRITE));
|
MIN_UNIT_TIME, MAX_UNIT_TIME, DEFAULT_UNIT_TIME, G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_DURATION,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_DURATION,
|
||||||
g_param_spec_uint ("max-duration", "Maximum duration",
|
g_param_spec_uint ("max-duration", "Maximum duration",
|
||||||
|
@ -284,8 +285,7 @@ gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
|
||||||
"depth", G_TYPE_INT, 16,
|
"depth", G_TYPE_INT, 16,
|
||||||
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||||
"channels", G_TYPE_INT, 1,
|
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, clock_rate, NULL);
|
||||||
"rate", G_TYPE_INT, clock_rate, NULL);
|
|
||||||
gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
|
gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
|
||||||
gst_caps_unref (srccaps);
|
gst_caps_unref (srccaps);
|
||||||
|
|
||||||
|
@ -328,8 +328,10 @@ gst_dtmf_src_generate_tone(GstRtpDTMFDepay *rtpdtmfdepay,
|
||||||
/*
|
/*
|
||||||
* We add the fundamental frequencies together.
|
* We add the fundamental frequencies together.
|
||||||
*/
|
*/
|
||||||
f1 = sin(2 * M_PI * key.low_frequency * (rtpdtmfdepay->sample / clock_rate));
|
f1 = sin (2 * M_PI * key.low_frequency * (rtpdtmfdepay->sample /
|
||||||
f2 = sin(2 * M_PI * key.high_frequency * (rtpdtmfdepay->sample / clock_rate));
|
clock_rate));
|
||||||
|
f2 = sin (2 * M_PI * key.high_frequency * (rtpdtmfdepay->sample /
|
||||||
|
clock_rate));
|
||||||
|
|
||||||
amplitude = (f1 + f2) / 2;
|
amplitude = (f1 + f2) / 2;
|
||||||
|
|
||||||
|
@ -385,12 +387,10 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
dtmf_payload.duration = g_ntohs (dtmf_payload.duration);
|
dtmf_payload.duration = g_ntohs (dtmf_payload.duration);
|
||||||
|
|
||||||
/* clip to whole units of unit_time */
|
/* clip to whole units of unit_time */
|
||||||
if (rtpdtmfdepay->unit_time)
|
if (rtpdtmfdepay->unit_time) {
|
||||||
{
|
|
||||||
guint unit_time_clock =
|
guint unit_time_clock =
|
||||||
(rtpdtmfdepay->unit_time * depayload->clock_rate) / 1000;
|
(rtpdtmfdepay->unit_time * depayload->clock_rate) / 1000;
|
||||||
if (dtmf_payload.duration % unit_time_clock)
|
if (dtmf_payload.duration % unit_time_clock) {
|
||||||
{
|
|
||||||
/* Make sure we don't overflow the duration */
|
/* Make sure we don't overflow the duration */
|
||||||
if (dtmf_payload.duration < G_MAXUINT16 - unit_time_clock)
|
if (dtmf_payload.duration < G_MAXUINT16 - unit_time_clock)
|
||||||
dtmf_payload.duration += unit_time_clock -
|
dtmf_payload.duration += unit_time_clock -
|
||||||
|
@ -401,8 +401,7 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clip to max duration */
|
/* clip to max duration */
|
||||||
if (rtpdtmfdepay->max_duration)
|
if (rtpdtmfdepay->max_duration) {
|
||||||
{
|
|
||||||
guint max_duration_clock =
|
guint max_duration_clock =
|
||||||
(rtpdtmfdepay->max_duration * depayload->clock_rate) / 1000;
|
(rtpdtmfdepay->max_duration * depayload->clock_rate) / 1000;
|
||||||
|
|
||||||
|
@ -415,7 +414,8 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
"marker=%d - timestamp=%u - event=%d - duration=%d",
|
"marker=%d - timestamp=%u - event=%d - duration=%d",
|
||||||
marker, timestamp, dtmf_payload.event, dtmf_payload.duration);
|
marker, timestamp, dtmf_payload.event, dtmf_payload.duration);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (depayload, "Previous information : timestamp=%u - duration=%d",
|
GST_DEBUG_OBJECT (depayload,
|
||||||
|
"Previous information : timestamp=%u - duration=%d",
|
||||||
rtpdtmfdepay->previous_ts, rtpdtmfdepay->previous_duration);
|
rtpdtmfdepay->previous_ts, rtpdtmfdepay->previous_duration);
|
||||||
|
|
||||||
/* First packet */
|
/* First packet */
|
||||||
|
@ -428,14 +428,14 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
structure = gst_structure_new ("dtmf-event",
|
structure = gst_structure_new ("dtmf-event",
|
||||||
"number", G_TYPE_INT, dtmf_payload.event,
|
"number", G_TYPE_INT, dtmf_payload.event,
|
||||||
"volume", G_TYPE_INT, dtmf_payload.volume,
|
"volume", G_TYPE_INT, dtmf_payload.volume,
|
||||||
"type", G_TYPE_INT, 1,
|
"type", G_TYPE_INT, 1, "method", G_TYPE_INT, 1, NULL);
|
||||||
"method", G_TYPE_INT, 1,
|
|
||||||
NULL);
|
|
||||||
if (structure) {
|
if (structure) {
|
||||||
dtmf_message = gst_message_new_element (GST_OBJECT (depayload), structure);
|
dtmf_message =
|
||||||
|
gst_message_new_element (GST_OBJECT (depayload), structure);
|
||||||
if (dtmf_message) {
|
if (dtmf_message) {
|
||||||
if (!gst_element_post_message (GST_ELEMENT (depayload), dtmf_message)) {
|
if (!gst_element_post_message (GST_ELEMENT (depayload), dtmf_message)) {
|
||||||
GST_ERROR_OBJECT (depayload, "Unable to send dtmf-event message to bus");
|
GST_ERROR_OBJECT (depayload,
|
||||||
|
"Unable to send dtmf-event message to bus");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_ERROR_OBJECT (depayload, "Unable to create dtmf-event message");
|
GST_ERROR_OBJECT (depayload, "Unable to create dtmf-event message");
|
||||||
|
@ -492,4 +492,3 @@ gst_rtp_dtmf_depay_plugin_init (GstPlugin * plugin)
|
||||||
return gst_element_register (plugin, "rtpdtmfdepay",
|
return gst_element_register (plugin, "rtpdtmfdepay",
|
||||||
GST_RANK_MARGINAL, GST_TYPE_RTP_DTMF_DEPAY);
|
GST_RANK_MARGINAL, GST_TYPE_RTP_DTMF_DEPAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "gstrtpdtmfcommon.h"
|
#include "gstrtpdtmfcommon.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_RTP_DTMF_DEPAY \
|
#define GST_TYPE_RTP_DTMF_DEPAY \
|
||||||
(gst_rtp_dtmf_depay_get_type())
|
(gst_rtp_dtmf_depay_get_type())
|
||||||
#define GST_RTP_DTMF_DEPAY(obj) \
|
#define GST_RTP_DTMF_DEPAY(obj) \
|
||||||
|
@ -41,8 +40,6 @@ G_BEGIN_DECLS
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DTMF_DEPAY))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DTMF_DEPAY))
|
||||||
#define GST_IS_RTP_DTMF_DEPAY_CLASS(klass) \
|
#define GST_IS_RTP_DTMF_DEPAY_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DTMF_DEPAY))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DTMF_DEPAY))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GstRtpDTMFDepay GstRtpDTMFDepay;
|
typedef struct _GstRtpDTMFDepay GstRtpDTMFDepay;
|
||||||
typedef struct _GstRtpDTMFDepayClass GstRtpDTMFDepayClass;
|
typedef struct _GstRtpDTMFDepayClass GstRtpDTMFDepayClass;
|
||||||
|
|
||||||
|
@ -65,5 +62,4 @@ struct _GstRtpDTMFDepayClass
|
||||||
gboolean gst_rtp_dtmf_depay_plugin_init (GstPlugin * plugin);
|
gboolean gst_rtp_dtmf_depay_plugin_init (GstPlugin * plugin);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_RTP_DTMF_DEPAY_H__ */
|
#endif /* __GST_RTP_DTMF_DEPAY_H__ */
|
||||||
|
|
|
@ -198,7 +198,6 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"ssrc = (int) [ 0, MAX ], "
|
"ssrc = (int) [ 0, MAX ], "
|
||||||
"encoding-name = (string) \"TELEPHONE-EVENT\"")
|
"encoding-name = (string) \"TELEPHONE-EVENT\"")
|
||||||
/* "events = (string) \"0-15\" */
|
/* "events = (string) \"0-15\" */
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,17 +304,13 @@ gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass)
|
||||||
gstelement_class->change_state =
|
gstelement_class->change_state =
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_change_state);
|
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_change_state);
|
||||||
|
|
||||||
gstbasesrc_class->unlock =
|
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_unlock);
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_unlock);
|
|
||||||
gstbasesrc_class->unlock_stop =
|
gstbasesrc_class->unlock_stop =
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_unlock_stop);
|
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_unlock_stop);
|
||||||
|
|
||||||
gstbasesrc_class->event =
|
gstbasesrc_class->event = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_handle_event);
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_handle_event);
|
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_create);
|
||||||
gstbasesrc_class->create =
|
gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_negotiate);
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_create);
|
|
||||||
gstbasesrc_class->negotiate =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_negotiate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -563,9 +558,8 @@ gst_rtp_dtmf_prepare_timestamps (GstRTPDTMFSrc *dtmfsrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
dtmfsrc->rtp_timestamp = dtmfsrc->ts_base +
|
dtmfsrc->rtp_timestamp = dtmfsrc->ts_base +
|
||||||
gst_util_uint64_scale_int (
|
gst_util_uint64_scale_int (gst_segment_to_running_time (&GST_BASE_SRC
|
||||||
gst_segment_to_running_time (&GST_BASE_SRC (dtmfsrc)->segment,
|
(dtmfsrc)->segment, GST_FORMAT_TIME, dtmfsrc->timestamp),
|
||||||
GST_FORMAT_TIME, dtmfsrc->timestamp),
|
|
||||||
dtmfsrc->clock_rate, GST_SECOND);
|
dtmfsrc->clock_rate, GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,8 +904,7 @@ gst_rtp_dtmf_src_negotiate (GstBaseSrc * basesrc)
|
||||||
} else {
|
} else {
|
||||||
if (gst_structure_has_field (s, "payload")) {
|
if (gst_structure_has_field (s, "payload")) {
|
||||||
/* can only fixate if there is a field */
|
/* can only fixate if there is a field */
|
||||||
gst_structure_fixate_field_nearest_int (s, "payload",
|
gst_structure_fixate_field_nearest_int (s, "payload", dtmfsrc->pt);
|
||||||
dtmfsrc->pt);
|
|
||||||
gst_structure_get_int (s, "payload", &pt);
|
gst_structure_get_int (s, "payload", &pt);
|
||||||
GST_LOG_OBJECT (dtmfsrc, "using peer pt %d", pt);
|
GST_LOG_OBJECT (dtmfsrc, "using peer pt %d", pt);
|
||||||
} else {
|
} else {
|
||||||
|
@ -922,8 +915,7 @@ gst_rtp_dtmf_src_negotiate (GstBaseSrc * basesrc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_structure_get_int (s, "clock-rate", &clock_rate))
|
if (gst_structure_get_int (s, "clock-rate", &clock_rate)) {
|
||||||
{
|
|
||||||
dtmfsrc->clock_rate = clock_rate;
|
dtmfsrc->clock_rate = clock_rate;
|
||||||
GST_LOG_OBJECT (dtmfsrc, "using clock-rate from caps %d",
|
GST_LOG_OBJECT (dtmfsrc, "using clock-rate from caps %d",
|
||||||
dtmfsrc->clock_rate);
|
dtmfsrc->clock_rate);
|
||||||
|
@ -931,8 +923,7 @@ gst_rtp_dtmf_src_negotiate (GstBaseSrc * basesrc)
|
||||||
GST_LOG_OBJECT (dtmfsrc, "using existing clock-rate %d",
|
GST_LOG_OBJECT (dtmfsrc, "using existing clock-rate %d",
|
||||||
dtmfsrc->clock_rate);
|
dtmfsrc->clock_rate);
|
||||||
}
|
}
|
||||||
gst_structure_set (s, "clock-rate", G_TYPE_INT, dtmfsrc->clock_rate,
|
gst_structure_set (s, "clock-rate", G_TYPE_INT, dtmfsrc->clock_rate, NULL);
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
|
||||||
if (gst_structure_has_field_typed (s, "ssrc", G_TYPE_UINT)) {
|
if (gst_structure_has_field_typed (s, "ssrc", G_TYPE_UINT)) {
|
||||||
|
@ -1063,7 +1054,8 @@ failure:
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_dtmf_src_unlock (GstBaseSrc *src) {
|
gst_rtp_dtmf_src_unlock (GstBaseSrc * src)
|
||||||
|
{
|
||||||
GstRTPDTMFSrc *dtmfsrc = GST_RTP_DTMF_SRC (src);
|
GstRTPDTMFSrc *dtmfsrc = GST_RTP_DTMF_SRC (src);
|
||||||
GstRTPDTMFSrcEvent *event = NULL;
|
GstRTPDTMFSrcEvent *event = NULL;
|
||||||
|
|
||||||
|
@ -1086,7 +1078,8 @@ gst_rtp_dtmf_src_unlock (GstBaseSrc *src) {
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_dtmf_src_unlock_stop (GstBaseSrc *src) {
|
gst_rtp_dtmf_src_unlock_stop (GstBaseSrc * src)
|
||||||
|
{
|
||||||
GstRTPDTMFSrc *dtmfsrc = GST_RTP_DTMF_SRC (src);
|
GstRTPDTMFSrc *dtmfsrc = GST_RTP_DTMF_SRC (src);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "Unlock stopped");
|
GST_DEBUG_OBJECT (dtmfsrc, "Unlock stopped");
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "gstrtpdtmfcommon.h"
|
#include "gstrtpdtmfcommon.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_RTP_DTMF_SRC (gst_rtp_dtmf_src_get_type())
|
#define GST_TYPE_RTP_DTMF_SRC (gst_rtp_dtmf_src_get_type())
|
||||||
#define GST_RTP_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrc))
|
#define GST_RTP_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrc))
|
||||||
#define GST_RTP_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrcClass))
|
#define GST_RTP_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrcClass))
|
||||||
|
@ -40,14 +39,13 @@ G_BEGIN_DECLS
|
||||||
#define GST_IS_RTP_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DTMF_SRC))
|
#define GST_IS_RTP_DTMF_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DTMF_SRC))
|
||||||
#define GST_IS_RTP_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DTMF_SRC))
|
#define GST_IS_RTP_DTMF_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DTMF_SRC))
|
||||||
#define GST_RTP_DTMF_SRC_CAST(obj) ((GstRTPDTMFSrc *)(obj))
|
#define GST_RTP_DTMF_SRC_CAST(obj) ((GstRTPDTMFSrc *)(obj))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GstRTPDTMFSrc GstRTPDTMFSrc;
|
typedef struct _GstRTPDTMFSrc GstRTPDTMFSrc;
|
||||||
typedef struct _GstRTPDTMFSrcClass GstRTPDTMFSrcClass;
|
typedef struct _GstRTPDTMFSrcClass GstRTPDTMFSrcClass;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum _GstRTPDTMFEventType {
|
enum _GstRTPDTMFEventType
|
||||||
|
{
|
||||||
RTP_DTMF_EVENT_TYPE_START,
|
RTP_DTMF_EVENT_TYPE_START,
|
||||||
RTP_DTMF_EVENT_TYPE_STOP,
|
RTP_DTMF_EVENT_TYPE_STOP,
|
||||||
RTP_DTMF_EVENT_TYPE_PAUSE_TASK
|
RTP_DTMF_EVENT_TYPE_PAUSE_TASK
|
||||||
|
@ -55,7 +53,8 @@ enum _GstRTPDTMFEventType {
|
||||||
|
|
||||||
typedef enum _GstRTPDTMFEventType GstRTPDTMFEventType;
|
typedef enum _GstRTPDTMFEventType GstRTPDTMFEventType;
|
||||||
|
|
||||||
struct _GstRTPDTMFSrcEvent {
|
struct _GstRTPDTMFSrcEvent
|
||||||
|
{
|
||||||
GstRTPDTMFEventType event_type;
|
GstRTPDTMFEventType event_type;
|
||||||
GstRTPDTMFPayload *payload;
|
GstRTPDTMFPayload *payload;
|
||||||
};
|
};
|
||||||
|
@ -68,7 +67,8 @@ typedef struct _GstRTPDTMFSrcEvent GstRTPDTMFSrcEvent;
|
||||||
*
|
*
|
||||||
* The opaque #GstRTPDTMFSrc data structure.
|
* The opaque #GstRTPDTMFSrc data structure.
|
||||||
*/
|
*/
|
||||||
struct _GstRTPDTMFSrc {
|
struct _GstRTPDTMFSrc
|
||||||
|
{
|
||||||
GstBaseSrc basesrc;
|
GstBaseSrc basesrc;
|
||||||
|
|
||||||
GAsyncQueue *event_queue;
|
GAsyncQueue *event_queue;
|
||||||
|
@ -97,7 +97,8 @@ struct _GstRTPDTMFSrc {
|
||||||
guint16 redundancy_count;
|
guint16 redundancy_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstRTPDTMFSrcClass {
|
struct _GstRTPDTMFSrcClass
|
||||||
|
{
|
||||||
GstBaseSrcClass parent_class;
|
GstBaseSrcClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,5 +108,4 @@ gboolean gst_rtp_dtmf_src_plugin_init (GstPlugin * plugin);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_RTP_DTMF_SRC_H__ */
|
#endif /* __GST_RTP_DTMF_SRC_H__ */
|
||||||
|
|
Loading…
Reference in a new issue