summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--src/camera.cc32
-rw-r--r--src/decoder.cc59
-rw-r--r--src/decoder.h12
-rw-r--r--src/encoder.cc40
-rw-r--r--src/encoder.h13
-rw-r--r--src/frame.h7
7 files changed, 136 insertions, 32 deletions
diff --git a/TODO b/TODO
index 8b7ce4c..a14cf28 100644
--- a/TODO
+++ b/TODO
@@ -5,7 +5,7 @@
MessageBox:
[x] - Make it.
- [/] - Make icons.
+ [x] - Make icons.
[ ] - Test it.
SplashScreen:
@@ -20,7 +20,7 @@ Mainwindow:
[ ] - Show network connection status in statusbar.
[ ] - Show camera connection status in statusbar.
[x] - Save movie messagebox (yes/no/dunno)
- [ ] - Create snapshot thumbnails from dv stream instead of the widget.
+ [x] - Create snapshot thumbnails from dv stream instead of the widget.
[ ] - Test it.
CPRQueryDialog:
@@ -42,6 +42,7 @@ Decoder:
[ ] - Enable sound decoding for the network stream.
[x] - Remove ffmpeg code.
[x] - Make use of 2.6 kernel (through raw1394)
+ [ ] - Set flags on frame objects.
Camera:
[x] - Add initialize method (constructor should do nothing).
diff --git a/src/camera.cc b/src/camera.cc
index 6300946..e7994f6 100644
--- a/src/camera.cc
+++ b/src/camera.cc
@@ -27,6 +27,9 @@
*/
/*
* $Log$
+ * Revision 1.10 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.9 2005/05/01 11:25:56 deva
* Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage.
*
@@ -149,23 +152,30 @@ void Camera::setCpr(char *newcpr)
void Camera::start()
{
- if(initialized) encoder->start();
- else errorstatus->pushError("Camera not initialized.");
+ if(initialized) {
+ decoder->start();
+ encoder->start();
+ } else {
+ errorstatus->pushError("Camera not initialized.");
+ }
}
void Camera::stop(n_savestate save)
{
- if(initialized) encoder->stop(save);
- else errorstatus->pushError("Camera not initialized.");
+ if(initialized) {
+ decoder->stop(save);
+ encoder->stop(save);
+ } else {
+ errorstatus->pushError("Camera not initialized.");
+ }
}
void Camera::freeze()
{
- // FIXME: Ensure they freeze the same frame, i.e. the player
- // shows the same frame that is actually frozen on the server.
if(initialized) {
player->stop();
- encoder->freeze();
+ // encoder->freeze();
+ decoder->freeze();
} else {
errorstatus->pushError("Camera not initialized.");
}
@@ -179,8 +189,12 @@ void Camera::unfreeze()
void Camera::snapshot(unsigned char *rgb)
{
- if(initialized) encoder->shoot(rgb);
- else errorstatus->pushError("Camera not initialized.");
+ if(initialized) {
+ decoder->shoot(rgb);
+ encoder->shoot(rgb);
+ } else {
+ errorstatus->pushError("Camera not initialized.");
+ }
}
Error *Camera::errorObject()
diff --git a/src/decoder.cc b/src/decoder.cc
index 2ab3b6b..4707c90 100644
--- a/src/decoder.cc
+++ b/src/decoder.cc
@@ -25,6 +25,9 @@
*/
/*
* $Log$
+ * Revision 1.22 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.21 2005/05/01 09:56:26 deva
* Added Id and Log tags to all files
*
@@ -60,6 +63,7 @@ Decoder::Decoder(Error* err,
player_queue = gplayer_queue;
mutex = gmutex;
running = grunning;
+ b_record = false; // Initially no recording is done.
}
Decoder::~Decoder()
@@ -68,6 +72,10 @@ Decoder::~Decoder()
void Decoder::decode()
{
+ bool local_shoot;
+ bool local_freeze;
+ bool local_record;
+
dv1394 dv_stream = dv1394(errobj); // Use default port and channel.
while(*running) {
@@ -78,10 +86,25 @@ void Decoder::decode()
// Read a dvframe
ptr = dv_stream.readFrame();
if(!ptr) return; // No frame read. (Due to firewire error)
+
+ local_shoot = b_shoot;
+ b_shoot = false;
+ local_freeze = b_freeze;
+ b_freeze = false;
+ local_record = b_record;
+
Frame *eframe = new Frame(ptr, DVPACKAGE_SIZE);
+ eframe->shoot = local_shoot;
+ eframe->freeze = local_freeze;
+ eframe->record = local_record;
+
Frame *pframe = new Frame(ptr, DVPACKAGE_SIZE);
- free(ptr);
+ pframe->shoot = local_shoot;
+ pframe->freeze = local_freeze;
+ pframe->record = local_record;
+ free(ptr);
+
encode_queue->push(eframe);
player_queue->push(pframe);
@@ -104,4 +127,38 @@ void Decoder::run() {
fprintf(stderr, "Decoder thread stopped.\n"); fflush(stderr);
}
+/*
+ * Set freeze bit on current frame.
+ */
+void Decoder::freeze()
+{
+ b_freeze = true;
+}
+
+
+/*
+ * Set shoot bit on current frame.
+ */
+void Decoder::shoot(unsigned char *rgb)
+{
+ b_shoot = true;
+}
+
+/*
+ * Set the record bit to true in all following frames.
+ */
+void Decoder::start()
+{
+ b_record = true;
+}
+
+/*
+ * Set the record bit to false in all following frames.
+ */
+void Decoder::stop(n_savestate save)
+{
+ b_record = false;
+}
+
+
#endif /*USE_GUI*/
diff --git a/src/decoder.h b/src/decoder.h
index a7e2b76..cc1ac22 100644
--- a/src/decoder.h
+++ b/src/decoder.h
@@ -24,6 +24,9 @@
*/
/*
* $Log$
+ * Revision 1.9 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.8 2005/05/01 09:56:26 deva
* Added Id and Log tags to all files
*
@@ -59,7 +62,16 @@ public:
~Decoder();
void run();
+ void freeze();
+ void shoot(unsigned char *rgb);
+ void start();
+ void stop(n_savestate save);
+
private:
+ volatile bool b_freeze;
+ volatile bool b_shoot;
+ volatile bool b_record;
+
Error *errobj;
AVCodecContext dvcodec;
diff --git a/src/encoder.cc b/src/encoder.cc
index d1d9362..cbafb99 100644
--- a/src/encoder.cc
+++ b/src/encoder.cc
@@ -25,6 +25,9 @@
*/
/*
* $Log$
+ * Revision 1.21 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.20 2005/05/02 09:18:13 deva
*
* Fixed decoding problem in snapshot thumbnails.
@@ -70,17 +73,17 @@ Encoder::Encoder(Error* err,
mutex = gmutex;
running = grunning;
- record = 0;
+ // record = 0;
sem_init(&record_sem, 0, 0);
s = NULL;
n = NULL;
- shoot_request = 0;
- shoot_value = 0;
- freeze_request = 0;
- freeze_value = 0;
+ // shoot_request = 0;
+ // shoot_value = 0;
+ // freeze_request = 0;
+ // freeze_value = 0;
}
@@ -101,20 +104,25 @@ void Encoder::encode()
frame = queue->pop();
if(frame) {
+ /*
if(record ||
(freeze_request != freeze_value) ||
(shoot_request != shoot_value)) {
+ */
+ if(frame->record ||
+ frame->freeze ||
+ frame->shoot) {
n_header h;
h.header_type = DATA_HEADER;
sprintf(h.header.h_data.cpr, cpr);
- h.header.h_data.freeze = (freeze_request != freeze_value);
- h.header.h_data.snapshot = (shoot_request != shoot_value);
- h.header.h_data.record = record;
+ h.header.h_data.freeze = frame->freeze;
+ h.header.h_data.snapshot = frame->shoot;
+ h.header.h_data.record = frame->record;
h.header.h_data.savestate = NO_CHANGE;
- if(freeze_request != freeze_value) freeze_value = freeze_request;
- if(shoot_request != shoot_value) shoot_value = shoot_request;
+ // if(freeze_request != freeze_value) freeze_value = freeze_request;
+ // if(shoot_request != shoot_value) shoot_value = shoot_request;
n->sendPackage(&h, frame->data, frame->size);
}
@@ -137,7 +145,7 @@ void Encoder::freeze()
s->sconnect(ip);
n = new Network(s, errobj);
}
- if(!errobj->hasError()) freeze_request = 1 - freeze_request;
+ // if(!errobj->hasError()) freeze_request = 1 - freeze_request;
}
@@ -153,7 +161,7 @@ void Encoder::shoot(unsigned char *rgb)
s->sconnect(ip);
n = new Network(s, errobj);
}
- if(!errobj->hasError()) shoot_request = 1 - shoot_request;
+ // if(!errobj->hasError()) shoot_request = 1 - shoot_request;
getScreenshot(rgb);
}
@@ -170,11 +178,12 @@ void Encoder::start() {
s->sconnect(ip);
n = new Network(s, errobj);
}
- if(!errobj->hasError()) record = 1;
+ // if(!errobj->hasError()) record = 1;
}
void Encoder::stop(n_savestate save) {
+/*
struct timespec ts;
// TODO: set save state in package header.
@@ -182,8 +191,8 @@ void Encoder::stop(n_savestate save) {
queue->lock();
fprintf(stderr, "Emptying queue"); fflush(stderr);
while(queue->peek()) {
- /* Remove any late buffer */
- /* We don't care, the encoder finishes them all */
+ // Remove any late buffer
+ // We don't care, the encoder finishes them all
ts.tv_sec = 0;
ts.tv_nsec = 500000000L; // 100ms
fprintf(stderr, "."); fflush(stderr);
@@ -194,6 +203,7 @@ void Encoder::stop(n_savestate save) {
record = 0;
queue->unlock();
+*/
if(s) {
if(n) delete n;
delete s;
diff --git a/src/encoder.h b/src/encoder.h
index 31aec20..0d84825 100644
--- a/src/encoder.h
+++ b/src/encoder.h
@@ -24,6 +24,9 @@
*/
/*
* $Log$
+ * Revision 1.9 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.8 2005/05/01 11:25:56 deva
* Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage.
*
@@ -95,12 +98,12 @@ private:
char ip[32];
char cpr[32];
- volatile int record;
+ // volatile int record;
- volatile int shoot_request;
- int shoot_value;
- volatile int freeze_request;
- int freeze_value;
+ // volatile int shoot_request;
+ // int shoot_value;
+ // volatile int freeze_request;
+ // int freeze_value;
sem_t record_sem;
void encode();
diff --git a/src/frame.h b/src/frame.h
index a10a934..2ef53ff 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -27,6 +27,9 @@
*/
/*
* $Log$
+ * Revision 1.4 2005/05/02 09:50:22 deva
+ * Rewrote freeze, shoot and record flags, from encoder to frame.
+ *
* Revision 1.3 2005/05/01 09:56:26 deva
* Added Id and Log tags to all files
*
@@ -42,6 +45,10 @@ public:
unsigned char *data;
int size;
+
+ bool shoot;
+ bool freeze;
+ bool record;
};
#endif/*__FRAME_H__*/