[svn-commits] rizzo: trunk r126572 - /trunk/channels/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 30 10:45:15 CDT 2008


Author: rizzo
Date: Mon Jun 30 10:45:15 2008
New Revision: 126572

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126572
Log:
implement the 'freeze' function for incoming frames;

fix a bug which caused a crash when a videodevice was
specified after startgui=1 in the config file. This also
involves a slightly different method to determine if the
gui is active or not.


Modified:
    trunk/channels/chan_oss.c
    trunk/channels/console_gui.c
    trunk/channels/console_video.c
    trunk/channels/console_video.h

Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?view=diff&rev=126572&r1=126571&r2=126572
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Mon Jun 30 10:45:15 2008
@@ -1387,6 +1387,11 @@
 		system(cmd);
 		ast_free(cmd);
 	}
+
+	/* if the config file requested to start the GUI, do it */
+	if (get_gui_startup(o->env))
+		console_video_start(o->env, NULL);
+
 	if (o == &oss_default)		/* we are done with the default */
 		return NULL;
 

Modified: trunk/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_gui.c?view=diff&rev=126572&r1=126571&r2=126572
==============================================================================
--- trunk/channels/console_gui.c (original)
+++ trunk/channels/console_gui.c Mon Jun 30 10:45:15 2008
@@ -50,7 +50,9 @@
   keystrokes are used as keypad functions, or as text input
   if we are in text-input mode.
 - drag on some keypad areas (sliders etc.) are mapped to the
-  corresponding functions;
+  corresponding functions (mute/unmute audio and video,
+  enable/disable Picture-in-Picture, freeze the incoming video,
+  dial numbers, pick up or hang up a call, ...)
 
 Configuration options control the appeareance of the gui:
 
@@ -58,9 +60,8 @@
     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
+- audio output device switching
 
 The audio switching feature should allow changing the device
 or switching to a recorded message for audio sent to remote party.
@@ -343,10 +344,10 @@
 	associated with the audio device markers, clicking on these markers
 	will change the source device for audio output */
 
+#endif
+	/* Keys related to video sources */
 	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"
 	associated with the device thumbnails, clicking on these pictures
@@ -389,12 +390,19 @@
 	case KEY_SENDVIDEO: /* send or do not send video */
 		env->out.sendvideo = !env->out.sendvideo;
 		break;
+
 	case KEY_PIP: /* enable or disable Picture in Picture */
 		env->out.picture_in_picture = !env->out.picture_in_picture;
 		break;
+
 	case KEY_MUTE: /* send or do not send audio */
 		ast_cli_command(env->gui->outfd, "console mute toggle");
 		break;
+
+	case KEY_FREEZE: /* freeze/unfreeze the incoming frames */
+		env->frame_freeze = !env->frame_freeze;
+		break;
+
 #ifdef notyet
 	case KEY_AUTOANSWER: {
 		struct chan_oss_pvt *o = find_desc(oss_active);
@@ -737,6 +745,7 @@
 	case KEY_AUTOANSWER:
 	case KEY_SENDVIDEO: /* send or not send the video */
 	case KEY_PIP: /* activate/deactivate picture in picture mode */
+	case KEY_FREEZE: /* freeze/unfreeze the incoming video */
 		keypad_toggle(env, index);
 		break;
 
@@ -746,8 +755,6 @@
 		break;
 
 #ifdef notyet /* XXX for future implementations */
-	case KEY_FREEZE:
-		break
 	case KEY_CAPTURE:
 		break;
 #endif
@@ -1407,6 +1414,9 @@
 	if (set_win(gui->screen, &gui->win[WIN_REMOTE], dpy_fmt,
 			env->rem_dpy.w, env->rem_dpy.h, x0-kp_w/2-BORDER-env->rem_dpy.w, y0))
 		goto no_sdl;
+	/* unfreeze incoming frames if set (to avoid showing nothing) */
+	env->frame_freeze = 0;
+
 	if (set_win(gui->screen, &gui->win[WIN_LOCAL], dpy_fmt,
 			env->loc_dpy.w, env->loc_dpy.h,
 			x0+kp_w/2+BORDER, y0))
@@ -1496,6 +1506,7 @@
 
 struct _s_k { const char *s; int k; };
 static struct _s_k gui_key_map[] = {
+	{"FREEZE",	KEY_FREEZE},
 	{"PIP",		KEY_PIP},
 	{"PICK_UP",	KEY_PICK_UP },
 	{"PICKUP",	KEY_PICK_UP },
@@ -1537,6 +1548,8 @@
  *	token circle xc yc diameter
  *	token circle xc yc x1 y1 h	# ellipse, main diameter and height
  *	token rect x0 y0 x1 y1 h	# rectangle with main side and eight
+ *	token x0 y0 w h			# horizontal rectangle (short format)
+ *					# this is used e.g. for message boards
  * token is the token to be returned, either a character or a symbol
  * as KEY_* above
  * Return 1 on success, 0 on error.
@@ -1578,10 +1591,10 @@
 		else if (e.c == KEY_EDIT)
 			r = gui->kp_edit;
 		if (r) {
-			r->x = atoi(s2);
-			r->y = e.x0;
-			r->w = e.y0;
-			r->h = e.x1;
+			r->x = atoi(s2);	/* this becomes x0 */
+			r->y = e.x0;		/* this becomes y0 */
+			r->w = e.y0;		/* this becomes w  */
+			r->h = e.x1;		/* this becomes h  */
 			break;
 		}
 		if (strcasecmp(s2, "circle"))	/* invalid */

Modified: trunk/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.c?view=diff&rev=126572&r1=126571&r2=126572
==============================================================================
--- trunk/channels/console_video.c (original)
+++ trunk/channels/console_video.c Mon Jun 30 10:45:15 2008
@@ -137,6 +137,11 @@
 {
 }
 
+int get_gui_startup(struct video_desc* env)
+{
+	return 0; /* no gui here */
+}
+
 int console_video_formats = 0;
 
 #else /* defined(HAVE_FFMPEG) && defined(HAVE_SDL) */
@@ -248,11 +253,11 @@
 	struct fbuf_t		rem_dpy;	/* display remote video, no buffer (it is in win[WIN_REMOTE].bmp) */
 	struct fbuf_t		loc_dpy;	/* display local source, no buffer (managed by SDL in bmp[1]) */
 
-	/*display for  sources in additional windows, 
-	ideally infinite additional sources could be present
-	pratically we assume a maximum of 9 sources to show*/
+	/* geometry of the thumbnails for all video sources. */
 	struct fbuf_t		src_dpy[MAX_VIDEO_SOURCES]; /* no buffer allocated here */
-	
+
+	int frame_freeze;	/* flag to freeze the incoming frame */
+
 	/* local information for grabbers, codecs, gui */
 	struct gui_info		*gui;
 	struct video_dec_desc	*in;		/* remote video descriptor */
@@ -272,6 +277,14 @@
 	b->w = x.w;
 	b->h = x.h;
 	b->pix_fmt = x.pix_fmt;
+}
+
+/* return the status of env->stayopen to chan_oss, as the latter
+ * does not have access to fields of struct video_desc
+ */
+int get_gui_startup(struct video_desc* env)
+{
+	return env->stayopen;
 }
 
 #if 0
@@ -432,6 +445,7 @@
 		v->devices[i].status_index = 0;
 	}
 	v->picture_in_picture = 0;
