From 9111e70794105f984df5b66bba81adc769bd5001 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 28 Jul 2005 15:31:18 +0000 Subject: *** empty log message *** --- src/Makefile.am | 1 + src/decoder.cc | 22 ++++++++++++++-------- src/dv1394.cc | 31 +++++++++++++++++++------------ src/dv1394.h | 9 +++++++-- src/dvfile.cc | 29 +++++++++++++++++++++++++++++ src/dvfile.h | 30 ++++++++++++++++++++++++++++++ src/frame_stream.h | 41 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 141 insertions(+), 22 deletions(-) create mode 100644 src/dvfile.cc create mode 100644 src/dvfile.h create mode 100644 src/frame_stream.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index f27b1dc..cff93b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,7 @@ EXTRA_DIST = \ encoder.h \ file.h \ frame.h \ + frame_stream.h \ historywidget.h \ img_encoder.h \ info.h \ diff --git a/src/decoder.cc b/src/decoder.cc index 26351fe..0655f61 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -34,12 +34,8 @@ */ #include #ifdef USE_GUI -/* -#include -#include -#include -#include -*/ + +#include "frame_stream.h" #include "miav_config.h" @@ -89,6 +85,8 @@ Decoder::~Decoder() void Decoder::decode() { + frame_stream *stream; + bool local_shoot; int local_freeze; bool local_record = false; @@ -96,14 +94,22 @@ void Decoder::decode() bool skip_frames = config->readInt("player_skip_frames"); - dv1394 dv_stream = dv1394(info); // Use default port and channel. + dv1394 dv1394_stream = dv1394(info); // Use default port and channel. + dvfile dvfile_stream = dvfile(info); + if(dv_stream.connect()) { + // Use the dv1394 stream for input. + stream = &dv1394_stream; + } else { + // Use the fallback dv filereader for input. + stream = &dvfile_stream; + } while(*running) { uint8_t *ptr; SDL_Event user_event; // Read a dvframe - ptr = dv_stream.readFrame(); + ptr = stream->readFrame(); if(!ptr) return; // No frame read. (Due to firewire error) old_record = local_record; diff --git a/src/dv1394.cc b/src/dv1394.cc index 4a2d4f7..270da2e 100644 --- a/src/dv1394.cc +++ b/src/dv1394.cc @@ -107,9 +107,21 @@ static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadl return 0; } -dv1394::dv1394(Info *ginfo, int port, int channel) +dv1394::dv1394(Info *i, int p, int c) +{ + info = i; + port = p; + channel = c; +} + +dv1394::~dv1394() +{ + // Close firewire connection. + if(handle) raw1394_destroy_handle(handle); +} + +bool dv1394::connect() { - info = ginfo; int n_ports; struct raw1394_portinfo pinf[ 16 ]; @@ -117,7 +129,7 @@ dv1394::dv1394(Info *ginfo, int port, int channel) handle = raw1394_new_handle(); if(!handle) { info->error("raw1394 - failed to get handle: %s.", strerror( errno ) ); - return; + return false; } // how many adapters are hooked in? @@ -125,7 +137,7 @@ dv1394::dv1394(Info *ginfo, int port, int channel) info->error("raw1394 - failed to get port info: %s.", strerror( errno ) ); raw1394_destroy_handle(handle); handle = NULL; - return; + return false; } // Tell raw1394 which host adapter to use @@ -133,19 +145,14 @@ dv1394::dv1394(Info *ginfo, int port, int channel) info->error("raw1394 - failed to set port: %s.", strerror( errno ) ); raw1394_destroy_handle(handle); handle = NULL; - return; + return false; } raw1394_set_iso_handler( handle, channel, raw_reader); raw1394_set_userdata( handle, ( void* ) NULL); raw1394_start_iso_rcv( handle, channel); - -} - -dv1394::~dv1394() -{ - // Close firewire connection. - if(handle) raw1394_destroy_handle(handle); + + return true; } unsigned char *dv1394::readFrame() diff --git a/src/dv1394.h b/src/dv1394.h index c63899e..7cea9d0 100644 --- a/src/dv1394.h +++ b/src/dv1394.h @@ -30,20 +30,25 @@ #ifdef USE_GUI +#include "frame_stream.h" #include #include "info.h" -class dv1394 { +class dv1394 : public frame_stream { public: - dv1394(Info* ginfo, int port = 0, int channel = 63); // 63 is default channel... sucks. + dv1394(Info* info, int port = 0, int channel = 63); // 63 is default channel... sucks. ~dv1394(); + bool connect(); + unsigned char *readFrame(); private: raw1394handle_t handle; Info *info; + int port; + int channel; }; #endif/*__MIAV_DV1394_H__*/ diff --git a/src/dvfile.cc b/src/dvfile.cc new file mode 100644 index 0000000..ef1db71 --- /dev/null +++ b/src/dvfile.cc @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * dvfile.cc + * + * Thu Jul 28 17:30:48 CEST 2005 + * Copyright 2005 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV 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. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#include "dvfile.h" + diff --git a/src/dvfile.h b/src/dvfile.h new file mode 100644 index 0000000..3a4d600 --- /dev/null +++ b/src/dvfile.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * dvfile.h + * + * Thu Jul 28 17:30:48 CEST 2005 + * Copyright 2005 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV 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. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_DVFILE_H__ +#define __MIAV_DVFILE_H__ +#endif/*__MIAV_DVFILE_H__*/ diff --git a/src/frame_stream.h b/src/frame_stream.h new file mode 100644 index 0000000..bc0b9a2 --- /dev/null +++ b/src/frame_stream.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * frame_stream.h + * + * Thu Jul 28 17:15:27 CEST 2005 + * Copyright 2005 Bent Bisballe + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV 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. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_FRAME_STREAM_H__ +#define __MIAV_FRAME_STREAM_H__ + +class frame_stream { +public: + frame_stream() {} + virtual ~frame_stream() {} + + virtual unsigned char *readFrame() = 0; +}; + + +#endif/*__MIAV_FRAME_STREAM_H__*/ + -- cgit v1.2.3