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