+	env->frame_freeze = 0;
 	return -1;
 }
 
@@ -545,7 +559,7 @@
 void console_video_uninit(struct video_desc *env)
 {
 	int i, t = 100;	/* initial wait is shorter, than make it longer */
-	if (env->stayopen == 0) {	/* in a call */
+	if (env->stayopen == 0) { /* gui opened by a call, do the shutdown */
 		env->shutdown = 1;
 		for (i=0; env->shutdown && i < 10; i++) {
 			if (env->owner)
@@ -555,6 +569,7 @@
 			if (env->owner)
 				ast_channel_lock(env->owner);
 		}
+		env->vthread = NULL;
 	}
 	env->owner = NULL;	/* this is unconditional */
 }
@@ -920,7 +935,8 @@
 		while (v->dec_in_dpy) {
 			struct fbuf_t *tmp = v->dec_in_dpy;	/* store current pointer */
 
-			if (v->d_callbacks->dec_run(v, tmp))
+			/* decode the frame, but show it only if not frozen */
+			if (v->d_callbacks->dec_run(v, tmp) && !env->frame_freeze)
 				show_frame(env, WIN_REMOTE);
 			tmp->used = 0;	/* mark buffer as free */
 			tmp->ebit = 0;
@@ -1045,7 +1061,7 @@
 	if (env == NULL)	/* video not initialized */
 		return;
 	env->owner = owner;	/* work even if no owner is specified */
-	if (env->stayopen)
+	if (env->vthread)
 		return;		/* already initialized, nothing to do */
 	init_env(env);
 	env->out.enc = map_config_video_format(env->codec_name);
@@ -1073,8 +1089,6 @@
 	ast_pthread_create_background(&env->vthread, NULL, video_thread, env);
 	/* detach the thread to make sure memory is freed on termination */
 	pthread_detach(env->vthread);
-	if (env->owner == NULL)
-		env->stayopen = 1;	/* manually opened so don't close on hangup */
 }
 
 /*
@@ -1204,6 +1218,7 @@
         } else if (!strcasecmp(var, "fps")) {
 		ast_cli(fd, "fps is [%d]\n", env->out.fps);
         } else if (!strcasecmp(var, "startgui")) {
+		env->stayopen = 1;
 		console_video_start(env, NULL);
         } else if (!strcasecmp(var, "stopgui") && env->stayopen != 0) {
 		env->stayopen = 0;
@@ -1236,7 +1251,7 @@
 			return 1;	/* error */
 		
 		}
-		/* set default values */
+		/* set default values - 0's are already there */
 		env->out.device_primary = 0;
 		env->out.device_secondary = 0;
 		env->out.fps = 5;
@@ -1244,7 +1259,6 @@
 		env->out.sendvideo = 1;
 		env->out.qmin = 3;
 		env->out.device_num = 0;
-		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));
@@ -1255,7 +1269,7 @@
 	CV_F("remote_size", video_geom(&env->rem_dpy, val));
 	CV_STR("keypad", env->keypad_file);
 	CV_F("region", keypad_cfg_read(env->gui, val));
-	CV_F("startgui", console_video_start(env, NULL));	// support enabling gui at startup
+	CV_UINT("startgui", env->stayopen);	/* enable gui at startup */
 	CV_STR("keypad_font", env->keypad_font);
 	CV_STR("sdl_videodriver", env->sdl_videodriver);
 	CV_UINT("fps", env->out.fps);

Modified: trunk/channels/console_video.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.h?view=diff&rev=126572&r1=126571&r2=126572
==============================================================================
--- trunk/channels/console_video.h (original)
+++ trunk/channels/console_video.h Mon Jun 30 10:45:15 2008
@@ -97,6 +97,7 @@
 int console_video_config(struct video_desc **penv, const char *var, const char *val);
 void console_video_uninit(struct video_desc *env);
 void console_video_start(struct video_desc *env, struct ast_channel *owner);
+int get_gui_startup(struct video_desc* env);
 
 /* console_board.c */
 




More information about the svn-commits mailing list