[asterisk-commits] rizzo: trunk r94822 - /trunk/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 26 18:21:02 CST 2007


Author: rizzo
Date: Wed Dec 26 18:21:02 2007
New Revision: 94822

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94822
Log:
Enable building the code even if SDL is not present (similarly,
SDL is also detected at runtime).
Now we should be able to stream video even without a rendering device
(useful for remote monitoring).


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

Modified: trunk/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_gui.c?view=diff&rev=94822&r1=94821&r2=94822
==============================================================================
--- trunk/channels/console_gui.c (original)
+++ trunk/channels/console_gui.c Wed Dec 26 18:21:02 2007
@@ -3,6 +3,7 @@
  * The routines here are in charge of loading the keypad and handling events.
  * $Revision$
  */
+
 
 #include "asterisk.h"
 #include "console_video.h"
@@ -11,6 +12,27 @@
 #include "asterisk/utils.h"	/* ast_calloc and ast_realloc */
 #include <math.h>		/* sqrt */
 
+/* we support 3 regions in the GUI */
+enum { WIN_LOCAL, WIN_REMOTE, WIN_KEYPAD, WIN_MAX };
+
+#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 void eventhandler(struct video_desc *env, const char *caption)	{}
+static int keypad_cfg_read(struct gui_info *gui, const char *val)	{ return 0; }
+
+#else /* HAVE_SDL, the real rendering code */
+
+#include <SDL/SDL.h>
+#ifdef HAVE_SDL_IMAGE
+#include <SDL/SDL_image.h>      /* for loading images */
+#endif
+#ifdef HAVE_SDL_TTF
+#include <SDL/SDL_ttf.h>        /* render text on sdl surfaces */
+#endif
+
 enum kp_type { KP_NONE, KP_RECT, KP_CIRCLE };
 struct keypad_entry {
         int c;  /* corresponding character */
@@ -18,10 +40,6 @@
         enum kp_type type;
 };
 
-/* our representation of a displayed window. SDL can only do one main
- * window so we map everything within that one
- */
-enum { WIN_LOCAL, WIN_REMOTE, WIN_KEYPAD, WIN_MAX };
 /* our representation of a displayed window. SDL can only do one main
  * window so we map everything within that one
  */
@@ -531,7 +549,7 @@
 
 /*! \brief refresh the screen, and also grab a bunch of events.
  */
-static void eventhandler(struct video_desc *env)
+static void eventhandler(struct video_desc *env, const char *caption)
 {
 	struct gui_info *gui = env->gui;
 #define N_EVENTS	32
@@ -540,7 +558,8 @@
 
 	if (!gui)
 		return;
-	// SDL_UpdateRects(gui->screen, 1, &gui->win[WIN_KEYPAD].rect);// XXX inefficient
+	if (caption)
+		SDL_WM_SetCaption(caption, NULL);
 
 #define MY_EV (SDL_MOUSEBUTTONDOWN|SDL_KEYDOWN)
 	while ( (n = SDL_PeepEvents(ev, N_EVENTS, SDL_GETEVENT, SDL_ALLEVENTS)) > 0) {
@@ -959,3 +978,4 @@
 	// ast_log(LOG_WARNING, "now %d regions\n", gui->kp_used);
 	return 1;
 }
+#endif	/* HAVE_SDL */

Modified: trunk/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.c?view=diff&rev=94822&r1=94821&r2=94822
==============================================================================
--- trunk/channels/console_video.c (original)
+++ trunk/channels/console_video.c Wed Dec 26 18:21:02 2007
@@ -88,10 +88,10 @@
 
 /*
  * Codecs are absolutely necessary or we cannot do anything.
- * In principle SDL is optional too (used for rendering only, but we
- * could still source data withouth it), however at the moment it is required.
- */
-#if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG) || !defined(HAVE_SDL)
+ * SDL is optional (used for rendering only), so that we can still
+ * stream video withouth displaying it.
+ */
+#if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG)
 /* stubs if required pieces are missing */
 int console_write_video(struct ast_channel *chan, struct ast_frame *f)
 {
@@ -1079,8 +1079,6 @@
 		}
 	}
 	sdl_setup(env);
-	if (env->gui)
-		SDL_UpdateRects(env->gui->screen, 1, &env->gui->win[WIN_KEYPAD].rect);// XXX inefficient
 	ast_mutex_init(&env->in.dec_in_lock);
 	if (!ast_strlen_zero(save_display))
 		setenv("DISPLAY", save_display, 1);
@@ -1097,16 +1095,15 @@
 	}
 
 	for (;;) {
-		/* XXX 20 times/sec */
-		struct timeval t = { 0, 50000 };
+		struct timeval t = { 0, 50000 };	/* XXX 20 times/sec */
 		struct ast_frame *p, *f;
 		struct video_in_desc *v = &env->in;
 		struct ast_channel *chan = env->owner;
 		int fd = chan->alertpipe[1];
+		char *caption = NULL, buf[160];
 
 		/* determine if video format changed */
 		if (count++ % 10 == 0) {
-			char buf[160];
 			if (env->out.sendvideo)
 			    sprintf(buf, "%s %s %dx%d @@ %dfps %dkbps",
 				env->out.videodevice, env->codec_name,
@@ -1114,14 +1111,14 @@
 				env->out.fps, env->out.bitrate/1000);
 			else
 			    sprintf(buf, "hold");
-			SDL_WM_SetCaption(buf, NULL);
+			caption = buf;
 		}
 
 		/* manage keypad events */
 		/* XXX here we should always check for events,
 		* otherwise the drag will not work */ 
 		if (env->gui)
-			eventhandler(env);
+			eventhandler(env, caption);
  
 		/* sleep for a while */
 		ast_select(0, NULL, NULL, NULL, &t);

Modified: trunk/channels/console_video.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.h?view=diff&rev=94822&r1=94821&r2=94822
==============================================================================
--- trunk/channels/console_video.h (original)
+++ trunk/channels/console_video.h Wed Dec 26 18:21:02 2007
@@ -23,7 +23,7 @@
 #ifndef CONSOLE_VIDEO_H
 #define CONSOLE_VIDEO_H
 
-#if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG) || !defined(HAVE_SDL)
+#if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG)
 #define CONSOLE_VIDEO_CMDS					\
 		"console {device}"
 #else
@@ -36,16 +36,6 @@
 #ifndef OLD_FFMPEG
 #include <ffmpeg/swscale.h>     /* requires a recent ffmpeg */
 #endif
-
-#include <SDL/SDL.h>
-#ifdef HAVE_SDL_IMAGE
-#include <SDL/SDL_image.h>      /* for loading images */
-#endif
-#ifdef HAVE_SDL_TTF
-#include <SDL/SDL_ttf.h>        /* render text on sdl surfaces */
-#endif
-
-
 
 #define CONSOLE_VIDEO_CMDS                              \
         "console {videodevice|videocodec|sendvideo"     \




More information about the asterisk-commits mailing list