| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
extern "C" |
|---|
| 38 |
{ |
|---|
| 39 |
#include <errno.h> |
|---|
| 40 |
|
|---|
| 41 |
#ifdef HAVE_CONFIG_H |
|---|
| 42 |
# include "config.h" |
|---|
| 43 |
#endif |
|---|
| 44 |
|
|---|
| 45 |
#include <vlc_common.h> |
|---|
| 46 |
#include <vlc_plugin.h> |
|---|
| 47 |
#include <vlc_interface.h> |
|---|
| 48 |
#include <vlc_vout.h> |
|---|
| 49 |
|
|---|
| 50 |
#ifdef HAVE_MACHINE_PARAM_H |
|---|
| 51 |
|
|---|
| 52 |
# include <machine/param.h> |
|---|
| 53 |
# include <sys/types.h> |
|---|
| 54 |
# include <sys/ipc.h> |
|---|
| 55 |
#endif |
|---|
| 56 |
|
|---|
| 57 |
#ifndef WIN32 |
|---|
| 58 |
# include <netinet/in.h> |
|---|
| 59 |
#endif |
|---|
| 60 |
|
|---|
| 61 |
#ifdef HAVE_SYS_SHM_H |
|---|
| 62 |
# include <sys/shm.h> |
|---|
| 63 |
#endif |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
#include <qapplication.h> |
|---|
| 67 |
#include <qpainter.h> |
|---|
| 68 |
|
|---|
| 69 |
#ifdef Q_WS_QWS |
|---|
| 70 |
# define USE_DIRECT_PAINTER |
|---|
| 71 |
# include <qdirectpainter_qws.h> |
|---|
| 72 |
# include <qgfxraster_qws.h> |
|---|
| 73 |
#endif |
|---|
| 74 |
|
|---|
| 75 |
extern "C" |
|---|
| 76 |
{ |
|---|
| 77 |
#include "qte.h" |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
#define DISPLAY_TEXT N_("QT Embedded display") |
|---|
| 83 |
#define DISPLAY_LONGTEXT N_( \ |
|---|
| 84 |
"Qt Embedded hardware display to use. " \ |
|---|
| 85 |
"By default VLC will use the value of the DISPLAY environment variable.") |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
static int Open ( vlc_object_t * ); |
|---|
| 91 |
static void Close ( vlc_object_t * ); |
|---|
| 92 |
static void Render ( vout_thread_t *, picture_t * ); |
|---|
| 93 |
static void Display ( vout_thread_t *, picture_t * ); |
|---|
| 94 |
static int Manage ( vout_thread_t * ); |
|---|
| 95 |
static int Init ( vout_thread_t * ); |
|---|
| 96 |
static void End ( vout_thread_t * ); |
|---|
| 97 |
|
|---|
| 98 |
static int OpenDisplay ( vout_thread_t * ); |
|---|
| 99 |
static void CloseDisplay( vout_thread_t * ); |
|---|
| 100 |
|
|---|
| 101 |
static int NewPicture ( vout_thread_t *, picture_t * ); |
|---|
| 102 |
static void FreePicture ( vout_thread_t *, picture_t * ); |
|---|
| 103 |
|
|---|
| 104 |
static void ToggleFullScreen ( vout_thread_t * ); |
|---|
| 105 |
|
|---|
| 106 |
static void* RunQtThread( vlc_object_t *p_this ); |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
extern "C" |
|---|
| 113 |
{ |
|---|
| 114 |
|
|---|
| 115 |
vlc_module_begin(); |
|---|
| 116 |
set_category( CAT_VIDEO ); |
|---|
| 117 |
set_subcategory( SUBCAT_VIDEO_VOUT ); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
set_description( N_("QT Embedded video output") ); |
|---|
| 121 |
set_capability( "video output", 70 ); |
|---|
| 122 |
add_shortcut( "qte" ); |
|---|
| 123 |
set_callbacks( Open, Close); |
|---|
| 124 |
vlc_module_end(); |
|---|
| 125 |
|
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
static inline void vout_Seek( off_t i_seek ) |
|---|
| 132 |
{ |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
static int Open( vlc_object_t *p_this ) |
|---|
| 139 |
{ |
|---|
| 140 |
vout_thread_t * p_vout = (vout_thread_t *)p_this; |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
p_vout->p_sys = (struct vout_sys_t*) malloc( sizeof( struct vout_sys_t ) ); |
|---|
| 144 |
|
|---|
| 145 |
if( p_vout->p_sys == NULL ) |
|---|
| 146 |
return( 1 ); |
|---|
| 147 |
|
|---|
| 148 |
p_vout->pf_init = Init; |
|---|
| 149 |
p_vout->pf_end = End; |
|---|
| 150 |
p_vout->pf_manage = Manage; |
|---|
| 151 |
p_vout->pf_render = NULL; |
|---|
| 152 |
p_vout->pf_display = Display; |
|---|
| 153 |
|
|---|
| 154 |
#ifdef NEED_QTE_MAIN |
|---|
| 155 |
p_vout->p_sys->p_qte_main = |
|---|
| 156 |
module_need( p_this, "gui-helper", "qte", true ); |
|---|
| 157 |
if( p_vout->p_sys->p_qte_main == NULL ) |
|---|
| 158 |
{ |
|---|
| 159 |
free( p_vout->p_sys ); |
|---|
| 160 |
return VLC_ENOMOD; |
|---|
| 161 |
} |
|---|
| 162 |
#endif |
|---|
| 163 |
|
|---|
| 164 |
if (OpenDisplay(p_vout)) |
|---|
| 165 |
{ |
|---|
| 166 |
msg_Err( p_vout, "Cannot set up qte video output" ); |
|---|
| 167 |
Close(p_this); |
|---|
| 168 |
return( -1 ); |
|---|
| 169 |
} |
|---|
| 170 |
return( 0 ); |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
static void Close ( vlc_object_t *p_this ) |
|---|
| 179 |
{ |
|---|
| 180 |
vout_thread_t * p_vout = (vout_thread_t *)p_this; |
|---|
| 181 |
|
|---|
| 182 |
msg_Dbg( p_vout, "close" ); |
|---|
| 183 |
if( p_vout->p_sys->p_event ) |
|---|
| 184 |
{ |
|---|
| 185 |
vlc_object_detach( p_vout->p_sys->p_event ); |
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
vlc_object_kill( p_vout->p_sys->p_event ); |
|---|
| 189 |
CloseDisplay(p_vout); |
|---|
| 190 |
|
|---|
| 191 |
vlc_thread_join( p_vout->p_sys->p_event ); |
|---|
| 192 |
vlc_object_release( p_vout->p_sys->p_event ); |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
#ifdef NEED_QTE_MAIN |
|---|
| 196 |
msg_Dbg( p_vout, "releasing gui-helper" ); |
|---|
| 197 |
module_unneed( p_vout, p_vout->p_sys->p_qte_main ); |
|---|
| 198 |
#endif |
|---|
| 199 |
|
|---|
| 200 |
if( p_vout->p_sys ) |
|---|
| 201 |
{ |
|---|
| 202 |
free( p_vout->p_sys ); |
|---|
| 203 |
p_vout->p_sys = NULL; |
|---|
| 204 |
} |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
static int Init( vout_thread_t *p_vout ) |
|---|
| 214 |
{ |
|---|
| 215 |
int i_index; |
|---|
| 216 |
picture_t* p_pic; |
|---|
| 217 |
int dd = QPixmap::defaultDepth(); |
|---|
| 218 |
|
|---|
| 219 |
I_OUTPUTPICTURES = 0; |
|---|
| 220 |
|
|---|
| 221 |
p_vout->output.i_chroma = (dd == 16) ? VLC_FOURCC('R','V','1','6'): VLC_FOURCC('R','V','3','2'); |
|---|
| 222 |
p_vout->output.i_rmask = 0xf800; |
|---|
| 223 |
p_vout->output.i_gmask = 0x07e0; |
|---|
| 224 |
p_vout->output.i_bmask = 0x001f; |
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
p_vout->output.i_width = p_vout->p_sys->i_width; |
|---|
| 228 |
p_vout->output.i_height = p_vout->p_sys->i_height; |
|---|
| 229 |
if( !p_vout->b_fullscreen ) |
|---|
| 230 |
{ |
|---|
| 231 |
p_vout->output.i_aspect = p_vout->output.i_width |
|---|
| 232 |
* VOUT_ASPECT_FACTOR |
|---|
| 233 |
/ p_vout->output.i_height; |
|---|
| 234 |
} |
|---|
| 235 |
else |
|---|
| 236 |
{ |
|---|
| 237 |
p_vout->output.i_aspect = p_vout->render.i_aspect; |
|---|
| 238 |
} |
|---|
| 239 |
#if 0 |
|---|
| 240 |
msg_Dbg( p_vout, "Init (h=%d,w=%d,aspect=%d)",p_vout->output.i_height,p_vout->output.i_width,p_vout->output.i_aspect ); |
|---|
| 241 |
#endif |
|---|
| 242 |
|
|---|
| 243 |
while( I_OUTPUTPICTURES < QTE_MAX_DIRECTBUFFERS ) |
|---|
| 244 |
{ |
|---|
| 245 |
p_pic = NULL; |
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ ) |
|---|
| 249 |
{ |
|---|
| 250 |
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE ) |
|---|
| 251 |
{ |
|---|
| 252 |
p_pic = p_vout->p_picture + i_index; |
|---|
| 253 |
break; |
|---|
| 254 |
} |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
if( p_pic == NULL || NewPicture( p_vout, p_pic ) ) |
|---|
| 259 |
{ |
|---|
| 260 |
break; |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
p_pic->i_status = DESTROYED_PICTURE; |
|---|
| 264 |
p_pic->i_type = DIRECT_PICTURE; |
|---|
| 265 |
|
|---|
| 266 |
PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic; |
|---|
| 267 |
|
|---|
| 268 |
I_OUTPUTPICTURES++; |
|---|
| 269 |
} |
|---|
| 270 |
|
|---|
| 271 |
return( 0 ); |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
static void Render( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 279 |
{ |
|---|
| 280 |
; |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
static void Display( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 289 |
{ |
|---|
| 290 |
unsigned int x, y, w, h; |
|---|
| 291 |
|
|---|
| 292 |
vout_PlacePicture( p_vout, p_vout->output.i_width, p_vout->output.i_height, |
|---|
| 293 |
&x, &y, &w, &h ); |
|---|
| 294 |
#if 0 |
|---|
| 295 |
msg_Dbg(p_vout, "+qte::Display( p_vout, i_width=%d, i_height=%d, x=%u, y=%u, w=%u, h=%u", |
|---|
| 296 |
p_vout->output.i_width, p_vout->output.i_height, x, y, w, h ); |
|---|
| 297 |
#endif |
|---|
| 298 |
|
|---|
| 299 |
if(p_vout->p_sys->p_VideoWidget) |
|---|
| 300 |
{ |
|---|
| 301 |
|
|---|
| 302 |
#ifndef USE_DIRECT_PAINTER |
|---|
| 303 |
msg_Dbg(p_vout, "not using direct painter"); |
|---|
| 304 |
QPainter p(p_vout->p_sys->p_VideoWidget); |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
int dd = QPixmap::defaultDepth(); |
|---|
| 308 |
int bytes = ( dd == 16 ) ? 2 : 4; |
|---|
| 309 |
int rw = h, rh = w; |
|---|
| 310 |
|
|---|
| 311 |
QImage rotatedFrame( rw, rh, bytes << 3 ); |
|---|
| 312 |
|
|---|
| 313 |
ushort* in = (ushort*)p_pic->p_sys->pQImage->bits(); |
|---|
| 314 |
ushort* out = (ushort*)rotatedFrame.bits(); |
|---|
| 315 |
|
|---|
| 316 |
int spl = rotatedFrame.bytesPerLine() / bytes; |
|---|
| 317 |
for (int x=0; x<h; x++) |
|---|
| 318 |
{ |
|---|
| 319 |
if ( bytes == 2 ) |
|---|
| 320 |
{ |
|---|
| 321 |
ushort* lout = out++ + (w - 1)*spl; |
|---|
| 322 |
for (int y=0; y<w; y++) |
|---|
| 323 |
{ |
|---|
| 324 |
*lout=*in++; |
|---|
| 325 |
lout-=spl; |
|---|
| 326 |
} |
|---|
| 327 |
} |
|---|
| 328 |
else |
|---|
| 329 |
{ |
|---|
| 330 |
ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
|---|
| 331 |
for (int y=0; y<w; y++) |
|---|
| 332 |
{ |
|---|
| 333 |
*lout=*((ulong*)in)++; |
|---|
| 334 |
lout-=spl; |
|---|
| 335 |
} |
|---|
| 336 |
} |
|---|
| 337 |
} |
|---|
| 338 |
|
|---|
| 339 |
p.drawImage( x, y, rotatedFrame, 0, 0, rw, rh ); |
|---|
| 340 |
#else |
|---|
| 341 |
QDirectPainter p(p_vout->p_sys->p_VideoWidget); |
|---|
| 342 |
p.transformOrientation(); |
|---|
| 343 |
|
|---|
| 344 |
memcpy(p.frameBuffer(), (p_pic->p_sys->pQImage->jumpTable())[0], h * p.lineStep()); |
|---|
| 345 |
#endif |
|---|
| 346 |
} |
|---|
| 347 |
} |
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
static int Manage( vout_thread_t *p_vout ) |
|---|
| 357 |
{ |
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) |
|---|
| 362 |
{ |
|---|
| 363 |
p_vout->b_fullscreen = ! p_vout->b_fullscreen; |
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; |
|---|
| 370 |
p_vout->i_changes |= VOUT_SIZE_CHANGE; |
|---|
| 371 |
} |
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 |
if( p_vout->i_changes & VOUT_SIZE_CHANGE ) |
|---|
| 377 |
{ |
|---|
| 378 |
msg_Dbg( p_vout, "video display resized (%dx%d)", |
|---|
| 379 |
p_vout->p_sys->i_width, p_vout->p_sys->i_height ); |
|---|
| 380 |
|
|---|
| 381 |
CloseDisplay( p_vout ); |
|---|
| 382 |
OpenDisplay( p_vout ); |
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
p_vout->i_changes &= ~VOUT_SIZE_CHANGE; |
|---|
| 387 |
} |
|---|
| 388 |
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
return 0; |
|---|
| 403 |
} |
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
static void End( vout_thread_t *p_vout ) |
|---|
| 412 |
{ |
|---|
| 413 |
int i_index; |
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
for( i_index = I_OUTPUTPICTURES ; i_index ; ) |
|---|
| 417 |
{ |
|---|
| 418 |
i_index--; |
|---|
| 419 |
FreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] ); |
|---|
| 420 |
} |
|---|
| 421 |
} |
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 430 |
{ |
|---|
| 431 |
int dd = QPixmap::defaultDepth(); |
|---|
| 432 |
|
|---|
| 433 |
p_pic->p_sys = (picture_sys_t*) malloc( sizeof( picture_sys_t ) ); |
|---|
| 434 |
if( p_pic->p_sys == NULL ) |
|---|
| 435 |
{ |
|---|
| 436 |
return -1; |
|---|
| 437 |
} |
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
p_pic->p_sys->pQImage = new QImage(p_vout->output.i_width, |
|---|
| 441 |
p_vout->output.i_height, dd ); |
|---|
| 442 |
|
|---|
| 443 |
if(p_pic->p_sys->pQImage == NULL) |
|---|
| 444 |
{ |
|---|
| 445 |
return -1; |
|---|
| 446 |
} |
|---|
| 447 |
|
|---|
| 448 |
switch( dd ) |
|---|
| 449 |
{ |
|---|
| 450 |
case 8: |
|---|
| 451 |
p_pic->p->i_pixel_pitch = 1; |
|---|
| 452 |
break; |
|---|
| 453 |
case 15: |
|---|
| 454 |
case 16: |
|---|
| 455 |
p_pic->p->i_pixel_pitch = 2; |
|---|
| 456 |
break; |
|---|
| 457 |
case 24: |
|---|
| 458 |
case 32: |
|---|
| 459 |
p_pic->p->i_pixel_pitch = 4; |
|---|
| 460 |
break; |
|---|
| 461 |
default: |
|---|
| 462 |
return( -1 ); |
|---|
| 463 |
} |
|---|
| 464 |
|
|---|
| 465 |
p_pic->p->p_pixels = (p_pic->p_sys->pQImage->jumpTable())[0]; |
|---|
| 466 |
p_pic->p->i_pitch = p_pic->p_sys->pQImage->bytesPerLine(); |
|---|
| 467 |
p_pic->p->i_lines = p_vout->output.i_height; |
|---|
| 468 |
p_pic->p->i_visible_lines = p_vout->output.i_height; |
|---|
| 469 |
p_pic->p->i_visible_pitch = |
|---|
| 470 |
p_pic->p->i_pixel_pitch * p_vout->output.i_width; |
|---|
| 471 |
|
|---|
| 472 |
p_pic->i_planes = 1; |
|---|
| 473 |
|
|---|
| 474 |
return 0; |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 481 |
{ |
|---|
| 482 |
delete p_pic->p_sys->pQImage; |
|---|
| 483 |
} |
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 |
static void ToggleFullScreen ( vout_thread_t *p_vout ) |
|---|
| 492 |
{ |
|---|
| 493 |
if ( p_vout->b_fullscreen ) |
|---|
| 494 |
p_vout->p_sys->p_VideoWidget->showFullScreen(); |
|---|
| 495 |
else |
|---|
| 496 |
p_vout->p_sys->p_VideoWidget->showNormal(); |
|---|
| 497 |
|
|---|
| 498 |
p_vout->b_fullscreen = !p_vout->b_fullscreen; |
|---|
| 499 |
} |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
static int OpenDisplay( vout_thread_t *p_vout ) |
|---|
| 508 |
{ |
|---|
| 509 |
|
|---|
| 510 |
p_vout->p_sys->p_QApplication = NULL; |
|---|
| 511 |
p_vout->p_sys->p_VideoWidget = NULL; |
|---|
| 512 |
|
|---|
| 513 |
p_vout->p_sys->p_event = (event_thread_t*) vlc_object_create( p_vout, sizeof(event_thread_t) ); |
|---|
| 514 |
p_vout->p_sys->p_event->p_vout = p_vout; |
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
#if 1 |
|---|
| 518 |
p_vout->b_fullscreen = true; |
|---|
| 519 |
#endif |
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
QWidget *desktop = p_vout->p_sys->p_QApplication->desktop(); |
|---|
| 523 |
p_vout->p_sys->i_width = p_vout->b_fullscreen ? desktop->height() : |
|---|
| 524 |
p_vout->i_window_width; |
|---|
| 525 |
p_vout->p_sys->i_height = p_vout->b_fullscreen ? desktop->width() : |
|---|
| 526 |
p_vout->i_window_height; |
|---|
| 527 |
|
|---|
| 528 |
#if 0 |
|---|
| 529 |
|
|---|
| 530 |
p_vout->i_changes |= VOUT_SIZE_CHANGE; |
|---|
| 531 |
p_vout->i_window_width = p_vout->p_sys->i_width; |
|---|
| 532 |
p_vout->i_window_height = p_vout->p_sys->i_height; |
|---|
| 533 |
#endif |
|---|
| 534 |
|
|---|
| 535 |
msg_Dbg( p_vout, "opening display (h=%d,w=%d)",p_vout->p_sys->i_height,p_vout->p_sys->i_width); |
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
if ( vlc_thread_create( p_vout->p_sys->p_event, "QT Embedded Thread", |
|---|
| 539 |
RunQtThread, |
|---|
| 540 |
VLC_THREAD_PRIORITY_OUTPUT, true) ) |
|---|
| 541 |
{ |
|---|
| 542 |
msg_Err( p_vout, "cannot create QT Embedded Thread" ); |
|---|
| 543 |
vlc_object_release( p_vout->p_sys->p_event ); |
|---|
| 544 |
p_vout->p_sys->p_event = NULL; |
|---|
| 545 |
return -1; |
|---|
| 546 |
} |
|---|
| 547 |
|
|---|
| 548 |
if( p_vout->p_sys->p_event->b_error ) |
|---|
| 549 |
{ |
|---|
| 550 |
msg_Err( p_vout, "RunQtThread failed" ); |
|---|
| 551 |
return -1; |
|---|
| 552 |
} |
|---|
| 553 |
|
|---|
| 554 |
vlc_object_attach( p_vout->p_sys->p_event, p_vout ); |
|---|
| 555 |
msg_Dbg( p_vout, "RunQtThread running" ); |
|---|
| 556 |
|
|---|
| 557 |
|
|---|
| 558 |
while(p_vout->p_sys->p_VideoWidget == NULL) |
|---|
| 559 |
{ |
|---|
| 560 |
msleep(1); |
|---|
| 561 |
} |
|---|
| 562 |
return VLC_SUCCESS; |
|---|
| 563 |
} |
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 |
static void CloseDisplay( vout_thread_t *p_vout ) |
|---|
| 570 |
{ |
|---|
| 571 |
|
|---|
| 572 |
msg_Dbg( p_vout, "destroying Qt Window" ); |
|---|
| 573 |
#ifdef NEED_QTE_MAIN |
|---|
| 574 |
if(p_vout->p_sys->p_QApplication) |
|---|
| 575 |
{ |
|---|
| 576 |
p_vout->p_sys->bRunning = FALSE; |
|---|
| 577 |
while(p_vout->p_sys->p_VideoWidget) |
|---|
| 578 |
{ |
|---|
| 579 |
msleep(1); |
|---|
| 580 |
} |
|---|
| 581 |
} |
|---|
| 582 |
#else |
|---|
| 583 |
if (p_vout->p_sys->p_QApplication) |
|---|
| 584 |
p_vout->p_sys->p_QApplication->quit(); |
|---|
| 585 |
#endif |
|---|
| 586 |
} |
|---|
| 587 |
|
|---|
| 588 |
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
static void* RunQtThread( vlc_object_t *p_this ) |
|---|
| 592 |
{ |
|---|
| 593 |
event_thread_t *p_event = (event_thread_t *)p_this; |
|---|
| 594 |
int canc = vlc_savecancel (); |
|---|
| 595 |
msg_Dbg( p_event->p_vout, "RunQtThread starting" ); |
|---|
| 596 |
|
|---|
| 597 |
#ifdef NEED_QTE_MAIN |
|---|
| 598 |
if (qApp) |
|---|
| 599 |
{ |
|---|
| 600 |
p_event->p_vout->p_sys->p_QApplication = qApp; |
|---|
| 601 |
p_event->p_vout->p_sys->bOwnsQApp = FALSE; |
|---|
| 602 |
p_event->p_vout->p_sys->p_VideoWidget = qApp->mainWidget(); |
|---|
| 603 |
msg_Dbg( p_event->p_vout, "RunQtThread applicaton attached" ); |
|---|
| 604 |
} |
|---|
| 605 |
#else |
|---|
| 606 |
if (qApp==NULL) |
|---|
| 607 |
{ |
|---|
| 608 |
int argc = 0; |
|---|
| 609 |
QApplication* pApp = new QApplication(argc, NULL); |
|---|
| 610 |
if(pApp) |
|---|
| 611 |
{ |
|---|
| 612 |
p_event->p_vout->p_sys->p_QApplication = pApp; |
|---|
| 613 |
p_event->p_vout->p_sys->bOwnsQApp = TRUE; |
|---|
| 614 |
} |
|---|
| 615 |
QWidget* pWidget = new QWidget(); |
|---|
| 616 |
if (pWidget) |
|---|
| 617 |
{ |
|---|
| 618 |
p_event->p_vout->p_sys->p_VideoWidget = pWidget; |
|---|
| 619 |
} |
|---|
| 620 |
} |
|---|
| 621 |
#endif |
|---|
| 622 |
|
|---|
| 623 |
vlc_thread_ready( p_event ); |
|---|
| 624 |
msg_Dbg( p_event->p_vout, "RunQtThread ready" ); |
|---|
| 625 |
|
|---|
| 626 |
if (p_event->p_vout->p_sys->p_QApplication) |
|---|
| 627 |
{ |
|---|
| 628 |
|
|---|
| 629 |
QWidget *desktop = p_event->p_vout->p_sys->p_QApplication->desktop(); |
|---|
| 630 |
p_event->p_vout->p_sys->p_VideoWidget->setMinimumWidth( 10 ); |
|---|
| 631 |
p_event->p_vout->p_sys->p_VideoWidget->setMinimumHeight( 10 ); |
|---|
| 632 |
p_event->p_vout->p_sys->p_VideoWidget->setBaseSize( p_event->p_vout->p_sys->i_width, |
|---|
| 633 |
p_event->p_vout->p_sys->i_height ); |
|---|
| 634 |
p_event->p_vout->p_sys->p_VideoWidget->setMaximumWidth( desktop->width() ); |
|---|
| 635 |
p_event->p_vout->p_sys->p_VideoWidget->setMaximumHeight( desktop->height() ); |
|---|
| 636 |
|
|---|
| 637 |
if (p_event->p_vout->b_fullscreen) |
|---|
| 638 |
p_event->p_vout->p_sys->p_VideoWidget->showFullScreen(); |
|---|
| 639 |
else |
|---|
| 640 |
p_event->p_vout->p_sys->p_VideoWidget->showNormal(); |
|---|
| 641 |
|
|---|
| 642 |
p_event->p_vout->p_sys->p_VideoWidget->show(); |
|---|
| 643 |
p_event->p_vout->p_sys->bRunning = TRUE; |
|---|
| 644 |
|
|---|
| 645 |
#ifdef NEED_QTE_MAIN |
|---|
| 646 |
while(vlc_object_alive (p_event) && p_event->p_vout->p_sys->bRunning) |
|---|
| 647 |
{ |
|---|
| 648 |
|
|---|
| 649 |
if( !vlc_object_alive (p_event) ) |
|---|
| 650 |
break; |
|---|
| 651 |
|
|---|
| 652 |
msleep(100); |
|---|
| 653 |
} |
|---|
| 654 |
#else |
|---|
| 655 |
|
|---|
| 656 |
p_event->p_vout->p_sys->pcQApplication->exec(); |
|---|
| 657 |
#endif |
|---|
| 658 |
} |
|---|
| 659 |
|
|---|
| 660 |
#ifndef NEED_QTE_MAIN |
|---|
| 661 |
if(p_event->p_vout->p_sys->p_QApplication) |
|---|
| 662 |
{ |
|---|
| 663 |
delete p_event->p_vout->p_sys->p_VideoWidget; |
|---|
| 664 |
p_event->p_vout->p_sys->p_VideoWidget = NULL; |
|---|
| 665 |
delete p_event->p_vout->p_sys->p_QApplication; |
|---|
| 666 |
p_event->p_vout->p_sys->p_QApplication = NULL; |
|---|
| 667 |
} |
|---|
| 668 |
#else |
|---|
| 669 |
p_event->p_vout->p_sys->p_VideoWidget = NULL; |
|---|
| 670 |
#endif |
|---|
| 671 |
|
|---|
| 672 |
msg_Dbg( p_event->p_vout, "RunQtThread terminating" ); |
|---|
| 673 |
vlc_restorecancel (canc); |
|---|
| 674 |
return NULL; |
|---|
| 675 |
} |
|---|
| 676 |
|
|---|