37 int width,
int height)
39 , drawingArea(drawing_area)
42 REQUIRE(drawing_area != NULL);
46 INFO(
stage,
"Trying XVideo at %d x %d", width, height);
53 Glib::RefPtr<Gdk::Window> area_window = drawing_area->get_window();
55 window = GDK_WINDOW_XID (area_window->gobj());
56 display = GDK_WINDOW_XDISPLAY (area_window->gobj());
59 XvAdaptorInfo* adaptorInfo;
61 if (XvQueryAdaptors (display,
window, &count, &adaptorInfo) == Success)
63 INFO(
stage,
"XvQueryAdaptors count: %d", count);
64 for (uint n = 0;
gotPort ==
false && n < count; ++n )
67 INFO(
stage,
"%s, %lu, %lu", adaptorInfo[ n ].
name,
68 adaptorInfo[ n ].base_id, adaptorInfo[ n ].num_ports - 1);
70 for (uint port = adaptorInfo[ n ].base_id;
71 port < adaptorInfo[ n ].base_id + adaptorInfo[ n ].num_ports;
74 if ( XvGrabPort( display, port, CurrentTime ) == Success )
77 XvImageFormatValues* list;
79 list = XvListImageFormats( display, port, &formats );
81 INFO(
stage,
"formats supported: %d", formats);
83 for (
int i = 0; i < formats; i ++ )
85 INFO(
stage,
"0x%x (%c%c%c%c) %s",
87 ( list[ i ].
id ) & 0xff,
88 ( list[ i ].
id >> 8 ) & 0xff,
89 ( list[ i ].
id >> 16 ) & 0xff,
90 ( list[ i ].
id >> 24 ) & 0xff,
91 ( list[ i ].
format == XvPacked ) ?
"packed" :
"planar" );
92 if ( list[ i ].
id == 0x32595559 && !
gotPort )
98 XvUngrabPort( display, port, CurrentTime );
115 XvQueryEncodings( display,
grabbedPort, &unum, &enc );
116 for (uint index = 0; index < unum; ++index )
118 INFO (
stage,
"%d: %s, %ldx%ld rate = %d/%d" 120 , enc->width, enc->height
121 , enc->rate.numerator
122 , enc->rate.denominator);
125 XvAttribute* xvattr = XvQueryPortAttributes (display,
grabbedPort, &num);
126 for (
int k = 0; k < num; k++ )
128 if ( xvattr[k].flags & XvSettable )
130 if (strcmp (xvattr[k].
name,
"XV_AUTOPAINT_COLORKEY") == 0 )
132 Atom val_atom = XInternAtom( display, xvattr[k].name, False );
133 if (XvSetPortAttribute(display,
grabbedPort, val_atom, 1 ) != Success )
134 NOBUG_ERROR(
stage,
"Couldn't set Xv attribute %s\n", xvattr[k].name);
137 if (strcmp (xvattr[k].name,
"XV_COLORKEY") == 0 )
139 Atom val_atom = XInternAtom( display, xvattr[k].name, False );
140 if ( XvSetPortAttribute( display,
grabbedPort, val_atom, 0x010102 ) != Success )
141 NOBUG_ERROR(
stage,
"Couldn't set Xv attribute %s\n", xvattr[k].name);
150 memset(&values, 0,
sizeof(XGCValues));
151 gc = XCreateGC( display,
window, 0, NULL );
155 shmInfo.shmid = shmget( IPC_PRIVATE,
xvImage->data_size, IPC_CREAT | 0777 );
166 if (!XShmAttach (display, &
shmInfo))
171 XSync( display,
false );
172 shmctl(
shmInfo.shmid, IPC_RMID, 0 );
183 XvDisplayer::~XvDisplayer()
185 NOBUG_ERROR(
stage,
"Destroying XV Displayer");
195 shmctl(
shmInfo.shmid, IPC_RMID, 0 );
214 REQUIRE (image != NULL);
221 int video_x = 0, video_y = 0, video_width = 0, video_height = 0;
226 video_x, video_y, video_width, video_height );
232 video_x, video_y, video_width, video_height,
false);
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.
uint grabbedPort
The current port being used.
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.