Asterisk - The Open Source Telephony Project  18.5.0
console_video.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2007 Luigi Rizzo
5  *
6  * See http://www.asterisk.org for more information about
7  * the Asterisk project. Please do not directly contact
8  * any of the maintainers of this project for assistance;
9  * the project provides a web site, mailing lists and IRC
10  * channels for your use.
11  *
12  * This program is free software, distributed under the terms of
13  * the GNU General Public License Version 2. See the LICENSE file
14  * at the top of the source tree.
15  */
16 
17 /*
18  * Common header for console video support
19  *
20  * $Revision$
21  */
22 
23 #ifndef CONSOLE_VIDEO_H
24 #define CONSOLE_VIDEO_H
25 
26 #if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG)
27 #define CONSOLE_VIDEO_CMDS \
28  "console {device}"
29 #else
30 
31 #include <ffmpeg/avcodec.h>
32 #ifndef OLD_FFMPEG
33 #include <ffmpeg/swscale.h> /* requires a recent ffmpeg */
34 #endif
35 
36 #define CONSOLE_VIDEO_CMDS \
37  "console {videodevice|videocodec" \
38  "|video_size|bitrate|fps|qmin" \
39  "|sendvideo|keypad" \
40  "|sdl_videodriver" \
41  "|device|startgui|stopgui" \
42  "}"
43 
44 #endif /* HAVE_VIDEO_CONSOLE and others */
45 
46 #define SRC_WIN_W 80 /* width of video thumbnails */
47 #define SRC_WIN_H 60 /* height of video thumbnails */
48 /* we only support a limited number of video sources in the GUI,
49  * because we need screen estate to switch between them.
50  */
51 #define MAX_VIDEO_SOURCES 9
52 
53 /*
54  * In many places we use buffers to store the raw frames (but not only),
55  * so here is a structure to keep all the info. data = NULL means the
56  * structure is not initialized, so the other fields are invalid.
57  * size = 0 means the buffer is not malloc'ed so we don't have to free it.
58  */
59 struct fbuf_t { /* frame buffers, dynamically allocated */
60  uint8_t *data; /* memory, malloced if size > 0, just reference
61  * otherwise */
62  int size; /* total size in bytes */
63  int used; /* space used so far */
64  int ebit; /* bits to ignore at the end */
65  int x; /* origin, if necessary */
66  int y;
67  int w; /* size */
68  int h;
69  int pix_fmt;
70  /* offsets and size of the copy in Picture-in-Picture mode */
71  int win_x;
72  int win_y;
73  int win_w;
74  int win_h;
75 };
76 
77 void fbuf_free(struct fbuf_t *);
78 
79 /* descriptor for a grabber */
80 struct grab_desc {
81  const char *name;
82  void *(*open)(const char *name, struct fbuf_t *geom, int fps);
83  struct fbuf_t *(*read)(void *d);
84  void (*move)(void *d, int dx, int dy);
85  void *(*close)(void *d);
86 };
87 
88 extern struct grab_desc *console_grabbers[];
89 
90 struct video_desc; /* opaque type for video support */
91 struct video_desc *get_video_desc(struct ast_channel *c);
92 
93 /* linked by console_video.o */
94 int console_write_video(struct ast_channel *chan, struct ast_frame *f);
95 extern int console_video_formats;
96 int console_video_cli(struct video_desc *env, const char *var, int fd);
97 int console_video_config(struct video_desc **penv, const char *var, const char *val);
98 void console_video_uninit(struct video_desc *env);
99 void console_video_start(struct video_desc *env, struct ast_channel *owner);
100 int get_gui_startup(struct video_desc* env);
101 
102 /* console_board.c */
103 
104 /* Where do we send the keyboard/keypad output */
105 enum kb_output {
107  KO_INPUT, /* the local input window */
108  KO_DIALED, /* the 'dialed number' window */
109  KO_MESSAGE, /* the 'message' window */
110 };
111 
112 enum drag_window { /* which window are we dragging */
114  DRAG_LOCAL, /* local video */
115  DRAG_REMOTE, /* remote video */
116  DRAG_DIALED, /* dialed number */
117  DRAG_INPUT, /* input window */
118  DRAG_MESSAGE, /* message window */
119  DRAG_PIP, /* picture in picture */
120 };
121 
122 /*! \brief support for drag actions */
123 struct drag_info {
124  int x_start; /* last known mouse position */
125  int y_start;
127 };
128 /*! \brief info related to the gui: button status, mouse coords, etc. */
129 struct board;
130 /* !\brief print a message on a board */
131 void move_message_board(struct board *b, int dy);
132 int print_message(struct board *b, const char *s);
133 
134 /*! \brief return the whole text from a board */
135 const char *read_message(const struct board *b);
136 
137 /*! \brief reset the board to blank */
138 int reset_board(struct board *b);
139 
140 /*! \brief deallocates memory space for a board */
141 void delete_board(struct board *b);
142 #endif /* CONSOLE_VIDEO_H */
143 /* end of file */
const char * name
Definition: console_video.h:81
Main Channel structure associated with a channel.
int print_message(struct board *b, const char *s)
Definition: ast_expr2.c:325
void fbuf_free(struct fbuf_t *)
void move_message_board(struct board *b, int dy)
static struct test_val d
#define var
Definition: ast_expr2f.c:614
int pix_fmt
Definition: console_video.h:69
int used
Definition: console_video.h:63
int console_video_formats
static struct test_val c
int console_write_video(struct ast_channel *chan, struct ast_frame *f)
struct grab_desc * console_grabbers[]
const char * read_message(const struct board *b)
return the whole text from a board
struct video_desc * get_video_desc(struct ast_channel *c)
return the pointer to the video descriptor
Definition: chan_oss.c:319
support for drag actions
int win_x
Definition: console_video.h:71
void console_video_start(struct video_desc *env, struct ast_channel *owner)
int win_h
Definition: console_video.h:74
drag_window
int win_y
Definition: console_video.h:72
int console_video_cli(struct video_desc *env, const char *var, int fd)
int console_video_config(struct video_desc **penv, const char *var, const char *val)
uint8_t * data
Definition: console_video.h:60
kb_output
void delete_board(struct board *b)
deallocates memory space for a board
int win_w
Definition: console_video.h:73
static const char name[]
Definition: cdr_mysql.c:74
int ebit
Definition: console_video.h:64
int get_gui_startup(struct video_desc *env)
Data structure associated with a single frame of data.
static struct test_val b
void console_video_uninit(struct video_desc *env)
int size
Definition: console_video.h:62
Definition: env.py:1
int reset_board(struct board *b)
reset the board to blank