2 * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
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 __GST_BASE_RTP_DEPAYLOAD_H__
21 #define __GST_BASE_RTP_DEPAYLOAD_H__
24 #include <gst/rtp/gstrtpbuffer.h>
28 #define GST_TYPE_BASE_RTP_DEPAYLOAD (gst_base_rtp_depayload_get_type())
29 #define GST_BASE_RTP_DEPAYLOAD(obj) \
30 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayload))
31 #define GST_BASE_RTP_DEPAYLOAD_CLASS(klass) \
32 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass))
33 #define GST_BASE_RTP_DEPAYLOAD_GET_CLASS(obj) \
34 (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass))
35 #define GST_IS_BASE_RTP_DEPAYLOAD(obj) \
36 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_DEPAYLOAD))
37 #define GST_IS_BASE_RTP_DEPAYLOAD_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_DEPAYLOAD))
40 #define GST_BASE_RTP_DEPAYLOAD_SINKPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->sinkpad)
41 #define GST_BASE_RTP_DEPAYLOAD_SRCPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->srcpad)
43 #ifndef GST_DISABLE_DEPRECATED
44 /* this was presumably never meant to be public API, or should at least
45 * have been prefixed if it was. Don't use. (FIXME: remove in 0.11) */
46 #define QUEUE_LOCK_INIT(base) (g_static_rec_mutex_init(&base->queuelock))
47 #define QUEUE_LOCK_FREE(base) (g_static_rec_mutex_free(&base->queuelock))
48 #define QUEUE_LOCK(base) (g_static_rec_mutex_lock(&base->queuelock))
49 #define QUEUE_UNLOCK(base) (g_static_rec_mutex_unlock(&base->queuelock))
52 typedef struct _GstBaseRTPDepayload GstBaseRTPDepayload;
53 typedef struct _GstBaseRTPDepayloadClass GstBaseRTPDepayloadClass;
54 typedef struct _GstBaseRTPDepayloadPrivate GstBaseRTPDepayloadPrivate;
56 struct _GstBaseRTPDepayload
60 GstPad *sinkpad, *srcpad;
62 #ifndef GST_REMOVE_DEPRECATED
63 /* lock to protect the queue, deprecated */
64 GStaticRecMutex queuelock;
67 gboolean thread_running;
68 /* the releaser thread, deprecated */
72 /* this attribute must be set by the child */
75 #ifndef GST_REMOVE_DEPRECATED
76 /* this value can be modified by the child if needed, deprecated */
80 /* we will queue up to RTP_QUEUEDELAY ms of packets,
81 * reordering them if necessary
82 * dropping any packets that are more than
83 * RTP_QUEUEDELAY ms late, deprecated */
87 gboolean need_newsegment;
90 GstBaseRTPDepayloadPrivate *priv;
92 gpointer _gst_reserved[GST_PADDING-1];
95 struct _GstBaseRTPDepayloadClass
97 GstElementClass parent_class;
99 /* virtuals, inform the subclass of the caps. */
100 gboolean (*set_caps) (GstBaseRTPDepayload *filter, GstCaps *caps);
102 /* non-pure function, default implementation in base class
103 * this does buffering, reordering and dropping, deprecated */
104 GstFlowReturn (*add_to_queue) (GstBaseRTPDepayload *filter, GstBuffer *in);
106 /* pure virtual function, child must use this to process incoming
107 * rtp packets. If the child returns a buffer without a valid timestamp,
108 * the timestamp of @in will be applied to the result buffer and the
109 * buffer will be pushed. If this function returns %NULL, nothing is
111 GstBuffer * (*process) (GstBaseRTPDepayload *base, GstBuffer *in);
113 /* non-pure function used to convert from RTP timestamp to GST timestamp
114 * this function is used by the child class before gst_pad_pushing */
115 void (*set_gst_timestamp) (GstBaseRTPDepayload *filter, guint32 timestamp, GstBuffer *buf);
117 /* non-pure function used to to signal the depayloader about packet loss. the
118 * timestamp and duration are the estimated values of the lost packet.
119 * The default implementation of this message pushes a segment update. */
120 gboolean (*packet_lost) (GstBaseRTPDepayload *filter, GstEvent *event);
122 /* the default implementation does the default actions for events but
123 * implementation can override.
125 gboolean (*handle_event) (GstBaseRTPDepayload * filter, GstEvent * event);
128 gpointer _gst_reserved[GST_PADDING-2];
131 GType gst_base_rtp_depayload_get_type (void);
133 GstFlowReturn gst_base_rtp_depayload_push (GstBaseRTPDepayload *filter, GstBuffer *out_buf);
134 GstFlowReturn gst_base_rtp_depayload_push_ts (GstBaseRTPDepayload *filter,
135 guint32 timestamp, GstBuffer *out_buf);
136 GstFlowReturn gst_base_rtp_depayload_push_list (GstBaseRTPDepayload *filter, GstBufferList *out_list);
141 #endif /* __GST_BASE_RTP_DEPAYLOAD_H__ */