48bc29c307db9bd2d1793f210c1e9d48e1accbc1
[platform/upstream/gstreamer.git] / gst-libs / gst / rtp / gstrtpbasepayload.h
1 /* GStreamer
2  * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
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_PAYLOAD_H__
21 #define __GST_RTP_BASE_PAYLOAD_H__
22
23 #include <gst/gst.h>
24
25 G_BEGIN_DECLS
26
27 #define GST_TYPE_RTP_BASE_PAYLOAD \
28         (gst_rtp_base_payload_get_type())
29 #define GST_RTP_BASE_PAYLOAD(obj) \
30         (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_BASE_PAYLOAD,GstRTPBasePayload))
31 #define GST_RTP_BASE_PAYLOAD_CLASS(klass) \
32         (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_BASE_PAYLOAD,GstRTPBasePayloadClass))
33 #define GST_RTP_BASE_PAYLOAD_GET_CLASS(obj) \
34         (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_BASE_PAYLOAD, GstRTPBasePayloadClass))
35 #define GST_IS_RTP_BASE_PAYLOAD(obj) \
36         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_BASE_PAYLOAD))
37 #define GST_IS_RTP_BASE_PAYLOAD_CLASS(klass) \
38         (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_BASE_PAYLOAD))
39 #define GST_RTP_BASE_PAYLOAD_CAST(obj) \
40         ((GstRTPBasePayload*)(obj))
41
42 typedef struct _GstRTPBasePayload GstRTPBasePayload;
43 typedef struct _GstRTPBasePayloadPrivate GstRTPBasePayloadPrivate;
44 typedef struct _GstRTPBasePayloadClass GstRTPBasePayloadClass;
45
46 /**
47  * GST_RTP_BASE_PAYLOAD_SINKPAD:
48  * @payload: a #GstRTPBasePayload
49  *
50  * Get access to the sinkpad of @payload.
51  */
52 #define GST_RTP_BASE_PAYLOAD_SINKPAD(payload) (GST_RTP_BASE_PAYLOAD (payload)->sinkpad)
53 /**
54  * GST_RTP_BASE_PAYLOAD_SRCPAD:
55  * @payload: a #GstRTPBasePayload
56  *
57  * Get access to the srcpad of @payload.
58  */
59 #define GST_RTP_BASE_PAYLOAD_SRCPAD(payload)  (GST_RTP_BASE_PAYLOAD (payload)->srcpad)
60
61 /**
62  * GST_RTP_BASE_PAYLOAD_PT:
63  * @payload: a #GstRTPBasePayload
64  *
65  * Get access to the configured payload type of @payload.
66  */
67 #define GST_RTP_BASE_PAYLOAD_PT(payload)  (GST_RTP_BASE_PAYLOAD (payload)->pt)
68 /**
69  * GST_RTP_BASE_PAYLOAD_MTU:
70  * @payload: a #GstRTPBasePayload
71  *
72  * Get access to the configured MTU of @payload.
73  */
74 #define GST_RTP_BASE_PAYLOAD_MTU(payload) (GST_RTP_BASE_PAYLOAD (payload)->mtu)
75
76 struct _GstRTPBasePayload
77 {
78   GstElement element;
79
80   /*< private >*/
81   GstPad  *sinkpad;
82   GstPad  *srcpad;
83
84   guint32  ts_base;
85   guint16  seqnum_base;
86
87   gchar   *media;
88   gchar   *encoding_name;
89   gboolean dynamic;
90   guint32  clock_rate;
91
92   gint32   ts_offset;
93   guint32  timestamp;
94   gint16   seqnum_offset;
95   guint16  seqnum;
96   gint64   max_ptime;
97   guint    pt;
98   guint    ssrc;
99   guint    current_ssrc;
100   guint    mtu;
101
102   GstSegment segment;
103
104   guint64  min_ptime;
105   guint64  ptime; /* in ns */
106   guint64  ptime_multiple; /* in ns */
107
108   /*< private >*/
109   GstRTPBasePayloadPrivate *priv;
110
111   gpointer _gst_reserved[GST_PADDING];
112 };
113
114 /**
115  * GstRTPBasePayloadClass:
116  * @parent_class: the parent class
117  * @get_caps: get desired caps
118  * @set_caps: configure the payloader
119  * @handle_buffer: process data
120  * @sink_event: custom event handling on the sinkpad
121  * @src_event: custom event handling on the srcpad
122  * @query: custom query handling
123  *
124  * Base class for audio RTP payloader.
125  */
126 struct _GstRTPBasePayloadClass
127 {
128   GstElementClass parent_class;
129
130   /* query accepted caps */
131   GstCaps *     (*get_caps)             (GstRTPBasePayload *payload, GstPad * pad, GstCaps * filter);
132   /* receive caps on the sink pad, configure the payloader. */
133   gboolean      (*set_caps)             (GstRTPBasePayload *payload, GstCaps *caps);
134
135   /* handle a buffer, perform 0 or more gst_rtp_base_payload_push() on
136    * the RTP buffers. This function takes ownership of the buffer. */
137   GstFlowReturn (*handle_buffer)        (GstRTPBasePayload *payload,
138                                          GstBuffer *buffer);
139   /* handle events and queries */
140   gboolean      (*sink_event)           (GstRTPBasePayload *payload, GstEvent * event);
141   gboolean      (*src_event)            (GstRTPBasePayload *payload, GstEvent * event);
142   gboolean      (*query)                (GstRTPBasePayload *payload, GstPad *pad, GstQuery * query);
143
144   /*< private >*/
145   gpointer _gst_reserved[GST_PADDING];
146 };
147
148 GST_EXPORT
149 GType           gst_rtp_base_payload_get_type           (void);
150
151 GST_EXPORT
152 void            gst_rtp_base_payload_set_options        (GstRTPBasePayload *payload,
153                                                          const gchar *media,
154                                                          gboolean dynamic,
155                                                          const gchar *encoding_name,
156                                                          guint32 clock_rate);
157
158 GST_EXPORT
159 gboolean        gst_rtp_base_payload_set_outcaps        (GstRTPBasePayload *payload,
160                                                          const gchar *fieldname, ...);
161
162 GST_EXPORT
163 gboolean        gst_rtp_base_payload_is_filled          (GstRTPBasePayload *payload,
164                                                          guint size, GstClockTime duration);
165
166 GST_EXPORT
167 GstFlowReturn   gst_rtp_base_payload_push               (GstRTPBasePayload *payload,
168                                                          GstBuffer *buffer);
169
170 GST_EXPORT
171 GstFlowReturn   gst_rtp_base_payload_push_list          (GstRTPBasePayload *payload,
172                                                          GstBufferList *list);
173
174 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
175 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBasePayload, gst_object_unref)
176 #endif
177
178 G_END_DECLS
179
180 #endif /* __GST_RTP_BASE_PAYLOAD_H__ */