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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 12 11:22:36 CST 2007


Author: rizzo
Date: Mon Nov 12 11:22:35 2007
New Revision: 89182

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89182
Log:
add code to read the keypad icon using the SDL_image library.


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=89182&r1=89181&r2=89182
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Mon Nov 12 11:22:35 2007
@@ -129,8 +129,8 @@
  
 +# GCC configuration flags for SDL library
 +ASTCFLAGS+=`sdl-config --cflags`
-+# Add library for ffmpeg and SDL lib.
-+AST_LIBS+=-lavcodec -lz -lm -g `sdl-config --libs`
++# Add library for ffmpeg and SDL lib. You also need SDL_image
++AST_LIBS+=-lavcodec -lz -lm -g `sdl-config --libs` -lSDL_image
 +
  # This is used when generating the doxygen documentation
  ifneq ($(DOT),:)
@@ -153,6 +153,7 @@
 #endif
 
 #include <SDL/SDL.h>
+#include <SDL/SDL_image.h>	/* for loading images */
 
 /*
  * In many places we use buffers to store the raw frames (but not only),
@@ -202,6 +203,7 @@
 	struct fbuf_t	enc_in;		/* encoder input buffer, allocated in video_out_init() */
 	struct fbuf_t	enc_out;	/* encoder output buffer, allocated in video_out_init() */
 	struct fbuf_t	loc_dpy;	/* display source buffer, no buffer (managed by SDL in bmp[1]) */
+	struct fbuf_t	keypad_dpy;	/* keypad source buffer, XXX */
 
 	struct video_codec_desc *enc;	/* encoder */
 	AVCodecContext	*enc_ctx;	/* encoding context */
@@ -288,6 +290,7 @@
  */
 struct video_desc {
 	char			codec_name[64];
+	char			keypad_file[256];
 
 	pthread_t		vthread;	/* video thread */
 	int			shutdown;	/* set to shutdown vthread */
@@ -1982,12 +1985,13 @@
 	p_out.linesize[2] = bmp->pitches[2];
 
 	my_scale(b_in, p_in, b_out, &p_out);
+	SDL_UnlockYUVOverlay(bmp);
 
 	/* lock to protect access to Xlib by different threads. */
 	ast_mutex_lock(&env->sdl_lock);
+	SDL_UpdateRects(env->screen, 1, &env->win[WIN_KEYPAD].rect);// XXX inefficient
 	SDL_DisplayYUVOverlay(bmp, &env->win[out].rect);
 	ast_mutex_unlock(&env->sdl_lock);
-	SDL_UnlockYUVOverlay(bmp);
 }
 
 static struct video_desc *get_video_desc(struct ast_channel *c);
@@ -2238,6 +2242,7 @@
 	copy_geometry(ei, c);	/* camera inherits from encoder input */
 	copy_geometry(ei, rd);	/* remote display inherits from encoder input */
 	copy_geometry(rd, ld);	/* local display inherits from remote display */
+	copy_geometry(rd, &env->out.keypad_dpy);	/* keypad inherits from remote display */
 }
 
 /* setup an sdl overlay and associated info, return 0 on success, != 0 on error */
@@ -2254,6 +2259,23 @@
 	return 0;
 }
 
+static SDL_Surface *get_keypad(struct video_desc *env)
+{
+	//SDL_Surface *image;
+	SDL_Surface *temp;
+ 
+	//temp = SDL_LoadBMP("/tmp/layer0.bmp");
+	temp = IMG_Load(env->keypad_file);
+	if (temp == NULL) {
+		fprintf(stderr, "Unable to load bitmap: %s\n", SDL_GetError());
+		return NULL;
+	}
+	return temp;
+	//image = SDL_DisplayFormat(temp);
+	//SDL_FreeSurface(temp);
+	//return image;
+}
+
 /*!
  * The first call to the video code, called by oss_new() or similar.
  * Here we initialize the various components we use, namely SDL for display,
@@ -2266,6 +2288,7 @@
 {
 	int dpy_fmt = SDL_IYUV_OVERLAY;	/* YV12 causes flicker in SDL */
 	int maxw, maxh;
+	SDL_Surface *keypad;
 
 	if (env == NULL)	/* video not initialized */
 		return;
@@ -2305,8 +2328,15 @@
 		/* again not fatal, just we won't display anything */
 		goto no_sdl;
 	}
-	maxw = env->in.rem_dpy.w + env->out.loc_dpy.w + 200;
-	maxh = MAX( MAX(env->in.rem_dpy.h, env->out.loc_dpy.h), 200);
+
+	keypad = get_keypad(env);
+	if (keypad) {
+		env->out.keypad_dpy.w = keypad->w;
+		env->out.keypad_dpy.h = keypad->h;
+	}
+
+	maxw = env->in.rem_dpy.w + env->out.loc_dpy.w + env->out.keypad_dpy.w;
+	maxh = MAX( MAX(env->in.rem_dpy.h, env->out.loc_dpy.h), env->out.keypad_dpy.h);
 	env->screen = SDL_SetVideoMode(maxw, maxh, 0, 0);
 	if (!env->screen) {
 		ast_log(LOG_ERROR, "SDL: could not set video mode - exiting\n");
@@ -2316,13 +2346,26 @@
 	if (set_win(env->screen, &env->win[WIN_REMOTE], dpy_fmt,
 			env->in.rem_dpy.w, env->in.rem_dpy.h, 0, 0))
 		goto no_sdl;
+	if (set_win(env->screen, &env->win[WIN_LOCAL], dpy_fmt,
+			env->out.loc_dpy.w, env->out.loc_dpy.h, env->in.rem_dpy.w + env->out.keypad_dpy.w, 0))
+		goto no_sdl;
+#if 1
+	if (keypad) { struct SDL_Rect dest;
+		dest.x = env->in.rem_dpy.w;
+		dest.y = 0;
+		dest.w = keypad->w;
+		dest.h = keypad->h;
+		env->win[WIN_KEYPAD].rect = dest;
+
+		SDL_BlitSurface(keypad, NULL, env->screen, &dest);
+		SDL_UpdateRects(env->screen, 1, &dest);
+	}
+#else
 	if (set_win(env->screen, &env->win[WIN_KEYPAD], dpy_fmt,
-			200, 200, env->in.rem_dpy.w, 0))
+			env->out.keypad_dpy.w, env->out.keypad_dpy.h, env->in.rem_dpy.w, 0))
 		goto no_sdl;
-	/* XXX later we redefine local ? */
-	if (set_win(env->screen, &env->win[WIN_LOCAL], dpy_fmt,
-			env->out.loc_dpy.w, env->out.loc_dpy.h, env->in.rem_dpy.w + 200, 0))
-		goto no_sdl;
+#endif
+
 	ast_mutex_init(&env->sdl_lock);
 	env->sdl_ok = 1;
 
@@ -2450,6 +2493,8 @@
         M_F("camera_size", video_geom(&env->out.loc_src, val))
         M_F("local_size", video_geom(&env->out.loc_dpy, val))
         M_F("remote_size", video_geom(&env->in.rem_dpy, val))
+        M_F("keypad_size", video_geom(&env->out.keypad_dpy, val))
+        M_STR("keypad", env->keypad_file)
         M_UINT("fps", env->out.fps)
         M_UINT("bitrate", env->out.bitrate)
         M_UINT("qmin", env->out.qmin)




More information about the asterisk-commits mailing list