[asterisk-commits] rizzo: branch rizzo/video_console r126223 - /team/rizzo/video_console/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 28 15:29:14 CDT 2008


Author: rizzo
Date: Sat Jun 28 15:29:14 2008
New Revision: 126223

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126223
Log:
add a missing pthread_detach so the video console does not leak memory
when closing the GUI.

Import another batch of code cleanup by Daniele Giannetti,
no functional changes but:
- put together some data structures
  related to thumbnails for the various video sources
- use a fixed size for the thumbnail array


Modified:
    team/rizzo/video_console/channels/console_board.c
    team/rizzo/video_console/channels/console_gui.c
    team/rizzo/video_console/channels/console_video.c
    team/rizzo/video_console/channels/console_video.h

Modified: team/rizzo/video_console/channels/console_board.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_board.c?view=diff&rev=126223&r1=126222&r2=126223
==============================================================================
--- team/rizzo/video_console/channels/console_board.c (original)
+++ team/rizzo/video_console/channels/console_board.c Sat Jun 28 15:29:14 2008
@@ -313,6 +313,23 @@
 	return 1;
 }
 
+/* deletes a board.
+ * we make the free operation on any fields of the board structure allocated
+ * in dynamic memory
+ */
+void delete_board(struct board *b)
+{
+	if (b) {
+		/* deletes the text */
+		if (b->text)
+			ast_free (b->text);
+		/* deallocates the blank surface */
+		SDL_FreeSurface(b->blank);
+		/* deallocates the board */
+		ast_free(b);
+	}
+}
+
 #if 0
 /*! \brief refresh the screen, and also grab a bunch of events.
  */

Modified: team/rizzo/video_console/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_gui.c?view=diff&rev=126223&r1=126222&r2=126223
==============================================================================
--- team/rizzo/video_console/channels/console_gui.c (original)
+++ team/rizzo/video_console/channels/console_gui.c Sat Jun 28 15:29:14 2008
@@ -57,6 +57,23 @@
     keypad = /tmp/kpad2.jpg	; the skin
     keypad_font = /tmp/font.png	; the font to use for output
 
+For future implementation, intresting features can be the following:
+- freeze of the video coming from our remote party
+- save of the whole SDL window as a picture
+- oudio output device switching
+
+The audio switching feature should allow changing the device
+or switching to a recorded message for audio sent to remote party.
+The selection of the device should happen clicking on a marker in the layout.
+For this reason above the thumbnails row in the layout we would like a new row,
+the elements composing the row could be message boards, reporting the name of the
+device or the path of the message to be played.
+
+For video input freeze and entire window capture, we define 2 new key types,
+those should be activated pressing the buttons on the keypad, associated with
+new regions inside the keypad pictureas comments
+
+
  *
  */
 
@@ -75,7 +92,7 @@
 #ifndef HAVE_SDL	/* stubs if we don't have any sdl */
 static void show_frame(struct video_desc *env, int out)	{}
 static void sdl_setup(struct video_desc *env)		{}
-static struct gui_info *cleanup_sdl(struct gui_info *gui)	{ return NULL; }
+static struct gui_info *cleanup_sdl(struct video_desc *env)	{ return NULL; }
 static void eventhandler(struct video_desc *env, const char *caption)	{}
 static int keypad_cfg_read(struct gui_info *gui, const char *val)	{ return 0; }
 
@@ -105,9 +122,16 @@
 /* our representation of a displayed window. SDL can only do one main
  * window so we map everything within that one
  */
