From 856ab0ece3e73e2b520d55aeab9adfbccdb6aa93 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 16 May 2005 16:00:56 +0000 Subject: Lots of stuff! --- etc/miav.conf | 2 +- src/camera.cc | 9 +++++++++ src/camera.h | 6 ++++++ src/decoder.cc | 55 ++++++++++++++++++++++++++++++++-------------------- src/mainwindow.cc | 39 +++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 7 +++++++ src/mov_encoder.cc | 8 ++++++-- src/queue.h | 13 +++++++++---- src/server.cc | 11 +++++++++-- src/server_status.cc | 6 +++++- 10 files changed, 125 insertions(+), 31 deletions(-) diff --git a/etc/miav.conf b/etc/miav.conf index 2ab5b48..c146221 100644 --- a/etc/miav.conf +++ b/etc/miav.conf @@ -30,4 +30,4 @@ server_root = "/tmp/miav_files" frame_sequence = "IPPPPPPPPPP" # quality in % - 100% is best quality -frame_quality = 80 +frame_quality = 90 diff --git a/src/camera.cc b/src/camera.cc index 7bb1e79..1137ba2 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.16 2005/05/16 16:00:56 deva + * + * Lots of stuff! + * * Revision 1.15 2005/05/07 10:25:34 deva * * Removed ffmpeg code from img_encoder and corrected decoding errors in mov_encoder @@ -229,4 +233,9 @@ void Camera::snapshot(unsigned char *rgb) } } +int Camera::getQueueLength() +{ + return encode_queue->length(); +} + #endif/* USE_GUI */ diff --git a/src/camera.h b/src/camera.h index b1aef2e..a495149 100644 --- a/src/camera.h +++ b/src/camera.h @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.12 2005/05/16 16:00:56 deva + * + * Lots of stuff! + * * Revision 1.11 2005/05/07 10:25:34 deva * * Removed ffmpeg code from img_encoder and corrected decoding errors in mov_encoder @@ -93,6 +97,8 @@ public: void unfreeze(); void snapshot(unsigned char *rgb); + int getQueueLength(); + private: // Info object passed to all sub objects. Info *info; diff --git a/src/decoder.cc b/src/decoder.cc index 2c68935..e908b63 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.28 2005/05/16 16:00:56 deva + * + * Lots of stuff! + * * Revision 1.27 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -120,7 +124,8 @@ void Decoder::decode() { bool local_shoot; bool local_freeze; - bool local_record; + bool local_record = false; + bool old_record; dv1394 dv_stream = dv1394(info); // Use default port and channel. @@ -133,6 +138,7 @@ void Decoder::decode() ptr = dv_stream.readFrame(); if(!ptr) return; // No frame read. (Due to firewire error) + old_record = local_record; local_shoot = b_shoot; b_shoot = false; local_freeze = b_freeze; @@ -152,29 +158,36 @@ void Decoder::decode() pthread_mutex_unlock(&shot_mutex); } - 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); - pframe->shoot = local_shoot; - pframe->freeze = local_freeze; - pframe->record = local_record; - - free(ptr); + if(local_record | (local_record != old_record) | local_shoot | local_freeze) { + Frame *eframe = new Frame(ptr, DVPACKAGE_SIZE); + eframe->shoot = local_shoot; + eframe->freeze = local_freeze; + eframe->record = local_record; - encode_queue->push(eframe); - player_queue->push(pframe); + encode_queue->push(eframe); + + sem_post(encode_sem); + } - sem_post(encode_sem); + static int showframe = 1; + // showframe = 1 - showframe; + if(showframe) { + Frame *pframe = new Frame(ptr, DVPACKAGE_SIZE); + pframe->shoot = local_shoot; + pframe->freeze = local_freeze; + pframe->record = local_record; + + player_queue->push(pframe); - // Create and send SDL event. - user_event.type = SDL_USEREVENT; - user_event.user.code = 0; - user_event.user.data1 = NULL; - user_event.user.data2 = NULL; - SDL_PushEvent(&user_event); + // Create and send SDL event. + user_event.type = SDL_USEREVENT; + user_event.user.code = 0; + user_event.user.data1 = NULL; + user_event.user.data2 = NULL; + SDL_PushEvent(&user_event); + } + + free(ptr); } // Kick the others so they wake up with empty queues diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 577058f..496817b 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.26 2005/05/16 16:00:56 deva + * + * Lots of stuff! + * * Revision 1.25 2005/05/03 09:22:12 deva * Implemented the gui part of the info object. * @@ -146,6 +150,11 @@ MainWindow::MainWindow(QApplication *qApp, QWidget* parent, const char* name ) camera->connect(config->readString("server_addr")->c_str(), config->readInt("server_port")); + // Make sure this is created *after* the camera object! + taskbartimer = new QTimer(this); + connect(taskbartimer, SIGNAL(timeout()), SLOT(taskbar_update())); + taskbartimer->start(200); + recording = false; frozen = false; @@ -261,6 +270,36 @@ void MainWindow::createGui() status->message( TXT_READY ); } + +#include +static struct timeval starttime; +static int h = 0; +static int m = 0; +static int s = 0; + +void MainWindow::taskbar_update() +{ + struct timeval time; + + if(recording) { + gettimeofday(&time, NULL); + + s = time.tv_sec - starttime.tv_sec; + + h = s / (60 * 60); + s -= h * (60 *60); + m = s / 60; + s -= m * 60; + } else { + gettimeofday(&starttime, NULL); + } + + char msg[256]; + int l = camera->getQueueLength(); + sprintf(msg, "Recording time: %d:%d:%d - Queue length: %d", h, m, s, l); + message(msg); +} + #define GREY 160 #define SPEED 0.07f void MainWindow::redraw_edge() diff --git a/src/mainwindow.h b/src/mainwindow.h index 5f0fe93..4f0d2d2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.13 2005/05/16 16:00:57 deva + * + * Lots of stuff! + * * Revision 1.12 2005/05/03 09:22:12 deva * Implemented the gui part of the info object. * @@ -115,6 +119,7 @@ public slots: void shoot_clicked(); void freeze_clicked(); void redraw_edge(); + void taskbar_update(); private: Info *info; @@ -137,6 +142,8 @@ private: QLabel *lbl_cpr; QLabel *lbl_name; + QTimer *taskbartimer; + // Used for the check_for_error_once_per_2_seconds (very ugly) QTimer *errtimer; diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 143fa2b..fed2c40 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.20 2005/05/16 16:00:57 deva + * + * Lots of stuff! + * * Revision 1.19 2005/05/16 13:25:52 deva * * Moved video setting to configuration file. @@ -165,7 +169,7 @@ MovEncoder::MovEncoder(const char *filename) // slices_per_frame is the number of frame slices per frame. More slices provide // better error recovery. There must be at least one slice per frame, and at most // height / 16 - fame_par.slices_per_frame = fame_par.height / 16; + fame_par.slices_per_frame = 1;//fame_par.height / 16; // frames_per_sequence is the maximum number of frames contained in a video // sequence. @@ -187,7 +191,7 @@ MovEncoder::MovEncoder(const char *filename) // verbose when set to 1 outputs information on copyright, modules used and // current frame on standard error. - fame_par.verbose = 1; + fame_par.verbose = 0; static const char profilename[] = "MIaV\0"; fame_par.profile = profilename; // profile name diff --git a/src/queue.h b/src/queue.h index 1967c0c..de7b8ff 100644 --- a/src/queue.h +++ b/src/queue.h @@ -38,6 +38,10 @@ /* * $Log$ + * Revision 1.15 2005/05/16 16:00:57 deva + * + * Lots of stuff! + * * Revision 1.14 2005/05/07 10:25:34 deva * * Removed ffmpeg code from img_encoder and corrected decoding errors in mov_encoder @@ -84,7 +88,7 @@ public: void lock(); void unlock(); - void plength(); + int length(); private: volatile bool locked; @@ -235,12 +239,13 @@ T *Queue::peek() * Print current length of queue */ template -void Queue::plength() +int Queue::length() { + int length; pthread_mutex_lock(&mutex); - fprintf(stderr, "[ql: %d]", count); - fflush(stderr); + length = count; pthread_mutex_unlock(&mutex); + return length; } /** diff --git a/src/server.cc b/src/server.cc index 76ba8c9..370af2e 100644 --- a/src/server.cc +++ b/src/server.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.14 2005/05/16 16:00:57 deva + * + * Lots of stuff! + * * Revision 1.13 2005/05/09 16:40:20 deva * * Added optimize yuv conversion code @@ -281,13 +285,15 @@ void newConnection(Socket *socket) frame = new Frame(NULL, DVPACKAGE_SIZE); - printf("New connection[pid: %d]...\n", getpid()); + fprintf(stderr, "New connection[pid: %d]...\n", getpid()); + fflush(stderr); Network network = Network(socket, &info); while(int ret = network.recvPackage(&h, frame->data, frame->size)) { status.checkPoint(); if(ret == -1) { fprintf(stderr, "An error occurred...!\n"); + fflush(stderr); break; } @@ -337,6 +343,7 @@ void newConnection(Socket *socket) if(enc) delete enc; - printf("Connection end[pid: %d]...\n", getpid()); + fprintf(stderr, "Connection end[pid: %d]...\n", getpid()); + fflush(stderr); } diff --git a/src/server_status.cc b/src/server_status.cc index 7583cc9..197e859 100644 --- a/src/server_status.cc +++ b/src/server_status.cc @@ -31,6 +31,10 @@ /* * $Log$ + * Revision 1.6 2005/05/16 16:00:57 deva + * + * Lots of stuff! + * * Revision 1.5 2005/05/16 13:25:52 deva * * Moved video setting to configuration file. @@ -52,7 +56,7 @@ #include -#define UPD 25 +#define UPD 10 ServerStatus::ServerStatus() { gettimeofday(&oldtime, NULL); -- cgit v1.2.3