support sdl_videodriver to send output to x11/aalib/console
authorLuigi Rizzo <rizzo@icir.org>
Sun, 23 Dec 2007 14:51:00 +0000 (14:51 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Sun, 23 Dec 2007 14:51:00 +0000 (14:51 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94741 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/console_video.c
channels/console_video.h

index 86473e5..a1a95a8 100644 (file)
@@ -341,6 +341,8 @@ struct video_desc {
        SDL_Surface             *screen;        /* the main window */
        char                    keypad_file[256];       /* image for the keypad */
        char                    keypad_font[256];       /* font for the keypad */
+
+       char                    sdl_videodriver[256];
        struct display_window   win[WIN_MAX];
 };
 
@@ -2679,10 +2681,23 @@ static void *video_thread(void *arg)
 {
        struct video_desc *env = arg;
        int count = 0;
+       char save_display[128] = "";
 
        env->screen = NULL;
        bzero(env->win, sizeof(env->win));
 
+       /* if sdl_videodriver is set, override the environment. Also,
+        * if it contains 'console' override DISPLAY around the call to SDL_Init
+        * so we use the console as opposed to the x11 version of aalib
+        */
+       if (!ast_strlen_zero(env->sdl_videodriver)) { /* override */
+               const char *s = getenv("DISPLAY");
+               setenv("SDL_VIDEODRIVER", env->sdl_videodriver, 1);
+               if (s && !strcasecmp(env->sdl_videodriver, "aalib-console")) {
+                       ast_copy_string(save_display, s, sizeof(save_display));
+                       unsetenv("DISPLAY");
+               }
+       }
        if (SDL_Init(SDL_INIT_VIDEO)) {
                ast_log(LOG_WARNING, "Could not initialize SDL - %s\n",
                        SDL_GetError());
@@ -2696,6 +2711,9 @@ static void *video_thread(void *arg)
                if (!env->gui_ok)
                        ast_log(LOG_WARNING, "cannot init console gui\n");
        }
+       if (!ast_strlen_zero(save_display))
+               setenv("DISPLAY", save_display, 1);
+
        if (video_open(&env->out)) {
                ast_log(LOG_WARNING, "cannot open local video source\n");
        } else {
@@ -3301,6 +3319,7 @@ int console_video_config(struct video_desc **penv,
        CV_STR("keypad", env->keypad_file);
        CV_F("region", keypad_cfg_read(&env->gui, val));
        CV_STR("keypad_font", env->keypad_font);
+       CV_STR("sdl_videodriver", env->sdl_videodriver);
        CV_UINT("fps", env->out.fps);
        CV_UINT("bitrate", env->out.bitrate);
        CV_UINT("qmin", env->out.qmin);
index cb627a1..edfff7f 100644 (file)
@@ -37,6 +37,7 @@ void console_video_start(struct video_desc *env, struct ast_channel *owner);
         "console {videodevice|videocodec|sendvideo"     \
         "|video_size|bitrate|fps|qmin"                  \
         "|keypad|keypad_mask|keypad_entry"              \
+       "|sdl_videodriver"                              \
         "|device"                                      \
        "}"