[asterisk-commits] rizzo: trunk r94810 - /trunk/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 26 15:10:43 CST 2007
Author: rizzo
Date: Wed Dec 26 15:10:42 2007
New Revision: 94810
URL: http://svn.digium.com/view/asterisk?view=rev&rev=94810
Log:
move more gui stuff into console_gui.c
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=94810&r1=94809&r2=94810
==============================================================================
--- trunk/channels/console_gui.c (original)
+++ trunk/channels/console_gui.c Wed Dec 26 15:10:42 2007
@@ -18,6 +18,17 @@
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
+ */
+struct display_window {
+ SDL_Overlay *bmp;
+ SDL_Rect rect; /* location of the window */
+};
#define GUI_BUFFER_LEN 256 /* buffer lenght used for input buffers */
struct keypad_entry; /* defined in console_gui.c */
@@ -39,6 +50,8 @@
SDL_Surface *keypad; /* the pixmap for the keypad */
int kp_size, kp_used;
struct keypad_entry *kp;
+
+ struct display_window win[WIN_MAX];
};
static void cleanup_sdl(struct video_desc *env)
@@ -61,19 +74,19 @@
if (gui->keypad)
SDL_FreeSurface(gui->keypad);
gui->keypad = NULL;
+
+ /* uninitialize the SDL environment */
+ for (i = 0; i < WIN_MAX; i++) {
+ if (gui->win[i].bmp)
+ SDL_FreeYUVOverlay(gui->win[i].bmp);
+ }
+ bzero(gui->win, sizeof(gui->win));
/* XXX free the keys entries */
ast_free(gui);
env->gui = NULL;
}
-
- /* uninitialize the SDL environment */
- for (i = 0; i < WIN_MAX; i++) {
- if (env->win[i].bmp)
- SDL_FreeYUVOverlay(env->win[i].bmp);
- }
SDL_Quit();
env->screen = NULL; /* XXX check reference */
- bzero(env->win, sizeof(env->win));
if (env->sdl_ok)
ast_mutex_destroy(&(env->in.dec_in_lock));
}
@@ -93,6 +106,7 @@
AVPicture *p_in, p_out;
struct fbuf_t *b_in, *b_out;
SDL_Overlay *bmp;
+ struct gui_info *gui = env->gui;
if (!env->sdl_ok)
return;
@@ -112,7 +126,7 @@
b_out = &env->in.rem_dpy;
p_in = (AVPicture *)env->in.d_frame;
}
- bmp = env->win[out].bmp;
+ bmp = gui->win[out].bmp;
SDL_LockYUVOverlay(bmp);
/* output picture info - this is sdl, YUV420P */
bzero(&p_out, sizeof(p_out));
@@ -126,7 +140,7 @@
my_scale(b_in, p_in, b_out, &p_out);
/* lock to protect access to Xlib by different threads. */
- SDL_DisplayYUVOverlay(bmp, &env->win[out].rect);
+ SDL_DisplayYUVOverlay(bmp, &gui->win[out].rect);
SDL_UnlockYUVOverlay(bmp);
}
@@ -311,11 +325,11 @@
int x = 30, y = 20; /* XXX change */
SDL_Surface *output = NULL;
SDL_Color color = {0, 0, 0}; /* text color */
- SDL_Rect dest = {env->win[WIN_KEYPAD].rect.x + x, y};
struct gui_info *gui = env->gui;
+ SDL_Rect dest = {gui->win[WIN_KEYPAD].rect.x + x, y};
/* clean surface each rewrite */
- SDL_BlitSurface(gui->keypad, NULL, env->screen, &env->win[WIN_KEYPAD].rect);
+ SDL_BlitSurface(gui->keypad, NULL, env->screen, &gui->win[WIN_KEYPAD].rect);
output = TTF_RenderText_Solid(gui->font, text, color);
if (output == NULL) {
@@ -325,7 +339,7 @@
SDL_BlitSurface(output, NULL, env->screen, &dest);
- SDL_UpdateRects(gui->keypad, 1, &env->win[WIN_KEYPAD].rect);
+ SDL_UpdateRects(gui->keypad, 1, &gui->win[WIN_KEYPAD].rect);
SDL_FreeSurface(output);
return 0; /* success */
#endif
@@ -356,9 +370,9 @@
/* define keypad boundary */
if (button.x < env->in.rem_dpy.w)
index = KEY_REM_DPY; /* click on remote video */
- else if (button.x > env->in.rem_dpy.w + env->out.keypad_dpy.w)
+ else if (button.x > env->in.rem_dpy.w + env->gui->keypad->w)
index = KEY_LOC_DPY; /* click on local video */
- else if (button.y > env->out.keypad_dpy.h)
+ else if (button.y > env->gui->keypad->h)
index = KEY_OUT_OF_KEYPAD; /* click outside the keypad */
else if (env->gui->kp) {
int i;
@@ -653,8 +667,6 @@
if (!env->gui->keypad)
return;
- env->out.keypad_dpy.w = env->gui->keypad->w;
- env->out.keypad_dpy.h = env->gui->keypad->h;
/*
* If the keypad image has a comment field, try to read
* the button location from there. The block must be
@@ -729,6 +741,7 @@
int dpy_fmt = SDL_IYUV_OVERLAY; /* YV12 causes flicker in SDL */
int depth, maxw, maxh;
const SDL_VideoInfo *info = SDL_GetVideoInfo();
+ int kp_w = 0, kp_h = 0; /* keypad width and height */
/* We want at least 16bpp to support YUV overlays.
* E.g with SDL_VIDEODRIVER = aalib the default is 8
@@ -753,10 +766,14 @@
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 + env->out.keypad_dpy.w;
- maxh = MAX( MAX(env->in.rem_dpy.h, env->out.loc_dpy.h), env->out.keypad_dpy.h);
+ 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);
@@ -766,19 +783,19 @@
}
SDL_WM_SetCaption("Asterisk console Video Output", NULL);
- if (set_win(env->screen, &env->win[WIN_REMOTE], dpy_fmt,
+ if (set_win(env->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->win[WIN_LOCAL], dpy_fmt,
+ if (set_win(env->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 + env->out.keypad_dpy.w, BORDER))
+ 3*BORDER+env->in.rem_dpy.w + kp_w, BORDER))
goto no_sdl;
/* display the skin, but do not free it as we need it later to
* restore text areas and maybe sliders too.
*/
if (env->gui && env->gui->keypad) {
- struct SDL_Rect *dest = &env->win[WIN_KEYPAD].rect;
+ struct SDL_Rect *dest = &env->gui->win[WIN_KEYPAD].rect;
dest->x = 2*BORDER + env->in.rem_dpy.w;
dest->y = BORDER;
dest->w = env->gui->keypad->w;
Modified: trunk/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.c?view=diff&rev=94810&r1=94809&r2=94810
==============================================================================
--- trunk/channels/console_video.c (original)
+++ trunk/channels/console_video.c Wed Dec 26 15:10:42 2007
@@ -196,7 +196,6 @@
struct fbuf_t enc_in; /* encoder input buffer, allocated in video_out_init() */
struct fbuf_t enc_out; /* encoder output buffer, allocated in video_out_init() */
struct fbuf_t loc_dpy; /* display source buffer, no buffer (managed by SDL in bmp[1]) */
- struct fbuf_t keypad_dpy; /* keypad source buffer, XXX */
struct video_codec_desc *enc; /* encoder */
void *enc_ctx; /* encoding context */
@@ -273,7 +272,6 @@
char keypad_font[256]; /* font for the keypad */
char sdl_videodriver[256];
- struct display_window win[WIN_MAX];
};
static AVPicture *fill_pict(struct fbuf_t *b, AVPicture *p);
@@ -1086,7 +1084,6 @@
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
@@ -1153,7 +1150,8 @@
/* sleep for a while */
ast_select(0, NULL, NULL, NULL, &t);
- SDL_UpdateRects(env->screen, 1, &env->win[WIN_KEYPAD].rect);// XXX inefficient
+ if (env->gui)
+ SDL_UpdateRects(env->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.
Modified: trunk/channels/console_video.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/console_video.h?view=diff&rev=94810&r1=94809&r2=94810
==============================================================================
--- trunk/channels/console_video.h (original)
+++ trunk/channels/console_video.h Wed Dec 26 15:10:42 2007
@@ -45,17 +45,6 @@
#include <SDL/SDL_ttf.h> /* render text on sdl surfaces */
#endif
-/* 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
- */
-struct display_window {
- SDL_Overlay *bmp;
- SDL_Rect rect; /* location of the window */
-};
#define CONSOLE_VIDEO_CMDS \
More information about the asterisk-commits
mailing list