#include "asterisk.h"
#include "console_video.h"
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/utils.h"
#include <math.h>
#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
#include <X11/Xlib.h>
Go to the source code of this file.
Data Structures | |
struct | _s_k |
struct | display_window |
struct | gui_info |
struct | keypad_entry |
struct | thumb_bd |
Macros | |
#define | BORDER 5 /* border around our windows */ |
#define | FONT_H 20 |
#define | FONT_W 9 |
#define | IS_ON 4 |
#define | IS_PRIMARY 1 |
#define | IS_SECONDARY 2 |
#define | MY_EV (SDL_MOUSEBUTTONDOWN|SDL_KEYDOWN) |
#define | N_EVENTS 32 |
#define | POLARITY -1 |
#define | SRC_MSG_BD_H 20 /* height of the message board below those windows */ |
Enumerations | |
enum | { WIN_LOCAL, WIN_REMOTE, WIN_KEYPAD, WIN_SRC1, WIN_SRC2, WIN_SRC3, WIN_SRC4, WIN_SRC5, WIN_SRC6, WIN_SRC7, WIN_SRC8, WIN_SRC9, WIN_MAX } |
enum | kp_type { KP_NONE, KP_RECT, KP_CIRCLE } |
enum | skin_area { KEY_PICK_UP = 128, KEY_HANG_UP = 129, KEY_MUTE = 130, KEY_AUTOANSWER = 131, KEY_SENDVIDEO = 132, KEY_LOCALVIDEO = 133, KEY_REMOTEVIDEO = 134, KEY_FLASH = 136, KEY_MESSAGEBOARD = 140, KEY_DIALEDBOARD = 141, KEY_EDITBOARD = 142, KEY_GUI_CLOSE = 199, KEY_KEYPAD = 200, KEY_FONT = 201, KEY_MESSAGE = 202, KEY_DIALED = 203, KEY_EDIT = 204, KEY_FREEZE = 220, KEY_CAPTURE = 221, KEY_PIP = 230, KEY_SRCS_WIN = 231, KEY_OUT_OF_KEYPAD = 241, KEY_REM_DPY = 242, KEY_LOC_DPY = 243, KEY_RESET = 253, KEY_NONE = 254, KEY_DIGIT_BACKGROUND = 255 } |
Functions | |
struct board * | board_setup (SDL_Surface *screen, SDL_Rect *dest, SDL_Surface *font, SDL_Rect *font_rects) |
Initialize the board. return 0 on success, 1 on error TODO, if this is done at reload time, free resources before allocate new ones TODO: resource deallocation in case of error. TODO: move the font load at gui_initialization TODO: deallocation of the message history. More... | |
static struct gui_info * | cleanup_sdl (struct gui_info *gui, int device_num) |
free the resources in struct gui_info and the descriptor itself. Return NULL so we can assign the value back to the descriptor in case. More... | |
int | compute_drag (int *start, int end, int magnifier) |
char * | console_do_answer (int fd) |
static void | eventhandler (struct video_desc *env, const char *caption) |
refresh the screen, and also grab a bunch of events. More... | |
static void | grabber_move (struct video_device *, int dx, int dy) |
static struct gui_info * | gui_init (const char *keypad_file, const char *font) |
static int | gui_map_token (const char *s) |
static void | handle_keyboard_input (struct video_desc *env, SDL_keysym *ks) |
static void | handle_mousedown (struct video_desc *env, SDL_MouseButtonEvent button) |
static void | init_board (struct gui_info *gui, struct board **dst, SDL_Rect *r, int dx, int dy) |
initialize the boards we have in the keypad More... | |
static int | keypad_cfg_read (struct gui_info *gui, const char *val) |
read a keypad entry line in the format reset token circle xc yc diameter token circle xc yc x1 y1 h # ellipse, main diameter and height token rect x0 y0 x1 y1 h # rectangle with main side and eight token x0 y0 w h # horizontal rectangle (short format)
this is used e.g. for message boardstoken is the token to be returned, either a character or a symbol as KEY_* above Return 1 on success, 0 on error. More... | |
static void | keypad_digit (struct video_desc *env, int digit) |
static void | keypad_pick_up (struct video_desc *env) |
static void | keypad_setup (struct gui_info *gui, const char *kp_file) |
static char * | keypad_toggle (struct video_desc *env, int index) |
static int | kp_match_area (const struct keypad_entry *e, int x, int y) |
static SDL_Surface * | load_image (const char *file) |
static char | map_key (SDL_keysym *ks) |
static int | my_x_handler (Display *d, XErrorEvent *e) |
static void | pip_move (struct video_desc *env, int dx, int dy) |
This function moves the picture in picture, controlling the limits of the containing buffer to avoid problems deriving from going through the limits. More... | |
static void | sdl_setup (struct video_desc *env) |
[re]set the main sdl window, useful in case of resize. We can tell the first from subsequent calls from the value of env->gui, which is NULL the first time. More... | |
static void | set_drag (struct drag_info *drag, int x, int y, enum drag_window win) |
static int | set_win (SDL_Surface *screen, struct display_window *win, int fmt, int w, int h, int x, int y) |
static void | show_frame (struct video_desc *env, int out) |
static int | switch_video_out (struct video_desc *env, int index, Uint8 button) |
Changes the video output (local video) source, controlling if it is already using that video device, and switching the correct fields of env->out. grabbers are always open and saved in the device table. The secondary or the primary device can be changed, according to the "button" parameter: the primary device is changed if button = SDL_BUTTON_LEFT; the secondary device is changed if button = not SDL_BUTTON_LEFT;. More... | |
static int | turn_on_off (int index, struct video_desc *env) |
tries to switch the state of a device from on to off or off to on we also have to update the status of the device and the correct message board More... | |
static int | update_device_info (struct video_desc *env, int i) |
static int | video_geom (struct fbuf_t *b, const char *s) |
Variables | |
static struct _s_k | gui_key_map [] |
char * | src_msgs [] |
static const char *const | us_kbd_map [] |
#define BORDER 5 /* border around our windows */ |
Definition at line 117 of file console_gui.c.
Referenced by handle_mousedown(), and sdl_setup().
#define FONT_H 20 |
Referenced by gui_init().
#define FONT_W 9 |
Referenced by gui_init().
#define IS_ON 4 |
Definition at line 237 of file console_gui.c.
Referenced by turn_on_off().
#define IS_PRIMARY 1 |
Definition at line 235 of file console_gui.c.
Referenced by switch_video_out().
#define IS_SECONDARY 2 |
Definition at line 236 of file console_gui.c.
Referenced by switch_video_out().
#define MY_EV (SDL_MOUSEBUTTONDOWN|SDL_KEYDOWN) |
#define N_EVENTS 32 |
Referenced by eventhandler().
#define POLARITY -1 |
Referenced by compute_drag().
Definition at line 118 of file console_gui.c.
Referenced by handle_mousedown(), and sdl_setup().
anonymous enum |
Enumerator | |
---|---|
WIN_LOCAL | |
WIN_REMOTE | |
WIN_KEYPAD | |
WIN_SRC1 | |
WIN_SRC2 | |
WIN_SRC3 | |
WIN_SRC4 | |
WIN_SRC5 | |
WIN_SRC6 | |
WIN_SRC7 | |
WIN_SRC8 | |
WIN_SRC9 | |
WIN_MAX |
Definition at line 93 of file console_gui.c.
enum kp_type |
Enumerator | |
---|---|
KP_NONE | |
KP_RECT | |
KP_CIRCLE |
Definition at line 120 of file console_gui.c.
enum skin_area |
Definition at line 318 of file console_gui.c.
struct board* board_setup | ( | SDL_Surface * | screen, |
SDL_Rect * | dest, | ||
SDL_Surface * | font, | ||
SDL_Rect * | font_rects | ||
) |
Initialize the board. return 0 on success, 1 on error TODO, if this is done at reload time, free resources before allocate new ones TODO: resource deallocation in case of error. TODO: move the font load at gui_initialization TODO: deallocation of the message history.
Definition at line 95 of file console_board.c.
References ast_calloc, ast_free, ast_log(), board::blank, board::cur_col, board::cur_line, board::font, FONT_H, board::font_rects, FONT_W, LOG_WARNING, board::p_h, board::p_rect, board::p_w, board::screen, board::text, board::v_h, and board::v_w.
Referenced by init_board(), and sdl_setup().
free the resources in struct gui_info and the descriptor itself. Return NULL so we can assign the value back to the descriptor in case.
Definition at line 185 of file console_gui.c.
References ast_free, gui_info::bd_dialed, gui_info::bd_msg, display_window::bmp, thumb_bd::board, delete_board(), gui_info::font, gui_info::keypad, gui_info::kp, gui_info::outfd, gui_info::thumb_bd_array, gui_info::win, and WIN_MAX.
Referenced by sdl_setup().
int compute_drag | ( | int * | start, |
int | end, | ||
int | magnifier | ||
) |
char* console_do_answer | ( | int | fd | ) |
|
static |
refresh the screen, and also grab a bunch of events.
Definition at line 953 of file console_gui.c.
References ast_log(), ast_tvdiff_ms(), ast_tvnow(), gui_info::bd_msg, compute_drag(), gui_info::drag, DRAG_LOCAL, DRAG_MESSAGE, DRAG_NONE, DRAG_PIP, drag_info::drag_window, grabber_move(), handle_keyboard_input(), handle_mousedown(), LOG_WARNING, move_message_board(), N_EVENTS, gui_info::outfd, pip_move(), type, drag_info::x_start, and drag_info::y_start.
|
static |
Referenced by eventhandler().
|
static |
Definition at line 1062 of file console_gui.c.
References ast_calloc, ast_free, ast_log(), ast_strlen_zero(), gui_info::drag, DRAG_NONE, drag_info::drag_window, gui_info::font, FONT_H, gui_info::font_rects, FONT_W, gui_info::kb_output, gui_info::keypad, keypad_setup(), KO_MESSAGE, load_image(), LOG_WARNING, and gui_info::outfd.
Referenced by sdl_setup().
|
static |
Definition at line 1536 of file console_gui.c.
References _s_k::k, KEY_NONE, and _s_k::s.
Referenced by keypad_cfg_read().
|
static |
Definition at line 875 of file console_gui.c.
References gui_info::bd_msg, gui_info::kb_output, keypad_pick_up(), KO_DIALED, KO_INPUT, KO_MESSAGE, map_key(), and print_message().
Referenced by eventhandler().
|
static |
Definition at line 619 of file console_gui.c.
References ast_log(), gui_info::bd_dialed, gui_info::bd_msg, BORDER, keypad_entry::c, gui_info::drag, DRAG_LOCAL, DRAG_MESSAGE, DRAG_NONE, DRAG_PIP, drag_info::drag_window, fbuf_t::h, KEY_AUTOANSWER, KEY_CAPTURE, KEY_DIGIT_BACKGROUND, KEY_FREEZE, KEY_HANG_UP, KEY_LOC_DPY, KEY_LOCALVIDEO, KEY_MESSAGEBOARD, KEY_MUTE, KEY_OUT_OF_KEYPAD, KEY_PICK_UP, KEY_PIP, KEY_REM_DPY, KEY_REMOTEVIDEO, KEY_SENDVIDEO, KEY_SRCS_WIN, gui_info::keypad, keypad_digit(), keypad_pick_up(), keypad_toggle(), gui_info::kp, kp_match_area(), gui_info::kp_size, gui_info::kp_used, LOG_WARNING, MAX, gui_info::outfd, print_message(), sdl_setup(), set_drag(), SRC_MSG_BD_H, SRC_WIN_H, SRC_WIN_W, switch_video_out(), turn_on_off(), update_device_info(), video_geom(), and fbuf_t::w.
Referenced by eventhandler().
|
static |
initialize the boards we have in the keypad
Definition at line 1186 of file console_gui.c.
References board_setup(), gui_info::font, gui_info::font_rects, and gui_info::screen.
Referenced by sdl_setup().
|
static |
read a keypad entry line in the format reset token circle xc yc diameter token circle xc yc x1 y1 h # ellipse, main diameter and height token rect x0 y0 x1 y1 h # rectangle with main side and eight token x0 y0 w h # horizontal rectangle (short format)
Definition at line 1561 of file console_gui.c.
References ast_calloc, ast_log(), ast_realloc, keypad_entry::c, gui_map_token(), keypad_entry::h, KEY_DIALED, KEY_EDIT, KEY_FONT, KEY_KEYPAD, KEY_MESSAGE, KEY_NONE, KEY_RESET, gui_info::kp, KP_CIRCLE, gui_info::kp_dialed, gui_info::kp_edit, gui_info::kp_msg, KP_RECT, gui_info::kp_rect, gui_info::kp_size, gui_info::kp_used, LOG_WARNING, keypad_entry::type, keypad_entry::x0, keypad_entry::x1, keypad_entry::y0, and keypad_entry::y1.
Referenced by keypad_setup().
|
static |
Definition at line 374 of file console_gui.c.
References AST_FRAME_DTMF, ast_queue_frame(), print_message(), and ast_frame::subclass.
Referenced by handle_mousedown().
|
static |
Definition at line 432 of file console_gui.c.
References ast_log(), ast_skip_blanks(), gui_info::bd_dialed, gui_info::bd_msg, LOG_WARNING, gui_info::outfd, print_message(), read_message(), and reset_board().
Referenced by handle_keyboard_input(), and handle_mousedown().
|
static |
Definition at line 1127 of file console_gui.c.
References ast_log(), ast_skip_blanks(), ast_trim_blanks(), gui_info::keypad, keypad_cfg_read(), load_image(), and LOG_WARNING.
Referenced by gui_init().
|
static |
Definition at line 389 of file console_gui.c.
References ast_log(), chan_oss_pvt::autoanswer, find_desc(), KEY_AUTOANSWER, KEY_FREEZE, KEY_MUTE, KEY_PIP, KEY_SENDVIDEO, LOG_WARNING, and oss_active.
Referenced by handle_mousedown().
|
static |
Definition at line 1487 of file console_gui.c.
References ast_log(), keypad_entry::c, keypad_entry::h, KP_CIRCLE, KP_RECT, LOG_WARNING, keypad_entry::type, keypad_entry::x0, keypad_entry::x1, keypad_entry::y0, and keypad_entry::y1.
Referenced by handle_mousedown().
|
static |
Definition at line 1043 of file console_gui.c.
Referenced by gui_init(), and keypad_setup().
|
static |
Definition at line 847 of file console_gui.c.
References us_kbd_map.
Referenced by handle_keyboard_input().
|
static |
Definition at line 1208 of file console_gui.c.
References ast_log(), and LOG_WARNING.
Referenced by sdl_setup().
|
static |
This function moves the picture in picture, controlling the limits of the containing buffer to avoid problems deriving from going through the limits.
env | = pointer to the descriptor of the video environment |
dx | = the variation of the x position |
dy | = the variation of the y position |
Definition at line 925 of file console_gui.c.
Referenced by eventhandler().
|
static |
[re]set the main sdl window, useful in case of resize. We can tell the first from subsequent calls from the value of env->gui, which is NULL the first time.
Definition at line 1219 of file console_gui.c.
References ast_log(), ast_strlen_zero(), gui_info::bd_dialed, gui_info::bd_msg, thumb_bd::board, board_setup(), BORDER, cleanup_sdl(), gui_info::font, gui_info::font_rects, gui_init(), init_board(), gui_info::keypad, gui_info::kp_dialed, gui_info::kp_msg, gui_info::kp_rect, LOG_ERROR, LOG_WARNING, MAX, my_x_handler(), display_window::rect, thumb_bd::rect, gui_info::screen, set_win(), SRC_MSG_BD_H, SRC_WIN_H, SRC_WIN_W, gui_info::thumb_bd_array, gui_info::win, WIN_KEYPAD, WIN_LOCAL, WIN_REMOTE, and WIN_SRC1.
Referenced by handle_mousedown().
|
static |
Definition at line 482 of file console_gui.c.
References drag_info::drag_window, gui_info::win, drag_info::x_start, and drag_info::y_start.
Referenced by handle_mousedown().
|
static |
Definition at line 1112 of file console_gui.c.
References display_window::bmp, and display_window::rect.
Referenced by sdl_setup().
|
static |
Definition at line 259 of file console_gui.c.
References display_window::bmp, fbuf_t::h, fbuf_t::pix_fmt, display_window::rect, fbuf_t::w, gui_info::win, WIN_LOCAL, WIN_REMOTE, and WIN_SRC1.
Referenced by hook_event_cb().
|
static |
Changes the video output (local video) source, controlling if it is already using that video device, and switching the correct fields of env->out. grabbers are always open and saved in the device table. The secondary or the primary device can be changed, according to the "button" parameter: the primary device is changed if button = SDL_BUTTON_LEFT; the secondary device is changed if button = not SDL_BUTTON_LEFT;.
the correct message boards of the sources are also updated with the new status
env | = pointer to the video environment descriptor |
index | = index of the device the caller wants to use are primary or secondary device |
button | = button clicked on the mouse |
returns 0 on success, returns 1 on error
Definition at line 516 of file console_gui.c.
References ast_log(), if(), IS_PRIMARY, IS_SECONDARY, LOG_WARNING, and update_device_info().
Referenced by handle_mousedown().
|
static |
tries to switch the state of a device from on to off or off to on we also have to update the status of the device and the correct message board
index | = the device that must be turned on or off |
env | = pointer to the video environment descriptor |
returns:
Definition at line 570 of file console_gui.c.
References ast_log(), console_grabbers, IS_ON, LOG_WARNING, grab_desc::open, and update_device_info().
Referenced by handle_mousedown().
|
static |
Definition at line 489 of file console_gui.c.
References print_message(), reset_board(), and src_msgs.
Referenced by handle_mousedown(), switch_video_out(), and turn_on_off().
|
static |
Referenced by handle_mousedown().
|
static |
Definition at line 1512 of file console_gui.c.
char* src_msgs[] |
Definition at line 239 of file console_gui.c.
Referenced by update_device_info().
|
static |
Definition at line 839 of file console_gui.c.
Referenced by map_key().