-struct display_window   {   
+struct display_window {
 	SDL_Overlay	*bmp;
 	SDL_Rect	rect;	/* location of the window */
+};
+
+/* each thumbnail message board has a rectangle associated for the geometry,
+ * and a board structure, we include these two elements in a singole structure */
+struct thumb_bd {
+	SDL_Rect		rect;		/* the rect for geometry and background */
+	struct board		*board;		/* the board */
 };
 
 struct gui_info {
@@ -125,6 +149,8 @@
 	/* each of the following board has two rectangles,
 	 * [0] is the geometry relative to the keypad,
 	 * [1] is the geometry relative to the whole screen
+	 * we do not use the thumb_bd for these boards because here we need
+	 * 2 rectangles for geometry
 	 */
 	SDL_Rect		kp_msg[2];		/* incoming msg, relative to kpad */
 	struct board		*bd_msg;
@@ -139,8 +165,7 @@
 	 * above the keypad in the layout, we only have the geometry
 	 * relative to the whole screen
 	 */
-	SDL_Rect		*rect_srcs_msg;
-	struct board		**bd_srcs_msg;
+	struct thumb_bd		thumb_bd_array[MAX_VIDEO_SOURCES];
 
 	/* variable-size array mapping keypad regions to functions */
 	int kp_size, kp_used;
@@ -151,10 +176,12 @@
 
 /*! \brief free the resources in struct gui_info and the descriptor itself.
  *  Return NULL so we can assign the value back to the descriptor in case.
- */
-static struct gui_info *cleanup_sdl(struct gui_info *gui)
+ * XXX fix the argument, should only use env->gui and the number of boards
+ */
+static struct gui_info *cleanup_sdl(struct video_desc *env)
 {
 	int i;
+	struct gui_info *gui = env->gui;
 
 	if (gui == NULL)
 		return NULL;
@@ -179,10 +206,19 @@
 			SDL_FreeYUVOverlay(gui->win[i].bmp);
 	}
 	bzero(gui, sizeof(gui));
-	if (gui->rect_srcs_msg)
-		ast_free(gui->rect_srcs_msg);
-	if (gui->bd_srcs_msg)
-		ast_free(gui->bd_srcs_msg);
+
+	/* deallocates the space allocated for the keypad message boards */
+	if (gui->bd_dialed)
+		delete_board(gui->bd_dialed);
+	if (gui->bd_msg)
+		delete_board(gui->bd_msg);
+
+	/* deallocates the space allocated for the thumbnail message boards */
+	for (i = 0; i < env->out.device_num; i++) {
+		if (gui->thumb_bd_array[i].board) /* may be useless */
+			delete_board(gui->thumb_bd_array[i].board);
+	}
+	
 	ast_free(gui);
 	SDL_Quit();
 	return NULL;
@@ -303,6 +339,15 @@
 	KEY_DIALED = 203,	/* area for dialed numbers */
 	KEY_EDIT = 204,		/* area for editing user input */
 
+#ifdef notyet /* XXX for future implementation */
+	KEY_AUDIO_SRCS = 210,
+	/*indexes between 210 and 219 (or more) have been reserved for the "keys"
+	associated with the audio device markers, clicking on these markers
+	will change the source device for audio output */
+
+	KEY_FREEZE = 220,	/* freeze the incoming video */
+	KEY_CAPTURE = 221,	/* capture the whole SDL window as a picture */
+#endif
 	/* video source switching key(s) */
 	KEY_PIP = 230,
 	/*indexes between 231 and 239 have been reserved for the "keys"
@@ -434,8 +479,8 @@
 
 static int update_device_info(struct video_desc *env, int i)
 {
-	reset_board(env->gui->bd_srcs_msg[i]);
-	print_message(env->gui->bd_srcs_msg[i],
+	reset_board(env->gui->thumb_bd_array[i].board);
+	print_message(env->gui->thumb_bd_array[i].board,
 		src_msgs[env->out.devices[i].status_index]);
 	return 0;
 }
@@ -517,6 +562,11 @@
 {
 	struct video_device *p = &env->out.devices[index];
 
+	if (index >= env->out.device_num) {
+		ast_log(LOG_WARNING, "no devices\n");
+		return 0;
+	}
+
 	if (!p->grabber) { /* device off */
 		void *g_data; /* result of grabber_open() */
 		struct grab_desc *g;
@@ -541,10 +591,8 @@
 		/* the grabber must be closed */
 		p->grabber_data = p->grabber->close(p->grabber_data);
 		p->grabber = NULL;
-		if (p->dev_buf) { /* free the buffer if necessary */
-			fbuf_free(p->dev_buf);
-			p->dev_buf = NULL;
-		}
+		/* dev_buf is already freed by grabber->close() */
+		p->dev_buf = NULL;
 		/* update the status of the source */
 		p->status_index &= ~IS_ON;
 		/* print the new message in the message board */
@@ -582,11 +630,12 @@
 	gui->drag.drag_window = DRAG_NONE;
 	
 	/* define keypad boundary */
-	if (button.y >= (env->out.devices ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0)) {
+	/* XXX this should be extended for clicks on different audio device markers */
+	if (button.y >= (env->out.device_num ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0)) {
 		/* if control reaches this point this means that the clicked point is
 		below the row of the additional sources windows*/
 		/* adjust the y coordinate as if additional devices windows were not present */
-		button.y -= (env->out.devices ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
+		button.y -= (env->out.device_num ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
 		if (button.y < BORDER)
 			index = KEY_OUT_OF_KEYPAD;
 		else if (button.y >= MAX(MAX(env->rem_dpy.h, env->loc_dpy.h), gui->keypad->h))
@@ -672,6 +721,11 @@
 		}
 	}
 
+	/* XXX for future implementation
+	else if (click on audio source marker)
+		change audio source device
+	*/
+
 	switch (index) {
 	/* answer/close function */
 	case KEY_PICK_UP:
@@ -693,6 +747,13 @@
 		break;
 	case KEY_REMOTEVIDEO:
 		break;
+
+#ifdef notyet /* XXX for future implementations */
+	case KEY_FREEZE:
+		break
+	case KEY_CAPTURE:
+		break;
+#endif
 
 	case KEY_MESSAGEBOARD:
 		if (button.button == SDL_BUTTON_LEFT)
@@ -713,13 +774,13 @@
 			  button.y >= BORDER+pip_loc_y && 
 			  button.y < BORDER+pip_loc_y+env->loc_dpy.h/3) {
 				/* set the y cordinate to his previous value */
-				button.y += (env->out.devices ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
+				button.y += (env->out.device_num ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
 				/* starts dragging the picture inside the picture */
 				set_drag(&gui->drag, button.x, button.y, DRAG_PIP);
 			}
 			else if (index == KEY_LOC_DPY) {
 				/* set the y cordinate to his previous value */
-				button.y += (env->out.devices ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
+				button.y += (env->out.device_num ? SRC_WIN_H+2*BORDER+SRC_MSG_BD_H : 0);
 				/* click in the local display, but not on the PiP */
 				set_drag(&gui->drag, button.x, button.y, DRAG_LOCAL);
 			}
@@ -845,8 +906,7 @@
 
 /*! \brief This function moves the picture in picture,
  * controlling the limits of the containing buffer
- * to avoid problems deriving from going through the limits
- * of the containing buffer.
+ * to avoid problems deriving from going through the limits.
  *
  * \param env = pointer to the descriptor of the video environment
  * \param dx = the variation of the x position
@@ -925,7 +985,7 @@
 
 			case SDL_MOUSEMOTION:
 			case SDL_MOUSEBUTTONUP:
-				if (drag->drag_window == DRAG_LOCAL && env->out.devices) {
+				if (drag->drag_window == DRAG_LOCAL && env->out.device_num) {
 					/* move the capture source */
 					int dx = compute_drag(&drag->x_start, ev[i].motion.x, 3);
 					int dy = compute_drag(&drag->y_start, ev[i].motion.y, 3);
@@ -1239,7 +1299,7 @@
 	
 	/* total height of the mother window to create */
 	maxh = MAX( MAX(env->rem_dpy.h, env->loc_dpy.h), kp_h)+2*BORDER;
-	maxh += env->out.devices ? (2*BORDER+SRC_WIN_H+SRC_MSG_BD_H) : 0;
+	maxh += env->out.device_num ? (2*BORDER+SRC_WIN_H+SRC_MSG_BD_H) : 0;
 	
 	gui->screen = SDL_SetVideoMode(maxw, maxh, depth, 0);
 	if (!gui->screen) {
@@ -1340,7 +1400,7 @@
     } while (0);
 #endif /* HAVE_X11 */
 
-	y0 = env->out.devices ? (3*BORDER+SRC_WIN_H+SRC_MSG_BD_H) : BORDER;
+	y0 = env->out.device_num ? (3*BORDER+SRC_WIN_H+SRC_MSG_BD_H) : BORDER;
 	
 	SDL_WM_SetCaption("Asterisk console Video Output", NULL);
 	
@@ -1353,49 +1413,31 @@
 			x0+kp_w/2+BORDER, y0))
 		goto no_sdl;
 	
-	/* if necessary, allocate memory space for rects that will contain messages
-	relative to the state of every single source */
-	if (!gui->rect_srcs_msg) {
-		gui->rect_srcs_msg = (struct SDL_Rect*)
-			ast_calloc(env->out.device_num, sizeof(struct SDL_Rect));
-		if (!gui->rect_srcs_msg) {
-			ast_log(LOG_ERROR, "no memory for source boards\n");
-			goto no_sdl;
-		}
-	}
-	/* if necessary, allocate memory space for the array of pointers 
-	to the message boards of the sources */
-	if (!gui->bd_srcs_msg) {
-		gui->bd_srcs_msg = (struct board**)ast_calloc(env->out.device_num, sizeof(struct board*));
-		if (!gui->bd_srcs_msg) {
-			ast_log(LOG_ERROR, "no memory for source boards\n");
-			goto no_sdl;
-		}
-	}
-
 	/* initialize device_num source windows (thumbnails) and boards
 	(for a maximum of 9 additional windows and boards) */
 	x = x0 - src_wins_tot_w/2 + BORDER;
 	for (i = 0; i < env->out.device_num; i++){
+		struct thumb_bd *p = &gui->thumb_bd_array[i];
 		if (set_win(gui->screen, &gui->win[i+WIN_SRC1], dpy_fmt,
 			SRC_WIN_W, SRC_WIN_H, x+i*(BORDER+SRC_WIN_W), BORDER))
 			goto no_sdl;
 		/* set geometry for the rect for the message board of the device */
-		gui->rect_srcs_msg[i].w = SRC_WIN_W;
-		gui->rect_srcs_msg[i].h = SRC_MSG_BD_H;
-		gui->rect_srcs_msg[i].x = x+i*(BORDER+SRC_WIN_W);
-		gui->rect_srcs_msg[i].y = 2*BORDER+SRC_WIN_H;
+		p->rect.w = SRC_WIN_W;
+		p->rect.h = SRC_MSG_BD_H;
+		p->rect.x = x+i*(BORDER+SRC_WIN_W);
+		p->rect.y = 2*BORDER+SRC_WIN_H;
 		/* the white color is used as background */
-		SDL_FillRect(gui->screen, &gui->rect_srcs_msg[i],
+		SDL_FillRect(gui->screen, &p->rect,
 			SDL_MapRGB(gui->screen->format, 255, 255, 255));
 		/* if necessary, initialize boards for the sources */
-		if (!gui->bd_srcs_msg[i])
-			gui->bd_srcs_msg[i] = 
-				board_setup(gui->screen, &gui->rect_srcs_msg[i],
+		if (!p->board)
+			p->board =
+				board_setup(gui->screen, &p->rect,
 				gui->font, gui->font_rects);
-	}
-	/* update new rects */
-	SDL_UpdateRects(gui->screen, env->out.device_num, gui->rect_srcs_msg);
+		/* update board rect */
+		SDL_UpdateRect(gui->screen, p->rect.x, p->rect.y, p->rect.w, p->rect.h);
+	}
+	
 
 	/* display the skin, but do not free it as we need it later to
 	restore text areas and maybe sliders too */
@@ -1417,7 +1459,7 @@
 
 no_sdl:
 	/* free resources in case of errors */
-	env->gui = cleanup_sdl(gui);
+	env->gui = cleanup_sdl(env);
 }
 
 /*

Modified: team/rizzo/video_console/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_video.c?view=diff&rev=126223&r1=126222&r2=126223
==============================================================================
--- team/rizzo/video_console/channels/console_video.c (original)
+++ team/rizzo/video_console/channels/console_video.c Sat Jun 28 15:29:14 2008
@@ -159,6 +159,7 @@
  */
 struct video_device {
 	char 			*name;		/* name of the device			*/
+	/* allocated dynamically (see fill_table function) */
 	struct grab_desc 	*grabber;	/* the grabber for the device type	*/
 	void 			*grabber_data;	/* device's private data structure	*/
 	struct fbuf_t		*dev_buf;	/* buffer for incoming data		*/
@@ -205,7 +206,10 @@
 					/* The initial part of AVFrame is an AVPicture */
 	int		mtu;
 	
-	struct video_device	*devices; /*table of devices built from the oss.config file */ 
+	/* Table of devices specified with "videodevice=" in oss.conf.
+	 * Static size as we have a limited number of entries.
+	 */
+	struct video_device	devices[MAX_VIDEO_SOURCES]; 
 	int 			device_num; /*number of devices in table*/
 	int			device_primary; /*index of the actual primary device in the table*/
 	int			device_secondary; /*index of the actual secondary device in the table*/
@@ -247,7 +251,7 @@
 	/*display for  sources in additional windows, 
 	ideally infinite additional sources could be present
 	pratically we assume a maximum of 9 sources to show*/
-	struct fbuf_t*		src_dpy;
+	struct fbuf_t		src_dpy[MAX_VIDEO_SOURCES]; /* no buffer allocated here */
 	
 	/* local information for grabbers, codecs, gui */
 	struct gui_info		*gui;
@@ -312,8 +316,6 @@
 			continue;
 		/* for each type of grabber supported... */
 		for (j = 0; (g = console_grabbers[j]); j++) {
-			if (g == NULL)
-				break;
 			/* the grabber is opened and the informations saved in the device table */
 			g_data = g->open(v->devices[i].name, &v->loc_src_geometry, v->fps);
 			if (!g_data)
@@ -419,10 +421,10 @@
 	/* close the grabbers */
 	for (i = 0; i < v->device_num; i++) {
 		if (v->devices[i].grabber){
-			v->devices[i].grabber_data=
+			v->devices[i].grabber_data =
 				v->devices[i].grabber->close(v->devices[i].grabber_data);
-			v->devices[i].grabber=NULL;
-			fbuf_free(v->devices[i].dev_buf);
+			v->devices[i].grabber = NULL;
+			/* dev_buf is already freed by grabber->close() */
 			v->devices[i].dev_buf = NULL;
 		}
 		v->devices[i].status_index = 0;
@@ -628,7 +630,7 @@
 		eff_h=out->win_h;
 	}
 #ifdef OLD_FFMPEG
-	/* XXX img_convert is deprecated, and does not do rescaling */
+	/* XXX img_convert is deprecated, and does not do rescaling, PiP not supported */
 	img_convert(p_out, out->pix_fmt,
 		p_in, in->pix_fmt, in->w, in->h);
 #else /* XXX replacement */
@@ -767,7 +769,7 @@
 	struct fbuf_t *loc_src_primary = NULL, *p_read;
 	int i;
 	/* if no device was found in the config file */
-	if (!env->out.devices)
+	if (!env->out.device_num)
 		return NULL;
 	/* every time this function is called we refresh the buffers of every device,
 	updating the private device buffer in the device table */
@@ -795,7 +797,7 @@
 			env->enc_in.win_y = env->out.pip_y;
 			env->enc_in.win_w = env->enc_in.w/3;
 			env->enc_in.win_h = env->enc_in.h/3;
-			/* scales to the correct geometry and inserts in 
+			/* scales to the correct geometry and inserts in
 			the enc_in buffer the picture in picture */
 			my_scale(loc_src_secondary, NULL, &env->enc_in, NULL);
 			/* returns to normal parameters (not picture in picture) */
@@ -811,9 +813,8 @@
 		}
 	}
 	show_frame(env, WIN_LOCAL); /* local rendering */
-	if (env->src_dpy)
-		for (i = 0; i < env->out.device_num; i++) 
-			show_frame(env, i+WIN_SRC1); /* rendering of every source device in thumbnails */
+	for (i = 0; i < env->out.device_num; i++) 
+		show_frame(env, i+WIN_SRC1); /* rendering of every source device in thumbnails */
 	if (tail == NULL)
 		tail = &dummy;
 	*tail = NULL;
@@ -866,7 +867,7 @@
 		ast_log(LOG_WARNING, "cannot open local video source\n");
 	} 
 
-	if (env->out.devices)
+	if (env->out.device_num)
 		env->out.devices[env->out.device_primary].status_index |= IS_PRIMARY | IS_SECONDARY;
 	
 	/* even if no device is connected, we must call video_out_init,
@@ -877,7 +878,7 @@
 
 	/* Writes intial status of the sources. */
 	for (i = 0; i < env->out.device_num; i++) {
-		print_message(env->gui->bd_srcs_msg[i],
+		print_message(env->gui->thumb_bd_array[i].board,
 		 src_msgs[env->out.devices[i].status_index]);
 	}
 
@@ -979,7 +980,7 @@
 	video_out_uninit(env);
 
 	if (env->gui)
-		env->gui = cleanup_sdl(env->gui);
+		env->gui = cleanup_sdl(env); /* XXX argument */
 	ast_mutex_destroy(&env->dec_lock);
 	env->shutdown = 0;
 	return NULL;
@@ -1016,14 +1017,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 */
-	/* allocate the array for the buffers for the thumbnail of each source device */
-	if (!env->src_dpy) {
-		env->src_dpy = (struct fbuf_t*) ast_calloc(env->out.device_num, sizeof(struct fbuf_t));
-		if (!env->src_dpy) {
-			ast_log(LOG_ERROR, "no memory for additional device display buffers\n");
-			return;
-		}
-	}
+
 	/* fix the size of buffers for small windows */
 	for (i = 0; i < env->out.device_num; i++) {
 		env->src_dpy[i].pix_fmt = PIX_FMT_YUV420P;
@@ -1076,9 +1070,11 @@
 		ast_log(LOG_WARNING, "bitrate unset, forcing to %d\n", env->out.bitrate);
 	}
 	ast_pthread_create_background(&env->vthread, NULL, video_thread, env);
+	/* detach the thread to be sure that when it will terminate his memory
+	space will be deallocated */
+	pthread_detach(env->vthread);
 	if (env->owner == NULL)
 		env->stayopen = 1;	/* manually opened so don't close on hangup */
-	env->out.picture_in_picture = 0; /* PiP mode intially disabled */
 	used_mem("end of console_video_start");
 }
 
@@ -1137,10 +1133,11 @@
 
 /*! \brief add an entry to the video_device table,
  * ignoring duplicate names.
- * The table is a dynamic array implemented using ast_realloc().
- * No limit on the size but we restrict to at most 9 entries.
- * The last_frame field in each entry of the table is initialized to
- * the current time, to avoid troubles later. XXX
+ * The table is a static array of 9 elements.
+ * The last_frame field of each entry of the table is initialized to
+ * the current time (we need a value inside this field, on stop of the
+ * GUI the last_frame value is not changed, to avoid checking if it is 0 we
+ * set the initial value on current time) XXX
  *
  * PARAMETERS:
  * \param devices_p = pointer to the table of devices
@@ -1149,10 +1146,9 @@
  *
  * returns 0 on success, 1 on error
  */
-static int device_table_fill(struct video_device **devices_p, int *device_num_p, const char *s)
+static int device_table_fill(struct video_device *devices, int *device_num_p, const char *s)
 {
 	int i;
-	void *temp;
 	struct video_device *p;
 
 	/* with the current implementation, we support a maximum of 9 devices.*/
@@ -1160,17 +1156,13 @@
 		return 0; /* more devices will be ignored */
 	/* ignore duplicate names */
 	for (i = 0; i < *device_num_p; i++) {
-		if (!strcmp((*devices_p)[i].name, s))
+		if (!strcmp(devices[i].name, s))
 			return 0;
 	}
-	/* inserts the new video device, changing the size of the table */
-	temp = ast_realloc(*devices_p, (*device_num_p+1)*sizeof(struct video_device));
-	if (temp == NULL) {
-		ast_log(LOG_WARNING, "cannot reallocate device table\n");
-		return 1;
-	}
-	*devices_p = (struct video_device*) temp;
-	p = &(*devices_p)[*device_num_p];
+	/* inserts the new video device */
+	p = &devices[*device_num_p];
+	/* XXX the string is allocated but NEVER deallocated,
+	the good time to do that is when the module is unloaded, now we skip the problem */
 	p->name = ast_strdup(s);		/* copy the name */
 	/* other fields initially NULL */
 	p->grabber = NULL;
@@ -1253,10 +1245,10 @@
 		env->out.sendvideo = 1;
 		env->out.qmin = 3;
 		env->out.device_num = 0;
-		env->out.devices = NULL;
+		env->out.picture_in_picture = 0; /* PiP mode intially disabled */
 	}
 	CV_START(var, val);
-	CV_F("videodevice", device_table_fill(&env->out.devices, &env->out.device_num, val));
+	CV_F("videodevice", device_table_fill(env->out.devices, &env->out.device_num, val));
 	CV_BOOL("sendvideo", env->out.sendvideo);
 	CV_F("video_size", video_geom(&env->enc_in, val));
 	CV_F("camera_size", video_geom(&env->out.loc_src_geometry, val));

Modified: team/rizzo/video_console/channels/console_video.h
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_video.h?view=diff&rev=126223&r1=126222&r2=126223
==============================================================================
--- team/rizzo/video_console/channels/console_video.h (original)
+++ team/rizzo/video_console/channels/console_video.h Sat Jun 28 15:29:14 2008
@@ -45,6 +45,10 @@
 
 #define SRC_WIN_W 80		/* width of the additional device windows */
 #define SRC_WIN_H 60		/* height of the additional device windows */
+/* we only support a limited number of video sources in the GUI,
+ * because we need screen estate to switch between them.
+ */
+#define	MAX_VIDEO_SOURCES	9
 
 /*
  * In many places we use buffers to store the raw frames (but not only),
@@ -131,5 +135,8 @@
 /*! \brief reset the board to blank */
 int reset_board(struct board *b);
 
+/*! \brief deallocates memory space for a board */
+void delete_board(struct board *b);
+
 #endif /* CONSOLE_VIDEO_H */
 /* end of file */




More information about the asterisk-commits mailing list