*
* 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\";"
+ "clock-rate = (int) [1, MAX ], "
+ "encoding-name = (string) { MP2T, MP2T-ES } ;"
/* All optional parameters
*
* "profile-level-id=[1,MAX]"
static gboolean gst_rtp_mp2t_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload,
- GstBuffer * buf);
+ GstRTPBuffer * rtp);
static void gst_rtp_mp2t_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
gstelement_class = (GstElementClass *) klass;
gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstrtpbasedepayload_class->process = gst_rtp_mp2t_depay_process;
+ 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_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_mp2t_depay_src_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_mp2t_depay_sink_template));
+ 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_details_simple (gstelement_class,
+ 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>, "
}
static GstBuffer *
-gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp2t_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
- gint payload_len;
- GstRTPBuffer rtp;
+ gint payload_len, leftover;
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
- gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
- payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+ payload_len = gst_rtp_buffer_get_payload_len (rtp);
if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
goto empty_packet;
- outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp,
- rtpmp2tdepay->skip_first_bytes, -1);
+ 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 (rtp,
+ rtpmp2tdepay->skip_first_bytes, payload_len);
- gst_rtp_buffer_unmap (&rtp);
+ 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_get_size (outbuf));
+ gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf, 0);
+ }
return outbuf;
{
GST_ELEMENT_WARNING (rtpmp2tdepay, STREAM, DECODE,
(NULL), ("Packet was empty"));
- gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}