[asterisk-commits] rizzo: branch rizzo/video_console r125702 - /team/rizzo/video_console/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 27 00:13:25 CDT 2008
Author: rizzo
Date: Fri Jun 27 00:13:25 2008
New Revision: 125702
URL: http://svn.digium.com/view/asterisk?view=rev&rev=125702
Log:
clean up some comments, and also some formatting changes.
Modified:
team/rizzo/video_console/channels/console_gui.c
team/rizzo/video_console/channels/console_video.c
Modified: team/rizzo/video_console/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_gui.c?view=diff&rev=125702&r1=125701&r2=125702
==============================================================================
--- team/rizzo/video_console/channels/console_gui.c (original)
+++ team/rizzo/video_console/channels/console_gui.c Fri Jun 27 00:13:25 2008
@@ -7,56 +7,55 @@
/*
* GUI layout, structure and management
-For the GUI we use SDL to create a large surface (gui->screen)
-containing four sections: remote video on the left, local video
-on the right, the keypad with all controls and text windows
-in the center, and above these three sections, the source device thumbnails section
-(including the relative message boards).
-The fourth section may even not be displayed if no devices are specified
-in the configuration file oss.conf
-The central section is built using an image for the skin, fonts and
-other GUI elements. Comments embedded in the image to indicate to
-what function each area is mapped to.
+For the GUI we use SDL to create a large surface (gui->screen) with 4 areas:
+remote video on the left, local video on the right, keypad with all controls
+and text windows in the center, and source device thumbnails on the top.
+The top row is not displayed if no devices are specified in the config file.
+
+ ________________________________________________________________
+ | ______ ______ ______ ______ ______ ______ ______ |
+ | | tn.1 | | tn.2 | | tn.3 | | tn.4 | | tn.5 | | tn.6 | | tn.7 | |
+ | |______| |______| |______| |______| |______| |______| |______| |
+ | ______ ______ ______ ______ ______ ______ ______ |
+ | |______| |______| |______| |______| |______| |______| |______| |
+ | _________________ __________________ _________________ |
+ | | | | | | | |
+ | | | | | | | |
+ | | | | | | | |
+ | | remote video | | | | local video | |
+ | | | | | | ______ | |
+ | | | | keypad | | | PIP || |
+ | | | | | | |______|| |
+ | |_________________| | | |_________________| |
+ | | | |
+ | | | |
+ | |__________________| |
+ |________________________________________________________________|
+
+
+The central section is built using an image (jpg, png, maybe gif too)
+for the skin, and other GUI elements. Comments embedded in the image
+indicate to what function each area is mapped to.
+Another image (png with transparency) is used for the font.
Mouse and keyboard events are detected on the whole surface, and
handled differently according to their location:
-
+- center/right click on the local/remote window are used to resize
+ the corresponding window;
+- clicks on the thumbnail start/stop sources and select them as
+ primary or secondary video sources;
- drag on the local video window are used to move the captured
- area (in the case of X11 grabber) or the picture-in-picture
- location (in case of camera included on the X11 grab).
-- click on the keypad are mapped to the corresponding key;
+ area (in the case of X11 grabber) or the picture-in-picture position;
+- keystrokes on the keypad are mapped to the corresponding key;
+ keystrokes are used as keypad functions, or as text input
+ if we are in text-input mode.
- drag on some keypad areas (sliders etc.) are mapped to the
corresponding functions;
-- keystrokes are used as keypad functions, or as text input
- if we are in text-input mode.
Configuration options control the appeareance of the gui:
- keypad = /tmp/phone.jpg ; the skin
- keypad_font = /tmp/font.ttf ; the font to use for output (XXX deprecated)
-
-with raw chunky graphics, the situation of the GUI can be represented as follows
- ____________________________________________________________________________
-| ______ ______ ______ ______ ______ ______ ______ |
-| | | | | | | | | | | | | | | |
-| |______| |______| |______| |______| |______| |______| |______| |
-| ______ ______ ______ ______ ______ ______ ______ |
-| |______| |______| |______| |______| |______| |______| |______| |
-| _______________________ __________________ _______________________ |
-| | | | | | | |
-| | | | | | | |
-| | | | | | | |
-| | remote video | | | | local video | |
-| | | | | | | |
-| | | | keypad | | | |
-| | | | | | | |
-| |_______________________| | | |_______________________| |
-| | | |
-| | | |
-| | | |
-| | | |
-| |__________________| |
-|____________________________________________________________________________|
+ keypad = /tmp/kpad2.jpg ; the skin
+ keypad_font = /tmp/font.png ; the font to use for output
*
*/
@@ -454,17 +453,15 @@
*/
static int switch_video_out(struct video_desc *env, int index, Uint8 button)
{
- int *p = &env->out.device_secondary; /* pointer to the index of the secondary device */
- /* the default switching is of the secondary device */
- /* device not found */
+ int *p; /* pointer to the index of the device to select */
+
if (index >= env->out.device_num) {
ast_log(LOG_WARNING, "no devices\n");
return 1;
}
- /* we have to switch the primary source if the left button is clicked */
- if (button == SDL_BUTTON_LEFT)
- p--;
- /* p becomes a pointer to the index to change (primary or secondary) */
+ /* select primary or secondary */
+ p = (button == SDL_BUTTON_LEFT) ? &env->out.device_primary :
+ &env->out.device_secondary;
/* controls if the device is already selected */
if (index == *p) {
ast_log(LOG_WARNING, "device %s already selected\n", env->out.devices[index].name);
@@ -512,12 +509,16 @@
* - 1 on success in switching from off to on
* - 2 on success in switching from on to off
*/
-static int turn_on_off(int index, struct video_desc *env){
+static int turn_on_off(int index, struct video_desc *env)
+{
struct video_device *p = &env->out.devices[index];
+
if (!p->grabber) { /* device off */
- void *g_data; /* container for the result of the open function on the grabber */
- struct grab_desc *g; /* sequentially we try all the defined types of grabber */
- int i; /* integer variable used as iterator */
+ void *g_data; /* result of grabber_open() */
+ struct grab_desc *g;
+ int i;
+
+ /* see if we can open one of the grabbers XXX */
for (i = 0; (g = console_grabbers[i]); i++) {
if (g == NULL)
break;
@@ -538,8 +539,7 @@
return 0; /* falure */
} else {
/* the grabber must be closed */
- p->grabber_data =
- p->grabber->close(p->grabber_data);
+ p->grabber_data = p->grabber->close(p->grabber_data);
p->grabber = NULL;
if (p->dev_buf) { /* free the buffer if necessary */
fbuf_free(p->dev_buf);
@@ -617,11 +617,10 @@
}
}
}
- } else if (button.y < BORDER)
+ } else if (button.y < BORDER) {
index = KEY_OUT_OF_KEYPAD;
- else {
+ } else { /* we are in the thumbnail area */
x = x0 - src_wins_tot_w/2 + BORDER;
- /* in the area of the small device windows */
if (button.y >= BORDER + SRC_WIN_H)
index = KEY_OUT_OF_KEYPAD;
else if (button.x < x)
Modified: team/rizzo/video_console/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_video.c?view=diff&rev=125702&r1=125701&r2=125702
==============================================================================
--- team/rizzo/video_console/channels/console_video.c (original)
+++ team/rizzo/video_console/channels/console_video.c Fri Jun 27 00:13:25 2008
@@ -158,12 +158,12 @@
* about the device
*/
struct video_device {
- char *name; /* name of the device */
- struct grab_desc *grabber; /* the grabber for the device type */
- void *grabber_data; /* device's private data structure */
- struct fbuf_t *dev_buf; /* buffer for incoming data */
- struct timeval last_frame; /* when we read the last frame ? */
- int status_index; /* what is the status of the device (source) */
+ char *name; /* name of the device */
+ struct grab_desc *grabber; /* the grabber for the device type */
+ void *grabber_data; /* device's private data structure */
+ struct fbuf_t *dev_buf; /* buffer for incoming data */
+ struct timeval last_frame; /* when we read the last frame ? */
+ int status_index; /* what is the status of the device (source) */
/* status index is set using the IS_ON, IS_PRIMARY and IS_SECONDARY costants */
/* status_index is the index of the status message in the src_msgs array in console_gui.c */
};
@@ -842,7 +842,7 @@
if (!ast_strlen_zero(save_display))
setenv("DISPLAY", save_display, 1);
- /* initialize grab coordinates */
+ /* initialize grab coordinates XXX do we need it ? */
env->out.loc_src_geometry.x = 0;
env->out.loc_src_geometry.y = 0;
@@ -855,15 +855,17 @@
if (env->out.devices)
env->out.devices[env->out.device_primary].status_index |= IS_PRIMARY | IS_SECONDARY;
- /* even if no device is connected, we must initialize the video_out_init,
- infact it is used in the get_video_frames function */
+ /* even if no device is connected, we must call video_out_init,
+ * as some of the data structures it initializes are
+ * used in get_video_frames()
+ */
video_out_init(env);
- /* writes intial messages in the source boards, those can be
- modified during the execution, beacuse of the events */
- for (i = 0; i < env->out.device_num; i++)
+ /* Writes intial status of the sources. */
+ for (i = 0; i < env->out.device_num; i++) {
print_message(env->gui->bd_srcs_msg[i],
src_msgs[env->out.devices[i].status_index]);
+ }
for (;;) {
struct timeval t = { 0, 50000 }; /* XXX 20 times/sec */
@@ -1108,51 +1110,50 @@
}
-/*! \brief fills the table of the video device with their name;
- * other fields in the rows of the table are assigned the NULL value.
- * The table is a list of objects, implemented using the ast_realloc function to make the
- * size dynamic, in this way it is ideally possible to manage an arbitrary number of devices.
- * actually, in prictice the maximum number of supported device si 9.
- * The last_frame field in each entry of the rable is initialized to the actual time
- * value, this needs to be done to avoid uninitialized access later
+/*! \brief add an entry to the video_device table,
+ * ignoring duplicate names.
+ * The table is a dynamic array implemented using ast_realloc().
+ * No limit on the size but we restrict to at most 9 entries.
+ * The last_frame field in each entry of the table is initialized to
+ * the current time, to avoid troubles later. XXX
*
* PARAMETERS:
* \param devices_p = pointer to the table of devices
* \param device_num_p = pointer to the number of devices
- * \param s = name of the new device
+ * \param s = name of the new device to insert
*
* returns 0 on success, 1 on error
*/
-static int device_table_fill (struct video_device **devices_p, int *device_num_p, const char *s)
+static int device_table_fill(struct video_device **devices_p, int *device_num_p, const char *s)
{
int i;
void *temp;
struct video_device *p;
+
/* with the current implementation, we support a maximum of 9 devices.*/
- if ((*device_num_p) >= 9)
+ if (*device_num_p >= 9)
return 0; /* more devices will be ignored */
- /* check if the entry has already been inserted */
- for (i = 0; i < *device_num_p; i++)
+ /* ignore duplicate names */
+ for (i = 0; i < *device_num_p; i++) {
if (!strcmp((*devices_p)[i].name, s))
return 0;
+ }
/* inserts the new video device, changing the size of the table */
temp = ast_realloc(*devices_p, (*device_num_p+1)*sizeof(struct video_device));
if (temp == NULL) {
- ast_log(LOG_WARNING, "cannot reallocate devices, maximum size reached\n");
+ ast_log(LOG_WARNING, "cannot reallocate device table\n");
return 1;
}
*devices_p = (struct video_device*) temp;
p = &(*devices_p)[*device_num_p];
- /* copy the name */
- p->name = ast_strdup(s);
+ p->name = ast_strdup(s); /* copy the name */
/* other fields initially NULL */
p->grabber = NULL;
p->grabber_data = NULL;
p->dev_buf = NULL;
p->last_frame = ast_tvnow();
p->status_index = 0;
- /* one device added */
- (*device_num_p)++;
+ (*device_num_p)++; /* one device added */
return 0;
}
More information about the asterisk-commits
mailing list