summaryrefslogtreecommitdiff
path: root/client/player.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/player.cc')
-rw-r--r--client/player.cc163
1 files changed, 159 insertions, 4 deletions
diff --git a/client/player.cc b/client/player.cc
index 4e33c76..9a02152 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -27,14 +27,169 @@
#include "player.h"
#include "info.h"
+#include <QX11Info>
-Player::Player()
-{}
+Player::Player(VideoWidget *v)
+{
+ video = v;
+
+ // dpy = XOpenDisplay(NULL); // Get the deafult display
+
+ display = video->x11Info().display();
+ drawable = video->winId();
+ gc = XCreateGC(display, drawable, 0, 0);
+
+ //
+ // Check version
+ //
+ unsigned int version, release;
+ unsigned int request_base, event_base, error_base;
+
+ switch(XvQueryExtension(display, &version, &release, &request_base, &event_base, &error_base)) {
+ case Success:
+ MIaV::info->info("Returned if XvQueryExtension(3X) completed successfully.");
+ break;
+
+ case XvBadExtension:
+ MIaV::info->info("Returned if the Xv video extension is not available for the named display.");
+ break;
+
+ case XvBadAlloc:
+ MIaV::info->info("Returned if XvQueryExtension(3X) failed to allocate memory to process the request.");
+ break;
+ }
+
+
+ //
+ // Find port
+ //
+ unsigned int adaptors;
+ XvAdaptorInfo *ai;
+
+ switch(XvQueryAdaptors(display, drawable, &adaptors, &ai)) {
+ case Success:
+ MIaV::info->info("Returned if XvQueryAdaptors(3X) completed successfully.");
+ break;
+
+ case XvBadExtension:
+ MIaV::info->info("Returned if the Xv video extension is not available for the named display.");
+ break;
+
+ case XvBadAlloc:
+ MIaV::info->info("Returned if XvQueryAdaptors(3X) failed to allocate memory to process the request.");
+ break;
+ }
+
+ /*
+ typedef struct {
+ XvPortID base_id;
+ unsigned long num_ports;
+ char type;
+ char *name;
+ unsigned long num_formats;
+ XvFormat *formats;
+ unsigned long num_adaptors;
+ } XvAdaptorInfo;
+ */
+ if(adaptors == 0) {
+ MIaV::info->error("Unable to find any adapters.");
+ return;
+ }
+
+ /* check adaptors */
+ port = 0;
+ for (unsigned int i = 0; i < adaptors; i++) {
+ if ((ai[i].type & XvInputMask) &&
+ (ai[i].type & XvImageMask) &&
+ (port == 0)) {
+ port = ai[i].base_id;
+ }
+ }
+
+ if(port == 0) {
+ MIaV::info->error("Unable to find suitable port.");
+ return;
+ }
+}
Player::~Player()
-{}
+{
+ //XCloseDisplay(dpy); // Close the Display
+}
void Player::run()
{
- // MIaV::info->info("The player thread is running.");
+ XvPutStill(display, port, drawable, gc, 0, 0, 320, 200, 0, 0, 320, 200);
+}
+
+
+// From:
+// http://cvs.sourceforge.net/viewcvs.py/libmpeg2/MSSG/display_x11.c?rev=1.2
+#if 0
+#ifdef HAVE_XV
+xv_port = 0;
+if (Success == XvQueryExtension(mydisplay,&ver,&rel,&req,&ev,&err)) {
+ /* check for Xvideo support */
+ if (Success != XvQueryAdaptors(mydisplay,DefaultRootWindow(mydisplay),
+ &adaptors,&ai)) {
+ fprintf(stderr,"Xv: XvQueryAdaptors failed");
+ exit(1);
+ }
+ /* check adaptors */
+ for (i = 0; i < adaptors; i++) {
+ if ((ai[i].type & XvInputMask) &&
+ (ai[i].type & XvImageMask) &&
+ (xv_port == 0)) {
+ xv_port = ai[i].base_id;
+ }
+ }
+ /* check image formats */
+ if (xv_port != 0) {
+ fo = XvListImageFormats(mydisplay, xv_port, (int*)&formats);
+ for(i = 0; i < formats; i++) {
+ fprintf(stderr, "Xvideo image format: 0x%x (%4.4s) %s\n",
+ fo[i].id,
+ (char*)&fo[i].id,
+ (fo[i].format == XvPacked) ? "packed" : "planar");
+ if (0x32315659 == fo[i].id) {
+ xv_format = fo[i].id;
+ break;
+ }
+ }
+ if (i == formats)
+ /* no matching image format not */
+ xv_port = 0;
+ }
+ if (xv_port != 0) {
+ fprintf(stderr,"using Xvideo port %d for hw scaling\n",
+ xv_port);
+
+ /* allocate XvImages. FIXME: no error checking, without
+ * mit-shm this will bomb... */
+ xvimage1 = XvShmCreateImage(mydisplay, xv_port, xv_format, 0,
+ image_width, image_height,
+ &Shminfo1);
+ Shminfo1.shmid = shmget(IPC_PRIVATE, xvimage1->data_size,
+ IPC_CREAT | 0777);
+ Shminfo1.shmaddr = (char *) shmat(Shminfo1.shmid, 0, 0);
+ Shminfo1.readOnly = False;
+ xvimage1->data = Shminfo1.shmaddr;
+ XShmAttach(mydisplay, &Shminfo1);
+ XSync(mydisplay, False);
+ shmctl(Shminfo1.shmid, IPC_RMID, 0);
+
+ /* so we can do grayscale while testing... */
+ memset(xvimage1->data,128,xvimage1->data_size);
+
+ /* catch window resizes */
+ XSelectInput(mydisplay, mywindow, StructureNotifyMask);
+ win_width = image_width;
+ win_height = image_height;
+
+ /* all done (I hope...) */
+ X_already_started++;
+ return;
+ }
}
+#endif/* HAVE_XV */
+#endif/* 0 */