summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2006-04-08 15:20:51 +0000
committerdeva <deva>2006-04-08 15:20:51 +0000
commit46b3c21f079a10e1ed072976d355a8026bcb7580 (patch)
tree7fb0311f5f76ec991ebc0a05ba3ab62cd5c8946d /client
parent9c078bc5e1468ed79d85fafbad41160c0170959e (diff)
*** empty log message ***
Diffstat (limited to 'client')
-rw-r--r--client/decoder.cc20
-rw-r--r--client/decoder.h5
-rw-r--r--client/mainwindow.cc6
-rw-r--r--client/miav_client.cc4
-rw-r--r--client/player.cc55
-rw-r--r--client/player.h17
-rw-r--r--client/videowidget.cc15
-rw-r--r--client/xvaccelrenderer.cc10
-rw-r--r--client/xvaccelrenderer.h5
9 files changed, 116 insertions, 21 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index d4d1d15..e181516 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -28,14 +28,30 @@
#include "info.h"
+#include "dv.h"
+//#include "dvfile.h"
+#include "dv1394.h"
+
Decoder::Decoder()
-{}
+{
+ frame = NULL;
+}
Decoder::~Decoder()
{}
void Decoder::run()
{
- // MIaV::info->info("The decoder thread is running.");
+ dv1394 reader;
+
+ reader.connect();
+
+ while(1) {
+ frame = reader.readFrame();
+ }
}
+unsigned char *Decoder::getFrame()
+{
+ return frame;
+}
diff --git a/client/decoder.h b/client/decoder.h
index 78caa59..ca684ed 100644
--- a/client/decoder.h
+++ b/client/decoder.h
@@ -35,7 +35,12 @@ public:
Decoder();
~Decoder();
+ unsigned char *getFrame();
+
void run();
+
+private:
+ unsigned char *frame;
};
#endif/*__MIAV_DECODER_H__*/
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index c3b8649..c3d29ba 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -48,7 +48,6 @@ QPushButton *MainWindow::createButton(char* icon)
Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding;
pixmap = pixmap.scaled(w,h, aspect, Qt::SmoothTransformation);
-
QPushButton *btn = new QPushButton();
btn->setIconSize(QSize(50,50));
@@ -62,8 +61,6 @@ MainWindow::MainWindow(): QWidget()
{
MIaV::info->log("Starting MIaV v. %s.", VERSION);
- resize(800, 600);
-
// Create the overlaying splashscreen
SplashScreen splash(this);
/*
@@ -127,7 +124,8 @@ MainWindow::MainWindow(): QWidget()
// Create statusbar
show();
- // setWindowState(Qt::WindowFullScreen);
+ //setWindowState(Qt::WindowFullScreen);
+ resize(800, 600);
MIaV::info->log("MIaV is ready.");
}
diff --git a/client/miav_client.cc b/client/miav_client.cc
index ff38f09..376a27e 100644
--- a/client/miav_client.cc
+++ b/client/miav_client.cc
@@ -48,11 +48,11 @@ int main(int argc, char *argv[])
MainWindow mainwindow;
Decoder decoder;
- Player player(mainwindow.getVideo());
+ Player player(mainwindow.getVideo(), &decoder);
NetworkSender sender;
decoder.start();
- player.start(500); // 25 frames / second
+ player.start(40); // 100: 10fps, 40: 25fps
sender.start();
return app.exec();
diff --git a/client/player.cc b/client/player.cc
index fad7df4..1edf2cb 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -26,23 +26,35 @@
*/
#include "player.h"
-static unsigned char yuv[720*576*4];
+#define WIDTH 720
+#define HEIGHT 576
+
+static unsigned char yuv_buf[WIDTH*HEIGHT*3];
static int num = 0;
+static bool first = true;
-Player::Player(VideoWidget *w)
+Player::Player(VideoWidget *w, Decoder *d)
{
widget = w;
+ decoder = d;
- render.init(widget, 720, 576);//widget->getWidth(), widget->getHeight()
+ render.init(widget, WIDTH, HEIGHT);//widget->getWidth(), widget->getHeight()
connect(this, SIGNAL(timeout()), this, SLOT(show_frame()));
+ /*
for(int x = 1; x < 720; x++)
for(int y = 1; y < 576; y++) {
yuv[x + y * 576 * 1] = x % 720 * 255;
yuv[x + y * 576 * 2] = y % 576 * 255;
yuv[x + y * 576 * 3] = (unsigned char)x % y;
}
+ */
+
+ dvdecoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE);
+ dvdecoder->quality = DV_QUALITY_BEST;
+
+ // reader.connect();
}
Player::~Player()
@@ -52,10 +64,45 @@ Player::~Player()
void Player::show_frame()
{
+ uint8_t *frame;
fprintf(stderr, "Frame!%d\n", num++);
+
+ frame = decoder->getFrame();
+
+ if(!frame) return;
+ if(first) {
+#ifdef COLORSPACE_YV12
+ yuv[0] = yuv_buf;
+ yuv[1] = (unsigned char*)yuv[0] + (WIDTH * HEIGHT);
+ yuv[2] = (unsigned char*)yuv[1] + (WIDTH * HEIGHT / 4);
+ pitches[0] = WIDTH;
+ pitches[1] = WIDTH / 2;
+ pitches[2] = WIDTH / 2;
+#else
+ yuv[0] = yuv_buf;
+ pitches[0] = WIDTH * 2;
+#endif
+
+ dv_parse_header(dvdecoder, frame);
+ //dv_parse_packs(decoder, frame->data); // Not needed anyway!
+
+ dvdecoder->system = e_dv_system_625_50; // PAL lines, PAL framerate
+ dvdecoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v
+ dvdecoder->std = e_dv_std_iec_61834;
+ dvdecoder->num_dif_seqs = 12;
+ first = false;
+ }
+
+ dv_decode_full_frame(dvdecoder,
+ frame,
+ e_dv_color_yuv,
+ yuv,
+ pitches);
+
render.width = widget->getWidth();
render.height = widget->getHeight();
- render.display(yuv, 720, 576);//widget->width(), widget->height());
+ render.display(yuv_buf, WIDTH, HEIGHT);//widget->width(), widget->height());
+
}
diff --git a/client/player.h b/client/player.h
index 59e1f70..d3db533 100644
--- a/client/player.h
+++ b/client/player.h
@@ -30,23 +30,38 @@
#include <QTimer>
#include "videowidget.h"
+#include "decoder.h"
+
+#include "dv1394.h"
#include <X11/Xlib.h>
#include <X11/extensions/Xvlib.h>
+// Use libdv
+#include <libdv/dv.h>
+#include <libdv/dv_types.h>
+
#include "xvaccelrenderer.h"
class Player : public QTimer
{
Q_OBJECT
public:
- Player(VideoWidget *widget);
+ Player(VideoWidget *widget, Decoder *decoder);
~Player();
public slots:
void show_frame();
private:
+ // dv1394 reader;
+
+ int pitches[3];
+ unsigned char* yuv[3];
+
+ dv_decoder_t *dvdecoder;
+
+ Decoder *decoder;
VideoWidget *widget;
XvAccelRender render;
diff --git a/client/videowidget.cc b/client/videowidget.cc
index edabf71..f6fc430 100644
--- a/client/videowidget.cc
+++ b/client/videowidget.cc
@@ -51,9 +51,24 @@ VideoWidget::~VideoWidget()
{
}
+//static QWidget *realparent;
void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
{
/*
+ fprintf(stderr, "Fullscreen\n");
+
+ if(isFullScreen()) {
+ // setWindowState(Qt::WindowNoState);
+ setParent(realparent);
+ showNormal();
+ } else {
+ realparent = parentWidget();
+ setParent(NULL);
+ showFullScreen();
+ // setWindowState(Qt::WindowFullScreen);
+ }
+ */
+ /*
if(!parent) { // We are a fullscreen window
QString ids;
setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()).toStdString().c_str(), 1);
diff --git a/client/xvaccelrenderer.cc b/client/xvaccelrenderer.cc
index 188574e..f030642 100644
--- a/client/xvaccelrenderer.cc
+++ b/client/xvaccelrenderer.cc
@@ -28,10 +28,6 @@
// Use this define for verbose output
#define VERBOSE_XV
-// Use this define for YV12 colorspace, default is YUY2
-//#define COLORSPACE_YV12
-
-
//static uint8_t GUI_XvSync(void);
@@ -118,7 +114,7 @@ uint8_t XvAccelRender::GUI_XvDisplay(uint8_t * src, uint32_t w, uint32_t h)
#else
XvPutImage(xv_display, xv_port, xv_win, xv_gc, xvimage,
0, 0, w, h, // src
- 0, 0, w / 3, h / 3 // dst
+ 0, 0, w, h // dst
);
#endif
@@ -226,11 +222,11 @@ uint8_t XvAccelRender::GUI_XvInit(QWidget * window, uint32_t w, uint32_t h)
}
#ifdef COLORSPACE_YV12
#ifdef VERBOSE_XV
- printf("\n Xv YV12 found at port :%d, format : %ld", port, xv_format);
+ printf("\n Xv YV12 found at port :%d, format : %d", port, xv_format);
#endif
#else
#ifdef VERBOSE_XV
- printf("\n Xv YUY2 found at port :%d, format : %ld", port, xv_format);
+ printf("\n Xv YUY2 found at port :%d, format : %d", port, xv_format);
#endif
#endif
diff --git a/client/xvaccelrenderer.h b/client/xvaccelrenderer.h
index 588516f..69745d6 100644
--- a/client/xvaccelrenderer.h
+++ b/client/xvaccelrenderer.h
@@ -15,10 +15,13 @@
#include <X11/extensions/XShm.h>
#include <errno.h>
+// Use this define for YV12 colorspace, default is YUY2
+//#define COLORSPACE_YV12
+
//typedef unsigned long int QWidget;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
-typedef unsigned long int uint32_t;
+typedef unsigned int uint32_t;
#define ADM_assert(x) assert(x)