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. Subclass must implement either 71 * this method or @process_rtp_packet to process incoming rtp packets. 72 * If the child returns a buffer without a valid timestamp, the timestamp 73 * of the provided buffer will be applied to the result buffer and the 74 * buffer will be pushed. If this function returns %NULL, nothing is pushed. 75 * @packet_lost: signal the depayloader about packet loss 76 * @handle_event: custom event handling 77 * @process_rtp_packet: Same as the process virtual function, but slightly more 78 * efficient, since it is passed the rtp buffer structure that has already 79 * been mapped (with GST_MAP_READ) by the base class and thus does not have 80 * to be mapped again by the subclass. Can be used by the subclass to process 81 * incoming rtp packets. If the subclass returns a buffer without a valid 82 * timestamp, the timestamp of the input buffer will be applied to the result 83 * buffer and the output buffer will be pushed out. If this function returns 84 * %NULL, nothing is pushed out. Since: 1.6. 85 * 86 * Base class for RTP depayloaders. 87 */ 88 struct _GstRTPBaseDepayloadClass 89 { 90 GstElementClass parent_class; 91 92 /*< public >*/ 93 /* virtuals, inform the subclass of the caps. */ 94 gboolean (*set_caps) (GstRTPBaseDepayload *filter, GstCaps *caps); 95 96 /* pure virtual function */ 97 GstBuffer * (*process) (GstRTPBaseDepayload *base, GstBuffer *in); 98 99 /* non-pure function used to to signal the depayloader about packet loss. the 100 * timestamp and duration are the estimated values of the lost packet. 101 * The default implementation of this message pushes a segment update. */ 102 gboolean (*packet_lost) (GstRTPBaseDepayload *filter, GstEvent *event); 103 104 /* the default implementation does the default actions for events but 105 * implementation can override. */ 106 gboolean (*handle_event) (GstRTPBaseDepayload * filter, GstEvent * event); 107 108 GstBuffer * (*process_rtp_packet) (GstRTPBaseDepayload *base, GstRTPBuffer * rtp_buffer); 109 110 /*< private >*/ 111 gpointer _gst_reserved[GST_PADDING - 1]; 112 }; 113 114 GST_RTP_API 115 GType gst_rtp_base_depayload_get_type (void); 116 117 GST_RTP_API 118 GstFlowReturn gst_rtp_base_depayload_push (GstRTPBaseDepayload *filter, GstBuffer *out_buf); 119 120 GST_RTP_API 121 GstFlowReturn gst_rtp_base_depayload_push_list (GstRTPBaseDepayload *filter, GstBufferList *out_list); 122 123 GST_RTP_API 124 gboolean gst_rtp_base_depayload_is_source_info_enabled (GstRTPBaseDepayload * depayload); 125 126 GST_RTP_API 127 void gst_rtp_base_depayload_set_source_info_enabled (GstRTPBaseDepayload * depayload, 128 gboolean enable); 129 130 131 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBaseDepayload, gst_object_unref) 132 133 G_END_DECLS 134 135 #endif /* __GST_RTP_BASE_DEPAYLOAD_H__ */ 136