[asterisk-commits] rizzo: branch rizzo/astobj2 r77265 - /team/rizzo/astobj2/channels/chan_oss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 26 07:32:32 CDT 2007
Author: rizzo
Date: Thu Jul 26 07:32:31 2007
New Revision: 77265
URL: http://svn.digium.com/view/asterisk?view=rev&rev=77265
Log:
more updates to this code - echo back the received
video stream to test the other direction as well.
Modified:
team/rizzo/astobj2/channels/chan_oss.c
Modified: team/rizzo/astobj2/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_oss.c?view=diff&rev=77265&r1=77264&r2=77265
==============================================================================
--- team/rizzo/astobj2/channels/chan_oss.c (original)
+++ team/rizzo/astobj2/channels/chan_oss.c Thu Jul 26 07:32:31 2007
@@ -346,6 +346,10 @@
SDL_Overlay *bmp;
int lastrxframe;
int discard;
+ struct timeval ts;
+ int received;
+
+ struct ast_frame *echo;
};
struct _cm { /* map ffmpeg codec types to asterisk formats */
@@ -419,6 +423,7 @@
env->bmp = NULL;
env->lastrxframe = -1;
+ env->ts = ast_tvnow();
codec = map_video_format(format);
ast_log(LOG_WARNING, "init for format 0x%x gives %d\n", format, codec);
avcodec_init();
@@ -473,6 +478,15 @@
*/
static void ffmpeg_uninit(struct video_desc *env)
{
+ struct ast_frame *f;
+ int i = 0;
+
+ while ( (f = env->echo) != NULL) {
+ env->echo = AST_LIST_NEXT(f, frame_list);
+ ast_frfree(f);
+ i++;
+ }
+ ast_log(LOG_WARNING, "ffmpeg_uninit drop %d frames\n", i);
if(env->context) {
avcodec_close(env->context);
av_free(env->context);
@@ -645,12 +659,26 @@
uint8_t *data;
int len;
struct video_desc *env = get_video_desc(chan);
+ struct timeval now = ast_tvnow();
+ int i;
+ struct ast_frame *f1, **fp;
if(!env->initialized)
ffmpeg_init(env, f->subclass);
if(!env->initialized)
return -1; /* error */
-
+ f1 = ast_frdup(f);
+ for (fp = &env->echo; (*fp) != NULL ; fp = &AST_LIST_NEXT((*fp), frame_list) )
+ ;
+ *fp = f1;
+
+ i = ast_tvdiff_ms(now, env->ts);
+ if (i > 1000) {
+ ast_log(LOG_WARNING, "received %d video frames in %d ms\n", env->received, i);
+ env->received = 0;
+ env->ts = now;
+ }
+ env->received++;
#if defined(DROP_PACKETS) && DROP_PACKETS > 0
/*
* Fragment of code to simulate lost/delayed packets
@@ -1369,9 +1397,35 @@
struct chan_oss_pvt *o = c->tech_pvt;
struct ast_frame *f = &o->read_f;
+ static int cnt;
+ static struct timeval ta;
+ struct timeval tb;
+
+ struct video_desc *env = get_video_desc(c);
+ if (env->echo) {
+ struct ast_frame *f1;
+ int i = 0;
+ for (f1 = env->echo; f1; f1 = AST_LIST_NEXT(f1, frame_list) )
+ i++;
+ ast_log(LOG_WARNING, "oss_read echo %d video frames\n", i);
+ }
+
+ tb = ast_tvnow();
+ if (tb.tv_sec > ta.tv_sec + 5) {
+ ast_log(LOG_WARNING, "read %d audio frames in %d ms\n",
+ cnt, ast_tvdiff_ms(tb, ta));
+ ta = tb;
+ cnt = 0;
+ }
+ cnt++;
+
/* XXX can be simplified returning &ast_null_frame */
/* prepare a NULL frame in case we don't have enough data to return */
bzero(f, sizeof(struct ast_frame));
+
+ AST_LIST_NEXT(f, frame_list) = env->echo;
+ env->echo = NULL;
+
f->frametype = AST_FRAME_NULL;
f->src = oss_tech.type;
More information about the asterisk-commits
mailing list