[asterisk-commits] rizzo: branch rizzo/video_v2 r82513 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Sep 16 13:56:37 CDT 2007
Author: rizzo
Date: Sun Sep 16 13:56:37 2007
New Revision: 82513
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82513
Log:
another interim commit for the frame splitting routine.
This version does not work so don't try it!
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=82513&r1=82512&r2=82513
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Sun Sep 16 13:56:37 2007
@@ -898,39 +898,6 @@
}
-/*
- * Find the next PSC (Picture Start Code) of the frame.
- * If everything is correct, we have a couple of 0 bytes in the psc.
- */
-static uint8_t *get_psc(uint8_t *begin, uint8_t *end, int packet_size)
-{
-#if 0
- int i;
- uint8_t *ret=NULL;
- uint8_t *p;
- if (begin==end) return NULL;
- for(i=1,p=begin+1;p<end && i<packet_size;++i,++p){
- if (p[-1]==0 && p[0]==0){
- ret=p-1;
- }
- p++;/* to skip possible 0 after the PSC that would make a double detection */
- }
-#else
- uint8_t *p, *ret = NULL;
- if(begin == end) return NULL;
- for(p = begin; p < end-2; ++p) {
- if(p[0] == 0 && p[1] == 0) {
- ret = p;
- break;
- }
- }
- if ( (p && ret - begin > 1400) || (!p && end - begin > 1400))
- fprintf(stderr, "get_psc in %d size %d found %p %d\n",
- end - begin, packet_size, p, ret - begin);
-#endif
- return ret;
-}
-
#ifndef MIN
#define MIN(a, b) (a) < (b) ? (a) : (b)
#endif
@@ -938,27 +905,40 @@
/*
* Create RTP/H.263 fragmets to avoid IP fragmentation
*/
-static struct ast_frame *create_video_segment(struct video_out_desc *out, uint8_t *start, uint8_t *end, int last_packet)
-{
- int len = end-start;
+static struct ast_frame *split_frame(struct video_out_desc *out, int len)
+{
uint8_t *data;
struct ast_frame *cur = NULL, *first = NULL;
int header = 0; // the first frag contains the PSC
-
- if (len > out->mtu)
- ast_log(LOG_WARNING, "watch out, oversized frame %d\n", len);
+ uint8_t *start = out->decbuf.data;
+ int have_psc = 0; /* did we skip 2 bytes for this frame ? */
+
while (len > 0) {
+ /* first try to split on a psc. if not, then create an artificial break */
struct ast_frame *f = ast_malloc(sizeof(*f));
- int size = len; // MIN(len, out->mtu);
-
+ int size = MIN(len, out->mtu + 2);
+ uint8_t *p;
+ for (p = start; p < start + size -2; p++) {
+ if (p[0] == 0 && p[1] == 0)
+ break;
+ }
+ if (p == 0) {
+ start += 2;
+ have_psc = 1; /* info for next frame */
+ continue;
+ }
+ if (p - start > out->mtu) {
+ ast_log(LOG_WARNING, "no psc in frame sized %d\n", len);
+ size = out->mtu;
+ }
if (cur)
AST_LIST_NEXT(cur, frame_list) = f;
else
first = f;
cur = f;
- data = ast_malloc(size+header);
- memcpy(data+header, start, size);
+ data = ast_malloc(size+2);
+ memcpy(data+2, start, size);
f->has_timing_info = 1;
f->ts = ast_tvdiff_ms(ast_tvnow(), out->ts);
@@ -977,55 +957,20 @@
f->data = data;
AST_LIST_NEXT(f, frame_list) = NULL;
- if (header == 2)
- data[0] = data[1] = 0; // P == 0
- else {
+ data[0] = data[1] = 0; // P == 0
+ if (have_psc)
data[0] |= 0x04; // P == 1
- header = 2;
- }
-
+
+ if (p - start > out->mtu)
+ have_psc = 0; /* info for next frame */
start += size;
len -= size;
}
if (cur)
- cur->subclass |= last_packet; // RTP Marker
+ cur->subclass |= 1; // RTP Marker
return first;
-}
-
-/*
- * Search for PSCs and create ast_frame list of RTP packets
- */
-static struct ast_frame *split_frame(struct video_out_desc *out, int len)
-{
- uint8_t *lastpsc = out->decbuf.data;
- uint8_t *end = out->decbuf.data+len;
- uint8_t *psc, *pos;
- struct ast_frame *f, *fp = NULL, *ftop = NULL;
- int last;
-
- while(1) {
- psc = get_psc(lastpsc+2, end, len);
-
- pos = (psc == NULL) ? end : psc;
- last = (psc == NULL) ? 1 : 0;
-
- f = create_video_segment(out, lastpsc, pos, last);
- lastpsc = psc;
-
- if(fp)
- AST_LIST_NEXT(fp, frame_list) = f;
- else
- ftop = f;
-
- if(psc == NULL)
- break;
-
- fp = f;
- }
- // ast_log(LOG_WARNING, "split_frame %d returns %p\n", len, ftop);
- return ftop;
}
static struct ast_frame *get_video_frames(struct video_desc *env)
More information about the asterisk-commits
mailing list