2bbfb9db889ac9a5d37944d324c4439a868eeb11
[platform/upstream/gstreamer.git] / gst / dtmf / gstrtpdtmfsrc.h
1 /* GStreamer RTP DTMF source
2  *
3  * gstrtpdtmfsrc.h:
4  *
5  * Copyright (C) <2007> Nokia Corporation.
6  *   Contact: Zeeshan Ali <zeeshan.ali@nokia.com>
7  * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #ifndef __GST_RTP_DTMF_SRC_H__
26 #define __GST_RTP_DTMF_SRC_H__
27
28 #include <gst/gst.h>
29 #include <gst/rtp/gstrtpbuffer.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_RTP_DTMF_SRC           (gst_rtp_dtmf_src_get_type())
34 #define GST_RTP_DTMF_SRC(obj)           (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrc))
35 #define GST_RTP_DTMF_SRC_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_DTMF_SRC,GstRTPDTMFSrcClass))
36 #define GST_RTP_DTMF_SRC_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_DTMF_SRC, GstRTPDTMFSrcClass))
37 #define GST_IS_RTP_DTMF_SRC(obj)                (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_DTMF_SRC))
38 #define GST_IS_RTP_DTMF_SRC_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_DTMF_SRC))
39 #define GST_RTP_DTMF_SRC_CAST(obj)              ((GstRTPDTMFSrc *)(obj))
40
41 typedef struct {
42   unsigned  event:8;         /* Current DTMF event */
43 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
44   unsigned  volume:6;        /* power level of the tone, in dBm0 */
45   unsigned  r:1;             /* Reserved-bit */
46   unsigned  e:1;             /* End-bit */
47 #elif G_BYTE_ORDER == G_BIG_ENDIAN
48   unsigned  e:1;             /* End-bit */
49   unsigned  r:1;             /* Reserved-bit */
50   unsigned  volume:6;        /* power level of the tone, in dBm0 */
51 #else
52 #error "G_BYTE_ORDER should be big or little endian."
53 #endif
54   unsigned  duration:16;     /* Duration of digit, in timestamp units */
55 } GstRTPDTMFPayload;
56
57 typedef struct _GstRTPDTMFSrc GstRTPDTMFSrc;
58 typedef struct _GstRTPDTMFSrcClass GstRTPDTMFSrcClass;
59
60
61
62 static enum _GstRTPDTMFEventType {
63   RTP_DTMF_EVENT_TYPE_START,
64   RTP_DTMF_EVENT_TYPE_STOP
65 };
66
67 typedef enum _GstRTPDTMFEventType GstRTPDTMFEventType;
68
69 struct _GstRTPDTMFSrcEvent {
70   GstRTPDTMFEventType  event_type;
71   GstRTPDTMFPayload*   payload;
72   guint32              sent_packets;
73 };
74
75 typedef struct _GstRTPDTMFSrcEvent GstRTPDTMFSrcEvent;
76
77 /**
78  * GstRTPDTMFSrc:
79  * @element: the parent element.
80  *
81  * The opaque #GstRTPDTMFSrc data structure.
82  */
83 struct _GstRTPDTMFSrc {
84   GstElement           element;
85
86   GstPad*              srcpad;
87   GstSegment           segment;
88   GAsyncQueue*         event_queue;
89   GstRTPDTMFSrcEvent*  last_event;
90
91   GstClockTime      timestamp;
92   gboolean          first_packet;
93   gboolean          last_packet;
94   guint32           ts_base;
95   guint16           seqnum_base;
96   gint16            seqnum_offset;
97   guint16           seqnum;
98   gint32            ts_offset;
99   guint32           rtp_timestamp;
100   guint             pt;
101   guint             ssrc;
102   guint             current_ssrc;
103   guint16           interval;
104   guint16           packet_redundancy;
105   guint32           clock_rate;
106 };
107
108 struct _GstRTPDTMFSrcClass {
109   GstElementClass parent_class;
110 };
111
112 GType gst_rtp_dtmf_src_get_type (void);
113
114 gboolean gst_rtp_dtmf_src_plugin_init (GstPlugin * plugin);
115
116
117 G_END_DECLS
118
119 #endif /* __GST_RTP_DTMF_SRC_H__ */