diff options
-rw-r--r-- | gst/dtmf/gstdtmfsrc.c | 31 | ||||
-rw-r--r-- | gst/dtmf/gstrtpdtmfsrc.c | 53 |
2 files changed, 49 insertions, 35 deletions
diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c index 713325a8..5cfaa53f 100644 --- a/gst/dtmf/gstdtmfsrc.c +++ b/gst/dtmf/gstdtmfsrc.c @@ -269,13 +269,13 @@ static void gst_dtmf_src_get_property (GObject * object, guint prop_id, static gboolean gst_dtmf_src_handle_event (GstPad * pad, GstEvent * event); static GstStateChangeReturn gst_dtmf_src_change_state (GstElement * element, GstStateChange transition); -static void gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration, - GstBuffer * buffer); +static void gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, + float duration, GstBuffer * buffer); static void gst_dtmf_src_push_next_tone_packet (GstDTMFSrc *dtmfsrc); static void gst_dtmf_src_start (GstDTMFSrc *dtmfsrc); static void gst_dtmf_src_stop (GstDTMFSrc *dtmfsrc); -static void gst_dtmf_src_add_start_event (GstDTMFSrc *dtmfsrc, gint event_number, - gint event_volume); +static void gst_dtmf_src_add_start_event (GstDTMFSrc *dtmfsrc, + gint event_number, gint event_volume); static void gst_dtmf_src_add_stop_event (GstDTMFSrc *dtmfsrc); static void @@ -615,7 +615,8 @@ gst_dtmf_src_generate_silence(GstBuffer * buffer, float duration) } static void -gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration, GstBuffer * buffer) +gst_dtmf_src_generate_tone(GstDTMFSrcEvent *event, DTMF_KEY key, float duration, + GstBuffer * buffer) { gint16 *p; gint tone_size; @@ -686,12 +687,14 @@ gst_dtmf_src_wait_for_buffer_ts (GstDTMFSrc *dtmfsrc, GstBuffer * buf) static GstBuffer * -gst_dtmf_src_create_next_tone_packet (GstDTMFSrc *dtmfsrc, GstDTMFSrcEvent *event) +gst_dtmf_src_create_next_tone_packet (GstDTMFSrc *dtmfsrc, + GstDTMFSrcEvent *event) { GstBuffer *buf = NULL; gboolean send_silence = FALSE; - GST_DEBUG_OBJECT (dtmfsrc, "Creating buffer for tone %s", DTMF_KEYS[event->event_number].event_name); + GST_DEBUG_OBJECT (dtmfsrc, "Creating buffer for tone %s", + DTMF_KEYS[event->event_number].event_name); /* create buffer to hold the tone */ buf = gst_buffer_new (); @@ -738,7 +741,8 @@ gst_dtmf_src_push_next_tone_packet (GstDTMFSrc *dtmfsrc) event = g_async_queue_pop (dtmfsrc->event_queue); if (event->event_type == DTMF_EVENT_TYPE_STOP) { - GST_WARNING_OBJECT (dtmfsrc, "Received a DTMF stop event when already stopped"); + GST_WARNING_OBJECT (dtmfsrc, + "Received a DTMF stop event when already stopped"); } else if (event->event_type == DTMF_EVENT_TYPE_START) { gst_dtmf_prepare_timestamps (dtmfsrc); @@ -748,12 +752,14 @@ gst_dtmf_src_push_next_tone_packet (GstDTMFSrc *dtmfsrc) event->packet_count = 0; dtmfsrc->last_event = event; } - } else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >= MIN_DUTY_CYCLE) { + } else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >= + MIN_DUTY_CYCLE) { event = g_async_queue_try_pop (dtmfsrc->event_queue); if (event != NULL) { if (event->event_type == DTMF_EVENT_TYPE_START) { - GST_WARNING_OBJECT (dtmfsrc, "Received two consecutive DTMF start events"); + GST_WARNING_OBJECT (dtmfsrc, + "Received two consecutive DTMF start events"); } else if (event->event_type == DTMF_EVENT_TYPE_STOP) { gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE); g_free (dtmfsrc->last_event); @@ -794,8 +800,9 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_PAUSED: gst_segment_init (&dtmfsrc->segment, GST_FORMAT_TIME); gst_pad_push_event (dtmfsrc->srcpad, gst_event_new_new_segment (FALSE, - dtmfsrc->segment.rate, dtmfsrc->segment.format, - dtmfsrc->segment.start, dtmfsrc->segment.stop, dtmfsrc->segment.time)); + dtmfsrc->segment.rate, dtmfsrc->segment.format, + dtmfsrc->segment.start, dtmfsrc->segment.stop, + dtmfsrc->segment.time)); /* Indicate that we don't do PRE_ROLL */ no_preroll = TRUE; break; diff --git a/gst/dtmf/gstrtpdtmfsrc.c b/gst/dtmf/gstrtpdtmfsrc.c index 26c8d0aa..138c498f 100644 --- a/gst/dtmf/gstrtpdtmfsrc.c +++ b/gst/dtmf/gstrtpdtmfsrc.c @@ -90,8 +90,8 @@ * <entry>method</entry> * <entry>G_TYPE_INT</entry> * <entry>1</entry> - * <entry>The method used for sending event, this element will react if this field - * is absent or 1. + * <entry>The method used for sending event, this element will react if this + * field is absent or 1. * </entry> * </row> * </tbody> @@ -576,7 +576,7 @@ gst_rtp_dtmf_prepare_timestamps (GstRTPDTMFSrc *dtmfsrc) clock = GST_ELEMENT_CLOCK (dtmfsrc); if (clock != NULL) dtmfsrc->timestamp = gst_clock_get_time (GST_ELEMENT_CLOCK (dtmfsrc)) - + (MIN_INTER_DIGIT_INTERVAL * GST_MSECOND); + + (MIN_INTER_DIGIT_INTERVAL * GST_MSECOND); else { GST_ERROR_OBJECT (dtmfsrc, "No clock set for element %s", @@ -685,7 +685,8 @@ gst_rtp_dtmf_src_wait_for_buffer_ts (GstRTPDTMFSrc *dtmfsrc, GstBuffer * buf) } static void -gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc *dtmfsrc, GstRTPDTMFSrcEvent *event, GstBuffer *buf) +gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc *dtmfsrc, + GstRTPDTMFSrcEvent *event, GstBuffer *buf) { gst_rtp_buffer_set_ssrc (buf, dtmfsrc->current_ssrc); gst_rtp_buffer_set_payload_type (buf, dtmfsrc->pt); @@ -705,7 +706,8 @@ gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc *dtmfsrc, GstRTPDTMFSrcEvent *ev } static void -gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, GstRTPDTMFSrcEvent *event,GstBuffer *buf) +gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, + GstRTPDTMFSrcEvent *event,GstBuffer *buf) { GstRTPDTMFPayload *payload; @@ -735,7 +737,8 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, GstRTPDTMFSrcEvent *ev } static GstBuffer * -gst_rtp_dtmf_src_create_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc, GstRTPDTMFSrcEvent *event) +gst_rtp_dtmf_src_create_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc, + GstRTPDTMFSrcEvent *event) { GstBuffer *buf = NULL; @@ -769,7 +772,8 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc) event = g_async_queue_pop (dtmfsrc->event_queue); if (event->event_type == RTP_DTMF_EVENT_TYPE_STOP) { - GST_WARNING_OBJECT (dtmfsrc, "Received a DTMF stop event when already stopped"); + GST_WARNING_OBJECT (dtmfsrc, + "Received a DTMF stop event when already stopped"); } else if (event->event_type == RTP_DTMF_EVENT_TYPE_START) { dtmfsrc->first_packet = TRUE; @@ -783,15 +787,17 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc) dtmfsrc->last_event = event; } - } else if (dtmfsrc->last_event->sent_packets * dtmfsrc->interval >= MIN_PULSE_DURATION){ + } else if (dtmfsrc->last_event->sent_packets * dtmfsrc->interval >= + MIN_PULSE_DURATION){ event = g_async_queue_try_pop (dtmfsrc->event_queue); if (event != NULL) { if (event->event_type == RTP_DTMF_EVENT_TYPE_START) { - GST_WARNING_OBJECT (dtmfsrc, "Received two consecutive DTMF start events"); + GST_WARNING_OBJECT (dtmfsrc, + "Received two consecutive DTMF start events"); } else if (event->event_type == RTP_DTMF_EVENT_TYPE_STOP) { - dtmfsrc->first_packet = FALSE; - dtmfsrc->last_packet = TRUE; + dtmfsrc->first_packet = FALSE; + dtmfsrc->last_packet = TRUE; } } } @@ -803,30 +809,31 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc) redundancy_count = dtmfsrc->packet_redundancy; if(dtmfsrc->first_packet == TRUE) { - GST_DEBUG_OBJECT (dtmfsrc, - "redundancy count set to %d due to dtmf start", - redundancy_count); + GST_DEBUG_OBJECT (dtmfsrc, + "redundancy count set to %d due to dtmf start", + redundancy_count); } else if(dtmfsrc->last_packet == TRUE) { - GST_DEBUG_OBJECT (dtmfsrc, - "redundancy count set to %d due to dtmf stop", - redundancy_count); + GST_DEBUG_OBJECT (dtmfsrc, + "redundancy count set to %d due to dtmf stop", + redundancy_count); } } /* create buffer to hold the payload */ - buf = gst_rtp_dtmf_src_create_next_rtp_packet (dtmfsrc, dtmfsrc->last_event); + buf = gst_rtp_dtmf_src_create_next_rtp_packet (dtmfsrc, + dtmfsrc->last_event); while ( redundancy_count-- ) { gst_buffer_ref(buf); GST_DEBUG_OBJECT (dtmfsrc, - "pushing buffer on src pad of size %d with redundancy count %d", - GST_BUFFER_SIZE (buf), redundancy_count); + "pushing buffer on src pad of size %d with redundancy count %d", + GST_BUFFER_SIZE (buf), redundancy_count); ret = gst_pad_push (dtmfsrc->srcpad, buf); if (ret != GST_FLOW_OK) - GST_ERROR_OBJECT (dtmfsrc, - "Failed to push buffer on src pad"); + GST_ERROR_OBJECT (dtmfsrc, + "Failed to push buffer on src pad"); /* Make sure only the first packet sent has the marker set */ gst_rtp_buffer_set_marker (buf, FALSE); @@ -834,7 +841,7 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc) gst_buffer_unref(buf); GST_DEBUG_OBJECT (dtmfsrc, - "pushed DTMF event '%d' on src pad", event->payload->event); + "pushed DTMF event '%d' on src pad", event->payload->event); if (dtmfsrc->last_event->payload->e) { /* Don't forget to release the stream lock */ |