diff --git a/channels/console_video.c b/channels/console_video.c index 86473e5898821722065ec4d0c2b1414d0c3b740c..a1a95a8105eee7dd6ed8bff63a6fd676e2014a66 100644 --- a/channels/console_video.c +++ b/channels/console_video.c @@ -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); diff --git a/channels/console_video.h b/channels/console_video.h index cb627a19708b2d0bc9499c99aa258c58ffc67f35..edfff7f04601385a90e69608ec4e2a3e113b919a 100644 --- a/channels/console_video.h +++ b/channels/console_video.h @@ -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" \ "}"