mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
rtpvp8: port to 0.11
This commit is contained in:
parent
0829043b87
commit
e1b7da5410
6 changed files with 107 additions and 101 deletions
|
@ -316,7 +316,7 @@ GST_PLUGINS_NONPORTED=" adpcmdec adpcmenc aiff asfmux \
|
|||
hdvparse hls id3tag inter interlace ivfparse jpegformat jp2kdecimator \
|
||||
kate liveadder legacyresample librfb mpegdemux mpegtsmux \
|
||||
mpegpsmux mve mxf mythtv nsf nuvdemux \
|
||||
patchdetect pnm rawparse real removesilence rtpvp8 scaletempo \
|
||||
patchdetect pnm rawparse real removesilence scaletempo \
|
||||
sdi segmentclip siren speed subenc stereo tta videofilters \
|
||||
videomeasure videosignal vmnc \
|
||||
decklink fbdev linsys shm vcd \
|
||||
|
|
|
@ -27,5 +27,5 @@ Android.mk: Makefile.am $(BUILT_SOURCES)
|
|||
$(libgstrtpvp8_la_LIBADD) \
|
||||
-ldl \
|
||||
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
|
||||
LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
|
||||
LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.11' \
|
||||
> $@
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* gst-rtp-vp8-depay.c - Source for GstRtpVP8Depay
|
||||
* gstrtpvp8depay.c - Source for GstRtpVP8Depay
|
||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||
* Copyright (C) 2011 Collabora Ltd.
|
||||
* Contact: Youness Alaoui <youness.alaoui@collabora.co.uk>
|
||||
|
@ -29,8 +29,7 @@
|
|||
GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_depay_debug);
|
||||
#define GST_CAT_DEFAULT gst_rtp_vp8_depay_debug
|
||||
|
||||
GST_BOILERPLATE (GstRtpVP8Depay, gst_rtp_vp8_depay, GstBaseRTPDepayload,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
G_DEFINE_TYPE (GstRtpVP8Depay, gst_rtp_vp8_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_vp8_depay_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
|
@ -49,40 +48,36 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
"encoding-name = (string) \"VP8-DRAFT-IETF-01\""));
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_depay_init (GstRtpVP8Depay * self, GstRtpVP8DepayClass * klass)
|
||||
gst_rtp_vp8_depay_init (GstRtpVP8Depay * self)
|
||||
{
|
||||
self->adapter = gst_adapter_new ();
|
||||
self->started = FALSE;
|
||||
}
|
||||
|
||||
static void gst_rtp_vp8_depay_dispose (GObject * object);
|
||||
static GstBuffer *gst_rtp_vp8_depay_process (GstBaseRTPDepayload * depayload,
|
||||
static GstBuffer *gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depayload,
|
||||
GstBuffer * buf);
|
||||
static gboolean gst_rtp_vp8_depay_set_caps (GstBaseRTPDepayload * depayload,
|
||||
static gboolean gst_rtp_vp8_depay_set_caps (GstRTPBaseDepayload * depayload,
|
||||
GstCaps * caps);
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_depay_base_init (gpointer klass)
|
||||
gst_rtp_vp8_depay_class_init (GstRtpVP8DepayClass * gst_rtp_vp8_depay_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (gst_rtp_vp8_depay_class);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gst_rtp_vp8_depay_class);
|
||||
GstRTPBaseDepayloadClass *depay_class =
|
||||
(GstRTPBaseDepayloadClass *) (gst_rtp_vp8_depay_class);
|
||||
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_vp8_depay_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_vp8_depay_src_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "RTP VP8 depayloader",
|
||||
gst_element_class_set_metadata (element_class, "RTP VP8 depayloader",
|
||||
"Codec/Depayloader/Network/RTP",
|
||||
"Extracts VP8 video from RTP packets)",
|
||||
"Sjoerd Simons <sjoerd@luon.net>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_depay_class_init (GstRtpVP8DepayClass * gst_rtp_vp8_depay_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (gst_rtp_vp8_depay_class);
|
||||
GstBaseRTPDepayloadClass *depay_class =
|
||||
(GstBaseRTPDepayloadClass *) (gst_rtp_vp8_depay_class);
|
||||
|
||||
object_class->dispose = gst_rtp_vp8_depay_dispose;
|
||||
|
||||
|
@ -104,18 +99,19 @@ gst_rtp_vp8_depay_dispose (GObject * object)
|
|||
|
||||
/* release any references held by the object here */
|
||||
|
||||
if (G_OBJECT_CLASS (parent_class)->dispose)
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
if (G_OBJECT_CLASS (gst_rtp_vp8_depay_parent_class)->dispose)
|
||||
G_OBJECT_CLASS (gst_rtp_vp8_depay_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_rtp_vp8_depay_process (GstBaseRTPDepayload * depay, GstBuffer * buf)
|
||||
gst_rtp_vp8_depay_process (GstRTPBaseDepayload * depay, GstBuffer * buf)
|
||||
{
|
||||
GstRtpVP8Depay *self = GST_RTP_VP8_DEPAY (depay);
|
||||
GstBuffer *payload;
|
||||
guint8 *data;
|
||||
guint offset;
|
||||
guint size = gst_rtp_buffer_get_payload_len (buf);
|
||||
guint size;
|
||||
GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
|
||||
|
||||
if (G_UNLIKELY (GST_BUFFER_IS_DISCONT (buf))) {
|
||||
GST_LOG_OBJECT (self, "Discontinuity, flushing adapter");
|
||||
|
@ -123,17 +119,20 @@ gst_rtp_vp8_depay_process (GstBaseRTPDepayload * depay, GstBuffer * buf)
|
|||
self->started = FALSE;
|
||||
}
|
||||
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtpbuffer);
|
||||
size = gst_rtp_buffer_get_payload_len (&rtpbuffer);
|
||||
|
||||
/* At least one header and one vp8 byte */
|
||||
if (G_UNLIKELY (size < 2))
|
||||
goto too_small;
|
||||
|
||||
data = gst_rtp_buffer_get_payload (buf);
|
||||
data = gst_rtp_buffer_get_payload (&rtpbuffer);
|
||||
|
||||
if (G_UNLIKELY (!self->started)) {
|
||||
/* Check if this is the start of a VP8 frame, otherwise bail */
|
||||
/* S=1 and PartID= 0 */
|
||||
if ((data[0] & 0x1F) != 0x10)
|
||||
return NULL;
|
||||
goto done;
|
||||
|
||||
self->started = TRUE;
|
||||
}
|
||||
|
@ -162,37 +161,41 @@ gst_rtp_vp8_depay_process (GstBaseRTPDepayload * depay, GstBuffer * buf)
|
|||
if (G_UNLIKELY (offset >= size))
|
||||
goto too_small;
|
||||
|
||||
payload = gst_rtp_buffer_get_payload_subbuffer (buf, offset, -1);
|
||||
payload = gst_rtp_buffer_get_payload_subbuffer (&rtpbuffer, offset, -1);
|
||||
gst_adapter_push (self->adapter, payload);
|
||||
|
||||
/* Marker indicates that it was the last rtp packet for this frame */
|
||||
if (gst_rtp_buffer_get_marker (buf)) {
|
||||
if (gst_rtp_buffer_get_marker (&rtpbuffer)) {
|
||||
GstBuffer *out;
|
||||
|
||||
out = gst_adapter_take_buffer (self->adapter,
|
||||
gst_adapter_available (self->adapter));
|
||||
|
||||
self->started = FALSE;
|
||||
gst_rtp_buffer_unmap (&rtpbuffer);
|
||||
return out;
|
||||
}
|
||||
|
||||
done:
|
||||
gst_rtp_buffer_unmap (&rtpbuffer);
|
||||
return NULL;
|
||||
|
||||
too_small:
|
||||
GST_LOG_OBJECT (self, "Invalid rtp packet (too small), ignoring");
|
||||
gst_adapter_clear (self->adapter);
|
||||
self->started = FALSE;
|
||||
return NULL;
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_vp8_depay_set_caps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
||||
gst_rtp_vp8_depay_set_caps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||
{
|
||||
GstCaps *srccaps = gst_caps_new_simple ("video/x-vp8",
|
||||
"framerate", GST_TYPE_FRACTION, 0, 1,
|
||||
NULL);
|
||||
|
||||
gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
|
||||
gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
|
||||
gst_caps_unref (srccaps);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* gst-rtp-vp8-depay.h - Header for GstRtpVP8Depay
|
||||
* gstrtpvp8depay.h - Header for GstRtpVP8Depay
|
||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
@ -22,19 +22,19 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include <gst/rtp/gstbasertpdepayload.h>
|
||||
#include <gst/rtp/gstrtpbasedepayload.h>
|
||||
|
||||
G_BEGIN_DECLS typedef struct _GstRtpVP8Depay GstRtpVP8Depay;
|
||||
typedef struct _GstRtpVP8DepayClass GstRtpVP8DepayClass;
|
||||
|
||||
struct _GstRtpVP8DepayClass
|
||||
{
|
||||
GstBaseRTPDepayloadClass parent_class;
|
||||
GstRTPBaseDepayloadClass parent_class;
|
||||
};
|
||||
|
||||
struct _GstRtpVP8Depay
|
||||
{
|
||||
GstBaseRTPDepayload parent;
|
||||
GstRTPBaseDepayload parent;
|
||||
GstAdapter *adapter;
|
||||
gboolean started;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* gst-rtp-vp8-pay.c - Source for GstRtpVP8Pay
|
||||
* gstrtpvp8pay.c - Source for GstRtpVP8Pay
|
||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||
* Copyright (C) 2011 Collabora Ltd.
|
||||
* Contact: Youness Alaoui <youness.alaoui@collabora.co.uk>
|
||||
|
@ -35,8 +35,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_pay_debug);
|
|||
|
||||
#define DEFAULT_PICTURE_ID_MODE VP8_PAY_PICTURE_ID_7BITS
|
||||
|
||||
GST_BOILERPLATE (GstRtpVP8Pay, gst_rtp_vp8_pay, GstBaseRTPPayload,
|
||||
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
G_DEFINE_TYPE (GstRtpVP8Pay, gst_rtp_vp8_pay, GST_TYPE_RTP_BASE_PAYLOAD);
|
||||
|
||||
static GstStaticPadTemplate gst_rtp_vp8_pay_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
|
@ -53,7 +52,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
GST_STATIC_CAPS ("video/x-vp8"));
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj, GstRtpVP8PayClass * klass)
|
||||
gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj)
|
||||
{
|
||||
/* TODO: Make it configurable */
|
||||
obj->picture_id_mode = DEFAULT_PICTURE_ID_MODE;
|
||||
|
@ -63,16 +62,20 @@ gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj, GstRtpVP8PayClass * klass)
|
|||
obj->picture_id = g_random_int_range (0, G_MAXUINT16) & 0x7FFF;
|
||||
}
|
||||
|
||||
static GstFlowReturn gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload,
|
||||
static GstFlowReturn gst_rtp_vp8_pay_handle_buffer (GstRTPBasePayload * payload,
|
||||
GstBuffer * buffer);
|
||||
static gboolean gst_rtp_vp8_pay_handle_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_rtp_vp8_pay_set_caps (GstBaseRTPPayload * payload,
|
||||
static gboolean gst_rtp_vp8_pay_sink_event (GstRTPBasePayload * payload,
|
||||
GstEvent * event);
|
||||
static gboolean gst_rtp_vp8_pay_set_caps (GstRTPBasePayload * payload,
|
||||
GstCaps * caps);
|
||||
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_pay_base_init (gpointer klass)
|
||||
gst_rtp_vp8_pay_class_init (GstRtpVP8PayClass * gst_rtp_vp8_pay_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gst_rtp_vp8_pay_class);
|
||||
GstRTPBasePayloadClass *pay_class =
|
||||
GST_RTP_BASE_PAYLOAD_CLASS (gst_rtp_vp8_pay_class);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_vp8_pay_sink_template));
|
||||
|
@ -82,16 +85,9 @@ gst_rtp_vp8_pay_base_init (gpointer klass)
|
|||
gst_element_class_set_details_simple (element_class, "RTP VP8 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Puts VP8 video in RTP packets)", "Sjoerd Simons <sjoerd@luon.net>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_vp8_pay_class_init (GstRtpVP8PayClass * gst_rtp_vp8_pay_class)
|
||||
{
|
||||
GstBaseRTPPayloadClass *pay_class =
|
||||
GST_BASE_RTP_PAYLOAD_CLASS (gst_rtp_vp8_pay_class);
|
||||
|
||||
pay_class->handle_buffer = gst_rtp_vp8_pay_handle_buffer;
|
||||
pay_class->handle_event = gst_rtp_vp8_pay_handle_event;
|
||||
pay_class->sink_event = gst_rtp_vp8_pay_sink_event;
|
||||
pay_class->set_caps = gst_rtp_vp8_pay_set_caps;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_rtp_vp8_pay_debug, "rtpvp8pay", 0,
|
||||
|
@ -101,23 +97,27 @@ gst_rtp_vp8_pay_class_init (GstRtpVP8PayClass * gst_rtp_vp8_pay_class)
|
|||
static gboolean
|
||||
gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
||||
{
|
||||
GstBitReader *reader;
|
||||
GstBitReader *reader = NULL;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
int i;
|
||||
gboolean keyframe;
|
||||
guint32 partition0_size;
|
||||
guint8 version;
|
||||
guint8 tmp8 = 0;
|
||||
guint8 *data;
|
||||
guint8 partitions;
|
||||
guint offset;
|
||||
BOOL_DECODER bc;
|
||||
guint8 *pdata;
|
||||
|
||||
reader = gst_bit_reader_new_from_buffer (buffer);
|
||||
|
||||
if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < 3))
|
||||
if (G_UNLIKELY (gst_buffer_get_size (buffer) < 3))
|
||||
goto error;
|
||||
|
||||
data = GST_BUFFER_DATA (buffer);
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
if (data == NULL)
|
||||
goto error;
|
||||
|
||||
reader = gst_bit_reader_new (data, size);
|
||||
|
||||
self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
|
||||
version = (data[0] >> 1) & 0x7;
|
||||
|
@ -154,8 +154,7 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||
}
|
||||
|
||||
offset = keyframe ? 10 : 3;
|
||||
vp8dx_start_decode (&bc, GST_BUFFER_DATA (buffer) + offset,
|
||||
GST_BUFFER_SIZE (buffer) - offset);
|
||||
vp8dx_start_decode (&bc, data + offset, size - offset);
|
||||
|
||||
if (keyframe) {
|
||||
/* color space (1 bit) and clamping type (1 bit) */
|
||||
|
@ -226,11 +225,11 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||
partitions = 1 << tmp8;
|
||||
|
||||
/* Check if things are still sensible */
|
||||
if (partition0_size + (partitions - 1) * 3 >= GST_BUFFER_SIZE (buffer))
|
||||
if (partition0_size + (partitions - 1) * 3 >= size)
|
||||
goto error;
|
||||
|
||||
/* partition data is right after the mode partition */
|
||||
data = GST_BUFFER_DATA (buffer) + partition0_size;
|
||||
pdata = data + partition0_size;
|
||||
|
||||
/* Set up mapping */
|
||||
self->n_partitions = partitions + 1;
|
||||
|
@ -239,29 +238,32 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
|||
|
||||
self->partition_offset[1] = self->partition_size[0];
|
||||
for (i = 1; i < partitions; i++) {
|
||||
guint size = (data[2] << 16 | data[1] << 8 | data[0]);
|
||||
guint psize = (pdata[2] << 16 | pdata[1] << 8 | pdata[0]);
|
||||
|
||||
data += 3;
|
||||
self->partition_size[i] = size;
|
||||
self->partition_offset[i + 1] = self->partition_offset[i] + size;
|
||||
pdata += 3;
|
||||
self->partition_size[i] = psize;
|
||||
self->partition_offset[i + 1] = self->partition_offset[i] + psize;
|
||||
}
|
||||
|
||||
/* Check that our partition offsets and sizes don't go outsize the buffer
|
||||
* size. */
|
||||
if (self->partition_offset[i] >= GST_BUFFER_SIZE (buffer))
|
||||
if (self->partition_offset[i] >= size)
|
||||
goto error;
|
||||
|
||||
self->partition_size[i] = GST_BUFFER_SIZE (buffer)
|
||||
- self->partition_offset[i];
|
||||
self->partition_size[i] = size - self->partition_offset[i];
|
||||
|
||||
self->partition_offset[i + 1] = GST_BUFFER_SIZE (buffer);
|
||||
self->partition_offset[i + 1] = size;
|
||||
|
||||
gst_bit_reader_free (reader);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
GST_DEBUG ("Failed to parse frame");
|
||||
gst_bit_reader_free (reader);
|
||||
if (reader) {
|
||||
gst_bit_reader_free (reader);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -297,8 +299,8 @@ gst_rtp_vp8_calc_header_len (GstRtpVP8Pay * self)
|
|||
static gsize
|
||||
gst_rtp_vp8_calc_payload_len (GstRtpVP8Pay * self)
|
||||
{
|
||||
GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (self);
|
||||
return gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU (payload) -
|
||||
GstRTPBasePayload *payload = GST_RTP_BASE_PAYLOAD (self);
|
||||
return gst_rtp_buffer_calc_payload_len (GST_RTP_BASE_PAYLOAD_MTU (payload) -
|
||||
gst_rtp_vp8_calc_header_len (self), 0, 0);
|
||||
}
|
||||
|
||||
|
@ -309,9 +311,11 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid,
|
|||
{
|
||||
GstBuffer *out;
|
||||
guint8 *p;
|
||||
GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
|
||||
|
||||
out = gst_rtp_buffer_new_allocate (gst_rtp_vp8_calc_header_len (self), 0, 0);
|
||||
p = gst_rtp_buffer_get_payload (out);
|
||||
gst_rtp_buffer_map (out, GST_MAP_READWRITE, &rtpbuffer);
|
||||
p = gst_rtp_buffer_get_payload (&rtpbuffer);
|
||||
/* X=0,R=0,N=0,S=start,PartID=partid */
|
||||
p[0] = (start << 4) | partid;
|
||||
if (self->picture_id_mode != VP8_PAY_NO_PICTURE_ID) {
|
||||
|
@ -329,10 +333,12 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid,
|
|||
}
|
||||
}
|
||||
|
||||
gst_rtp_buffer_set_marker (out, mark);
|
||||
gst_rtp_buffer_set_marker (&rtpbuffer, mark);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtpbuffer);
|
||||
|
||||
GST_BUFFER_DURATION (out) = GST_BUFFER_DURATION (in);
|
||||
GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (in);
|
||||
GST_BUFFER_PTS (out) = GST_BUFFER_PTS (in);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -340,16 +346,17 @@ gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid,
|
|||
|
||||
static guint
|
||||
gst_rtp_vp8_payload_next (GstRtpVP8Pay * self,
|
||||
GstBufferListIterator * it, guint offset, GstBuffer * buffer)
|
||||
GstBufferList * list, guint offset, GstBuffer * buffer)
|
||||
{
|
||||
guint partition;
|
||||
GstBuffer *header;
|
||||
GstBuffer *sub;
|
||||
GstBuffer *out;
|
||||
gboolean mark;
|
||||
gsize remaining;
|
||||
gsize available;
|
||||
|
||||
remaining = GST_BUFFER_SIZE (buffer) - offset;
|
||||
remaining = gst_buffer_get_size (buffer) - offset;
|
||||
available = gst_rtp_vp8_calc_payload_len (self);
|
||||
if (available > remaining)
|
||||
available = remaining;
|
||||
|
@ -361,23 +368,22 @@ gst_rtp_vp8_payload_next (GstRtpVP8Pay * self,
|
|||
/* whole set of partitions, payload them and done */
|
||||
header = gst_rtp_vp8_create_header_buffer (self, partition,
|
||||
offset == self->partition_offset[partition], mark, buffer);
|
||||
sub = gst_buffer_create_sub (buffer, offset, available);
|
||||
sub = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, available);
|
||||
|
||||
gst_buffer_list_iterator_add_group (it);
|
||||
gst_buffer_list_iterator_add (it, header);
|
||||
gst_buffer_list_iterator_add (it, sub);
|
||||
out = gst_buffer_join (header, sub);
|
||||
|
||||
return GST_BUFFER_SIZE (sub);
|
||||
gst_buffer_list_insert (list, -1, out);
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
|
||||
static GstFlowReturn
|
||||
gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
||||
gst_rtp_vp8_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
||||
{
|
||||
GstRtpVP8Pay *self = GST_RTP_VP8_PAY (payload);
|
||||
GstFlowReturn ret;
|
||||
GstBufferList *list;
|
||||
GstBufferListIterator *it;
|
||||
guint offset;
|
||||
|
||||
if (G_UNLIKELY (!gst_rtp_vp8_pay_parse_frame (self, buffer))) {
|
||||
|
@ -386,13 +392,11 @@ gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
|||
}
|
||||
|
||||
list = gst_buffer_list_new ();
|
||||
it = gst_buffer_list_iterate (list);
|
||||
|
||||
for (offset = 0; offset < GST_BUFFER_SIZE (buffer);)
|
||||
offset += gst_rtp_vp8_payload_next (self, it, offset, buffer);
|
||||
for (offset = 0; offset < gst_buffer_get_size (buffer);)
|
||||
offset += gst_rtp_vp8_payload_next (self, list, offset, buffer);
|
||||
|
||||
ret = gst_basertppayload_push_list (payload, list);
|
||||
gst_buffer_list_iterator_free (it);
|
||||
ret = gst_rtp_base_payload_push_list (payload, list);
|
||||
|
||||
/* Incremenent and wrap the picture id if it overflows */
|
||||
if ((self->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS &&
|
||||
|
@ -405,9 +409,9 @@ gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_vp8_pay_handle_event (GstPad * pad, GstEvent * event)
|
||||
gst_rtp_vp8_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
|
||||
{
|
||||
GstRtpVP8Pay *self = GST_RTP_VP8_PAY (gst_pad_get_parent (pad));
|
||||
GstRtpVP8Pay *self = GST_RTP_VP8_PAY (payload);
|
||||
|
||||
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START) {
|
||||
if (self->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS)
|
||||
|
@ -416,17 +420,16 @@ gst_rtp_vp8_pay_handle_event (GstPad * pad, GstEvent * event)
|
|||
self->picture_id = g_random_int_range (0, G_MAXUINT16) & 0x7FFF;
|
||||
}
|
||||
|
||||
gst_object_unref (self);
|
||||
|
||||
return FALSE;
|
||||
return GST_RTP_BASE_PAYLOAD_CLASS (gst_rtp_vp8_pay_parent_class)->sink_event
|
||||
(payload, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_vp8_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||
gst_rtp_vp8_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps)
|
||||
{
|
||||
gst_basertppayload_set_options (payload, "video", TRUE,
|
||||
gst_rtp_base_payload_set_options (payload, "video", TRUE,
|
||||
"VP8-DRAFT-IETF-01", 90000);
|
||||
return gst_basertppayload_set_outcaps (payload, NULL);
|
||||
return gst_rtp_base_payload_set_outcaps (payload, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* gst-rtp-vp8-pay.h - Header for GstRtpVP8Pay
|
||||
* gstrtpvp8pay.h - Header for GstRtpVP8Pay
|
||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include <gst/rtp/gstbasertppayload.h>
|
||||
#include <gst/rtp/gstrtpbasepayload.h>
|
||||
|
||||
G_BEGIN_DECLS typedef struct _GstRtpVP8Pay GstRtpVP8Pay;
|
||||
typedef struct _GstRtpVP8PayClass GstRtpVP8PayClass;
|
||||
|
@ -36,12 +36,12 @@ enum _PictureIDMode {
|
|||
|
||||
struct _GstRtpVP8PayClass
|
||||
{
|
||||
GstBaseRTPPayloadClass parent_class;
|
||||
GstRTPBasePayloadClass parent_class;
|
||||
};
|
||||
|
||||
struct _GstRtpVP8Pay
|
||||
{
|
||||
GstBaseRTPPayload parent;
|
||||
GstRTPBasePayload parent;
|
||||
gboolean is_keyframe;
|
||||
gint n_partitions;
|
||||
/* Treat frame header & tag & partition size block as the first partition,
|
||||
|
|
Loading…
Reference in a new issue