From d5e1739f5288355869eccd53ab3eb1a4000d1cab Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 14 Apr 2005 17:28:21 +0000 Subject: Unified the frame types. --- src/Makefile.am | 9 +++---- src/camera.cc | 4 +-- src/camera.h | 4 +-- src/decoder.cc | 73 +++++++++++++----------------------------------------- src/decoder.h | 17 +++++++------ src/dvframe.cc | 39 ----------------------------- src/dvframe.h | 47 ----------------------------------- src/encoder.cc | 11 ++++---- src/encoder.h | 17 ++++++------- src/ffframe.cc | 41 ------------------------------ src/ffframe.h | 38 ---------------------------- src/frame.cc | 40 ++++++++++++++++++++++++++++++ src/frame.h | 38 ++++++++++++++++++++++++++++ src/img_encoder.cc | 6 ++--- src/img_encoder.h | 4 +-- src/mov_encoder.cc | 6 ++--- src/mov_encoder.h | 4 +-- src/player.cc | 48 +++++++++++++++++++++++++---------- src/player.h | 10 ++++---- src/queue.h | 4 +-- src/server.cc | 14 ++++++----- src/server.h | 2 +- 22 files changed, 186 insertions(+), 290 deletions(-) delete mode 100644 src/dvframe.cc delete mode 100644 src/dvframe.h delete mode 100644 src/ffframe.cc delete mode 100644 src/ffframe.h create mode 100644 src/frame.cc create mode 100644 src/frame.h diff --git a/src/Makefile.am b/src/Makefile.am index 24c6972..4f0ffa2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,9 +11,8 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \ aboutwindow.cc \ camera.cc \ decoder.cc \ - dvframe.cc \ encoder.cc \ - ffframe.cc \ + frame.cc \ mainwindow.cc \ cprquerydialog.cc \ miav.cc \ @@ -37,10 +36,9 @@ EXTRA_DIST = \ camera.h \ cprquerydialog.h \ decoder.h \ - dvframe.h \ encoder.h \ error.h \ - ffframe.h \ + frame.h \ img_encoder.h \ mainwindow.h \ messagebox.h \ @@ -55,7 +53,8 @@ EXTRA_DIST = \ socket.h \ thread.h \ util.h \ - videowidget.h + videowidget.h \ + debug.h miav_LDADD := $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList o; fi ) \ -lavcodec -lavformat diff --git a/src/camera.cc b/src/camera.cc index a73c063..449c653 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -46,8 +46,8 @@ void Camera::connect(const char *ip, const int port) av_register_all(); - encode_queue = new Queue(); // infinite size - player_queue = new Queue(1); // fixed size of 1 + encode_queue = new Queue(); // infinite size + player_queue = new Queue(1); // fixed size of 1 sem_init(&encode_sem, 0, 0); sem_init(&player_sem, 0, 0); diff --git a/src/camera.h b/src/camera.h index e5b4cee..ab18d04 100644 --- a/src/camera.h +++ b/src/camera.h @@ -88,8 +88,8 @@ private: Decoder *decoder; Player *player; - Queue *encode_queue; - Queue *player_queue; + Queue *encode_queue; + Queue *player_queue; sem_t encode_sem; sem_t player_sem; pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/decoder.cc b/src/decoder.cc index 10ef245..9633f18 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -27,14 +27,15 @@ #include #include #include + #include "decoder.h" #include "debug.h" Decoder::Decoder(Error* err, sem_t *gencode_sem, sem_t *gplayer_sem, - Queue *gencode_queue, - Queue *gplayer_queue, + Queue *gencode_queue, + Queue *gplayer_queue, pthread_mutex_t *gmutex, volatile int *grunning) { @@ -46,24 +47,12 @@ Decoder::Decoder(Error* err, mutex = gmutex; running = grunning; - AVCodec *dec_codec; - - // Find ffmpeg-dv-codec - if(!(dec_codec = avcodec_find_decoder(CODEC_ID_DVVIDEO))) { - errobj->pushError("Unable to find codec."); - return; - } - - // Initialize ffmpeg-dv-codec - if(avcodec_open(&dvcodec, dec_codec) < 0) { - errobj->pushError("Error while opening codec for input stream."); - return; - } + // Initialize libdv } Decoder::~Decoder() { - avcodec_close(&dvcodec); + // Close libdv } static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadlet_t *data ) @@ -120,7 +109,7 @@ static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadl memcpy( framedata + dif_sequence * 150 * 80 + ( 7 + ( dif_block / 15 ) + dif_block ) * 80, p, 480 ); break; - default: // we canĀ“t handle any other data + default: // we can't handle any other data break; } } @@ -164,69 +153,41 @@ void Decoder::decode() raw1394_start_iso_rcv( handle, channel); while(*running) { - AVPacket pkt; uint8_t *ptr; int len; SDL_Event user_event; + // Read a dvframe while(1) { raw1394_loop_iterate(handle); - pkt.data = (uint8_t *)raw1394_get_userdata(handle); - if(pkt.data) { + ptr = (uint8_t *)raw1394_get_userdata(handle); + if(ptr) { raw1394_set_userdata(handle, NULL); break; } + len = DVPACKAGE_SIZE; } -printf("1"); fflush(stdout); - len = pkt.size = DVPACKAGE_SIZE; - ptr = pkt.data; - pkt.stream_index = 0; - - // NOTE: we only decode video, we only need the data from stream_index 0 - // (stream 0: video, stream 1: audio) - // while(pkt.stream_index == 0 && len > 0) { - int ret; - int got_picture; - // buf_t *buf = buf_alloc(); - FFFrame *fff = new FFFrame(); ALLOC(fff, "FFFrame in decode"); - memset(fff->frame, 0 , sizeof(AVFrame)); - //DVFrame *dvf = new DVFrame(); ALLOC(dvf, "DVFrame in decode"); - // dvf->type = DVF_VIDEO; - - // memcpy(dvf->frame, ptr, len); - -printf("2"); fflush(stdout); - ret = avcodec_decode_video(&dvcodec, fff->frame, &got_picture, ptr, len); -printf("3"); fflush(stdout); - - if(ret < 0) { - errobj->pushError("Error while decoding stream."); - return; - } - -printf("4"); fflush(stdout); + Frame *frame = new Frame((void*)ptr, len); + pthread_mutex_lock(mutex); - // encode_queue->push(dvf); - player_queue->push(fff); + encode_queue->push(frame); + player_queue->push(frame); pthread_mutex_unlock(mutex); -printf("5"); fflush(stdout); sem_post(encode_sem); + // 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; -printf("6"); fflush(stdout); SDL_PushEvent(&user_event); -printf("7"); fflush(stdout); + // Free framedata. free(ptr); -printf("8"); fflush(stdout); } -printf("9"); fflush(stdout); - /* Kick the others so they wake up with empty queues */ + // Kick the others so they wake up with empty queues sem_post(encode_sem); pthread_exit(NULL); } diff --git a/src/decoder.h b/src/decoder.h index 6d50e5b..0fd09d1 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -30,24 +30,25 @@ #include #include #include -#include +//#include #include -#include +#include "queue.h" #include "encoder.h" #include "player.h" #include "thread.h" -#include "ffframe.h" -#include +#include "frame.h" + +#define DVPACKAGE_SIZE 144000 class Decoder : public Thread { public: Decoder(Error* err, sem_t *gencode_sem, sem_t *gplayer_sem, - Queue *gencode_queue, - Queue *gplayer_queue, + Queue *gencode_queue, + Queue *gplayer_queue, pthread_mutex_t *gmutex, volatile int *grunning); ~Decoder(); @@ -59,8 +60,8 @@ private: sem_t *encode_sem; sem_t *player_sem; - Queue *encode_queue; - Queue *player_queue; + Queue *encode_queue; + Queue *player_queue; pthread_mutex_t *mutex; volatile int *running; diff --git a/src/dvframe.cc b/src/dvframe.cc deleted file mode 100644 index c1948ba..0000000 --- a/src/dvframe.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * frame.cc - * - * Mon Nov 15 19:45:07 CET 2004 - * Copyright 2004 Bent Bisballe - * deva@aasimon.org - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include - -#include "dvframe.h" - -#include - -DVFrame::DVFrame() -{ - memset(frame, 0, sizeof(frame)); -} - -DVFrame::~DVFrame() -{ -} - diff --git a/src/dvframe.h b/src/dvframe.h deleted file mode 100644 index 3bf61fe..0000000 --- a/src/dvframe.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * frame.h - * - * Mon Nov 15 19:45:07 CET 2004 - * Copyright 2004 Bent Bisballe - * deva@aasimon.org - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -#ifndef __DVFRAME_H__ -#define __DVFRAME_H__ - -#include - -#define DVPACKAGE_SIZE 144000 - -typedef enum { - DVF_AUDIO = 0x01, - DVF_VIDEO = 0x02 -} DVFrameType; - - -class DVFrame { -public: - DVFrame(); - ~DVFrame(); - DVFrameType type; - char frame[DVPACKAGE_SIZE]; -}; - -#endif/*__DVFRAME_H__*/ diff --git a/src/encoder.cc b/src/encoder.cc index ca8fb4f..a762c99 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -30,7 +30,7 @@ Encoder::Encoder(Error* err, const char *gip, const int gport, sem_t *gsem, - Queue *gqueue, + Queue *gqueue, pthread_mutex_t *gmutex, volatile int *grunning) { @@ -68,7 +68,7 @@ Encoder::~Encoder() void Encoder::encode() { - DVFrame *f; + Frame *f; while(*running) { sem_wait(sem); @@ -92,10 +92,11 @@ void Encoder::encode() if(freeze_request != freeze_value) freeze_value = freeze_request; if(shoot_request != shoot_value) shoot_value = shoot_request; - n->sendPackage(&h, f->frame, sizeof(f->frame)); + n->sendPackage(&h, f->data, f->size); + + free(f->data); + delete f; } - - if(f) delete f; } pthread_exit(NULL); } diff --git a/src/encoder.h b/src/encoder.h index 75788b4..d9534b3 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -30,17 +30,14 @@ #include #include #include -#include - -#include +//#include +#include "miav.h" #include "util.h" -#include - #include "package.h" - #include "thread.h" -#include +#include "frame.h" +#include "queue.h" // FIXME: One size fits all... #define VIDEO_BUFFER_SIZE (1024*1024) @@ -56,7 +53,7 @@ public: const char *gip, const int gport, sem_t *gsem, - Queue *gqueue, + Queue *gqueue, pthread_mutex_t *gmutex, volatile int *grunning); ~Encoder(); @@ -71,9 +68,9 @@ public: void run(); - AVFormatContext *fc; + // AVFormatContext *fc; sem_t *sem; - Queue *queue; + Queue *queue; pthread_mutex_t *mutex; volatile int *running; diff --git a/src/ffframe.cc b/src/ffframe.cc deleted file mode 100644 index d2bd5f9..0000000 --- a/src/ffframe.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * frame.cc - * - * Mon Nov 15 19:45:07 CET 2004 - * Copyright 2004 Bent Bisballe - * deva@aasimon.org - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include "ffframe.h" - -#include "debug.h" - -FFFrame::FFFrame() -{ - frame = avcodec_alloc_frame(); ALLOC(frame, "FFFrame (inside obj)"); - fprintf(stderr, "Frame: %d, \n", frame); fflush(stderr); -} - -FFFrame::~FFFrame() -{ - av_free(frame); FREE(frame); -} - diff --git a/src/ffframe.h b/src/ffframe.h deleted file mode 100644 index 5b02780..0000000 --- a/src/ffframe.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * frame.h - * - * Mon Nov 15 19:45:07 CET 2004 - * Copyright 2004 Bent Bisballe - * deva@aasimon.org - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -#ifndef __FFFRAME_H__ -#define __FFFRAME_H__ - -#include - -class FFFrame { -public: - FFFrame(); - ~FFFrame(); - AVFrame *frame; -}; - -#endif/*__FFFRAME_H__*/ diff --git a/src/frame.cc b/src/frame.cc new file mode 100644 index 0000000..61b2ec7 --- /dev/null +++ b/src/frame.cc @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * frame.cc + * + * Mon Nov 15 19:45:07 CET 2004 + * Copyright 2004 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include "frame.h" + +#include "debug.h" + +Frame::Frame(void *d, int sz) +{ + data = d; + size = sz; +} + +Frame::~Frame() +{ +} + diff --git a/src/frame.h b/src/frame.h new file mode 100644 index 0000000..8894dff --- /dev/null +++ b/src/frame.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * frame.h + * + * Mon Nov 15 19:45:07 CET 2004 + * Copyright 2004 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#ifndef __FRAME_H__ +#define __FRAME_H__ + +class Frame { +public: + Frame(void *d, int sz); + ~Frame(); + + void *data; + int size; +}; + +#endif/*__FRAME_H__*/ diff --git a/src/img_encoder.cc b/src/img_encoder.cc index 1a464f8..d83a906 100644 --- a/src/img_encoder.cc +++ b/src/img_encoder.cc @@ -59,7 +59,7 @@ ImgEncoder::~ImgEncoder() // FIXME: free: deccodec and dcc } -void ImgEncoder::encode(DVFrame *dvframe, +void ImgEncoder::encode(Frame *dvframe, char *filename, int quality) { @@ -71,8 +71,8 @@ void ImgEncoder::encode(DVFrame *dvframe, int got_picture = 1; int len; - ptr = (uint8_t *)dvframe->frame; - len = sizeof(dvframe->frame); + ptr = (uint8_t *)dvframe->data; + len = dvframe->size; ret = avcodec_decode_video(dcc, rawframe, &got_picture, ptr, len); diff --git a/src/img_encoder.h b/src/img_encoder.h index 79f4184..92fe0de 100644 --- a/src/img_encoder.h +++ b/src/img_encoder.h @@ -23,7 +23,7 @@ #ifndef __RTVIDEOREC_IMGENCODER_H #define __RTVIDEOREC_IMGENCODER_H -#include "dvframe.h" +#include "frame.h" #include "util.h" #include @@ -46,7 +46,7 @@ class ImgEncoder { public: ImgEncoder(); ~ImgEncoder(); - void encode(DVFrame *frame, char* filename, int quality); + void encode(Frame *frame, char* filename, int quality); void writeJPEGFile(char *filename, int quality, JSAMPLE * image_buffer, // Points to large array of R,G,B-order data diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index ece1cff..edfafb7 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -166,7 +166,7 @@ MovEncoder::~MovEncoder() url_fclose(&efc->pb); } -void MovEncoder::encode(DVFrame *dvframe) +void MovEncoder::encode(Frame *dvframe) { int ret; AVFrame *rawframe = avcodec_alloc_frame();ALLOC(dcc, "mov_encoder, rawframe"); @@ -176,8 +176,8 @@ void MovEncoder::encode(DVFrame *dvframe) int got_picture = 1; int len; - ptr = (uint8_t *)dvframe->frame; - len = sizeof(dvframe->frame); + ptr = (uint8_t *)dvframe->data; + len = dvframe->size; ret = avcodec_decode_video(dcc,//&dfc->streams[0]->codec, rawframe, &got_picture, ptr, len); diff --git a/src/mov_encoder.h b/src/mov_encoder.h index eb67350..ecdb95e 100644 --- a/src/mov_encoder.h +++ b/src/mov_encoder.h @@ -28,7 +28,7 @@ #include #include -#include +#include "frame.h" #include "util.h" @@ -38,7 +38,7 @@ class MovEncoder { public: MovEncoder(const char *filename); ~MovEncoder(); - void encode(DVFrame *frame); + void encode(Frame *frame); private: // Decoder diff --git a/src/player.cc b/src/player.cc index dcce6b7..2a08dc1 100644 --- a/src/player.cc +++ b/src/player.cc @@ -25,10 +25,14 @@ #include "player.h" +// Use libdv +#include +#include + Player::Player(Error *err, volatile int *grunning, sem_t *gsem, - Queue *gqueue, + Queue *gqueue, pthread_mutex_t *gmutex) { // No errors has ocurred... yet! @@ -85,8 +89,11 @@ void Player::player() { SDL_Event event; SDL_Rect rect; - FFFrame *f; - AVPicture pict; + Frame *frame; + // AVPicture pict; + unsigned char pixel_buffer[720 * 576 * 3]; + int pitches[3]; + int i; struct timespec ts; @@ -97,13 +104,21 @@ void Player::player() rect.y = 0; rect.w = DISPLAYWIDTH; rect.h = DISPLAYHEIGHT; - + /* //+++++Reference to the overlay pixels/pitches, only after creating a new overlay+++++ + // ????????? for(i = 0; i < 3; i++) { pict.data[i] = overlay->pixels[i]; pict.linesize[i] = overlay->pitches[i]; } - + */ + + dv_decoder_t *decoder = NULL; + decoder = dv_decoder_new(FALSE, FALSE, FALSE); + decoder->quality = DV_QUALITY_BEST; + decoder->clamp_luma = FALSE; + decoder->clamp_chroma = FALSE; + while(*running) { // Wait for the semaphore to be free... then run sem_wait(&play_sem); @@ -124,18 +139,25 @@ void Player::player() case SDL_USEREVENT: pthread_mutex_lock(mutex); - f = queue->pop(); + frame = queue->pop(); pthread_mutex_unlock(mutex); - if(!f) break; + if(!frame) break; - img_convert(&pict, PIX_FMT_YUV420P, (AVPicture *)f->frame, - PIX_FMT_YUV420P, DISPLAYWIDTH, DISPLAYHEIGHT); + // img_convert(&pict, PIX_FMT_YUV420P, (AVPicture *)f->frame, + // PIX_FMT_YUV420P, DISPLAYWIDTH, DISPLAYHEIGHT); + // libdv img decode + dv_decode_full_frame(decoder, + (const uint8_t*)frame->data, + e_dv_color_yuv, + (uint8_t**)pixel_buffer, + pitches); + SDL_LockYUVOverlay(overlay); - overlay->pixels = pict.data; + overlay->pixels = (Uint8**)pixel_buffer; SDL_UnlockYUVOverlay(overlay); SDL_DisplayYUVOverlay(overlay, &rect); - delete f; + // delete f; break; case SDL_QUIT: @@ -154,9 +176,9 @@ void Player::player() nanosleep(&ts, NULL); pthread_mutex_lock(mutex); - f = queue->pop(); + frame = queue->pop(); pthread_mutex_unlock(mutex); - if(f) delete f; + // if(f) delete f; } void Player::run() diff --git a/src/player.h b/src/player.h index 2af4165..ca2d241 100644 --- a/src/player.h +++ b/src/player.h @@ -34,13 +34,13 @@ #include #include #include -#include +//#include #include "util.h" -#include +#include "queue.h" #include "thread.h" -#include "ffframe.h" +#include "frame.h" #include @@ -56,7 +56,7 @@ public: Player(Error* err, volatile int *grunning, sem_t *gsem, - Queue *gqueue, + Queue *gqueue, pthread_mutex_t *gmutex); ~Player(); @@ -75,7 +75,7 @@ private: volatile int *running; sem_t *sem; - Queue *queue; + Queue *queue; pthread_mutex_t *mutex; sem_t play_sem; diff --git a/src/queue.h b/src/queue.h index 7352071..8851c57 100644 --- a/src/queue.h +++ b/src/queue.h @@ -70,7 +70,7 @@ Queue::~Queue() { if(count != 0) { fprintf(stderr, "Queue not empty (%d)\n", count); - while(T *t = pop()) delete t; + while(T *t = pop()) {}//delete t; } } @@ -84,7 +84,7 @@ void Queue::push(T *t) if(limit && count > 0) { T* tmp = (T*)pop(); - delete tmp; + // delete tmp; } if(!head) { diff --git a/src/server.cc b/src/server.cc index 44abe2d..b659fb5 100644 --- a/src/server.cc +++ b/src/server.cc @@ -32,7 +32,7 @@ #include "mov_encoder.h" #include "img_encoder.h" -void saveFrameAsImage(char* cpr, DVFrame *f) +void saveFrameAsImage(char* cpr, Frame *f) { char fname[256]; ImgEncoder imgenc; @@ -78,16 +78,17 @@ void newConnection(Socket *s) { n_savestate savestate = LATER; n_header h; - DVFrame *f; - DVFrame *freeze_frame = NULL; + Frame *f; + Frame *freeze_frame = NULL; MovEncoder *enc = NULL; - f = new DVFrame(); + // FIXME: Allocate buffer + f = new Frame(NULL, 0); printf("New connection[pid: %d]...\n", getpid()); Network n = Network(s); - while(int ret = n.recvPackage(&h, (void*)f->frame, DVPACKAGE_SIZE)) { + while(int ret = n.recvPackage(&h, f->data, DVPACKAGE_SIZE)) { if(ret == -1) { fprintf(stderr, "An error occurred...!\n"); break; @@ -125,7 +126,8 @@ void newConnection(Socket *s) delete f; } - f = new DVFrame(); + // FIXME: Allocate buffer + f = new Frame(NULL, 0); } // TODO: Use save state diff --git a/src/server.h b/src/server.h index fd28f33..0aa9a9a 100644 --- a/src/server.h +++ b/src/server.h @@ -35,7 +35,7 @@ #include -#include "dvframe.h" +#include "frame.h" #include "socket.h" void newConnection(Socket *s); -- cgit v1.2.3