*
* 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 <gst/rtp/gstrtpbuffer.h>
#include "gstrtpdvpay.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY (rtpdvpay_debug);
#define GST_CAT_DEFAULT (rtpdvpay_debug)
)
);
-static gboolean gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_dv_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * payload,
+static GstFlowReturn gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * payload,
GstBuffer * buffer);
#define GST_TYPE_DV_PAY_MODE (gst_dv_pay_mode_get_type())
guint prop_id, GValue * value, GParamSpec * pspec);
#define gst_rtp_dv_pay_parent_class parent_class
-G_DEFINE_TYPE (GstRTPDVPay, gst_rtp_dv_pay, GST_TYPE_BASE_RTP_PAYLOAD);
+G_DEFINE_TYPE (GstRTPDVPay, gst_rtp_dv_pay, GST_TYPE_RTP_BASE_PAYLOAD);
static void
gst_rtp_dv_pay_class_init (GstRTPDVPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpdvpay_debug, "rtpdvpay", 0, "DV RTP Payloader");
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_dv_pay_set_property;
gobject_class->get_property = gst_dv_pay_get_property;
GST_TYPE_DV_PAY_MODE, DEFAULT_MODE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_dv_pay_sink_template));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&gst_rtp_dv_pay_src_template));
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_dv_pay_sink_template);
+ gst_element_class_add_static_pad_template (gstelement_class,
+ &gst_rtp_dv_pay_src_template);
- gst_element_class_set_details_simple (gstelement_class, "RTP DV Payloader",
+ gst_element_class_set_static_metadata (gstelement_class, "RTP DV Payloader",
"Codec/Payloader/Network/RTP",
"Payloads DV into RTP packets (RFC 3189)",
"Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
- gstbasertppayload_class->set_caps = gst_rtp_dv_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_dv_pay_handle_buffer;
+ gstrtpbasepayload_class->set_caps = gst_rtp_dv_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_dv_pay_handle_buffer;
+
+#ifndef TIZEN_FEATURE_GST_UPSTREAM_AVOID_BUILD_BREAK
+ gst_type_mark_as_plugin_api (GST_TYPE_DV_PAY_MODE, 0);
+#endif
}
static void
}
static gboolean
-gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_dv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
/* We don't do anything here, but we could check if it's a system stream and if
* it's not, default to sending the video only. We will negotiate downstream
default:
break;
}
- gst_basertppayload_set_options (GST_BASE_RTP_PAYLOAD (rtpdvpay), media, TRUE,
- "DV", 90000);
+ gst_rtp_base_payload_set_options (GST_RTP_BASE_PAYLOAD (rtpdvpay), media,
+ TRUE, "DV", 90000);
if (audio_bundled) {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpdvpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay),
"encode", G_TYPE_STRING, encode,
"audio", G_TYPE_STRING, "bundled", NULL);
} else {
- res = gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpdvpay),
+ res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay),
"encode", G_TYPE_STRING, encode, NULL);
}
return res;
/* Get a DV frame, chop it up in pieces, and push the pieces to the RTP layer.
*/
static GstFlowReturn
-gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstRTPDVPay *rtpdvpay;
GstBuffer *outbuf;
GstFlowReturn ret = GST_FLOW_OK;
gint hdrlen;
- gsize size, osize;
- guint8 *data, *odata;
+ gsize size;
+ GstMapInfo map;
+ guint8 *data;
guint8 *dest;
guint filled;
GstRTPBuffer rtp = { NULL, };
* Therefore, we round the available room down to the nearest multiple of 80.
*
* The available room is just the packet MTU, minus the RTP header length. */
- max_payload_size = ((GST_BASE_RTP_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
+ max_payload_size = ((GST_RTP_BASE_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
/* The length of the buffer to transmit. */
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
-
- odata = data;
- osize = size;
+ if (!gst_buffer_map (buffer, &map, GST_MAP_READ)) {
+ GST_ELEMENT_ERROR (rtpdvpay, CORE, FAILED,
+ (NULL), ("Failed to map buffer"));
+ gst_buffer_unref (buffer);
+ return GST_FLOW_ERROR;
+ }
+ data = map.data;
+ size = map.size;
GST_DEBUG_OBJECT (rtpdvpay,
- "DV RTP payloader got buffer of %u bytes, splitting in %u byte "
- "payload fragments, at time %" GST_TIME_FORMAT, size, max_payload_size,
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+ "DV RTP payloader got buffer of %" G_GSIZE_FORMAT
+ " bytes, splitting in %u byte " "payload fragments, at time %"
+ GST_TIME_FORMAT, size, max_payload_size,
+ GST_TIME_ARGS (GST_BUFFER_PTS (buffer)));
if (!rtpdvpay->negotiated) {
gst_dv_pay_negotiate (rtpdvpay, data, size);
/* Allocate a new buffer, set the timestamp */
if (outbuf == NULL) {
outbuf = gst_rtp_buffer_new_allocate (max_payload_size, 0, 0);
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
-
- gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+ GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (buffer);
+
+ if (!gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp)) {
+ gst_buffer_unref (outbuf);
+ GST_ELEMENT_ERROR (rtpdvpay, CORE, FAILED,
+ (NULL), ("Failed to map RTP buffer"));
+ ret = GST_FLOW_ERROR;
+ goto beach;
+ }
dest = gst_rtp_buffer_get_payload (&rtp);
filled = 0;
}
/* Push out the created piece, and check for errors. */
gst_rtp_buffer_unmap (&rtp);
- ret = gst_basertppayload_push (basepayload, outbuf);
+ gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buffer, 0);
+ ret = gst_rtp_base_payload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
break;
outbuf = NULL;
}
}
- gst_buffer_unmap (buffer, odata, osize);
+
+beach:
+ gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
return ret;