2 * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
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.
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.
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.
20 #ifndef __RTP_JITTER_BUFFER_H__
21 #define __RTP_JITTER_BUFFER_H__
24 #include <gst/rtp/gstrtcpbuffer.h>
25 #include <gst/netbuffer/gstnetbuffer.h>
27 typedef struct _RTPJitterBuffer RTPJitterBuffer;
28 typedef struct _RTPJitterBufferClass RTPJitterBufferClass;
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))
39 * @jbuf: an #RTPJitterBuffer
40 * @user_data: user data specified when registering
42 * This callback will be called when the tail buffer of @jbuf changed.
44 typedef void (*RTPTailChanged) (RTPJitterBuffer *jbuf, gpointer user_data);
46 #define RTP_JITTER_BUFFER_MAX_WINDOW 512
50 * A JitterBuffer in the #RTPSession
52 struct _RTPJitterBuffer {
59 /* for calculating skew */
60 GstClockTime base_time;
61 GstClockTime base_rtptime;
63 gint64 window[RTP_JITTER_BUFFER_MAX_WINDOW];
66 gboolean window_filling;
69 gint64 prev_send_diff;
72 struct _RTPJitterBufferClass {
73 GObjectClass parent_class;
76 GType rtp_jitter_buffer_get_type (void);
78 /* managing lifetime */
79 RTPJitterBuffer* rtp_jitter_buffer_new (void);
81 void rtp_jitter_buffer_set_clock_rate (RTPJitterBuffer *jbuf, gint clock_rate);
82 gint rtp_jitter_buffer_get_clock_rate (RTPJitterBuffer *jbuf);
84 void rtp_jitter_buffer_reset_skew (RTPJitterBuffer *jbuf);
86 gboolean rtp_jitter_buffer_insert (RTPJitterBuffer *jbuf, GstBuffer *buf,
87 GstClockTime time, gboolean *tail);
88 GstBuffer * rtp_jitter_buffer_peek (RTPJitterBuffer *jbuf);
89 GstBuffer * rtp_jitter_buffer_pop (RTPJitterBuffer *jbuf);
91 void rtp_jitter_buffer_flush (RTPJitterBuffer *jbuf);
93 guint rtp_jitter_buffer_num_packets (RTPJitterBuffer *jbuf);
94 guint32 rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer *jbuf);
96 #endif /* __RTP_JITTER_BUFFER_H__ */