mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gst/rtp/: Added simple mpeg transport stream payloader.
Original commit message from CVS: * gst/rtp/Makefile.am: * gst/rtp/gstrtp.c: (plugin_init): * gst/rtp/gstrtpmp2tpay.c: (gst_rtp_mp2t_pay_base_init), (gst_rtp_mp2t_pay_class_init), (gst_rtp_mp2t_pay_init), (gst_rtp_mp2t_pay_setcaps), (gst_rtp_mp2t_pay_handle_buffer), (gst_rtp_mp2t_pay_plugin_init): * gst/rtp/gstrtpmp2tpay.h: Added simple mpeg transport stream payloader.
This commit is contained in:
parent
7fd025043d
commit
bd4b1f680c
5 changed files with 233 additions and 0 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-02-18 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/rtp/Makefile.am:
|
||||
* gst/rtp/gstrtp.c: (plugin_init):
|
||||
* gst/rtp/gstrtpmp2tpay.c: (gst_rtp_mp2t_pay_base_init),
|
||||
(gst_rtp_mp2t_pay_class_init), (gst_rtp_mp2t_pay_init),
|
||||
(gst_rtp_mp2t_pay_setcaps), (gst_rtp_mp2t_pay_handle_buffer),
|
||||
(gst_rtp_mp2t_pay_plugin_init):
|
||||
* gst/rtp/gstrtpmp2tpay.h:
|
||||
Added simple mpeg transport stream payloader.
|
||||
|
||||
2007-02-16 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/rtsp/URLS:
|
||||
|
|
|
@ -25,6 +25,7 @@ libgstrtp_la_SOURCES = \
|
|||
gstrtpL16pay.c \
|
||||
gstasteriskh263.c \
|
||||
gstrtpmp2tdepay.c \
|
||||
gstrtpmp2tpay.c \
|
||||
gstrtpmp4vdepay.c \
|
||||
gstrtpmp4vpay.c \
|
||||
gstrtpmp4gdepay.c \
|
||||
|
@ -72,6 +73,7 @@ noinst_HEADERS = \
|
|||
gstrtph263pay.h \
|
||||
gstrtph264depay.h \
|
||||
gstrtpmp2tdepay.h \
|
||||
gstrtpmp2tpay.h \
|
||||
gstrtpmp4vdepay.h \
|
||||
gstrtpmp4vpay.h \
|
||||
gstrtpmp4gdepay.h \
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "gstrtpL16pay.h"
|
||||
#include "gstasteriskh263.h"
|
||||
#include "gstrtpmp2tdepay.h"
|
||||
#include "gstrtpmp2tpay.h"
|
||||
#include "gstrtpmp4vdepay.h"
|
||||
#include "gstrtpmp4vpay.h"
|
||||
#include "gstrtpmp4gdepay.h"
|
||||
|
@ -128,6 +129,9 @@ plugin_init (GstPlugin * plugin)
|
|||
if (!gst_rtp_mp2t_depay_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_rtp_mp2t_pay_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_rtp_mp4v_pay_plugin_init (plugin))
|
||||
return FALSE;
|
||||
|
||||
|
|
159
gst/rtp/gstrtpmp2tpay.c
Normal file
159
gst/rtp/gstrtpmp2tpay.c
Normal file
|
@ -0,0 +1,159 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gst/rtp/gstrtpbuffer.h>
|
||||
|
||||
#include "gstrtpmp2tpay.h"
|
||||
|
||||
/* elementfactory information */
|
||||
static const GstElementDetails gst_rtp_mp2t_pay_details =
|
||||
GST_ELEMENT_DETAILS ("RTP MP2T audio payloader",
|
||||
"Codec/Payloader/Network",
|
||||
"Payload-encodes MPEG2 TS into RTP packets (RFC 2250)",
|
||||
"Wim Taymans <wim@fluendo.com>");
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_mp2t_pay_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/mpegts,"
|
||||
"packetsize=(int)188," "systemstream=(boolean)true")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_mp2t_pay_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("application/x-rtp, "
|
||||
"media = (string) \"video\", "
|
||||
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
|
||||
"clock-rate = (int) 90000, " "encoding-name = (string) \"MP2T-ES\"")
|
||||
);
|
||||
|
||||
static gboolean gst_rtp_mp2t_pay_setcaps (GstBaseRTPPayload * payload,
|
||||
GstCaps * caps);
|
||||
static GstFlowReturn gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload *
|
||||
payload, GstBuffer * buffer);
|
||||
|
||||
GST_BOILERPLATE (GstRTPMP2TPay, gst_rtp_mp2t_pay, GstBaseRTPPayload,
|
||||
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_mp2t_pay_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_mp2t_pay_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_mp2t_pay_src_template));
|
||||
gst_element_class_set_details (element_class, &gst_rtp_mp2t_pay_details);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_mp2t_pay_class_init (GstRTPMP2TPayClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPPayloadClass *gstbasertppayload_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
|
||||
|
||||
gstbasertppayload_class->set_caps = gst_rtp_mp2t_pay_setcaps;
|
||||
gstbasertppayload_class->handle_buffer = gst_rtp_mp2t_pay_handle_buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_mp2t_pay_init (GstRTPMP2TPay * rtpmp2tpay, GstRTPMP2TPayClass * klass)
|
||||
{
|
||||
GST_BASE_RTP_PAYLOAD (rtpmp2tpay)->clock_rate = 90000;
|
||||
GST_BASE_RTP_PAYLOAD_PT (rtpmp2tpay) = GST_RTP_PAYLOAD_MP2T;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_mp2t_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||
{
|
||||
const char *stname;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
stname = gst_structure_get_name (structure);
|
||||
|
||||
gst_basertppayload_set_options (payload, "video", TRUE, "MP2T-ES", 90000);
|
||||
gst_basertppayload_set_outcaps (payload, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_rtp_mp2t_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
GstRTPMP2TPay *rtpmp2tpay;
|
||||
guint size, payload_len;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *payload, *data;
|
||||
GstClockTime timestamp;
|
||||
GstFlowReturn ret;
|
||||
|
||||
rtpmp2tpay = GST_RTP_MP2T_PAY (basepayload);
|
||||
|
||||
size = GST_BUFFER_SIZE (buffer);
|
||||
data = GST_BUFFER_DATA (buffer);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
/* FIXME, only one MP2T frame per RTP packet for now */
|
||||
payload_len = size;
|
||||
|
||||
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
|
||||
|
||||
/* copy timestamp */
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||
|
||||
/* get payload */
|
||||
payload = gst_rtp_buffer_get_payload (outbuf);
|
||||
|
||||
/* copy data in payload */
|
||||
memcpy (payload, data, size);
|
||||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
GST_DEBUG_OBJECT (rtpmp2tpay, "pushing buffer of size %d",
|
||||
GST_BUFFER_SIZE (outbuf));
|
||||
|
||||
ret = gst_basertppayload_push (basepayload, outbuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_rtp_mp2t_pay_plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
return gst_element_register (plugin, "rtpmp2tpay",
|
||||
GST_RANK_NONE, GST_TYPE_RTP_MP2T_PAY);
|
||||
}
|
57
gst/rtp/gstrtpmp2tpay.h
Normal file
57
gst/rtp/gstrtpmp2tpay.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GST_RTP_MP2T_PAY_H__
|
||||
#define __GST_RTP_MP2T_PAY_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/rtp/gstbasertppayload.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstRTPMP2TPay GstRTPMP2TPay;
|
||||
typedef struct _GstRTPMP2TPayClass GstRTPMP2TPayClass;
|
||||
|
||||
#define GST_TYPE_RTP_MP2T_PAY \
|
||||
(gst_rtp_mp2t_pay_get_type())
|
||||
#define GST_RTP_MP2T_PAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_MP2T_PAY,GstRTPMP2TPay))
|
||||
#define GST_RTP_MP2T_PAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_MP2T_PAY,GstRTPMP2TPayClass))
|
||||
#define GST_IS_RTP_MP2T_PAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_MP2T_PAY))
|
||||
#define GST_IS_RTP_MP2T_PAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_MP2T_PAY))
|
||||
|
||||
struct _GstRTPMP2TPay
|
||||
{
|
||||
GstBaseRTPPayload payload;
|
||||
};
|
||||
|
||||
struct _GstRTPMP2TPayClass
|
||||
{
|
||||
GstBaseRTPPayloadClass parent_class;
|
||||
};
|
||||
|
||||
gboolean gst_rtp_mp2t_pay_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_RTP_MP2T_PAY_H__ */
|
Loading…
Reference in a new issue