From 84e9873f846478476487d5cd2587e5879a0be8ea Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 28 Jul 2005 16:31:18 +0000 Subject: *** empty log message *** --- src/Makefile.am | 2 ++ src/decoder.cc | 15 ++++++++------- src/dvfile.cc | 30 ++++++++++++++++++++++++++++++ src/dvfile.h | 21 +++++++++++++++++++++ 4 files changed, 61 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index cff93b1..2382214 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,7 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \ daemon.cc \ decoder.cc \ dv1394.cc \ + dvfile.cc \ encoder.cc \ file.cc \ frame.cc \ @@ -49,6 +50,7 @@ EXTRA_DIST = \ decoder.h \ dv.h \ dv1394.h \ + dvfile.h \ encoder.h \ file.h \ frame.h \ diff --git a/src/decoder.cc b/src/decoder.cc index 0655f61..dea0ae4 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -47,8 +47,9 @@ #include -#include "dv1394.h" #include "dv.h" +#include "dvfile.h" +#include "dv1394.h" #include "decoder.h" #include "debug.h" @@ -85,7 +86,7 @@ Decoder::~Decoder() void Decoder::decode() { - frame_stream *stream; + frame_stream *dvstream; bool local_shoot; int local_freeze; @@ -96,12 +97,12 @@ void Decoder::decode() dv1394 dv1394_stream = dv1394(info); // Use default port and channel. dvfile dvfile_stream = dvfile(info); - if(dv_stream.connect()) { + if(dv1394_stream.connect()) { // Use the dv1394 stream for input. - stream = &dv1394_stream; + dvstream = &dv1394_stream; } else { // Use the fallback dv filereader for input. - stream = &dvfile_stream; + dvstream = &dvfile_stream; } while(*running) { @@ -109,8 +110,8 @@ void Decoder::decode() SDL_Event user_event; // Read a dvframe - ptr = stream->readFrame(); - if(!ptr) return; // No frame read. (Due to firewire error) + ptr = dvstream->readFrame(); + if(!ptr) return; // No frame read. (Due to dv read error) old_record = local_record; local_shoot = b_shoot; diff --git a/src/dvfile.cc b/src/dvfile.cc index ef1db71..a0dccf3 100644 --- a/src/dvfile.cc +++ b/src/dvfile.cc @@ -27,3 +27,33 @@ #include "config.h" #include "dvfile.h" +#include "dv.h" + +#include + +dvfile::dvfile(Info* i) +{ + info = i; + fp = fopen(TEST_MOVIE, "r"); +} + +dvfile::~dvfile() +{ + fclose(fp); +} + +unsigned char *dvfile::readFrame() +{ + struct timespec ts; + unsigned char *frame = new unsigned char[DVPACKAGE_SIZE]; + + ts.tv_sec = 0; + ts.tv_nsec = 1000000000L / 25L; // 1/25s + nanosleep(&ts, NULL); + + while(fread(frame, DVPACKAGE_SIZE, 1, fp) == 0) { + fseek(fp, 0L, SEEK_SET); + } + + return frame; +} diff --git a/src/dvfile.h b/src/dvfile.h index 3a4d600..cf78d1a 100644 --- a/src/dvfile.h +++ b/src/dvfile.h @@ -27,4 +27,25 @@ #include "config.h" #ifndef __MIAV_DVFILE_H__ #define __MIAV_DVFILE_H__ + +#include "frame_stream.h" + +#include + +#include "info.h" + +#define TEST_MOVIE PIXMAPS"/maage.dv" + +class dvfile : public frame_stream { +public: + dvfile(Info* info); + ~dvfile(); + + unsigned char *readFrame(); + +private: + Info* info; + FILE* fp; +}; + #endif/*__MIAV_DVFILE_H__*/ -- cgit v1.2.3