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>
26 typedef struct _RTPJitterBuffer RTPJitterBuffer;
27 typedef struct _RTPJitterBufferClass RTPJitterBufferClass;
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))
38 * @jbuf: an #RTPJitterBuffer
39 * @user_data: user data specified when registering
41 * This callback will be called when the tail buffer of @jbuf changed.
43 typedef void (*RTPTailChanged) (RTPJitterBuffer *jbuf, gpointer user_data);
45 #define RTP_JITTER_BUFFER_MAX_WINDOW 512
49 * A JitterBuffer in the #RTPSession
51 struct _RTPJitterBuffer {
56 /* for calculating skew */
57 GstClockTime base_time;
58 GstClockTime base_rtptime;
59 GstClockTime base_extrtp;
61 gint64 window[RTP_JITTER_BUFFER_MAX_WINDOW];
64 gboolean window_filling;
67 gint64 prev_send_diff;
70 struct _RTPJitterBufferClass {
71 GObjectClass parent_class;
74 GType rtp_jitter_buffer_get_type (void);
76 /* managing lifetime */
77 RTPJitterBuffer* rtp_jitter_buffer_new (void);
79 void rtp_jitter_buffer_reset_skew (RTPJitterBuffer *jbuf);
81 gboolean rtp_jitter_buffer_insert (RTPJitterBuffer *jbuf, GstBuffer *buf,
85 GstBuffer * rtp_jitter_buffer_peek (RTPJitterBuffer *jbuf);
86 GstBuffer * rtp_jitter_buffer_pop (RTPJitterBuffer *jbuf);
88 void rtp_jitter_buffer_flush (RTPJitterBuffer *jbuf);
90 guint rtp_jitter_buffer_num_packets (RTPJitterBuffer *jbuf);
91 guint32 rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer *jbuf);
93 void rtp_jitter_buffer_get_sync (RTPJitterBuffer *jbuf, guint64 *rtptime,
97 #endif /* __RTP_JITTER_BUFFER_H__ */