[asterisk-commits] rizzo: branch rizzo/video_v2 r82591 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 17 11:35:31 CDT 2007
Author: rizzo
Date: Mon Sep 17 11:35:31 2007
New Revision: 82591
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82591
Log:
more debugging...
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=82591&r1=82590&r2=82591
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Mon Sep 17 11:35:31 2007
@@ -922,53 +922,55 @@
*/
static struct ast_frame *split_frame(struct video_out_desc *out, int len)
{
- uint8_t *data;
struct ast_frame *cur = NULL, *first = NULL;
- uint8_t *start = out->decbuf.data;
- int have_psc = 0; /* did we skip 2 bytes for this frame ? */
- int l; /* size of the current fragment */
- l = len;
-
- for (;len > 0; start += l, len -= l) {
- /* First try to split on a psc. If not, create an artificial break */
+ uint8_t *d = out->decbuf.data;
+ int l = len; /* size of the current fragment. If 0, must look for a psc */
+ int totlen = len, frags = 0;
+
+ for (;len > 0; len -= l, d += l) {
+ uint8_t *data;
struct ast_frame *f;
-#if 0
- int max_size = len;
- max_size = MIN(len, out->mtu + 2);
- for (l = 0; l < max_size -2; l++) {
- if (start[l] == 0 && start[l+1] == 0)
- break;
- }
- if (l == 0) {
- l = 2;
- have_psc = 1; /* info for next frame */
- continue;
- }
- if (l > out->mtu) {
+ int i;
+
+ if (len >= 2 && d[0] == 0 && d[1] == 0) {
+ /* we are starting a new block, so look for a PSC. */
+ for (i = 2; i < len - 2; i++) {
+ if (d[i] == 0 && d[i+1] == 0) {
+ l = i;
+ break;
+ }
+ }
+ }
+ if (l > out->mtu || l > len) {
+ /* psc not found, split */
ast_log(LOG_WARNING, "no psc in frame sized %d\n", len);
- l = out->mtu;
- }
-#endif
- /* temporary - assume we have psc, drop first 2 bytes, send one large packet */
-
- ast_log(LOG_WARNING, "len %d\n", l);
+ l = MIN(len, out->mtu);
+ }
+ if (l < 1 || l > 128*1024) {
+ ast_log(LOG_WARNING, "--- frame error l %d\n", l);
+ break;
+ }
f = ast_calloc(1, sizeof(*f));
- data = ast_calloc(1, l+2);
- if (l < 1 || l > 128*1024 || f == NULL || data == NULL) {
+ data = ast_calloc(1, l+2); /* 2 extra bytes for header */
+ if (f == NULL || data == NULL) {
ast_log(LOG_WARNING, "--- frame error f %p d %p l %d\n",
- f, data, l);
+ f, d, l);
+ if (f)
+ ast_free(f);
+ if (d)
+ ast_free(d);
break;
}
f->mallocd = AST_MALLOCD_DATA | AST_MALLOCD_HDR;
f->data = data;
- if (data[0] == 0 && data[1] == 0) { /* a psc */
- memcpy(data, start, l);
- data[0] |= 0x04; // P == 1
+ if (d[0] == 0 && d[1] == 0) { /* we start with a psc */
+ memcpy(data, d, l);
+ data[0] |= 0x04; // set P == 1, and we are done
f->datalen = l;
- } else {
+ } else { /* no psc, create a header */
data[0] = data[1] = 0; // P == 0
- memcpy(data + 2, start, l);
+ memcpy(data + 2, d, l);
f->datalen = l + 2;
}
@@ -979,8 +981,6 @@
f->samples = 0;
f->offset = 0;
f->src = "Console";
- // This flags tells asterisk that the data and
- // the header are dinamically allocated
f->delivery.tv_sec = 0;
f->delivery.tv_usec = 0;
f->seqno = ++(out->lasttxframe);
@@ -991,13 +991,14 @@
else
first = f;
cur = f;
- have_psc = (l <= out->mtu);
+ frags++;
+ ast_log(LOG_WARNING, "-- frag %d size %d left %d\n", frags, f->datalen, len - l);
}
if (cur)
cur->subclass |= 1; // RTP Marker
- // ast_log(LOG_WARNING, "done, first %p\n", first);
+ ast_log(LOG_WARNING, "done, totlen %d frags %d\n", totlen, frags);
return first;
}
@@ -1073,7 +1074,6 @@
fprintf(stderr, "video_out_init fd %d\n", env->out.fd);
video_out_init(&env->out, CONSOLE_FORMAT_VIDEO);
}
- ast_log(LOG_WARNING, "console_video_start owner %p", owner);
env->out.ts = ast_tvnow();
}
#endif /* video support */
More information about the asterisk-commits
mailing list