f5656ace9ade75b0307ea9aaf471e8259688942f
[platform/upstream/gstreamer.git] / gst-libs / gst / rtp / gstrtpbasedepayload.h
1 /* GStreamer
2  * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __GST_RTP_BASE_DEPAYLOAD_H__
21 #define __GST_RTP_BASE_DEPAYLOAD_H__
22
23 #include <gst/gst.h>
24 #include <gst/rtp/gstrtpbuffer.h>
25
26 G_BEGIN_DECLS
27
28 #define GST_TYPE_RTP_BASE_DEPAYLOAD (gst_rtp_base_depayload_get_type())
29 #define GST_RTP_BASE_DEPAYLOAD(obj) \
30   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayload))
31 #define GST_RTP_BASE_DEPAYLOAD_CLASS(klass) \
32   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayloadClass))
33 #define GST_RTP_BASE_DEPAYLOAD_GET_CLASS(obj) \
34         (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayloadClass))
35 #define GST_IS_RTP_BASE_DEPAYLOAD(obj) \
36   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_BASE_DEPAYLOAD))
37 #define GST_IS_RTP_BASE_DEPAYLOAD_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_BASE_DEPAYLOAD))
39 #define GST_RTP_BASE_DEPAYLOAD_CAST(obj) ((GstRTPBaseDepayload *)(obj))
40
41 #define GST_RTP_BASE_DEPAYLOAD_SINKPAD(depayload) (GST_RTP_BASE_DEPAYLOAD_CAST (depayload)->sinkpad)
42 #define GST_RTP_BASE_DEPAYLOAD_SRCPAD(depayload)  (GST_RTP_BASE_DEPAYLOAD_CAST (depayload)->srcpad)
43
44 typedef struct _GstRTPBaseDepayload      GstRTPBaseDepayload;
45 typedef struct _GstRTPBaseDepayloadClass GstRTPBaseDepayloadClass;
46 typedef struct _GstRTPBaseDepayloadPrivate GstRTPBaseDepayloadPrivate;
47
48 struct _GstRTPBaseDepayload
49 {
50   GstElement parent;
51
52   GstPad *sinkpad, *srcpad;
53
54   /* this attribute must be set by the child */
55   guint clock_rate;
56
57   GstSegment segment;
58   gboolean need_newsegment;
59
60   /*< private >*/
61   GstRTPBaseDepayloadPrivate *priv;
62
63   gpointer _gst_reserved[GST_PADDING];
64 };
65
66 /**
67  * GstRTPBaseDepayloadClass:
68  * @parent_class: the parent class
69  * @set_caps: configure the depayloader
70  * @process: process incoming rtp packets
71  * @packet_lost: signal the depayloader about packet loss
72  * @handle_event: custom event handling
73  *
74  * Base class for RTP depayloaders.
75  */
76 struct _GstRTPBaseDepayloadClass
77 {
78   GstElementClass parent_class;
79
80   /* virtuals, inform the subclass of the caps. */
81   gboolean (*set_caps) (GstRTPBaseDepayload *filter, GstCaps *caps);
82
83   /* pure virtual function, child must implement either this method
84    * or the process_rtp_packet virtual method to process incoming
85    * rtp packets. If the child returns a buffer without a valid timestamp,
86    * the timestamp of @in will be applied to the result buffer and the
87    * buffer will be pushed. If this function returns %NULL, nothing is
88    * pushed.  */
89   GstBuffer * (*process) (GstRTPBaseDepayload *base, GstBuffer *in);
90
91   /* non-pure function used to to signal the depayloader about packet loss. the
92    * timestamp and duration are the estimated values of the lost packet.
93    * The default implementation of this message pushes a segment update. */
94   gboolean (*packet_lost) (GstRTPBaseDepayload *filter, GstEvent *event);
95
96   /* the default implementation does the default actions for events but
97    * implementation can override. */
98   gboolean (*handle_event) (GstRTPBaseDepayload * filter, GstEvent * event);
99
100   /* Optional. Same as the process virtual function, but slightly more
101    * efficient, since it is passed the rtp buffer structure that has already
102    * been mapped (with GST_MAP_READ) by the base class and thus does not have
103    * to be mapped again by the subclass. Can be used by the subclass to process
104    * incoming rtp packets. If the subclass returns a buffer without a valid
105    * timestamp, the timestamp of the input buffer will be applied to the result
106    * buffer and the output buffer will be pushed out. If this function returns
107    * %NULL, nothing is pushed out.
108    *
109    * Since: 1.6
110    */
111   GstBuffer * (*process_rtp_packet) (GstRTPBaseDepayload *base, GstRTPBuffer * rtp_buffer);
112
113   /*< private >*/
114   gpointer _gst_reserved[GST_PADDING - 1];
115 };
116
117 GST_EXPORT
118 GType gst_rtp_base_depayload_get_type (void);
119
120 GST_EXPORT
121 GstFlowReturn   gst_rtp_base_depayload_push       (GstRTPBaseDepayload *filter, GstBuffer *out_buf);
122
123 GST_EXPORT
124 GstFlowReturn   gst_rtp_base_depayload_push_list  (GstRTPBaseDepayload *filter, GstBufferList *out_list);
125
126
127 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
128 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBaseDepayload, gst_object_unref)
129 #endif
130
131 G_END_DECLS
132
133 #endif /* __GST_RTP_BASE_DEPAYLOAD_H__ */