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];
96 * GstBaseRTPDepayloadClass:
97 * @parent_class: the parent class
98 * @set_caps: configure the depayloader
99 * @add_to_queue: (deprecated)
100 * @process: process incoming rtp packets
101 * @set_gst_timestamp: convert from RTP timestamp to GST timestamp
102 * @packet_lost: signal the depayloader about packet loss
103 * @handle_event: custom event handling
105 * Base class for audio RTP payloader.
107 struct _GstBaseRTPDepayloadClass
109 GstElementClass parent_class;
111 /* virtuals, inform the subclass of the caps. */
112 gboolean (*set_caps) (GstBaseRTPDepayload *filter, GstCaps *caps);
114 /* non-pure function, default implementation in base class
115 * this does buffering, reordering and dropping, deprecated */
116 GstFlowReturn (*add_to_queue) (GstBaseRTPDepayload *filter, GstBuffer *in);
118 /* pure virtual function, child must use this to process incoming
119 * rtp packets. If the child returns a buffer without a valid timestamp,
120 * the timestamp of @in will be applied to the result buffer and the
121 * buffer will be pushed. If this function returns %NULL, nothing is
123 GstBuffer * (*process) (GstBaseRTPDepayload *base, GstBuffer *in);
125 /* non-pure function used to convert from RTP timestamp to GST timestamp
126 * this function is used by the child class before gst_pad_pushing */
127 void (*set_gst_timestamp) (GstBaseRTPDepayload *filter, guint32 timestamp, GstBuffer *buf);
129 /* non-pure function used to to signal the depayloader about packet loss. the
130 * timestamp and duration are the estimated values of the lost packet.
131 * The default implementation of this message pushes a segment update. */
132 gboolean (*packet_lost) (GstBaseRTPDepayload *filter, GstEvent *event);
134 /* the default implementation does the default actions for events but
135 * implementation can override.
137 gboolean (*handle_event) (GstBaseRTPDepayload * filter, GstEvent * event);
140 gpointer _gst_reserved[GST_PADDING-2];
143 GType gst_base_rtp_depayload_get_type (void);
145 GstFlowReturn gst_base_rtp_depayload_push (GstBaseRTPDepayload *filter, GstBuffer *out_buf);
146 GstFlowReturn gst_base_rtp_depayload_push_ts (GstBaseRTPDepayload *filter,
147 guint32 timestamp, GstBuffer *out_buf);
148 GstFlowReturn gst_base_rtp_depayload_push_list (GstBaseRTPDepayload *filter, GstBufferList *out_list);
153 #endif /* __GST_BASE_RTP_DEPAYLOAD_H__ */