[asterisk-commits] rizzo: branch rizzo/video_v2 r85285 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 10 10:13:57 CDT 2007
Author: rizzo
Date: Wed Oct 10 10:13:56 2007
New Revision: 85285
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85285
Log:
more segmentation and reassembly stuff...
Modified:
team/rizzo/video_v2/channels/console_video.c
Modified: team/rizzo/video_v2/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/console_video.c?view=diff&rev=85285&r1=85284&r2=85285
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 10:13:56 2007
@@ -249,8 +249,8 @@
/*! \brief inizialize the decoder */
typedef int (*decoder_init_f)(struct video_in_desc *v);
-/*! \brief extract the bitstream from RTP frames */
-typedef uint8_t *(*decoder_decap_f)(uint8_t *data, int *len);
+/*! \brief extract the bitstream from RTP frames, return 0 if ok, 1 on error */
+typedef int (*decoder_decap_f)(struct fbuf_t *b, uint8_t *data, int len);
/*! \brief actually call the decoder */
typedef int (*decoder_decode_f)(struct video_in_desc *v, struct fbuf_t *b);
@@ -518,18 +518,6 @@
/*! \brief extract the bitstreem from the RTP payload.
* This is format dependent.
- * For h261, the format is defined in RFC 4587
- * and basically has a fixed 4-byte header as follows:
- * 3 bits SBIT start bit, how many msbits to ignore in first byte
- * 3 bits EBIT end bit, how many lsbits to ignore in last byte
- * 1 bit I 1 if frame only contain INTRA blocks
- * 1 bit V 0 if motion vector not used, 1 if may be used
- * 4 bits GOBN gob number at start of packet (0 for gob header)
- * 5 bits MBAP macroblock address predictor
- * 5 bits QUANT quantizer value
- * 5 bits HMVD horiz motion vector
- * 5 bits VMVD vert. motion vector
- *
* For h263+, the format is defined in RFC 2429
* and basically has a fixed 2-byte header as follows:
* 5 bits RR reserved, shall be 0
@@ -542,31 +530,29 @@
*
* XXX the code below is not complete.
*/
-static uint8_t *h263p_decap(uint8_t *data, int *len)
+static int h263p_decap(struct fbuf_t *b, uint8_t *data, int len)
{
int PLEN;
int P;
- if (*len < 2) {
- ast_log(LOG_WARNING, "invalid framesize %d\n", *len);
- *len = 0;
- return data;
+ if (len < 2) {
+ ast_log(LOG_WARNING, "invalid framesize %d\n", len);
+ return 1;
}
PLEN = rfc2429_get_PLEN(data);
P = rfc2429_get_P(data);
if (PLEN > 0) {
data += PLEN;
- (*len) -= PLEN;
+ len -= PLEN;
}
if (P)
data[0] = data[1] = 0;
else {
data += 2;
- (*len) -= 2;
- }
-
- return data;
+ len -= 2;
+ }
+ return fbuf_append(b, data, len, 0, 0); /* XXX no bit alignment support */
}
/*
@@ -771,22 +757,22 @@
}
/* XXX We only drop the header here, but maybe we need more. */
-static uint8_t *h263_decap(uint8_t *data, int *len)
-{
- if (*len < 4) {
- ast_log(LOG_WARNING, "invalid framesize %d\n", *len);
- *len = 0;
- return data;
+static int h263_decap(struct fbuf_t *b, uint8_t *data, int len)
+{
+ if (len < 4) {
+ ast_log(LOG_WARNING, "invalid framesize %d\n", len);
+ return 1; /* error */
}
if ( (data[0] & 0x80) == 0) {
- *len -= 4;
- return data+4;
+ len -= 4;
+ data += 4;
} else {
ast_log(LOG_WARNING, "unsupported mode 0x%x\n",
data[0]);
- }
- return data;
+ return 1;
+ }
+ return fbuf_append(b, data, len, 0, 0); /* XXX no bit alignment support yet */
}
static struct video_codec_desc h263_codec = {
@@ -920,16 +906,20 @@
/*
* Pieces might be unaligned so we really need to put them together.
*/
-static uint8_t *h261_decap(uint8_t *data, int *len)
-{
- if (*len < 4) {
- ast_log(LOG_WARNING, "invalid framesize %d\n", *len);
- *len = 0;
- return data;
- }
-
- *len -= 4;
- return data+4;
+static int h261_decap(struct fbuf_t *b, uint8_t *data, int len)
+{
+ int ebit, sbit;
+
+ if (len < 4) {
+ ast_log(LOG_WARNING, "invalid framesize %d\n", len);
+ return 1;
+ }
+ sbit = (data[0] >> 5) & 7;
+ ebit = (data[0] >> 2) & 7;
+ ast_log(LOG_WARNING, "sbit %d ebit %d\n", sbit, ebit);
+ len -= 4;
+ data += 4;
+ return fbuf_append(b, data, len, sbit, ebit);
}
static struct video_codec_desc h261_codec = {
@@ -1582,8 +1572,6 @@
*/
static int console_write_video(struct ast_channel *chan, struct ast_frame *f)
{
- uint8_t *data;
- int len;
struct video_desc *env = get_video_desc(chan);
struct video_in_desc *v = &env->in;
@@ -1636,15 +1624,10 @@
ast_log(LOG_WARNING, "empty video frame, discard\n");
return 0;
}
- len = f->datalen;
- data = env->current_codec->dec_decap(f->data, &len);
- if (len < 1 || len > 128*1024) {
- ast_log(LOG_WARNING, "--- huge frame %d\n", len);
+ if (env->current_codec->dec_decap(&v->dec_in, f->data, f->datalen)) {
+ ast_log(LOG_WARNING, "error in dec_decap, enter discard\n");
v->discard = 1;
- return 0;
- }
-
- fbuf_append(&v->dec_in, data, len, 0, 0);
+ }
if (f->subclass & 0x01) { // RTP Marker
if (env->current_codec->dec_run(v, &v->dec_in)) {
show_frame(env, 0);
More information about the asterisk-commits
mailing list