expand tabs
[platform/upstream/gstreamer.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,GstBaseRTPPayload))
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(obj) \
38         (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_PAYLOAD))
39
40 typedef struct _GstBaseRTPPayload GstBaseRTPPayload;
41 typedef struct _GstBaseRTPPayloadClass GstBaseRTPPayloadClass;
42
43 #define GST_BASE_RTP_PAYLOAD_SINKPAD(payload) (GST_BASE_RTP_PAYLOAD (payload)->sinkpad)
44 #define GST_BASE_RTP_PAYLOAD_SRCPAD(payload)  (GST_BASE_RTP_PAYLOAD (payload)->srcpad)
45
46 #define GST_BASE_RTP_PAYLOAD_PT(payload)  (GST_BASE_RTP_PAYLOAD (payload)->pt)
47 #define GST_BASE_RTP_PAYLOAD_MTU(payload) (GST_BASE_RTP_PAYLOAD (payload)->mtu)
48
49 struct _GstBaseRTPPayload
50 {
51   GstElement element;
52
53   /*< private >*/
54   GstPad  *sinkpad;
55   GstPad  *srcpad;
56
57   GRand   *seq_rand;
58   GRand   *ssrc_rand;
59   GRand   *ts_rand;
60
61   guint32  ts_base;
62   guint16  seqnum_base;
63
64   gchar   *media;
65   gchar   *encoding_name;
66   gboolean dynamic;
67   guint32  clock_rate;
68
69   gint32   ts_offset;
70   guint32  timestamp;
71   gint16   seqnum_offset;
72   guint16  seqnum;
73   gint64   max_ptime;
74   guint    pt;
75   guint    ssrc;
76   guint    current_ssrc;
77   guint    mtu;
78
79   GstSegment segment;
80
81   /*< private >*/
82   gpointer _gst_reserved[GST_PADDING];
83 };
84
85 struct _GstBaseRTPPayloadClass
86 {
87   GstElementClass parent_class;
88
89   /* receive caps on the sink pad, configure the payloader. */
90   gboolean      (*set_caps)             (GstBaseRTPPayload *payload, GstCaps *caps);
91   /* handle a buffer, perform 0 or more gst_basertppayload_push() on
92    * the RTP buffers */
93   GstFlowReturn (*handle_buffer)        (GstBaseRTPPayload *payload, 
94                                          GstBuffer *buffer);
95
96   /*< private >*/
97   gpointer _gst_reserved[GST_PADDING];
98 };
99
100 GType           gst_basertppayload_get_type             (void);
101
102 void            gst_basertppayload_set_options          (GstBaseRTPPayload *payload, 
103                                                          gchar *media, gboolean dynamic,
104                                                          gchar *encoding_name,
105                                                          guint32 clock_rate);
106
107 gboolean        gst_basertppayload_set_outcaps          (GstBaseRTPPayload *payload, 
108                                                          gchar *fieldname, ...);
109
110 gboolean        gst_basertppayload_is_filled            (GstBaseRTPPayload *payload,
111                                                          guint size, GstClockTime duration);
112
113 GstFlowReturn   gst_basertppayload_push                 (GstBaseRTPPayload *payload, 
114                                                          GstBuffer *buffer);
115
116 G_END_DECLS
117
118 #endif /* __GST_BASE_RTP_PAYLOAD_H__ */