gst/rtpmanager/gstrtpjitterbuffer.c: Remove jitter correction code, it's now in the...
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / rtpjitterbuffer.h
1 /* GStreamer
2  * Copyright (C) <2007> Wim Taymans <wim@fluendo.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 #include <gst/netbuffer/gstnetbuffer.h>
26
27 typedef struct _RTPJitterBuffer RTPJitterBuffer;
28 typedef struct _RTPJitterBufferClass RTPJitterBufferClass;
29
30 #define RTP_TYPE_JITTER_BUFFER             (rtp_jitter_buffer_get_type())
31 #define RTP_JITTER_BUFFER(src)             (G_TYPE_CHECK_INSTANCE_CAST((src),RTP_TYPE_JITTER_BUFFER,RTPJitterBuffer))
32 #define RTP_JITTER_BUFFER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),RTP_TYPE_JITTER_BUFFER,RTPJitterBufferClass))
33 #define RTP_IS_JITTER_BUFFER(src)          (G_TYPE_CHECK_INSTANCE_TYPE((src),RTP_TYPE_JITTER_BUFFER))
34 #define RTP_IS_JITTER_BUFFER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),RTP_TYPE_JITTER_BUFFER))
35 #define RTP_JITTER_BUFFER_CAST(src)        ((RTPJitterBuffer *)(src))
36
37 /**
38  * RTPTailChanged:
39  * @jbuf: an #RTPJitterBuffer
40  * @user_data: user data specified when registering
41  *
42  * This callback will be called when the tail buffer of @jbuf changed.
43  */
44 typedef void (*RTPTailChanged) (RTPJitterBuffer *jbuf, gpointer user_data);
45
46 #define RTP_JITTER_BUFFER_MAX_WINDOW 512
47 /**
48  * RTPJitterBuffer:
49  *
50  * A JitterBuffer in the #RTPSession
51  */
52 struct _RTPJitterBuffer {
53   GObject        object;
54
55   GQueue        *packets;
56
57   gint           clock_rate;
58
59   /* for calculating skew */
60   GstClockTime   base_time;
61   GstClockTime   base_rtptime;
62   guint64        ext_rtptime;
63   gint64         window[RTP_JITTER_BUFFER_MAX_WINDOW];
64   guint          window_pos;
65   guint          window_size;
66   gboolean       window_filling;
67   gint64         window_min;
68   gint64         skew;
69
70   RTPTailChanged tail_changed;
71   gpointer       user_data;
72 };
73
74 struct _RTPJitterBufferClass {
75   GObjectClass   parent_class;
76 };
77
78 GType rtp_jitter_buffer_get_type (void);
79
80 /* managing lifetime */
81 RTPJitterBuffer*      rtp_jitter_buffer_new              (void);
82
83 void                  rtp_jitter_buffer_set_tail_changed (RTPJitterBuffer *jbuf, RTPTailChanged func, 
84                                                           gpointer user_data);
85
86 void                  rtp_jitter_buffer_set_clock_rate   (RTPJitterBuffer *jbuf, gint clock_rate);
87 gint                  rtp_jitter_buffer_get_clock_rate   (RTPJitterBuffer *jbuf);
88
89 gboolean              rtp_jitter_buffer_insert           (RTPJitterBuffer *jbuf, GstBuffer *buf, GstClockTime time);
90 GstBuffer *           rtp_jitter_buffer_pop              (RTPJitterBuffer *jbuf);
91
92 void                  rtp_jitter_buffer_flush            (RTPJitterBuffer *jbuf);
93
94 guint                 rtp_jitter_buffer_num_packets      (RTPJitterBuffer *jbuf);
95 guint32               rtp_jitter_buffer_get_ts_diff      (RTPJitterBuffer *jbuf);
96
97 #endif /* __RTP_JITTER_BUFFER_H__ */