console_video.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. * Common header for console video support
  18. *
  19. * $Revision$
  20. */
  21. #ifndef CONSOLE_VIDEO_H
  22. #define CONSOLE_VIDEO_H
  23. #if !defined(HAVE_VIDEO_CONSOLE) || !defined(HAVE_FFMPEG)
  24. #define CONSOLE_VIDEO_CMDS \
  25. "console {device}"
  26. #else
  27. #include <ffmpeg/avcodec.h>
  28. #ifndef OLD_FFMPEG
  29. #include <ffmpeg/swscale.h> /* requires a recent ffmpeg */
  30. #endif
  31. #define CONSOLE_VIDEO_CMDS \
  32. "console {videodevice|videocodec" \
  33. "|video_size|bitrate|fps|qmin" \
  34. "|sendvideo|keypad" \
  35. "|sdl_videodriver" \
  36. "|device|startgui|stopgui" \
  37. "}"
  38. #endif /* HAVE_VIDEO_CONSOLE and others */
  39. #define SRC_WIN_W 80 /* width of video thumbnails */
  40. #define SRC_WIN_H 60 /* height of video thumbnails */
  41. /* we only support a limited number of video sources in the GUI,
  42. * because we need screen estate to switch between them.
  43. */
  44. #define MAX_VIDEO_SOURCES 9
  45. /*
  46. * In many places we use buffers to store the raw frames (but not only),
  47. * so here is a structure to keep all the info. data = NULL means the
  48. * structure is not initialized, so the other fields are invalid.
  49. * size = 0 means the buffer is not malloc'ed so we don't have to free it.
  50. */
  51. struct fbuf_t { /* frame buffers, dynamically allocated */
  52. uint8_t *data; /* memory, malloced if size > 0, just reference
  53. * otherwise */
  54. int size; /* total size in bytes */
  55. int used; /* space used so far */
  56. int ebit; /* bits to ignore at the end */
  57. int x; /* origin, if necessary */
  58. int y;
  59. int w; /* size */
  60. int h;
  61. int pix_fmt;
  62. /* offsets and size of the copy in Picture-in-Picture mode */
  63. int win_x;
  64. int win_y;
  65. int win_w;
  66. int win_h;
  67. };
  68. void fbuf_free(struct fbuf_t *);
  69. /* descriptor for a grabber */
  70. struct grab_desc {
  71. const char *name;
  72. void *(*open)(const char *name, struct fbuf_t *geom, int fps);
  73. struct fbuf_t *(*read)(void *d);
  74. void (*move)(void *d, int dx, int dy);
  75. void *(*close)(void *d);
  76. };
  77. extern struct grab_desc *console_grabbers[];
  78. struct video_desc; /* opaque type for video support */
  79. struct video_desc *get_video_desc(struct ast_channel *c);
  80. /* linked by console_video.o */
  81. int console_write_video(struct ast_channel *chan, struct ast_frame *f);
  82. extern int console_video_formats;
  83. int console_video_cli(struct video_desc *env, const char *var, int fd);
  84. int console_video_config(struct video_desc **penv, const char *var, const char *val);
  85. void console_video_uninit(struct video_desc *env);
  86. void console_video_start(struct video_desc *env, struct ast_channel *owner);
  87. int get_gui_startup(struct video_desc* env);
  88. /* console_board.c */
  89. /* Where do we send the keyboard/keypad output */
  90. enum kb_output {
  91. KO_NONE,
  92. KO_INPUT, /* the local input window */
  93. KO_DIALED, /* the 'dialed number' window */
  94. KO_MESSAGE, /* the 'message' window */
  95. };
  96. enum drag_window { /* which window are we dragging */
  97. DRAG_NONE,
  98. DRAG_LOCAL, /* local video */
  99. DRAG_REMOTE, /* remote video */
  100. DRAG_DIALED, /* dialed number */
  101. DRAG_INPUT, /* input window */
  102. DRAG_MESSAGE, /* message window */
  103. DRAG_PIP, /* picture in picture */
  104. };
  105. /*! \brief support for drag actions */
  106. struct drag_info {
  107. int x_start; /* last known mouse position */
  108. int y_start;
  109. enum drag_window drag_window;
  110. };
  111. /*! \brief info related to the gui: button status, mouse coords, etc. */
  112. struct board;
  113. /* !\brief print a message on a board */
  114. void move_message_board(struct board *b, int dy);
  115. int print_message(struct board *b, const char *s);
  116. /*! \brief return the whole text from a board */
  117. const char *read_message(const struct board *b);
  118. /*! \brief reset the board to blank */
  119. int reset_board(struct board *b);
  120. /*! \brief deallocates memory space for a board */
  121. void delete_board(struct board *b);
  122. #endif /* CONSOLE_VIDEO_H */
  123. /* end of file */