#include <displayer.h>
Inheritance diagram for XvDisplayer:


Public Member Functions | |
| XvDisplayer (GtkWidget *drawingarea, int width, int height, bool isPAL, bool isWidescreen) | |
| XVideo Constructor. | |
| ~XvDisplayer () | |
| bool | usable () |
| Indicates if an object can be used to render images on the running system. | |
| DisplayerInput | format () |
| Indicates the format required by the abstract put method. | |
Protected Member Functions | |
| void | put (void *image) |
Private Attributes | |
| bool | gotPort |
| int | grabbedPort |
| GtkWidget * | drawingarea |
| Display * | display |
| Window | window |
| GC | gc |
| XGCValues | values |
| XvImage * | xvImage |
| unsigned int | port |
| XShmSegmentInfo | shmInfo |
| char | pix [MAX_WIDTH *MAX_HEIGHT *4] |
| bool | isPAL |
| bool | isWidescreen |
|
||||||||||||||||||||||||
|
XVideo Constructor.
Definition at line 461 of file displayer.cc. References count, display, format(), gc, gotPort, grabbedPort, Displayer::img_height, Displayer::img_width, pix, port, shmInfo, values, window, and xvImage. 00461 : 00462 xvImage( NULL ) 00463 { 00464 00465 cerr << ">> Trying XVideo at " << width << "x" << height << endl; 00466 00467 this->drawingarea = drawingarea; 00468 img_width = width; 00469 img_height = height; 00470 this->isPAL = isPAL; 00471 this->isWidescreen = isWidescreen; 00472 00473 shmInfo.shmaddr = NULL; 00474 gotPort = false; 00475 00476 window = GDK_WINDOW_XID( drawingarea->window ); 00477 display = GDK_WINDOW_XDISPLAY( drawingarea->window ); 00478 00479 unsigned int count; 00480 XvAdaptorInfo *adaptorInfo; 00481 00482 if ( XvQueryAdaptors( display, window, &count, &adaptorInfo ) == Success ) 00483 { 00484 00485 cerr << ">>> XvQueryAdaptors count: " << count << endl; 00486 for ( unsigned int n = 0; gotPort == false && n < count; ++n ) 00487 { 00488 // Diagnostics 00489 cerr << ">>> Xv: " << adaptorInfo[ n ].name 00490 << ": ports " << adaptorInfo[ n ].base_id 00491 << " - " << adaptorInfo[ n ].base_id + 00492 adaptorInfo[ n ].num_ports - 1 00493 << endl; 00494 00495 for ( port = adaptorInfo[ n ].base_id; 00496 port < adaptorInfo[ n ].base_id + adaptorInfo[ n ].num_ports; 00497 port ++ ) 00498 { 00499 if ( XvGrabPort( display, port, CurrentTime ) == 0 ) 00500 { 00501 00502 int formats; 00503 XvImageFormatValues *list; 00504 00505 list = XvListImageFormats( display, port, &formats ); 00506 00507 cerr << ">>> formats supported: " << formats << endl; 00508 00509 for ( int i = 0; i < formats; i ++ ) 00510 { 00511 fprintf( stderr, ">>> 0x%x (%c%c%c%c) %s\n", 00512 list[ i ].id, 00513 ( list[ i ].id ) & 0xff, 00514 ( list[ i ].id >> 8 ) & 0xff, 00515 ( list[ i ].id >> 16 ) & 0xff, 00516 ( list[ i ].id >> 24 ) & 0xff, 00517 ( list[ i ].format == XvPacked ) ? "packed" : "planar" ); 00518 if ( list[ i ].id == 0x32595559 && !gotPort ) 00519 gotPort = true; 00520 } 00521 00522 if ( !gotPort ) 00523 { 00524 XvUngrabPort( display, port, CurrentTime ); 00525 } 00526 else 00527 { 00528 grabbedPort = port; 00529 break; 00530 } 00531 } 00532 } 00533 } 00534 00535 if ( gotPort ) 00536 { 00537 int num; 00538 unsigned int unum; 00539 XvEncodingInfo *enc; 00540 00541 XvQueryEncodings( display, grabbedPort, &unum, &enc ); 00542 for ( unsigned int index = 0; index < unum; index ++ ) 00543 { 00544 fprintf( stderr, ">>> %d: %s, %ldx%ld rate = %d/%d\n", index, enc->name, 00545 enc->width, enc->height, enc->rate.numerator, 00546 enc->rate.denominator ); 00547 } 00548 00549 XvAttribute *xvattr = XvQueryPortAttributes( display, port, &num ); 00550 for ( int k = 0; k < num; k++ ) 00551 { 00552 if ( xvattr[k].flags & XvSettable ) 00553 { 00554 if ( strcmp( xvattr[k].name, "XV_AUTOPAINT_COLORKEY") == 0 ) 00555 { 00556 Atom val_atom = XInternAtom( display, xvattr[k].name, False ); 00557 if ( XvSetPortAttribute( display, port, val_atom, 1 ) != Success ) 00558 fprintf(stderr, "Couldn't set Xv attribute %s\n", xvattr[k].name); 00559 } 00560 else if ( strcmp( xvattr[k].name, "XV_COLORKEY") == 0 ) 00561 { 00562 Atom val_atom = XInternAtom( display, xvattr[k].name, False ); 00563 if ( XvSetPortAttribute( display, port, val_atom, 0x010102 ) != Success ) 00564 fprintf(stderr, "Couldn't set Xv attribute %s\n", xvattr[k].name); 00565 } 00566 } 00567 } 00568 } 00569 00570 if ( gotPort ) 00571 { 00572 gc = XCreateGC( display, window, 0, &values ); 00573 00574 xvImage = ( XvImage * ) XvShmCreateImage( display, port, 0x32595559, 0, width, height, &shmInfo ); 00575 00576 shmInfo.shmid = shmget( IPC_PRIVATE, xvImage->data_size, IPC_CREAT | 0777 ); 00577 if (shmInfo.shmid < 0) { 00578 perror("shmget"); 00579 gotPort = false; 00580 } else { 00581 shmInfo.shmaddr = ( char * ) shmat( shmInfo.shmid, 0, 0 ); 00582 xvImage->data = shmInfo.shmaddr; 00583 shmInfo.readOnly = 0; 00584 if ( !XShmAttach( gdk_display, &shmInfo ) ) 00585 { 00586 gotPort = false; 00587 } 00588 XSync( display, false ); 00589 shmctl( shmInfo.shmid, IPC_RMID, 0 ); 00590 #if 0 00591 xvImage = ( XvImage * ) XvCreateImage( display, port, 0x32595559, pix, width , height ); 00592 #endif 00593 } 00594 } 00595 } 00596 else 00597 { 00598 gotPort = false; 00599 } 00600 }
|
|
|
Definition at line 602 of file displayer.cc. References display, gotPort, grabbedPort, port, shmInfo, window, and xvImage. 00603 {
00604 cerr << ">> Destroying XV Displayer" << endl;
00605
00606 if ( gotPort )
00607 {
00608 XvUngrabPort( display, grabbedPort, CurrentTime );
00609 }
00610
00611 if ( xvImage != NULL )
00612 XvStopVideo( display, port, window );
00613
00614 if ( shmInfo.shmaddr != NULL )
00615 {
00616 XShmDetach( display, &shmInfo );
00617 shmctl( shmInfo.shmid, IPC_RMID, 0 );
00618 shmdt( shmInfo.shmaddr );
00619 }
00620 if ( xvImage != NULL )
00621 XFree( xvImage );
00622 }
|
|
|
Indicates the format required by the abstract put method.
Reimplemented from Displayer. Definition at line 629 of file displayer.cc. References DISPLAY_YUV. Referenced by XvDisplayer(). 00630 {
00631 return DISPLAY_YUV;
00632 }
|
|
|
Implements Displayer. Definition at line 634 of file displayer.cc. References display, drawingarea, gc, AspectRatioCalculator::height, isPAL, isWidescreen, port, Displayer::preferredHeight(), AspectRatioCalculator::width, window, AspectRatioCalculator::x, xvImage, and AspectRatioCalculator::y. 00635 {
00636 AspectRatioCalculator calc( ( ( GtkWidget * ) drawingarea ) ->allocation.width,
00637 ( ( GtkWidget * ) drawingarea ) ->allocation.height,
00638 this->preferredWidth(), this->preferredHeight(),
00639 isPAL, isWidescreen );
00640
00641 memcpy( xvImage->data, image, xvImage->data_size );
00642
00643 XvShmPutImage( display, port, window, gc, xvImage,
00644 0, 0, this->preferredWidth(), this->preferredHeight(),
00645 calc.x, calc.y, calc.width, calc.height, false );
00646 #if 0
00647
00648 XvPutImage( display, port, window, gc, xvImage,
00649 0, 0, this->preferredWidth(), this->preferredHeight(),
00650 calc.x, calc.y, calc.width, calc.height );
00651 #endif
00652 }
|
|
|
Indicates if an object can be used to render images on the running system.
Reimplemented from Displayer. Definition at line 624 of file displayer.cc. References gotPort. 00625 {
00626 return gotPort;
00627 }
|
|
|
Definition at line 160 of file displayer.h. Referenced by put(), XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 159 of file displayer.h. Referenced by put(). |
|
|
Definition at line 162 of file displayer.h. Referenced by put(), and XvDisplayer(). |
|
|
Definition at line 157 of file displayer.h. Referenced by usable(), XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 158 of file displayer.h. Referenced by XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 168 of file displayer.h. Referenced by put(). |
|
|
Definition at line 169 of file displayer.h. Referenced by put(). |
|
|
Definition at line 167 of file displayer.h. Referenced by XvDisplayer(). |
|
|
Definition at line 165 of file displayer.h. Referenced by put(), XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 166 of file displayer.h. Referenced by XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 163 of file displayer.h. Referenced by XvDisplayer(). |
|
|
Definition at line 161 of file displayer.h. Referenced by put(), XvDisplayer(), and ~XvDisplayer(). |
|
|
Definition at line 164 of file displayer.h. Referenced by put(), XvDisplayer(), and ~XvDisplayer(). |
1.4.2