*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <string.h>
#include "gstrtpmp2tdepay.h"
+#include "gstrtputils.h"
/* RtpMP2TDepay signals and args */
enum
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"video\", "
- "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
- "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP2T-ES\";"
+ "clock-rate = (int) [1, MAX ], "
+ "encoding-name = (string) { MP2T, MP2T-ES } ;"
/* All optional parameters
*
* "profile-level-id=[1,MAX]"
"clock-rate = (int) [1, MAX ]")
);
-GST_BOILERPLATE (GstRtpMP2TDepay, gst_rtp_mp2t_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpMP2TDepay, gst_rtp_mp2t_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
-static gboolean gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp2t_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload,
- GstBuffer * buf);
+static GstBuffer *gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload,
+ GstRTPBuffer * rtp);
static void gst_rtp_mp2t_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
GValue * value, GParamSpec * pspec);
static void
-gst_rtp_mp2t_depay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp2t_depay_src_template);
- gst_element_class_add_static_pad_template (element_class,
- &gst_rtp_mp2t_depay_sink_template);
-
- gst_element_class_set_details_simple (element_class,
- "RTP MPEG Transport Stream depayloader", "Codec/Depayloader/Network/RTP",
- "Extracts MPEG2 TS from RTP packets (RFC 2250)",
- "Wim Taymans <wim.taymans@gmail.com>, "
- "Thijs Vermeir <thijs.vermeir@barco.com>");
-}
-
-static void
gst_rtp_mp2t_depay_class_init (GstRtpMP2TDepayClass * klass)
{
GObjectClass *gobject_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
- gstbasertpdepayload_class->process = gst_rtp_mp2t_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_mp2t_depay_setcaps;
+ gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_mp2t_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_mp2t_depay_setcaps;
gobject_class->set_property = gst_rtp_mp2t_depay_set_property;
gobject_class->get_property = gst_rtp_mp2t_depay_get_property;
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_mp2t_depay_src_template);
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_mp2t_depay_sink_template);
+
+ gst_element_class_set_static_metadata (gstelement_class,
+ "RTP MPEG Transport Stream depayloader", "Codec/Depayloader/Network/RTP",
+ "Extracts MPEG2 TS from RTP packets (RFC 2250)",
+ "Wim Taymans <wim.taymans@gmail.com>, "
+ "Thijs Vermeir <thijs.vermeir@barco.com>");
+
g_object_class_install_property (gobject_class, PROP_SKIP_FIRST_BYTES,
g_param_spec_uint ("skip-first-bytes",
"Skip first bytes",
}
static void
-gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * rtpmp2tdepay,
- GstRtpMP2TDepayClass * klass)
+gst_rtp_mp2t_depay_init (GstRtpMP2TDepay * rtpmp2tdepay)
{
rtpmp2tdepay->skip_first_bytes = DEFAULT_SKIP_FIRST_BYTES;
}
static gboolean
-gst_rtp_mp2t_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp2t_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure;
srccaps = gst_caps_new_simple ("video/mpegts",
"packetsize", G_TYPE_INT, 188,
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
- res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return res;
}
static GstBuffer *
-gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
- gint payload_len;
+ gint payload_len, leftover;
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
- payload_len = gst_rtp_buffer_get_payload_len (buf);
+ payload_len = gst_rtp_buffer_get_payload_len (rtp);
if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
goto empty_packet;
+ payload_len -= rtpmp2tdepay->skip_first_bytes;
+
+ /* RFC 2250
+ *
+ * 2. Encapsulation of MPEG System and Transport Streams
+ *
+ * For MPEG2 Transport Streams the RTP payload will contain an integral
+ * number of MPEG transport packets.
+ */
+ leftover = payload_len % 188;
+ if (G_UNLIKELY (leftover)) {
+ GST_WARNING ("We don't have an integral number of buffers (leftover: %d)",
+ leftover);
+
+ payload_len -= leftover;
+ }
+
outbuf =
- gst_rtp_buffer_get_payload_subbuffer (buf, rtpmp2tdepay->skip_first_bytes,
- -1);
+ gst_rtp_buffer_get_payload_subbuffer (rtp,
+ rtpmp2tdepay->skip_first_bytes, payload_len);
+
+ if (outbuf) {
+ GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %"
+ G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
- if (outbuf)
- GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, 0);
+ }
return outbuf;