diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/mainwindow.cc | 14 | ||||
-rw-r--r-- | client/mainwindow.h | 8 | ||||
-rw-r--r-- | client/miav_client.cc | 4 | ||||
-rw-r--r-- | client/player.cc | 163 | ||||
-rw-r--r-- | client/player.h | 15 |
5 files changed, 192 insertions, 12 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 08d68f9..57f1929 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -32,18 +32,22 @@ #include <QGridLayout> -#include "videowidget.h" #include "historywidget.h" -// Macro for creating buttons -static QPushButton *createButton(char* icon) +#include <QX11Info> + +QPushButton *MainWindow::createButton(char* icon) { QPixmap pixmap(icon); + int w = (int)((double)x11Info().appDpiX() / 1.5); + int h = (int)((double)x11Info().appDpiY() / 1.5); + Qt::AspectRatioMode aspect = pixmap.width()<pixmap.height()? Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding; - pixmap = pixmap.scaled(50, 50, aspect, Qt::SmoothTransformation); + pixmap = pixmap.scaled(w,h, aspect, Qt::SmoothTransformation); + QPushButton *btn = new QPushButton(); btn->setIconSize(pixmap.size()); btn->setIcon(pixmap); @@ -71,7 +75,7 @@ MainWindow::MainWindow(): QWidget() setLayout(layout); // Create the videoarea - VideoWidget *video = new VideoWidget(); + video = new VideoWidget(); layout->addWidget(video, 0,0, 1,4); // Create the control buttons diff --git a/client/mainwindow.h b/client/mainwindow.h index b4ce7e1..9332b0d 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -28,7 +28,10 @@ #define __MIAV_MAINWINDOW_H__ #include <QWidget> + +#include <QPushButton> #include "historyframe.h" +#include "videowidget.h" /** * Images @@ -56,6 +59,8 @@ public: MainWindow(); ~MainWindow(); + VideoWidget *getVideo() { return video; } + public slots: void cpr_clicked(); void clear_clicked(); @@ -67,6 +72,9 @@ public slots: private: HistoryFrame *history; + VideoWidget *video; + + QPushButton *createButton(char* icon); }; #endif/*__MIAV_MAINWINDOW_H__*/ diff --git a/client/miav_client.cc b/client/miav_client.cc index 756b434..4051b16 100644 --- a/client/miav_client.cc +++ b/client/miav_client.cc @@ -46,9 +46,9 @@ int main(int argc, char *argv[]) MIaV::initInfo(&info); MainWindow mainwindow; - + Decoder decoder; - Player player; + Player player(mainwindow.getVideo()); NetworkSender sender; decoder.start(); 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 */ diff --git a/client/player.h b/client/player.h index f8497d0..abceb9d 100644 --- a/client/player.h +++ b/client/player.h @@ -29,13 +29,26 @@ #include <QThread> +#include "videowidget.h" + +#include <X11/Xlib.h> +#include <X11/extensions/Xvlib.h> + class Player : public QThread { public: - Player(); + Player(VideoWidget *video); ~Player(); void run(); + +private: + Display *display; + Drawable drawable; + GC gc; + XvPortID port; + + VideoWidget *video; }; #endif/*__MIAV_PLAYER_H__*/ |