1 /*******************************************************************************
2 * video_output.h : video output thread
4 *******************************************************************************
5 * This module describes the programming interface for video output threads.
6 * It includes functions allowing to open a new thread, send pictures to a
7 * thread, and destroy a previously oppenned video output thread.
8 *******************************************************************************
15 *******************************************************************************/
17 /* ?? this over-complicated API and code should be re-designed, with a simple
18 * video-stream associated to a window (each window designed to be openned in
19 * a parent one and probably without border), and have an api looking like
25 * vout_AddReservedPicture
29 * the overlay/transparent, permanent and such stuff should disapear.
32 /*******************************************************************************
33 * vout_stream_t: video stream descriptor
34 *******************************************************************************
35 * Each video stream has a set of properties, stored in this structure. It is
36 * part of vout_thread_t and is not supposed to be used anywhere else.
37 *******************************************************************************/
40 int i_status; /* is stream active ? */
41 picture_t * p_next_picture; /* next picture to be displayed */
45 count_t c_pictures; /* total number of pictures added */
46 count_t c_rendered_pictures; /* number of rendered pictures */
50 /* Video stream status */
51 #define VOUT_INACTIVE_STREAM 0 /* stream is inactive (empty) */
52 #define VOUT_ACTIVE_STREAM 1 /* stream is active */
53 #define VOUT_ENDING_STREAM 2 /* stream will be destroyed when empty */
54 #define VOUT_DESTROYED_STREAM 3 /* stream must be destroyed */
56 /*******************************************************************************
57 * vout_thread_t: video output thread descriptor
58 *******************************************************************************
59 * Any independant video output device, such as an X11 window, is represented
60 * by a video output thread, and described using following structure.
61 *******************************************************************************/
62 typedef struct vout_thread_s
64 /* Thread properties and locks */
65 boolean_t b_die; /* `die' flag */
66 boolean_t b_error; /* `error' flag */
67 boolean_t b_active; /* `active' flag */
68 pthread_t thread_id; /* id for pthread functions */
69 pthread_mutex_t streams_lock; /* streams modification lock */
70 pthread_mutex_t pictures_lock; /* pictures modification lock */
71 int * pi_status; /* temporary status flag */
73 /* Common display properties */
74 int i_width; /* current output method width */
75 int i_height; /* current output method height */
76 int i_screen_depth; /* bits per pixel */
77 int i_bytes_per_pixel; /* real screen depth */
80 struct vout_x11_s * p_x11; /* X11 output method */
83 int i_max_pictures; /* heap maximal size */
84 int i_pictures; /* current heap size */
85 picture_t * p_picture; /* pictures */
88 vout_stream_t p_stream[VOUT_MAX_STREAMS]; /* streams data */
92 count_t c_loops; /* number of loops */
93 count_t c_idle_loops; /* number of idle loops */
94 count_t c_pictures; /* number of pictures added to heap */
95 count_t c_rendered_pictures; /* number of pictures rendered */
98 /* Rendering functions - these functions are of vout_render_blank_t and
99 * vout_render_line_t, but are not declared here using these types since
100 * they require vout_thread_t to be defined */
101 void (* RenderRGBBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
102 int i_x, int i_y, int i_width, int i_height );
103 void (* RenderPixelBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
104 int i_x, int i_y, int i_width, int i_height );
105 void (* RenderRGBLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
106 int i_x, int i_y, int i_pic_x, int i_pic_y,
107 int i_width, int i_line_width, int i_ratio );
108 void (* RenderPixelLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
109 int i_x, int i_y, int i_pic_x, int i_pic_y,
110 int i_width, int i_line_width, int i_ratio );
111 void (* RenderRGBMaskLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
112 int i_x, int i_y, int i_pic_x, int i_pic_y,
113 int i_width, int i_line_width, int i_ratio );
114 void (* RenderPixelMaskLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
115 int i_x, int i_y, int i_pic_x, int i_pic_y,
116 int i_width, int i_line_width, int i_ratio );
117 /* ?? add YUV types */
120 /*******************************************************************************
121 * vout_render_blank_t: blank rendering function
122 * vout_render_line_t: rectangle rendering functions
123 *******************************************************************************
124 * All rendering functions should be of these types - for blank pictures
125 * (pictures with uniform color), blank rendering functions are called once. For
126 * other pictures, each function is called once for each picture line. Note that
127 * the part of the picture sent to the rendering functions is in the output
128 * window, since the clipping is done before.
129 * p_vout is the calling thread
130 * pixel is the color or pixel value of the rectange to be drawn
131 * p_pic is the picture to be rendered
132 * i_x, i_y is the absolute position in output window
133 * i_pic_x is the first pixel to be drawn in the picture
134 * i_pic_y is the line of the picture to be drawn
135 * i_width is the width of the area to be rendered in the picture (not in the
136 * output window), except for blank pictures, where it is the absolute size
137 * of the area to be rendered
138 * i_height is the height og the area to be rendered
139 * i_line_width is the number of time the line must be copied
140 * i_ratio is the horizontal display ratio
141 *******************************************************************************/
142 typedef void (vout_render_blank_t)( vout_thread_t *p_vout, pixel_t pixel,
143 int i_x, int i_y, int i_width, int i_height );
144 typedef void (vout_render_line_t) ( vout_thread_t *p_vout, picture_t *p_pic,
145 int i_x, int i_y, int i_pic_x, int i_pic_y,
146 int i_width, int i_line_width, int i_ratio );
148 /*******************************************************************************
150 *******************************************************************************/
151 vout_thread_t * vout_CreateThread ( video_cfg_t *p_cfg, int *pi_status );
152 void vout_DestroyThread ( vout_thread_t *p_vout, int *pi_status );
154 picture_t * vout_DisplayPicture ( vout_thread_t *p_vout, picture_t *p_pic );
155 picture_t * vout_DisplayPictureCopy ( vout_thread_t *p_vout, picture_t *p_pic );
156 picture_t * vout_DisplayPictureReplicate ( vout_thread_t *p_vout, picture_t *p_pic );
157 picture_t * vout_DisplayReservedPicture ( vout_thread_t *p_vout, picture_t *p_pic );
159 picture_t * vout_CreateReservedPicture ( vout_thread_t *p_vout, video_cfg_t *p_cfg );
160 picture_t * vout_ReservePicture ( vout_thread_t *p_vout, picture_t *p_pic );
161 picture_t * vout_ReservePictureCopy ( vout_thread_t *p_vout, picture_t *p_pic );
162 picture_t * vout_ReservePictureReplicate ( vout_thread_t *p_vout, picture_t *p_pic );
163 void vout_RemovePicture ( vout_thread_t *p_vout, picture_t *p_pic );
165 void vout_RefreshPermanentPicture ( vout_thread_t *p_vout, picture_t *p_pic,
166 mtime_t displa_date );
168 void vout_LinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
169 void vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
171 int vout_CreateStream ( vout_thread_t *p_vout );
172 void vout_EndStream ( vout_thread_t *p_vout, int i_stream );
173 void vout_DestroyStream ( vout_thread_t *p_vout, int i_stream );
176 void vout_PrintHeap ( vout_thread_t *p_vout, char *psz_str );