mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
rtpvp8: Update the pay/depay to the ietf-draft-01 spec
This commit is contained in:
parent
88aade4150
commit
1cf155d70d
3 changed files with 158 additions and 134 deletions
|
@ -1,6 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* gst-rtp-vp8-depay.c - Source for GstRtpVP8Depay
|
* gst-rtp-vp8-depay.c - Source for GstRtpVP8Depay
|
||||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||||
|
* Copyright (C) 2011 Collabora Ltd.
|
||||||
|
* Contact: Youness Alaoui <youness.alaoui@collabora.co.uk>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -44,7 +46,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ","
|
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ","
|
||||||
"clock-rate = (int) 90000,"
|
"clock-rate = (int) 90000,"
|
||||||
"media = (string) \"video\","
|
"media = (string) \"video\","
|
||||||
"encoding-name = (string) \"VP8-DRAFT-0-3-2\""));
|
"encoding-name = (string) \"VP8-DRAFT-IETF-01\""));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_vp8_depay_init (GstRtpVP8Depay * self, GstRtpVP8DepayClass * klass)
|
gst_rtp_vp8_depay_init (GstRtpVP8Depay * self, GstRtpVP8DepayClass * klass)
|
||||||
|
@ -129,22 +131,32 @@ gst_rtp_vp8_depay_process (GstBaseRTPDepayload * depay, GstBuffer * buf)
|
||||||
|
|
||||||
if (G_UNLIKELY (!self->started)) {
|
if (G_UNLIKELY (!self->started)) {
|
||||||
/* Check if this is the start of a VP8 frame, otherwise bail */
|
/* Check if this is the start of a VP8 frame, otherwise bail */
|
||||||
if ((data[0] & 0x1) == 0)
|
/* S=1 and PartID= 0 */
|
||||||
|
if ((data[0] & 0x1F) != 0x10)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
self->started = TRUE;
|
self->started = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = 1;
|
offset = 1;
|
||||||
if ((data[0] & 0x10) != 0) {
|
/* Check X optional header */
|
||||||
/* Skip Picture identifier bytes */
|
if ((data[0] & 0x80) != 0) {
|
||||||
for (; (data[offset] & 0x80) != 0; offset++) {
|
offset++;
|
||||||
/* should be at least one more pictureID byte and at least one byte in
|
/* Check I optional header */
|
||||||
* the vp8 payload */
|
if ((data[1] & 0x80) != 0) {
|
||||||
|
offset++;
|
||||||
if (G_UNLIKELY (offset + 2 >= size))
|
if (G_UNLIKELY (offset + 2 >= size))
|
||||||
goto too_small;
|
goto too_small;
|
||||||
|
/* Check for 16 bits PictureID */
|
||||||
|
if ((data[2] & 0x80) != 0)
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
offset++;
|
/* Check L optional header */
|
||||||
|
if ((data[1] & 0x40) != 0)
|
||||||
|
offset++;
|
||||||
|
/* Check T optional header */
|
||||||
|
if ((data[1] & 0x20) != 0)
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY (offset >= size))
|
if (G_UNLIKELY (offset >= size))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* gst-rtp-vp8-pay.c - Source for GstRtpVP8Pay
|
* gst-rtp-vp8-pay.c - Source for GstRtpVP8Pay
|
||||||
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
* Copyright (C) 2011 Sjoerd Simons <sjoerd@luon.net>
|
||||||
|
* Copyright (C) 2011 Collabora Ltd.
|
||||||
|
* Contact: Youness Alaoui <youness.alaoui@collabora.co.uk>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -28,14 +30,11 @@
|
||||||
#include "dboolhuff.h"
|
#include "dboolhuff.h"
|
||||||
#include "gstrtpvp8pay.h"
|
#include "gstrtpvp8pay.h"
|
||||||
|
|
||||||
#define FI_FRAG_UNFRAGMENTED 0x0
|
|
||||||
#define FI_FRAG_START 0x1
|
|
||||||
#define FI_FRAG_MIDDLE 0x2
|
|
||||||
#define FI_FRAG_END 0x3
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_pay_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_rtp_vp8_pay_debug);
|
||||||
#define GST_CAT_DEFAULT gst_rtp_vp8_pay_debug
|
#define GST_CAT_DEFAULT gst_rtp_vp8_pay_debug
|
||||||
|
|
||||||
|
#define DEFAULT_PICTURE_ID_MODE VP8_PAY_PICTURE_ID_7BITS
|
||||||
|
|
||||||
GST_BOILERPLATE (GstRtpVP8Pay, gst_rtp_vp8_pay, GstBaseRTPPayload,
|
GST_BOILERPLATE (GstRtpVP8Pay, gst_rtp_vp8_pay, GstBaseRTPPayload,
|
||||||
GST_TYPE_BASE_RTP_PAYLOAD);
|
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("application/x-rtp, "
|
GST_STATIC_CAPS ("application/x-rtp, "
|
||||||
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ","
|
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ","
|
||||||
"clock-rate = (int) 90000, encoding-name = (string) \"VP8-DRAFT-0-3-2\""));
|
"clock-rate = (int) 90000, encoding-name = (string) \"VP8-DRAFT-IETF-01\""));
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_vp8_pay_sink_template =
|
static GstStaticPadTemplate gst_rtp_vp8_pay_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
@ -56,10 +55,17 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
static void
|
static void
|
||||||
gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj, GstRtpVP8PayClass * klass)
|
gst_rtp_vp8_pay_init (GstRtpVP8Pay * obj, GstRtpVP8PayClass * klass)
|
||||||
{
|
{
|
||||||
|
/* TODO: Make it configurable */
|
||||||
|
obj->picture_id_mode = DEFAULT_PICTURE_ID_MODE;
|
||||||
|
if (obj->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS)
|
||||||
|
obj->picture_id = g_random_int_range (0, G_MAXUINT8) & 0x7F;
|
||||||
|
else if (obj->picture_id_mode == VP8_PAY_PICTURE_ID_15BITS)
|
||||||
|
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 (GstBaseRTPPayload * payload,
|
||||||
GstBuffer * buffer);
|
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_set_caps (GstBaseRTPPayload * payload,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
|
|
||||||
|
@ -85,48 +91,20 @@ gst_rtp_vp8_pay_class_init (GstRtpVP8PayClass * gst_rtp_vp8_pay_class)
|
||||||
GST_BASE_RTP_PAYLOAD_CLASS (gst_rtp_vp8_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_buffer = gst_rtp_vp8_pay_handle_buffer;
|
||||||
|
pay_class->handle_event = gst_rtp_vp8_pay_handle_event;
|
||||||
pay_class->set_caps = gst_rtp_vp8_pay_set_caps;
|
pay_class->set_caps = gst_rtp_vp8_pay_set_caps;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_rtp_vp8_pay_debug, "rtpvp8pay", 0,
|
GST_DEBUG_CATEGORY_INIT (gst_rtp_vp8_pay_debug, "rtpvp8pay", 0,
|
||||||
"VP8 Video RTP Payloader");
|
"VP8 Video RTP Payloader");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gsize
|
|
||||||
gst_rtp_vp8_calc_payload_len (GstBaseRTPPayload * payload)
|
|
||||||
{
|
|
||||||
return gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU (payload) -
|
|
||||||
1, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* When growing the vp8 header keep gst_rtp_vp8_calc_payload_len in sync */
|
|
||||||
static GstBuffer *
|
|
||||||
gst_rtp_vp8_create_header_buffer (gboolean start, gboolean mark, guint fi,
|
|
||||||
GstBuffer * in)
|
|
||||||
{
|
|
||||||
GstBuffer *out;
|
|
||||||
guint8 *p;
|
|
||||||
|
|
||||||
out = gst_rtp_buffer_new_allocate (1, 0, 0);
|
|
||||||
p = gst_rtp_buffer_get_payload (out);
|
|
||||||
/* Hardcode I = 0 and N = 0, only set FI and B */
|
|
||||||
p[0] = (fi & 0x3) << 1 | (start ? 1 : 0);
|
|
||||||
|
|
||||||
gst_rtp_buffer_set_marker (out, mark);
|
|
||||||
|
|
||||||
GST_BUFFER_DURATION (out) = GST_BUFFER_DURATION (in);
|
|
||||||
GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (in);
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBitReader *reader;
|
GstBitReader *reader;
|
||||||
int i;
|
int i;
|
||||||
gboolean keyframe;
|
gboolean keyframe;
|
||||||
guint32 header_size;
|
guint32 partition0_size;
|
||||||
guint8 version;
|
guint8 version;
|
||||||
guint8 tmp8 = 0;
|
guint8 tmp8 = 0;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
@ -150,11 +128,11 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keyframe, version and show_frame use 5 bits */
|
/* keyframe, version and show_frame use 5 bits */
|
||||||
header_size = data[2] << 11 | data[1] << 3 | (data[0] >> 5);
|
partition0_size = data[2] << 11 | data[1] << 3 | (data[0] >> 5);
|
||||||
|
|
||||||
/* Include the uncompressed data blob in the header */
|
/* Include the uncompressed data blob in the first partition */
|
||||||
offset = keyframe ? 10 : 3;
|
offset = keyframe ? 10 : 3;
|
||||||
header_size += offset;
|
partition0_size += offset;
|
||||||
|
|
||||||
if (!gst_bit_reader_skip (reader, 24))
|
if (!gst_bit_reader_skip (reader, 24))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -248,17 +226,16 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer)
|
||||||
partitions = 1 << tmp8;
|
partitions = 1 << tmp8;
|
||||||
|
|
||||||
/* Check if things are still sensible */
|
/* Check if things are still sensible */
|
||||||
if (header_size + (partitions - 1) * 3 >= GST_BUFFER_SIZE (buffer))
|
if (partition0_size + (partitions - 1) * 3 >= GST_BUFFER_SIZE (buffer))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* partition data is right after the frame header */
|
/* partition data is right after the mode partition */
|
||||||
data = GST_BUFFER_DATA (buffer) + header_size;
|
data = GST_BUFFER_DATA (buffer) + partition0_size;
|
||||||
|
|
||||||
/* Set up mapping, count the initial header as a partition to make other
|
/* Set up mapping */
|
||||||
* sections of the code easier */
|
|
||||||
self->n_partitions = partitions + 1;
|
self->n_partitions = partitions + 1;
|
||||||
self->partition_offset[0] = 0;
|
self->partition_offset[0] = 0;
|
||||||
self->partition_size[0] = header_size + (partitions - 1) * 3;
|
self->partition_size[0] = partition0_size + (partitions - 1) * 3;
|
||||||
|
|
||||||
self->partition_offset[1] = self->partition_size[0];
|
self->partition_offset[1] = self->partition_size[0];
|
||||||
for (i = 1; i < partitions; i++) {
|
for (i = 1; i < partitions; i++) {
|
||||||
|
@ -289,101 +266,108 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
gst_rtp_vp8_fit_partitions (GstRtpVP8Pay * self, gint first, gsize available)
|
gst_rtp_vp8_offset_to_partition (GstRtpVP8Pay * self, guint offset)
|
||||||
{
|
{
|
||||||
guint num = 0;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_assert (first < self->n_partitions);
|
for (i = 0; i < self->n_partitions; i++) {
|
||||||
|
if (offset >= self->partition_offset[i] &&
|
||||||
for (i = first;
|
offset < self->partition_offset[i + 1])
|
||||||
i < self->n_partitions && self->partition_size[i] < available; i++) {
|
return i;
|
||||||
num++;
|
|
||||||
available -= self->partition_size[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static gsize
|
||||||
gst_rtp_vp8_create_sub (GstRtpVP8Pay * self,
|
gst_rtp_vp8_calc_header_len (GstRtpVP8Pay * self)
|
||||||
GstBuffer * buffer, guint current, guint num)
|
|
||||||
{
|
{
|
||||||
guint offset = self->partition_offset[current];
|
switch (self->picture_id_mode) {
|
||||||
guint size = self->partition_offset[current + num] - offset;
|
case VP8_PAY_PICTURE_ID_7BITS:
|
||||||
|
return 3;
|
||||||
|
case VP8_PAY_PICTURE_ID_15BITS:
|
||||||
|
return 4;
|
||||||
|
case VP8_PAY_NO_PICTURE_ID:
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return gst_buffer_create_sub (buffer, offset, size);
|
|
||||||
|
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) -
|
||||||
|
gst_rtp_vp8_calc_header_len (self), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When growing the vp8 header keep gst_rtp_vp8_calc_payload_len in sync */
|
||||||
|
static GstBuffer *
|
||||||
|
gst_rtp_vp8_create_header_buffer (GstRtpVP8Pay * self, guint8 partid,
|
||||||
|
gboolean start, gboolean mark, GstBuffer * in)
|
||||||
|
{
|
||||||
|
GstBuffer *out;
|
||||||
|
guint8 *p;
|
||||||
|
|
||||||
|
out = gst_rtp_buffer_new_allocate (gst_rtp_vp8_calc_header_len (self), 0, 0);
|
||||||
|
p = gst_rtp_buffer_get_payload (out);
|
||||||
|
/* 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) {
|
||||||
|
/* Enable X=1 */
|
||||||
|
p[0] |= 0x80;
|
||||||
|
/* X: I=1,L=0,T=0,RSVA=0 */
|
||||||
|
p[1] = 0x80;
|
||||||
|
if (self->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS) {
|
||||||
|
/* I: 7 bit picture_id */
|
||||||
|
p[2] = self->picture_id & 0x7F;
|
||||||
|
} else {
|
||||||
|
/* I: 15 bit picture_id */
|
||||||
|
p[2] = 0x80 | ((self->picture_id & 0x7FFF) >> 8);
|
||||||
|
p[3] = self->picture_id & 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_rtp_buffer_set_marker (out, mark);
|
||||||
|
|
||||||
|
GST_BUFFER_DURATION (out) = GST_BUFFER_DURATION (in);
|
||||||
|
GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (in);
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
gst_rtp_vp8_payload_next (GstRtpVP8Pay * self,
|
gst_rtp_vp8_payload_next (GstRtpVP8Pay * self,
|
||||||
GstBufferListIterator * it, guint first, GstBuffer * buffer)
|
GstBufferListIterator * it, guint offset, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint num;
|
guint partition;
|
||||||
GstBuffer *header;
|
GstBuffer *header;
|
||||||
GstBuffer *sub;
|
GstBuffer *sub;
|
||||||
gboolean mark;
|
gboolean mark;
|
||||||
gsize available = gst_rtp_vp8_calc_payload_len (GST_BASE_RTP_PAYLOAD (self));
|
gsize remaining;
|
||||||
|
gsize available;
|
||||||
|
|
||||||
g_assert (first < 9);
|
remaining = GST_BUFFER_SIZE (buffer) - offset;
|
||||||
|
available = gst_rtp_vp8_calc_payload_len (self);
|
||||||
|
if (available > remaining)
|
||||||
|
available = remaining;
|
||||||
|
|
||||||
/* How many partitions can we fit */
|
partition = gst_rtp_vp8_offset_to_partition (self, offset);
|
||||||
num = gst_rtp_vp8_fit_partitions (self, first, available);
|
g_assert (partition < self->n_partitions);
|
||||||
|
|
||||||
if (num > 0) {
|
mark = (remaining == available);
|
||||||
mark = (first + num == self->n_partitions);
|
/* whole set of partitions, payload them and done */
|
||||||
/* whole set of partitions, payload them and done */
|
header = gst_rtp_vp8_create_header_buffer (self, partition,
|
||||||
header = gst_rtp_vp8_create_header_buffer (first == 0, mark,
|
offset == self->partition_offset[partition], mark, buffer);
|
||||||
FI_FRAG_UNFRAGMENTED, buffer);
|
sub = gst_buffer_create_sub (buffer, offset, available);
|
||||||
sub = gst_rtp_vp8_create_sub (self, buffer, first, num);
|
|
||||||
|
|
||||||
gst_buffer_list_iterator_add_group (it);
|
gst_buffer_list_iterator_add_group (it);
|
||||||
gst_buffer_list_iterator_add (it, header);
|
gst_buffer_list_iterator_add (it, header);
|
||||||
gst_buffer_list_iterator_add (it, sub);
|
gst_buffer_list_iterator_add (it, sub);
|
||||||
} else {
|
|
||||||
/* Fragmented packets */
|
|
||||||
guint offset = self->partition_offset[first];
|
|
||||||
guint left = self->partition_size[first];
|
|
||||||
gboolean start = (first == 0);
|
|
||||||
|
|
||||||
header = gst_rtp_vp8_create_header_buffer (start, FALSE,
|
return GST_BUFFER_SIZE (sub);
|
||||||
FI_FRAG_START, buffer);
|
|
||||||
sub = gst_buffer_create_sub (buffer, offset, available);
|
|
||||||
offset += available;
|
|
||||||
|
|
||||||
gst_buffer_list_iterator_add_group (it);
|
|
||||||
gst_buffer_list_iterator_add (it, header);
|
|
||||||
gst_buffer_list_iterator_add (it, sub);
|
|
||||||
|
|
||||||
left -= available;
|
|
||||||
|
|
||||||
for (; left > available; left -= available) {
|
|
||||||
header = gst_rtp_vp8_create_header_buffer (start, FALSE,
|
|
||||||
FI_FRAG_MIDDLE, buffer);
|
|
||||||
|
|
||||||
sub = gst_buffer_create_sub (buffer, offset, available);
|
|
||||||
offset += available;
|
|
||||||
|
|
||||||
gst_buffer_list_iterator_add_group (it);
|
|
||||||
gst_buffer_list_iterator_add (it, header);
|
|
||||||
gst_buffer_list_iterator_add (it, sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
mark = (first + 1 == self->n_partitions);
|
|
||||||
|
|
||||||
header = gst_rtp_vp8_create_header_buffer (start, mark,
|
|
||||||
FI_FRAG_END, buffer);
|
|
||||||
sub = gst_buffer_create_sub (buffer, offset, left);
|
|
||||||
|
|
||||||
gst_buffer_list_iterator_add_group (it);
|
|
||||||
gst_buffer_list_iterator_add (it, header);
|
|
||||||
gst_buffer_list_iterator_add (it, sub);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,10 +378,9 @@ gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBufferList *list;
|
GstBufferList *list;
|
||||||
GstBufferListIterator *it;
|
GstBufferListIterator *it;
|
||||||
guint current;
|
guint offset;
|
||||||
|
|
||||||
if (G_UNLIKELY (!gst_rtp_vp8_pay_parse_frame (self, buffer))) {
|
if (G_UNLIKELY (!gst_rtp_vp8_pay_parse_frame (self, buffer))) {
|
||||||
/* FIXME throw flow error */
|
|
||||||
g_message ("Failed to parse frame");
|
g_message ("Failed to parse frame");
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -405,24 +388,44 @@ gst_rtp_vp8_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
||||||
list = gst_buffer_list_new ();
|
list = gst_buffer_list_new ();
|
||||||
it = gst_buffer_list_iterate (list);
|
it = gst_buffer_list_iterate (list);
|
||||||
|
|
||||||
for (current = 0; current < self->n_partitions;) {
|
for (offset = 0; offset < GST_BUFFER_SIZE (buffer);)
|
||||||
guint n;
|
offset += gst_rtp_vp8_payload_next (self, it, offset, buffer);
|
||||||
|
|
||||||
n = gst_rtp_vp8_payload_next (self, it, current, buffer);
|
|
||||||
current += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_basertppayload_push_list (payload, list);
|
ret = gst_basertppayload_push_list (payload, list);
|
||||||
gst_buffer_list_iterator_free (it);
|
gst_buffer_list_iterator_free (it);
|
||||||
|
|
||||||
|
/* Incremenent and wrap the picture id if it overflows */
|
||||||
|
if ((self->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS &&
|
||||||
|
++self->picture_id >= 0x80) ||
|
||||||
|
(self->picture_id_mode == VP8_PAY_PICTURE_ID_15BITS &&
|
||||||
|
++self->picture_id >= 0x8000))
|
||||||
|
self->picture_id = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_rtp_vp8_pay_handle_event (GstPad * pad, GstEvent * event)
|
||||||
|
{
|
||||||
|
GstRtpVP8Pay *self = GST_RTP_VP8_PAY (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START) {
|
||||||
|
if (obj->picture_id_mode == VP8_PAY_PICTURE_ID_7BITS)
|
||||||
|
obj->picture_id = g_random_int_range (0, G_MAXUINT8) & 0x7F;
|
||||||
|
else if (obj->picture_id_mode == VP8_PAY_PICTURE_ID_15BITS)
|
||||||
|
obj->picture_id = g_random_int_range (0, G_MAXUINT16) & 0x7FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_object_unref (self);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_vp8_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
|
gst_rtp_vp8_pay_set_caps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gst_basertppayload_set_options (payload, "video", TRUE,
|
gst_basertppayload_set_options (payload, "video", TRUE,
|
||||||
"VP8-DRAFT-0-3-2", 90000);
|
"VP8-DRAFT-IETF-01", 90000);
|
||||||
return gst_basertppayload_set_outcaps (payload, NULL);
|
return gst_basertppayload_set_outcaps (payload, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS typedef struct _GstRtpVP8Pay GstRtpVP8Pay;
|
G_BEGIN_DECLS typedef struct _GstRtpVP8Pay GstRtpVP8Pay;
|
||||||
typedef struct _GstRtpVP8PayClass GstRtpVP8PayClass;
|
typedef struct _GstRtpVP8PayClass GstRtpVP8PayClass;
|
||||||
|
typedef enum _PictureIDMode PictureIDMode;
|
||||||
|
|
||||||
|
enum _PictureIDMode {
|
||||||
|
VP8_PAY_NO_PICTURE_ID,
|
||||||
|
VP8_PAY_PICTURE_ID_7BITS,
|
||||||
|
VP8_PAY_PICTURE_ID_15BITS,
|
||||||
|
};
|
||||||
|
|
||||||
struct _GstRtpVP8PayClass
|
struct _GstRtpVP8PayClass
|
||||||
{
|
{
|
||||||
|
@ -41,6 +48,8 @@ struct _GstRtpVP8Pay
|
||||||
* folowed by max. 8 data partitions. last offset is the end of the buffer */
|
* folowed by max. 8 data partitions. last offset is the end of the buffer */
|
||||||
guint partition_offset[10];
|
guint partition_offset[10];
|
||||||
guint partition_size[9];
|
guint partition_size[9];
|
||||||
|
PictureIDMode picture_id_mode;
|
||||||
|
guint16 picture_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_rtp_vp8_pay_get_type (void);
|
GType gst_rtp_vp8_pay_get_type (void);
|
||||||
|
|
Loading…
Reference in a new issue