gst/rtpmanager/gstrtpbin.*: Add signal to notify listeners when a sender becomes...
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / rtpjitterbuffer.h
1 /* GStreamer
2  * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __RTP_JITTER_BUFFER_H__
21 #define __RTP_JITTER_BUFFER_H__
22
23 #include <gst/gst.h>
24 #include <gst/rtp/gstrtcpbuffer.h>
25
26 typedef struct _RTPJitterBuffer RTPJitterBuffer;
27 typedef struct _RTPJitterBufferClass RTPJitterBufferClass;
28
29 #define RTP_TYPE_JITTER_BUFFER             (rtp_jitter_buffer_get_type())
30 #define RTP_JITTER_BUFFER(src)             (G_TYPE_CHECK_INSTANCE_CAST((src),RTP_TYPE_JITTER_BUFFER,RTPJitterBuffer))
31 #define RTP_JITTER_BUFFER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),RTP_TYPE_JITTER_BUFFER,RTPJitterBufferClass))
32 #define RTP_IS_JITTER_BUFFER(src)          (G_TYPE_CHECK_INSTANCE_TYPE((src),RTP_TYPE_JITTER_BUFFER))
33 #define RTP_IS_JITTER_BUFFER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),RTP_TYPE_JITTER_BUFFER))
34 #define RTP_JITTER_BUFFER_CAST(src)        ((RTPJitterBuffer *)(src))
35
36 /**
37  * RTPTailChanged:
38  * @jbuf: an #RTPJitterBuffer
39  * @user_data: user data specified when registering
40  *
41  * This callback will be called when the tail buffer of @jbuf changed.
42  */
43 typedef void (*RTPTailChanged) (RTPJitterBuffer *jbuf, gpointer user_data);
44
45 #define RTP_JITTER_BUFFER_MAX_WINDOW 512
46 /**
47  * RTPJitterBuffer:
48  *
49  * A JitterBuffer in the #RTPSession
50  */
51 struct _RTPJitterBuffer {
52   GObject        object;
53
54   GQueue        *packets;
55
56   /* for calculating skew */
57   GstClockTime   base_time;
58   GstClockTime   base_rtptime;
59   GstClockTime   base_extrtp;
60   guint64        ext_rtptime;
61   gint64         window[RTP_JITTER_BUFFER_MAX_WINDOW];
62   guint          window_pos;
63   guint          window_size;
64   gboolean       window_filling;
65   gint64         window_min;
66   gint64         skew;
67   gint64         prev_send_diff;
68 };
69
70 struct _RTPJitterBufferClass {
71   GObjectClass   parent_class;
72 };
73
74 GType rtp_jitter_buffer_get_type (void);
75
76 /* managing lifetime */
77 RTPJitterBuffer*      rtp_jitter_buffer_new              (void);
78
79 void                  rtp_jitter_buffer_reset_skew       (RTPJitterBuffer *jbuf);
80
81 gboolean              rtp_jitter_buffer_insert           (RTPJitterBuffer *jbuf, GstBuffer *buf,
82                                                           GstClockTime time,
83                                                           guint32 clock_rate,
84                                                           gboolean *tail);
85 GstBuffer *           rtp_jitter_buffer_peek             (RTPJitterBuffer *jbuf);
86 GstBuffer *           rtp_jitter_buffer_pop              (RTPJitterBuffer *jbuf);
87
88 void                  rtp_jitter_buffer_flush            (RTPJitterBuffer *jbuf);
89
90 guint                 rtp_jitter_buffer_num_packets      (RTPJitterBuffer *jbuf);
91 guint32               rtp_jitter_buffer_get_ts_diff      (RTPJitterBuffer *jbuf);
92
93 void                  rtp_jitter_buffer_get_sync         (RTPJitterBuffer *jbuf, guint64 *rtptime,
94                                                           guint64 *timestamp);
95
96
97 #endif /* __RTP_JITTER_BUFFER_H__ */