#ifdef HAVE_SDL_TTF
TTF_Font *font; /* font to be used */
#endif
+ /* support for display. */
+ SDL_Surface *screen; /* the main window */
+
int outfd; /* fd for output */
SDL_Surface *keypad; /* the pixmap for the keypad */
int kp_size, kp_used;
}
bzero(gui->win, sizeof(gui->win));
/* XXX free the keys entries */
+ gui->screen = NULL; /* XXX check reference */
+ ast_mutex_destroy(&(env->in.dec_in_lock));
ast_free(gui);
env->gui = NULL;
}
SDL_Quit();
- env->screen = NULL; /* XXX check reference */
- if (env->sdl_ok)
- ast_mutex_destroy(&(env->in.dec_in_lock));
}
/*
SDL_Overlay *bmp;
struct gui_info *gui = env->gui;
- if (!env->sdl_ok)
+ if (!gui)
return;
if (out == WIN_LOCAL) { /* webcam/x11 to sdl */
SDL_Rect dest = {gui->win[WIN_KEYPAD].rect.x + x, y};
/* clean surface each rewrite */
- SDL_BlitSurface(gui->keypad, NULL, env->screen, &gui->win[WIN_KEYPAD].rect);
+ SDL_BlitSurface(gui->keypad, NULL, gui->screen, &gui->win[WIN_KEYPAD].rect);
output = TTF_RenderText_Solid(gui->font, text, color);
if (output == NULL) {
return 1;
}
- SDL_BlitSurface(output, NULL, env->screen, &dest);
+ SDL_BlitSurface(output, NULL, gui->screen, &dest);
SDL_UpdateRects(gui->keypad, 1, &gui->win[WIN_KEYPAD].rect);
SDL_FreeSurface(output);
int depth, maxw, maxh;
const SDL_VideoInfo *info = SDL_GetVideoInfo();
int kp_w = 0, kp_h = 0; /* keypad width and height */
+ int sdl_ok = 0;
/* We want at least 16bpp to support YUV overlays.
* E.g with SDL_VIDEODRIVER = aalib the default is 8
env->gui = gui_init(env);
ast_log(LOG_WARNING, "gui_init returned %p\n", env->gui);
- if (env->gui) {
- keypad_setup(env);
- ast_log(LOG_WARNING, "keypad_setup returned %p %d\n",
- env->gui->keypad, env->gui->kp_used);
- if (env->gui->keypad) {
- kp_w = env->gui->keypad->w;
- kp_h = env->gui->keypad->h;
- }
+ if (!env->gui)
+ goto no_sdl;
+ keypad_setup(env);
+ ast_log(LOG_WARNING, "keypad_setup returned %p %d\n",
+ env->gui->keypad, env->gui->kp_used);
+ if (env->gui->keypad) {
+ kp_w = env->gui->keypad->w;
+ kp_h = env->gui->keypad->h;
}
#define BORDER 5 /* border around our windows */
maxw = env->in.rem_dpy.w + env->out.loc_dpy.w + kp_w;
maxh = MAX( MAX(env->in.rem_dpy.h, env->out.loc_dpy.h), kp_h);
maxw += 4 * BORDER;
maxh += 2 * BORDER;
- env->screen = SDL_SetVideoMode(maxw, maxh, depth, 0);
- if (!env->screen) {
+ env->gui->screen = SDL_SetVideoMode(maxw, maxh, depth, 0);
+ if (!env->gui->screen) {
ast_log(LOG_ERROR, "SDL: could not set video mode - exiting\n");
goto no_sdl;
}
SDL_WM_SetCaption("Asterisk console Video Output", NULL);
- if (set_win(env->screen, &env->gui->win[WIN_REMOTE], dpy_fmt,
+ if (set_win(env->gui->screen, &env->gui->win[WIN_REMOTE], dpy_fmt,
env->in.rem_dpy.w, env->in.rem_dpy.h, BORDER, BORDER))
goto no_sdl;
- if (set_win(env->screen, &env->gui->win[WIN_LOCAL], dpy_fmt,
+ if (set_win(env->gui->screen, &env->gui->win[WIN_LOCAL], dpy_fmt,
env->out.loc_dpy.w, env->out.loc_dpy.h,
3*BORDER+env->in.rem_dpy.w + kp_w, BORDER))
goto no_sdl;
dest->y = BORDER;
dest->w = env->gui->keypad->w;
dest->h = env->gui->keypad->h;
- SDL_BlitSurface(env->gui->keypad, NULL, env->screen, dest);
- SDL_UpdateRects(env->screen, 1, dest);
+ SDL_BlitSurface(env->gui->keypad, NULL, env->gui->screen, dest);
+ SDL_UpdateRects(env->gui->screen, 1, dest);
}
env->in.dec_in_cur = &env->in.dec_in[0];
env->in.dec_in_dpy = NULL; /* nothing to display */
- env->sdl_ok = 1;
+ sdl_ok = 1;
no_sdl:
- if (env->sdl_ok == 0) /* free resources in case of errors */
+ if (!sdl_ok) /* free resources in case of errors */
cleanup_sdl(env);
}
AST_FORMAT_H263_PLUS | AST_FORMAT_H263 |
AST_FORMAT_MP4_VIDEO | AST_FORMAT_H264 | AST_FORMAT_H261 ;
-#ifdef HAVE_X11
-#include <X11/Xlib.h> /* this should be conditional */
-#endif
-
-#include <ffmpeg/avcodec.h>
-#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
/*
* In many places we use buffers to store the raw frames (but not only),
struct gui_info *gui;
- /* support for display. */
- int sdl_ok;
- SDL_Surface *screen; /* the main window */
char keypad_file[256]; /* image for the keypad */
char keypad_font[256]; /* font for the keypad */
struct video_desc *env = get_video_desc(chan);
struct video_in_desc *v = &env->in;
+ if (!env->gui) /* no gui, no rendering */
+ return 0;
if (v->dec == NULL) { /* try to get the codec */
v->dec = map_video_codec(f->subclass & ~1);
if (v->dec == NULL) {
int count = 0;
char save_display[128] = "";
- env->screen = NULL;
-
/* 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
/* again not fatal, just we won't display anything */
} else {
sdl_setup(env);
- if (env->sdl_ok)
- ast_mutex_init(&env->in.dec_in_lock);
}
+ ast_mutex_init(&env->in.dec_in_lock);
if (!ast_strlen_zero(save_display))
setenv("DISPLAY", save_display, 1);
ast_select(0, NULL, NULL, NULL, &t);
if (env->gui)
- SDL_UpdateRects(env->screen, 1, &env->gui->win[WIN_KEYPAD].rect);// XXX inefficient
+ SDL_UpdateRects(env->gui->screen, 1, &env->gui->win[WIN_KEYPAD].rect);// XXX inefficient
/*
* While there is something to display, call the decoder and free
* the buffer, possibly enabling the receiver to store new data.
video_in_uninit(&env->in);
video_out_uninit(&env->out);
- if (env->sdl_ok)
+ if (env->gui)
cleanup_sdl(env);
-
+ ast_mutex_destroy(&(env->in.dec_in_lock));
env->shutdown = 0;
return NULL;
}