tizen 2.3 release
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / rtp / gstbasertppayload.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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_BASE_RTP_PAYLOAD_H__
21 #define __GST_BASE_RTP_PAYLOAD_H__
22
23 #include <gst/gst.h>
24
25 G_BEGIN_DECLS
26
27 #define GST_TYPE_BASE_RTP_PAYLOAD \
28         (gst_basertppayload_get_type())
29 #define GST_BASE_RTP_PAYLOAD(obj) \
30         (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_PAYLOAD,GstBaseRTPPayload))
31 #define GST_BASE_RTP_PAYLOAD_CLASS(klass) \
32         (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_PAYLOAD,GstBaseRTPPayloadClass))
33 #define GST_BASE_RTP_PAYLOAD_GET_CLASS(obj) \
34         (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_RTP_PAYLOAD, GstBaseRTPPayloadClass))
35 #define GST_IS_BASE_RTP_PAYLOAD(obj) \
36         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_PAYLOAD))
37 #define GST_IS_BASE_RTP_PAYLOAD_CLASS(klass) \
38         (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_PAYLOAD))
39 #define GST_BASE_RTP_PAYLOAD_CAST(obj) \
40         ((GstBaseRTPPayload*)(obj))
41
42 typedef struct _GstBaseRTPPayload GstBaseRTPPayload;
43 typedef struct _GstBaseRTPPayloadPrivate GstBaseRTPPayloadPrivate;
44 typedef struct _GstBaseRTPPayloadClass GstBaseRTPPayloadClass;
45
46 /**
47  * GST_BASE_RTP_PAYLOAD_SINKPAD:
48  * @payload: a #GstBaseRTPPayload
49  *
50  * Get access to the sinkpad of @payload.
51  */
52 #define GST_BASE_RTP_PAYLOAD_SINKPAD(payload) (GST_BASE_RTP_PAYLOAD (payload)->sinkpad)
53 /**
54  * GST_BASE_RTP_PAYLOAD_SRCPAD:
55  * @payload: a #GstBaseRTPPayload
56  *
57  * Get access to the srcpad of @payload.
58  */
59 #define GST_BASE_RTP_PAYLOAD_SRCPAD(payload)  (GST_BASE_RTP_PAYLOAD (payload)->srcpad)
60
61 /**
62  * GST_BASE_RTP_PAYLOAD_PT:
63  * @payload: a #GstBaseRTPPayload
64  *
65  * Get access to the configured payload type of @payload.
66  */
67 #define GST_BASE_RTP_PAYLOAD_PT(payload)  (GST_BASE_RTP_PAYLOAD (payload)->pt)
68 /**
69  * GST_BASE_RTP_PAYLOAD_MTU:
70  * @payload: a #GstBaseRTPPayload
71  *
72  * Get access to the configured MTU of @payload.
73  */
74 #define GST_BASE_RTP_PAYLOAD_MTU(payload) (GST_BASE_RTP_PAYLOAD (payload)->mtu)
75
76 struct _GstBaseRTPPayload
77 {
78   GstElement element;
79
80   /*< private >*/
81   GstPad  *sinkpad;
82   GstPad  *srcpad;
83
84   /* FIXME 0.11: none of these GRands are used anymore, remove them */
85   GRand   *seq_rand;
86   GRand   *ssrc_rand;
87   GRand   *ts_rand;
88
89   guint32  ts_base;
90   guint16  seqnum_base;
91
92   gchar   *media;
93   gchar   *encoding_name;
94   gboolean dynamic;
95   guint32  clock_rate;
96
97   gint32   ts_offset;
98   guint32  timestamp;
99   gint16   seqnum_offset;
100   guint16  seqnum;
101   gint64   max_ptime;
102   guint    pt;
103   guint    ssrc;
104   guint    current_ssrc;
105   guint    mtu;
106
107   GstSegment segment;
108
109   guint64  min_ptime;
110
111   /*< private >*/
112   GstBaseRTPPayloadPrivate *priv;
113
114   union  {
115     struct {
116       guint64 ptime; /* in ns */
117       guint64 ptime_multiple; /* in ns */
118     } ABI;
119     gpointer _gst_reserved[GST_PADDING - (sizeof(guint64)/sizeof(gpointer)) - 1];
120   } abidata;
121 };
122
123 /**
124  * GstBaseRTPPayloadClass:
125  * @parent_class: the parent class
126  * @set_caps: configure the payloader
127  * @handle_buffer: process data
128  * @handle_event: custom event handling
129  * @get_caps: get desired caps
130  *
131  * Base class for audio RTP payloader.
132  */
133 struct _GstBaseRTPPayloadClass
134 {
135   GstElementClass parent_class;
136
137   /* receive caps on the sink pad, configure the payloader. */
138   gboolean      (*set_caps)             (GstBaseRTPPayload *payload, GstCaps *caps);
139   /* handle a buffer, perform 0 or more gst_basertppayload_push() on
140    * the RTP buffers. This function takes ownership of the buffer. */
141   GstFlowReturn (*handle_buffer)        (GstBaseRTPPayload *payload,
142                                          GstBuffer *buffer);
143   gboolean      (*handle_event)         (GstPad * pad, GstEvent * event);
144   GstCaps *     (*get_caps)             (GstBaseRTPPayload *payload, GstPad * pad);
145
146   /*< private >*/
147   gpointer _gst_reserved[GST_PADDING-2];
148 };
149
150 GType           gst_basertppayload_get_type             (void);
151
152 void            gst_basertppayload_set_options          (GstBaseRTPPayload *payload,
153                                                          const gchar *media,
154                                                          gboolean dynamic,
155                                                          const gchar *encoding_name,
156                                                          guint32 clock_rate);
157
158 gboolean        gst_basertppayload_set_outcaps          (GstBaseRTPPayload *payload,
159                                                          const gchar *fieldname, ...);
160
161 gboolean        gst_basertppayload_is_filled            (GstBaseRTPPayload *payload,
162                                                          guint size, GstClockTime duration);
163
164 GstFlowReturn   gst_basertppayload_push                 (GstBaseRTPPayload *payload,
165                                                          GstBuffer *buffer);
166
167 GstFlowReturn   gst_basertppayload_push_list            (GstBaseRTPPayload *payload,
168                                                          GstBufferList *list);
169
170 G_END_DECLS
171
172 #endif /* __GST_BASE_RTP_PAYLOAD_H__ */