GST_H263_PAYLOAD_PICTURE_FORMAT_PLUS = 7
} GstRtpH263PayPictureFormat;
-static guint format_props[8][2] = { {254, 254},
+static const guint format_props[8][2] = { {254, 254},
{6, 8},
{9, 11},
{18, 22},
*/
#define MCBPC_I_LEN 9
#define MCBPC_I_WID 6
-static guint32 mcbpc_I[9][6] = {
+static const guint32 mcbpc_I[9][6] = {
{0x8000, 0x8000, 1, 0, 0, 3},
{0x2000, 0xe000, 3, 0, 1, 3},
{0x4000, 0xe000, 3, 1, 0, 3},
*/
#define MCBPC_P_LEN 21
#define MCBPC_P_WID 6
-static guint16 mcbpc_P[21][6] = {
+static const guint16 mcbpc_P[21][6] = {
{0x8000, 0x8000, 1, 0, 0, 0},
{0x3000, 0xf000, 4, 0, 1, 0},
{0x2000, 0xf000, 4, 1, 0, 0},
*/
#define CBPY_LEN 16
#define CBPY_WID 7
-static guint8 cbpy_I[16][7] = {
+static const guint8 cbpy_I[16][7] = {
{0x30, 0xf0, 4, 0, 0, 0, 0},
{0x28, 0xf8, 5, 0, 0, 0, 1},
{0x20, 0xf8, 5, 0, 0, 1, 0},
/*
* P-frame CBPY (code, mask, nbits, Y0, Y1, Y2, Y3)
*/
-static guint8 cbpy_P[16][7] = {
+static const guint8 cbpy_P[16][7] = {
{0x30, 0xf0, 4, 1, 1, 1, 1},
{0x28, 0xf8, 5, 1, 1, 1, 0},
{0x20, 0xf8, 5, 1, 1, 0, 1},
*/
#define TCOEF_LEN 103
#define TCOEF_WID 6
-static guint16 tcoef[103][6] = {
+static const guint16 tcoef[103][6] = {
{0x8000, 0xc000, 3, 0, 0, 1},
{0xf000, 0xf000, 5, 0, 0, 2},
{0x5400, 0xfc00, 7, 0, 0, 3},
*/
#define MVD_LEN 64
#define MVD_WID 5
-static guint16 mvd[64][5] = {
+static const guint16 mvd[64][5] = {
{0x0028, 0xfff8, 13, 0x0060, 0x0020},
{0x0038, 0xfff8, 13, 0x0061, 0x0021},
{0x0050, 0xfff0, 12, 0x0062, 0x0022},
PROP_MODE_A_ONLY
};
-/* elementfactory information */
-static const GstElementDetails gst_rtp_h263pay_details =
-GST_ELEMENT_DETAILS ("RTP H263 packet payloader",
- "Codec/Payloader/Network",
- "Payload-encodes H263 video in RTP packets (RFC 2190)",
- "Neil Stratford <neils@vipadia.com>"
- "Dejan Sakelsak <dejan.sakelsak@marand.si>");
-
static GstStaticPadTemplate gst_rtp_h263_pay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
"clock-rate = (int) 90000, " "encoding-name = (string) \"H263\"")
);
-static void gst_rtp_h263_pay_class_init (GstRtpH263PayClass * klass);
-static void gst_rtp_h263_pay_base_init (GstRtpH263PayClass * klass);
-static void gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay);
static void gst_rtp_h263_pay_finalize (GObject * object);
static gboolean gst_rtp_h263_pay_setcaps (GstBaseRTPPayload * payload,
guint ind);
static void gst_rtp_h263_pay_package_destroy (GstRtpH263PayPackage * pack);
-static GstBaseRTPPayloadClass *parent_class = NULL;
+GST_BOILERPLATE (GstRtpH263Pay, gst_rtp_h263_pay, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD)
-static GType
-gst_rtp_h263_pay_get_type (void)
-{
- static GType rtph263pay_type = 0;
-
- if (!rtph263pay_type) {
- static const GTypeInfo rtph263pay_info = {
- sizeof (GstRtpH263PayClass),
- (GBaseInitFunc) gst_rtp_h263_pay_base_init,
- NULL,
- (GClassInitFunc) gst_rtp_h263_pay_class_init,
- NULL,
- NULL,
- sizeof (GstRtpH263Pay),
- 0,
- (GInstanceInitFunc) gst_rtp_h263_pay_init,
- };
-
- rtph263pay_type =
- g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRtpH263Pay",
- &rtph263pay_info, 0);
- }
- return rtph263pay_type;
-}
-
-static void
-gst_rtp_h263_pay_base_init (GstRtpH263PayClass * klass)
+ static void gst_rtp_h263_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_h263_pay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_h263_pay_sink_template));
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rtp_h263_pay_src_template);
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rtp_h263_pay_sink_template);
- gst_element_class_set_details (element_class, &gst_rtp_h263pay_details);
+ gst_element_class_set_details_simple (element_class,
+ "RTP H263 packet payloader", "Codec/Payloader/Network/RTP",
+ "Payload-encodes H263 video in RTP packets (RFC 2190)",
+ "Neil Stratford <neils@vipadia.com>"
+ "Dejan Sakelsak <dejan.sakelsak@marand.si>");
}
static void
gobject_class = (GObjectClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
gobject_class->finalize = gst_rtp_h263_pay_finalize;
gstbasertppayload_class->set_caps = gst_rtp_h263_pay_setcaps;
PROP_MODE_A_ONLY, g_param_spec_boolean ("modea-only",
"Fragment packets in mode A Only",
"Disable packetization modes B and C", DEFAULT_MODE_A,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
GST_DEBUG_CATEGORY_INIT (rtph263pay_debug, "rtph263pay", 0,
"H263 RTP Payloader");
}
static void
-gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay)
+gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay, GstRtpH263PayClass * klass)
{
rtph263pay->adapter = gst_adapter_new ();
}
static GstRtpH263PayPackage *
-gst_rtp_h263_pay_package_new_empty ()
+gst_rtp_h263_pay_package_new_empty (void)
{
return (GstRtpH263PayPackage *) g_malloc0 (sizeof (GstRtpH263PayPackage));
}
for (i = 3; i < range - 3; i++) {
if ((current[i] == 0x0) &&
(current[i + 1] == 0x0) && (current[i + 2] >> 7 == 0x1)) {
- GST_LOG ("GOB end found at: %p start: %p len: %d", current + i - 1,
- boundry->end + 1, current + i - boundry->end + 2);
+ GST_LOG ("GOB end found at: %p start: %p len: %u", current + i - 1,
+ boundry->end + 1, (guint) (current + i - boundry->end + 2));
gst_rtp_h263_pay_boundry_init (boundry, boundry->end + 1,
current + i - 1, 0, 0);
* decode CBPY and return index in table or -1 if not found
*/
static gint
-gst_rtp_h263_pay_decode_cbpy (guint32 value, guint8 cbpy_table[16][7])
+gst_rtp_h263_pay_decode_cbpy (guint32 value, const guint8 cbpy_table[16][7])
{
gint i;
} else {
if (n > rest_bits) {
context->window =
- (context->window << rest_bits) | (*context->
- win_end & (((guint) pow (2.0, (double) rest_bits)) - 1));
+ (context->
+ window << rest_bits) | (*context->win_end & (((guint) pow (2.0,
+ (double) rest_bits)) - 1));
n -= rest_bits;
rest_bits = 0;
} else {
/*
* Copy the payload data in the buffer
*/
- GST_DEBUG ("Copiing memory");
+ GST_DEBUG ("Copying memory");
memcpy (payload, (guint8 *) package->payload_start, package->payload_len);
/*
(context->gobs[last]->end - context->gobs[first]->start) + 1;
pack->marker = FALSE;
- if (last == format_props[context->piclayer->ptype_srcformat][0] - 1) {
+ if (last == context->no_gobs - 1) {
pack->marker = TRUE;
}
GstRtpH263PayBoundry bound;
gint first;
guint payload_len;
+ gboolean forcea = FALSE;
GST_DEBUG ("Frame too large for MTU");
/*
gst_rtp_h263_pay_boundry_init (&bound, NULL, rtph263pay->data - 1, 0, 0);
context->gobs =
- (GstRtpH263PayGob **) g_malloc0 (format_props[context->piclayer->
- ptype_srcformat][0] * sizeof (GstRtpH263PayGob *));
+ (GstRtpH263PayGob **) g_malloc0 (format_props[context->
+ piclayer->ptype_srcformat][0] * sizeof (GstRtpH263PayGob *));
for (i = 0; i < format_props[context->piclayer->ptype_srcformat][0]; i++) {
GST_DEBUG ("Searching for gob %d", i);
if (!gst_rtp_h263_pay_gobfinder (rtph263pay, &bound)) {
- GST_WARNING
- ("No GOB's were found in data stream! Please enable RTP mode in encoder. Forcing mode A for now.");
- ret = gst_rtp_h263_send_entire_frame (rtph263pay, context);
- goto end;
+ if (i <= 1) {
+ GST_WARNING
+ ("No GOB's were found in data stream! Please enable RTP mode in encoder. Forcing mode A for now.");
+ ret = gst_rtp_h263_send_entire_frame (rtph263pay, context);
+ goto end;
+ } else {
+ /* try to send fragments corresponding to found GOBs */
+ forcea = TRUE;
+ break;
+ }
}
context->gobs[i] = gst_rtp_h263_pay_gob_new (&bound, i);
context->gobs[i]->start, context->gobs[i]->length,
context->gobs[i]->ebit, context->gobs[i]->sbit);
}
+ /* NOTE some places may still assume this to be the max possible */
+ context->no_gobs = i;
+ GST_DEBUG ("Found %d GOBS of maximum %d",
+ context->no_gobs, format_props[context->piclayer->ptype_srcformat][0]);
// Make packages smaller than MTU
// A mode
first = 0;
payload_len = 0;
i = 0;
- while (i < format_props[context->piclayer->ptype_srcformat][0]) {
+ while (i < context->no_gobs) {
if (context->gobs[i]->length >= context->mtu) {
if (payload_len == 0) {
GST_DEBUG ("GOB len > MTU");
- if (rtph263pay->prop_payload_mode) {
+ if (rtph263pay->prop_payload_mode || forcea) {
payload_len = context->gobs[i]->length;
goto force_a;
}
GST_DEBUG ("GOB %d fills mtu", i);
payload_len += context->gobs[i]->length;
i++;
- if (i == format_props[context->piclayer->ptype_srcformat][0]) {
+ if (i == context->no_gobs) {
GST_DEBUG ("LAST GOB %d", i);
goto payload_a_push;
}
gst_rtp_h263_pay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rtph263pay",
- GST_RANK_NONE, GST_TYPE_RTP_H263_PAY);
+ GST_RANK_SECONDARY, GST_TYPE_RTP_H263_PAY);
}