46 int width,
int height)
48 , drawingArea(drawing_area)
51 REQUIRE(drawing_area != NULL);
55 INFO(
stage,
"Trying XVideo at %d x %d", width, height);
62 Glib::RefPtr<Gdk::Window> area_window = drawing_area->get_window();
64 window = GDK_WINDOW_XID (area_window->gobj());
65 display = GDK_WINDOW_XDISPLAY (area_window->gobj());
68 XvAdaptorInfo* adaptorInfo;
70 if (XvQueryAdaptors (display,
window, &count, &adaptorInfo) == Success)
72 INFO(
stage,
"XvQueryAdaptors count: %d", count);
73 for (
unsigned int n = 0;
gotPort ==
false && n < count; ++n )
76 INFO(
stage,
"%s, %lu, %lu", adaptorInfo[ n ].
name,
77 adaptorInfo[ n ].base_id, adaptorInfo[ n ].num_ports - 1);
79 for (
unsigned int port = adaptorInfo[ n ].base_id;
80 port < adaptorInfo[ n ].base_id + adaptorInfo[ n ].num_ports;
83 if ( XvGrabPort( display, port, CurrentTime ) == Success )
86 XvImageFormatValues *list;
88 list = XvListImageFormats( display, port, &formats );
90 INFO(
stage,
"formats supported: %d", formats);
92 for (
int i = 0; i < formats; i ++ )
94 INFO(
stage,
"0x%x (%c%c%c%c) %s",
96 ( list[ i ].
id ) & 0xff,
97 ( list[ i ].
id >> 8 ) & 0xff,
98 ( list[ i ].
id >> 16 ) & 0xff,
99 ( list[ i ].
id >> 24 ) & 0xff,
100 ( list[ i ].
format == XvPacked ) ?
"packed" :
"planar" );
101 if ( list[ i ].
id == 0x32595559 && !
gotPort )
107 XvUngrabPort( display, port, CurrentTime );
124 XvQueryEncodings( display,
grabbedPort, &unum, &enc );
125 for (
unsigned int index = 0; index < unum; index ++ )
127 INFO (
stage,
"%d: %s, %ldx%ld rate = %d/%d" 129 , enc->width, enc->height
130 , enc->rate.numerator
131 , enc->rate.denominator);
134 XvAttribute *xvattr = XvQueryPortAttributes (display,
grabbedPort, &num);
135 for (
int k = 0; k < num; k++ )
137 if ( xvattr[k].flags & XvSettable )
139 if ( strcmp( xvattr[k].
name,
"XV_AUTOPAINT_COLORKEY") == 0 )
141 Atom val_atom = XInternAtom( display, xvattr[k].name, False );
142 if (XvSetPortAttribute(display,
grabbedPort, val_atom, 1 ) != Success )
143 NOBUG_ERROR(
stage,
"Couldn't set Xv attribute %s\n", xvattr[k].name);
145 else if ( strcmp( xvattr[k].name,
"XV_COLORKEY") == 0 )
147 Atom val_atom = XInternAtom( display, xvattr[k].name, False );
148 if ( XvSetPortAttribute( display,
grabbedPort, val_atom, 0x010102 ) != Success )
149 NOBUG_ERROR(
stage,
"Couldn't set Xv attribute %s\n", xvattr[k].name);
158 memset(&values, 0,
sizeof(XGCValues));
159 gc = XCreateGC( display,
window, 0, NULL );
163 shmInfo.shmid = shmget( IPC_PRIVATE,
xvImage->data_size, IPC_CREAT | 0777 );
174 if ( !XShmAttach( display, &
shmInfo ))
179 XSync( display,
false );
180 shmctl(
shmInfo.shmid, IPC_RMID, 0 );
191 XvDisplayer::~XvDisplayer()
193 NOBUG_ERROR(
stage,
"Destroying XV Displayer");
203 shmctl(
shmInfo.shmid, IPC_RMID, 0 );
222 REQUIRE (image != NULL);
229 int video_x = 0, video_y = 0, video_width = 0, video_height = 0;
234 video_x, video_y, video_width, video_height );
240 video_x, video_y, video_width, video_height,
false);
unsigned int grabbedPort
The current port being used.
GC gc
The graphics context which will be used when rendering video.
bool usable()
Indicates if this object can be used to render images on the running system.
static void calculateVideoLayout(int widget_width, int widget_height, int image_width, int image_height, int &video_x, int &video_y, int &video_width, int &video_height)
Calculates the coordinates for placing a video image inside a widget.
virtual int preferredHeight()
Expected height of input to put.
virtual DisplayerInput format()
Indicates the format required by the abstract put method.
virtual int preferredWidth()
Expected width of input to put.
void put(void *const image)
Put an image of a given width and height with the expected input format (as indicated by the format m...
This header is for including and configuring NoBug.
Window window
The X11 window that video will be drawn into.
bool gotPort
Specifies whether the object is currently attached to an XVideo port.
XShmSegmentInfo shmInfo
Info about the shared memory segment.
Lumiera GTK UI implementation root.
XvDisplayer(Gtk::Widget *drawing_area, int width, int height)
Constructor.
Display * display
The display that video will be drawn into.
Gtk::Widget * drawingArea
The widget that video will be drawn into.
XvImage * xvImage
The shared memory image object which video will be written into.
A set of basic GTK includes for the UI.
Implementation of video output via XVideo.