[asterisk-commits] rizzo: branch rizzo/video_v2 r82745 - /team/rizzo/video_v2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 18 02:11:36 CDT 2007


Author: rizzo
Date: Tue Sep 18 02:11:36 2007
New Revision: 82745

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82745
Log:
some debugging code

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=82745&r1=82744&r2=82745
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Tue Sep 18 02:11:36 2007
@@ -211,8 +211,6 @@
 		x_ofs, y_ofs, v->w, v->h, AllPlanes, ZPixmap);
 	if (v->image == NULL) {
 		ast_log(LOG_WARNING, "error creating Ximage\n");
-		XCloseDisplay(v->dpy);
-		v->image = NULL;
 		goto error;
 	}
 	ast_log(LOG_WARNING, "image: data %p %d bpp, mask 0x%lx 0x%lx 0x%lx\n",
@@ -272,12 +270,16 @@
 	return v->fd;
 
 error:
+	if (v->dpy)
+		XCloseDisplay(v->dpy);
+	v->dpy = NULL;
 	if (v->fd >= 0)
 		close(v->fd);
 	v->fd = -1;
 	if (v->buf.data)
 		ast_free(v->buf.data);
 	v->buf.data = NULL;
+	v->buf.size = v->buf.used = 0;	/* for safety */
 	return -1;
 }
 
@@ -344,8 +346,6 @@
 		}
 	}
 }
-
-static void show_frame(struct video_desc *env, int out);
 
 /* Helper function to process incoming video.
  * For each incoming video call invoke ffmpeg_init() to intialize
@@ -691,7 +691,7 @@
  * The size is taken from the configuration.
  *
  * TODO: change the call img_convert(): it is deprecated.
- * 'out' is set to display the outgoing stream
+ * 'out' is 0 for received data, 1 for the local video, 2 on init (debug)
  */
 static void show_frame(struct video_desc *env, int out)
 {
@@ -705,8 +705,10 @@
 	char *src = NULL;	/* pixel input */
 	int pix_fmt;
 
-	int fmt = SDL_YV12_OVERLAY;
-	fmt = SDL_IYUV_OVERLAY;
+	int fmt = SDL_IYUV_OVERLAY;	/* YV12 causes flicker in SDL */
+
+	if (out == 2)
+		ast_log(LOG_WARNING, "out %d initialized %d\n", out, env->initialized);
 
 	if (!env->initialized)
 		return;
@@ -731,6 +733,7 @@
 #endif
 
 	ast_mutex_lock(&env->lock);
+	// ast_log(LOG_WARNING, "in critical section, screen %p\n", env->screen);
 	/* first time we run, we also initialize sdl and the two bitmaps we use */
 	if(env->screen == NULL) {
 		env->screen = SDL_SetVideoMode(2*w, h, 0, 0);
@@ -745,9 +748,10 @@
 		env->bmp[0] = SDL_CreateYUVOverlay(w, h, fmt, env->screen);
 	if(!env->bmp[1])
 		env->bmp[1] = SDL_CreateYUVOverlay(w, h, fmt, env->screen);
+	// ast_log(LOG_WARNING, "end critical section\n");
 	ast_mutex_unlock(&env->lock);
 
-	bmp = env->bmp[out];
+	bmp = env->bmp[out ? 1 : 0];
 	SDL_LockYUVOverlay(bmp);
 	pict.data[0] = bmp->pixels[0];
 	pict.data[1] = bmp->pixels[1];
@@ -789,12 +793,17 @@
 
 #endif /* XXX replacement */
 	}
-	SDL_UnlockYUVOverlay(bmp);
 	rect.x = w*out;
 	rect.y = 0;
 	rect.w = w;
 	rect.h = h;
+	if (out > 1)
+		ast_log(LOG_WARNING, "about to display\n");
+
 	SDL_DisplayYUVOverlay(bmp, &rect);
+	if (out > 1)
+		ast_log(LOG_WARNING, "SDL_DisplayYUVOverlay done\n");
+	SDL_UnlockYUVOverlay(bmp);
 }
 
 /*
@@ -1077,8 +1086,9 @@
 	env->owner = owner;
         ast_pthread_create_background(&env->vthread, NULL, video_thread, env);
 	video_open(env);	/* also allocate out.buf.data */
-	show_frame(env, 1);
-
+	show_frame(env, 2);
+
+	ast_log(LOG_WARNING, "----------------- video_out_init buf %p owner %p\n", env->out.buf.data, owner);
 	if (env->out.buf.data && owner) {  /* talk to the local video source */
 		/* try to register the fd. Unfortunately, if the webcam
 		 * driver does not support select/poll we are out of luck.




More information about the asterisk-commits mailing list