summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2006-06-15 17:35:33 +0000
committerdeva <deva>2006-06-15 17:35:33 +0000
commit897867cc9d3bc869317666993a9cc6ef38c163e2 (patch)
tree49127ab698c52d0a7a2c7749081f15784cddf4bc /client
parentd8404ce282917ef81418387f20fc5ee3607be391 (diff)
Prepared for the client to use uncompressed frames (YUV422 instead of DV).
Still a lot of work to do though!
Diffstat (limited to 'client')
-rw-r--r--client/decoder.cc44
-rw-r--r--client/decoder.h5
-rw-r--r--client/dv1394.cc7
-rw-r--r--client/dv1394.h2
-rw-r--r--client/dvfile.cc10
-rw-r--r--client/dvfile.h2
-rw-r--r--client/networksender.cc8
-rw-r--r--client/networksender.h2
-rw-r--r--client/player.cc14
-rw-r--r--client/player.h5
10 files changed, 61 insertions, 38 deletions
diff --git a/client/decoder.cc b/client/decoder.cc
index 11cee08..c7a5097 100644
--- a/client/decoder.cc
+++ b/client/decoder.cc
@@ -47,7 +47,7 @@
Decoder::Decoder()
{
running = true;
- memset(pframe, 0, sizeof(pframe)); // Init an empty frame
+ pframe = NULL;
qApp->installEventFilter(this);
}
@@ -68,16 +68,29 @@ void Decoder::run()
reader.connect();
#endif/* READ_DV_FROM_FILE*/
+ LibDVWrapper dvdecoder(DV::ColorBest, DV::PAL, DV::YUV_422);
+
while(running) {
- char *frame = (char*)reader.readFrame();
- if(!frame) continue; // An empty frame
+ Frame *dvframe = reader.readFrame();
+ if(!dvframe) continue; // An empty frame
+
+ Frame *yuvframe = dvdecoder.decode(dvframe); // Decode the DV frame to YUV422 and PCM audio
+ if(!yuvframe) continue; // An error ocurred
if(MIaV::control.isFrozen() == false) {
- pmutex.lock();
- memcpy(pframe, frame, DVPACKAGE_SIZE);
- pmutex.unlock();
+ if(yuvframe->vformat != VF_YUV422) {
+ fprintf(stderr, "Wrong videoformat in Decoder, expected VF_YUV422, got %i\n", yuvframe->vformat);
+ } else {
+ if(!pframe) {
+ fprintf(stderr, "PFrame data not set!\n");
+ } else {
+ pmutex.lock();
+ memcpy(pframe, yuvframe->vframe, yuvframe->vframesize);
+ pmutex.unlock();
+ }
+ }
}
-
+
if(MIaV::control.isRecording()) {
if(newconnection) {
NetworkSender *sender = new NetworkSender(MIaV::control.getCpr());
@@ -92,7 +105,7 @@ void Decoder::run()
sendersmutex.lock();
if(senders.isEmpty() == false)
- senders.back()->pushFrame(frame,
+ senders.back()->pushFrame(yuvframe,
MIaV::control.getShot(),
MIaV::control.getFreeze());
sendersmutex.unlock();
@@ -113,17 +126,24 @@ void Decoder::run()
sendersmutex.unlock();
- free(frame);
+ // free(frame);
newconnection = true;
+
}
}
// closesem.release(); // Unlock the shutdown process
}
-char *Decoder::pframeAcquire()
+void Decoder::setPFrameData(char *pframe)
+{
+ pmutex.lock();
+ this->pframe = pframe;
+ pmutex.unlock();
+}
+
+void Decoder::pframeAcquire()
{
pmutex.lock();;
- return pframe;
}
void Decoder::pframeRelease()
@@ -133,12 +153,14 @@ void Decoder::pframeRelease()
void Decoder::snapshot(char *rgb)
{
+ /*
LibDVWrapper dv;
dv.setOutputBuffer(rgb, DV::BGR0);
pmutex.lock();
dv.decode(pframe);
pmutex.unlock();
+ */
}
bool Decoder::eventFilter(QObject *o, QEvent *e)
diff --git a/client/decoder.h b/client/decoder.h
index 2f8d575..f156884 100644
--- a/client/decoder.h
+++ b/client/decoder.h
@@ -51,7 +51,8 @@ public:
void snapshot(char *rgb);
- char *pframeAcquire();
+ void setPFrameData(char *pframe);
+ void pframeAcquire();
void pframeRelease();
Status status();
@@ -64,7 +65,7 @@ private:
QSemaphore closesem;
QMutex pmutex;
- char pframe[DVPACKAGE_SIZE]; // Player frame
+ char *pframe; // Player frame
QMutex mutex;
diff --git a/client/dv1394.cc b/client/dv1394.cc
index e463c54..7dac7b3 100644
--- a/client/dv1394.cc
+++ b/client/dv1394.cc
@@ -150,7 +150,7 @@ bool dv1394::connect()
return true;
}
-unsigned char *dv1394::readFrame()
+Frame *dv1394::readFrame()
{
// Firewire port not correctly opened.
if(!handle) return NULL;
@@ -164,6 +164,9 @@ unsigned char *dv1394::readFrame()
break;
}
}
- return ptr;
+
+ Frame *frame = new Frame((char*)ptr, DVPACKAGE_SIZE, VF_DV, NULL, 0, AF_DV);
+
+ return frame;
}
diff --git a/client/dv1394.h b/client/dv1394.h
index 8485638..5f99199 100644
--- a/client/dv1394.h
+++ b/client/dv1394.h
@@ -39,7 +39,7 @@ public:
bool connect();
- unsigned char *readFrame();
+ Frame *readFrame();
private:
raw1394handle_t handle;
diff --git a/client/dvfile.cc b/client/dvfile.cc
index 676d6b1..601c21d 100644
--- a/client/dvfile.cc
+++ b/client/dvfile.cc
@@ -42,19 +42,21 @@ dvfile::~dvfile()
fclose(fp);
}
-unsigned char *dvfile::readFrame()
+Frame *dvfile::readFrame()
{
- unsigned char *frame = new unsigned char[DVPACKAGE_SIZE];
+ unsigned char *ptr = new unsigned char[DVPACKAGE_SIZE];
sleep_1_frame();
if(fp) {
- while(fread(frame, DVPACKAGE_SIZE, 1, fp) == 0) {
+ while(fread(ptr, DVPACKAGE_SIZE, 1, fp) == 0) {
fseek(fp, 0L, SEEK_SET);
}
} else {
- memset(frame, 0, sizeof(frame));
+ memset(ptr, 0, sizeof(ptr));
}
+ Frame *frame = new Frame((char*)ptr, DVPACKAGE_SIZE, VF_DV, NULL, 0, AF_DV);
+
return frame;
}
diff --git a/client/dvfile.h b/client/dvfile.h
index 9eedd00..b65dc36 100644
--- a/client/dvfile.h
+++ b/client/dvfile.h
@@ -40,7 +40,7 @@ public:
dvfile();
~dvfile();
- unsigned char *readFrame();
+ Frame *readFrame();
private:
FILE* fp;
diff --git a/client/networksender.cc b/client/networksender.cc
index 11eb259..f8912f1 100644
--- a/client/networksender.cc
+++ b/client/networksender.cc
@@ -32,7 +32,7 @@
NetworkSender::NetworkSender(QString cpr)
{
- ip = "192.168.0.10";
+ ip = "127.0.0.1";
port = 6666;
// Connect
@@ -60,11 +60,11 @@ NetworkSender::~NetworkSender()
fprintf(stderr, "Disconnect [%p]\n", this);
}
-void NetworkSender::pushFrame(char* framedata, bool freeze, bool snapshot)
+void NetworkSender::pushFrame(Frame* frame, bool freeze, bool snapshot)
{
printf("F: %d S %d\n", freeze, snapshot);
- Frame *frame = new Frame((unsigned char*)framedata);
+ // Frame *frame = new Frame((unsigned char*)framedata);
frame->freeze = freeze;
frame->shoot = snapshot;
@@ -104,6 +104,8 @@ void NetworkSender::run()
sleep_1_frame();
sleep_1_frame();
sleep_1_frame();
+ if(frame->vframe) delete frame->vframe;
+ if(frame->aframe) delete frame->aframe;
delete frame;
// TODO: Read status from network
diff --git a/client/networksender.h b/client/networksender.h
index e3beb5a..71ce7e7 100644
--- a/client/networksender.h
+++ b/client/networksender.h
@@ -43,7 +43,7 @@ public:
NetworkSender(QString cpr);
~NetworkSender();
- void pushFrame(char* frame, bool freeze, bool snapshot);
+ void pushFrame(Frame* frame, bool freeze, bool snapshot);
unsigned int queueSize();
void run();
diff --git a/client/player.cc b/client/player.cc
index 44e9cc9..dc3002d 100644
--- a/client/player.cc
+++ b/client/player.cc
@@ -34,25 +34,21 @@ Player::Player(QWidget *w, Decoder *d) :
{
widget = w;
decoder = d;
- dvdecoder = new LibDVWrapper(DV::ColorBest, DV::PAL, DV::YUV_422);
connect(this, SIGNAL(timeout()), this, SLOT(show_frame()));
-
- dvdecoder->setOutputBuffer(render.getDisplayData());
+ decoder->setPFrameData(render.getDisplayData());
}
Player::~Player()
{
- delete dvdecoder;
+ // delete dvdecoder;
}
void Player::show_frame()
{
- char *frame;
+ // char *frame;
- frame = decoder->pframeAcquire(); // Acquire frame data
- dvdecoder->decode(frame); // Decode the DV frame to YUV
- decoder->pframeRelease(); // Release frame data
+ decoder->pframeAcquire(); // Acquire frame data
// Scale the video in aspect:
if((double)widget->width() / WIDTH < (double)widget->height() / HEIGHT) {
@@ -65,4 +61,6 @@ void Player::show_frame()
// Display the YUV frame
render.display(WIDTH, HEIGHT);
+
+ decoder->pframeRelease(); // Release frame data
}
diff --git a/client/player.h b/client/player.h
index d56ae4b..edd7bcf 100644
--- a/client/player.h
+++ b/client/player.h
@@ -38,9 +38,6 @@
#include <X11/extensions/Xvlib.h>
#include <QImage>
-
-#include "libdv_wrapper.h"
-
#include "xvaccelrenderer.h"
class Player : public QTimer
@@ -54,8 +51,6 @@ public slots:
void show_frame();
private:
- LibDVWrapper *dvdecoder;
-
Decoder *decoder;
QWidget *widget;
XvAccelRender render;