From 7384366b76d3f78b23f1fe39b7959665978c7f87 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 25 Mar 2006 18:15:23 +0000 Subject: [PATCH] Windows port --- Makefile | 3 +- audio.h | 2 - audiowin.h | 2 - main.cc | 6 +- video.cc | 363 --------------------------------------------------- video.h | 92 ++++++------- videomvp.cc | 369 ++++++++++++++++++++++++++++++++++++++++++++++++++++ videomvp.h | 82 ++++++++++++ videowin.cc | 213 ++++++++++++++++++++++++++++++ videowin.h | 69 ++++++++++ 10 files changed, 777 insertions(+), 424 deletions(-) create mode 100644 videomvp.cc create mode 100644 videomvp.h create mode 100644 videowin.cc create mode 100644 videowin.h diff --git a/Makefile b/Makefile index ba18e92..a57fc1b 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o fonts/helvB24.o fonts/helvB18.o OBJECTS2 = remote.o led.o mtd.o video.o audio.o osd.o surface.o \ - audiomvp.o audiowin.o + audiomvp.o audiowin.o \ + videomvp.o videowin.o OBJECTS = $(OBJECTS1) $(OBJECTS2) diff --git a/audio.h b/audio.h index b3c0c5a..44ee779 100644 --- a/audio.h +++ b/audio.h @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Thanks to Jon Gettler and BtB for all the ioctl information - #ifndef AUDIO_H #define AUDIO_H diff --git a/audiowin.h b/audiowin.h index 823fb65..e1c2e0c 100644 --- a/audiowin.h +++ b/audiowin.h @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Thanks to Jon Gettler and BtB for all the ioctl information - #ifndef AUDIOWIN_H #define AUDIOWIN_H diff --git a/main.cc b/main.cc index f403e5e..7fc0681 100644 --- a/main.cc +++ b/main.cc @@ -31,7 +31,6 @@ #include "led.h" #include "mtd.h" #include "timers.h" -#include "video.h" #include "vdr.h" #include "osd.h" #include "viewman.h" @@ -39,8 +38,10 @@ #ifndef WIN32 #include "audiomvp.h" + #include "videomvp.h" #else #include "audiowin.h" + #include "videowin.h" #endif void sighandler(int signalReceived); @@ -74,11 +75,12 @@ int main(int argc, char** argv) timers = new Timers(); osd = new Osd(); vdr = new VDR(); - video = new Video(); #ifndef WIN32 audio = new AudioMVP(); + video = new VideoMVP(); #else audio = new AudioWin(); + video = new VideoWin(); #endif viewman = new ViewMan(); command = new Command(); diff --git a/video.cc b/video.cc index 008e11a..7d3ad02 100644 --- a/video.cc +++ b/video.cc @@ -49,366 +49,3 @@ Video* Video::getInstance() { return instance; } - -int Video::init(UCHAR tformat) -{ - if (initted) return 0; - initted = 1; - - if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0; - - if (!setFormat(tformat)) { shutdown(); return 0; } - if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; } - if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; } - if (!setMode(NORMAL)) { shutdown(); return 0; } - if (!setSource()) { shutdown(); return 0; } - if (!attachFrameBuffer()) { shutdown(); return 0; } - - setTVsize(ASPECT4X3); - - if (format == PAL) setLetterboxBorder("38"); - else setLetterboxBorder("31"); - - stop(); - - - return 1; -} - -void Video::setLetterboxBorder(char* border) -{ - FILE* fdlbox = fopen("/proc/lbox_border", "w"); - if (!fdlbox) return; - fputs(border, fdlbox); - fclose(fdlbox); -} - -int Video::setTVsize(UCHAR ttvsize) -{ - tvsize = ttvsize; - - // Override the aspect ratio usage, temporarily use to set the video chip mode - if (!setAspectRatio(tvsize)) { shutdown(); return 0; } - close(fdVideo); - if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0; - if (!setSource()) { shutdown(); return 0; } - if (!attachFrameBuffer()) { shutdown(); return 0; } - - // Reopening the fd causes the scart aspect line to go back to 4:3 - // Set this again to the same as the tv screen size - if (!setAspectRatio(tvsize)) { shutdown(); return 0; } - - // mode == LETTERBOX is invalid if the TV is widescreen - if (tvsize == ASPECT16X9) setMode(NORMAL); - - return 1; -} - -int Video::setDefaultAspect() -{ - return setAspectRatio(tvsize); -} - -int Video::shutdown() -{ - if (!initted) return 0; - initted = 0; - close(fdVideo); - return 1; -} - -int Video::checkSCART() -{ - // Returns 3 for SCART Composite out - // Returns 3 for SCART S-Video out - // Returns 2 for SCART RGB out - // Returns 3 for SCART not plugged in - - // So, as you can have RGB and composite out simultaneously, - // and it can't detect S-Video, what is the point of this? - - int scart; - if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10; - - return scart; -} - -int Video::setFormat(UCHAR tformat) -{ - if (!initted) return 0; - if ((tformat != PAL) && (tformat != NTSC)) return 0; - format = tformat; - - if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0; - - if (format == NTSC) - { - screenWidth = 720; - screenHeight = 480; - } - if (format == PAL) - { - screenWidth = 720; - screenHeight = 576; - } - - return 1; -} - -int Video::setConnection(UCHAR tconnection) -{ - if (!initted) return 0; - if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0; - connection = tconnection; - - if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0; - return 1; -} - -int Video::setAspectRatio(UCHAR taspectRatio) -{ - if (!initted) return 0; - if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0; - aspectRatio = taspectRatio; - - if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0; - return 1; -} - -int Video::setMode(UCHAR tmode) -{ - if (!initted) return 0; - - if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode - - if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH) - && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0; - mode = tmode; - - if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0; - return 1; -} - -int Video::getMode() -{ - return mode; -} - -int Video::signalOff() -{ - if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0; - return 1; -} - -int Video::signalOn() -{ - if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0; - return 1; -} - -int Video::setSource() -{ - if (!initted) return 0; - - // What does this do... - if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0; - return 1; -} - -int Video::setPosition(int x, int y) -{ - if (!initted) return 0; - -// vid_pos_regs_t pos_d; -// pos_d.x = x; -// pos_d.y = y; - - vid_pos_regs_t pos_d; - - memset(&pos_d, 0, sizeof(pos_d)); - - pos_d.dest.y = y; - pos_d.dest.x = x; -/* -typedef struct { - int w; - int h; - int scale; - int x1; - int y; - int x; - int y2; - int x3; - int y3; - int x4; - int y4; -} vid_pos_regs_t; -*/ - -/* - pos_d.w = 100; - pos_d.h = 30; - pos_d.scale = 2; - pos_d.x1 = 0; - pos_d.y = 100; // Top left X - pos_d.x = 50; // Top left Y - pos_d.y2 = 30; - pos_d.x3 = 60; - pos_d.y3 = 90; - pos_d.x4 = 120; - pos_d.y4 = 150; -*/ - - if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0; - return 1; -} - -int Video::sync() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0; - return 1; -} - -int Video::play() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; - return 1; -} - -int Video::stop() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0; - return 1; -} - -int Video::reset() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; - return 1; -} - -int Video::pause() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0; - return 1; -} - -int Video::unPause() // FIXME get rid - same as play!! -{ - if (!initted) return 0; - if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; - return 1; -} - -int Video::fastForward() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0; - return 1; -} - -int Video::unFastForward() -{ - if (!initted) return 0; - -// if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this. - - if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; - return 1; -} - -int Video::attachFrameBuffer() -{ - if (!initted) return 0; - - if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0; - return 1; -} - -int Video::blank(void) -{ - if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0; - if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0; - return 1; -} - -int Video::getFD() -{ - if (!initted) return 0; - - return fdVideo; -} - -UCHAR Video::getFormat() -{ - return format; -} - -UINT Video::getScreenWidth() -{ - return screenWidth; -} - -UINT Video::getScreenHeight() -{ - return screenHeight; -} - -UCHAR Video::getTVsize() -{ - return tvsize; -} - -ULLONG Video::getCurrentTimestamp() -{ - sync_data_t timestamps; - if (ioctl(fdVideo, AV_GET_VID_TIMESTAMPS, ×tamps) == 0) - { - // FIXME are these the right way around? - - timestamps.stc = (timestamps.stc >> 31 ) | (timestamps.stc & 1); - timestamps.pts = (timestamps.pts >> 31 ) | (timestamps.pts & 1); - - return timestamps.stc; - } - else - { - return 0; - } -} - -ULONG Video::timecodeToFrameNumber(ULLONG timecode) -{ - if (format == PAL) return (ULONG)(((double)timecode / (double)90000) * (double)25); - else return (ULONG)(((double)timecode / (double)90000) * (double)30); -} - -#ifdef DEV -int Video::test() -{ - return 0; - -// ULLONG stc = 0; -// return ioctl(fdVideo, AV_SET_VID_STC, &stc); -/* - // reset(); - return 1; -*/ -} - -int Video::test2() -{ - return 0; -} -#endif diff --git a/video.h b/video.h index 88267b3..21b00d7 100644 --- a/video.h +++ b/video.h @@ -18,32 +18,55 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Thanks to Jon Gettler and BtB of the MVPMC project for all the hardware information - - #ifndef VIDEO_H #define VIDEO_H -// FIXME - check why so many things include unistd - #include -#include -#include -#include -#include - #include "defines.h" -#include "stb.h" class Video { public: Video(); - ~Video(); + virtual ~Video(); static Video* getInstance(); - int init(UCHAR format); - int shutdown(); + virtual int init(UCHAR format)=0; + virtual int shutdown()=0; + virtual int setFormat(UCHAR format)=0; + virtual int setConnection(UCHAR connection)=0; + virtual int setAspectRatio(UCHAR aspectRatio)=0; // This one does the pin 8 scart widescreen switching + virtual int setMode(UCHAR mode)=0; + virtual int setTVsize(UCHAR size)=0; // Is the TV a widescreen? + virtual int setDefaultAspect()=0; + virtual int setSource()=0; + virtual int setPosition(int x, int y)=0; + virtual int sync()=0; + virtual int play()=0; + virtual int stop()=0; + virtual int pause()=0; + virtual int unPause()=0; + virtual int fastForward()=0; + virtual int unFastForward()=0; + virtual int reset()=0; + virtual int blank()=0; + virtual int signalOn()=0; + virtual int signalOff()=0; + virtual int attachFrameBuffer()=0; // What does this do? + virtual ULONG timecodeToFrameNumber(ULLONG timecode)=0; + virtual int getFD()=0; + virtual ULLONG getCurrentTimestamp()=0; + +#ifdef DEV + virtual int test() { return 0; } + virtual int test2() { return 0; } +#endif + + int getMode() { return mode; } + UCHAR getFormat() { return format; } + UINT getScreenWidth() { return screenWidth; } + UINT getScreenHeight() { return screenHeight; } + UCHAR getTVsize() { return tvsize; } // Video formats - AV_SET_VID_DISP_FMT const static UCHAR NTSC = 0; @@ -88,48 +111,9 @@ class Video const static UCHAR ZOOM = 5; const static UCHAR UNKNOWN6 = 6; - int setFormat(UCHAR format); - int setConnection(UCHAR connection); - int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching - int setMode(UCHAR mode); - int setTVsize(UCHAR size); // Is the TV a widescreen? - int setDefaultAspect(); - int setSource(); - int setPosition(int x, int y); - int sync(); - int play(); - int stop(); - int pause(); - int unPause(); - int fastForward(); - int unFastForward(); - int reset(); - int blank(); - int signalOn(); - int signalOff(); - int attachFrameBuffer(); // What does this do? - ULONG timecodeToFrameNumber(ULLONG timecode); - -#ifdef DEV - int test(); - int test2(); -#endif - - int getMode(); - int getFD(); - UCHAR getFormat(); - UINT getScreenWidth(); - UINT getScreenHeight(); - UCHAR getTVsize(); - ULLONG getCurrentTimestamp(); - - private: - int checkSCART(); - void setLetterboxBorder(char* border); - + protected: static Video* instance; int initted; - int fdVideo; UCHAR tvsize; diff --git a/videomvp.cc b/videomvp.cc new file mode 100644 index 0000000..f3e33cb --- /dev/null +++ b/videomvp.cc @@ -0,0 +1,369 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "videomvp.h" + +VideoMVP::VideoMVP() +{ + if (instance) return; +} + +VideoMVP::~VideoMVP() +{ + instance = NULL; +} + +int VideoMVP::init(UCHAR tformat) +{ + if (initted) return 0; + initted = 1; + + if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0; + + if (!setFormat(tformat)) { shutdown(); return 0; } + if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; } + if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; } + if (!setMode(NORMAL)) { shutdown(); return 0; } + if (!setSource()) { shutdown(); return 0; } + if (!attachFrameBuffer()) { shutdown(); return 0; } + + setTVsize(ASPECT4X3); + + if (format == PAL) setLetterboxBorder("38"); + else setLetterboxBorder("31"); + + stop(); + + + return 1; +} + +void VideoMVP::setLetterboxBorder(char* border) +{ + FILE* fdlbox = fopen("/proc/lbox_border", "w"); + if (!fdlbox) return; + fputs(border, fdlbox); + fclose(fdlbox); +} + +int VideoMVP::setTVsize(UCHAR ttvsize) +{ + tvsize = ttvsize; + + // Override the aspect ratio usage, temporarily use to set the video chip mode + if (!setAspectRatio(tvsize)) { shutdown(); return 0; } + close(fdVideo); + if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0; + if (!setSource()) { shutdown(); return 0; } + if (!attachFrameBuffer()) { shutdown(); return 0; } + + // Reopening the fd causes the scart aspect line to go back to 4:3 + // Set this again to the same as the tv screen size + if (!setAspectRatio(tvsize)) { shutdown(); return 0; } + + // mode == LETTERBOX is invalid if the TV is widescreen + if (tvsize == ASPECT16X9) setMode(NORMAL); + + return 1; +} + +int VideoMVP::setDefaultAspect() +{ + return setAspectRatio(tvsize); +} + +int VideoMVP::shutdown() +{ + if (!initted) return 0; + initted = 0; + close(fdVideo); + return 1; +} + +int VideoMVP::checkSCART() +{ + // Returns 3 for SCART Composite out + // Returns 3 for SCART S-Video out + // Returns 2 for SCART RGB out + // Returns 3 for SCART not plugged in + + // So, as you can have RGB and composite out simultaneously, + // and it can't detect S-Video, what is the point of this? + + int scart; + if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10; + + return scart; +} + +int VideoMVP::setFormat(UCHAR tformat) +{ + if (!initted) return 0; + if ((tformat != PAL) && (tformat != NTSC)) return 0; + format = tformat; + + if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0; + + if (format == NTSC) + { + screenWidth = 720; + screenHeight = 480; + } + if (format == PAL) + { + screenWidth = 720; + screenHeight = 576; + } + + return 1; +} + +int VideoMVP::setConnection(UCHAR tconnection) +{ + if (!initted) return 0; + if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0; + connection = tconnection; + + if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0; + return 1; +} + +int VideoMVP::setAspectRatio(UCHAR taspectRatio) +{ + if (!initted) return 0; + if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0; + aspectRatio = taspectRatio; + + if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0; + return 1; +} + +int VideoMVP::setMode(UCHAR tmode) +{ + if (!initted) return 0; + + if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode + + if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH) + && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0; + mode = tmode; + + if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0; + return 1; +} + +int VideoMVP::signalOff() +{ + if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0; + return 1; +} + +int VideoMVP::signalOn() +{ + if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0; + return 1; +} + +int VideoMVP::setSource() +{ + if (!initted) return 0; + + // What does this do... + if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0; + return 1; +} + +int VideoMVP::setPosition(int x, int y) +{ + if (!initted) return 0; + +// vid_pos_regs_t pos_d; +// pos_d.x = x; +// pos_d.y = y; + + vid_pos_regs_t pos_d; + + memset(&pos_d, 0, sizeof(pos_d)); + + pos_d.dest.y = y; + pos_d.dest.x = x; +/* +typedef struct { + int w; + int h; + int scale; + int x1; + int y; + int x; + int y2; + int x3; + int y3; + int x4; + int y4; +} vid_pos_regs_t; +*/ + +/* + pos_d.w = 100; + pos_d.h = 30; + pos_d.scale = 2; + pos_d.x1 = 0; + pos_d.y = 100; // Top left X + pos_d.x = 50; // Top left Y + pos_d.y2 = 30; + pos_d.x3 = 60; + pos_d.y3 = 90; + pos_d.x4 = 120; + pos_d.y4 = 150; +*/ + + if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0; + return 1; +} + +int VideoMVP::sync() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0; + return 1; +} + +int VideoMVP::play() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; + return 1; +} + +int VideoMVP::stop() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0; + return 1; +} + +int VideoMVP::reset() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; + return 1; +} + +int VideoMVP::pause() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0; + return 1; +} + +int VideoMVP::unPause() // FIXME get rid - same as play!! +{ + if (!initted) return 0; + if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; + return 1; +} + +int VideoMVP::fastForward() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0; + return 1; +} + +int VideoMVP::unFastForward() +{ + if (!initted) return 0; + +// if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this. + + if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0; + return 1; +} + +int VideoMVP::attachFrameBuffer() +{ + if (!initted) return 0; + + if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0; + return 1; +} + +int VideoMVP::blank(void) +{ + if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0; + if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0; + return 1; +} + +int VideoMVP::getFD() +{ + if (!initted) return 0; + + return fdVideo; +} + +ULLONG VideoMVP::getCurrentTimestamp() +{ + sync_data_t timestamps; + if (ioctl(fdVideo, AV_GET_VID_TIMESTAMPS, ×tamps) == 0) + { + // FIXME are these the right way around? + + timestamps.stc = (timestamps.stc >> 31 ) | (timestamps.stc & 1); + timestamps.pts = (timestamps.pts >> 31 ) | (timestamps.pts & 1); + + return timestamps.stc; + } + else + { + return 0; + } +} + +ULONG VideoMVP::timecodeToFrameNumber(ULLONG timecode) +{ + if (format == PAL) return (ULONG)(((double)timecode / (double)90000) * (double)25); + else return (ULONG)(((double)timecode / (double)90000) * (double)30); +} + +#ifdef DEV +int VideoMVP::test() +{ + return 0; + +// ULLONG stc = 0; +// return ioctl(fdVideo, AV_SET_VID_STC, &stc); +/* + // reset(); + return 1; +*/ +} + +int VideoMVP::test2() +{ + return 0; +} +#endif diff --git a/videomvp.h b/videomvp.h new file mode 100644 index 0000000..be955ee --- /dev/null +++ b/videomvp.h @@ -0,0 +1,82 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +// Thanks to Jon Gettler and BtB of the MVPMC project for all the hardware information + + +#ifndef VIDEOMVP_H +#define VIDEOMVP_H + +// FIXME - check why so many things include unistd + +#include +#include +#include +#include +#include + +#include "defines.h" +#include "video.h" +#include "stb.h" + +class VideoMVP : public Video +{ + public: + VideoMVP(); + ~VideoMVP(); + + int init(UCHAR format); + int shutdown(); + + int setFormat(UCHAR format); + int setConnection(UCHAR connection); + int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching + int setMode(UCHAR mode); + int setTVsize(UCHAR size); // Is the TV a widescreen? + int setDefaultAspect(); + int setSource(); + int setPosition(int x, int y); + int sync(); + int play(); + int stop(); + int pause(); + int unPause(); + int fastForward(); + int unFastForward(); + int reset(); + int blank(); + int signalOn(); + int signalOff(); + int attachFrameBuffer(); // What does this do? + ULONG timecodeToFrameNumber(ULLONG timecode); + int getFD(); + ULLONG getCurrentTimestamp(); + +#ifdef DEV + int test(); + int test2(); +#endif + + private: + int checkSCART(); + void setLetterboxBorder(char* border); +}; + +#endif diff --git a/videowin.cc b/videowin.cc new file mode 100644 index 0000000..b993812 --- /dev/null +++ b/videowin.cc @@ -0,0 +1,213 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "videowin.h" + +VideoWin::VideoWin() +{ + if (instance) return; +} + +VideoWin::~VideoWin() +{ + instance = NULL; +} + +int VideoWin::init(UCHAR tformat) +{ + if (initted) return 0; + initted = 1; + return 1; +} + +int VideoWin::setTVsize(UCHAR ttvsize) +{ + return 1; +} + +int VideoWin::setDefaultAspect() +{ + return setAspectRatio(tvsize); +} + +int VideoWin::shutdown() +{ + if (!initted) return 0; + initted = 0; + return 1; +} + +int VideoWin::setFormat(UCHAR tformat) +{ + if (!initted) return 0; + if ((tformat != PAL) && (tformat != NTSC)) return 0; + format = tformat; + + return 1; +} + +int VideoWin::setConnection(UCHAR tconnection) +{ + if (!initted) return 0; + if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0; + connection = tconnection; + + return 1; +} + +int VideoWin::setAspectRatio(UCHAR taspectRatio) +{ + if (!initted) return 0; + if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0; + aspectRatio = taspectRatio; + + return 1; +} + +int VideoWin::setMode(UCHAR tmode) +{ + if (!initted) return 0; + + if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode + + if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH) + && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0; + mode = tmode; + + return 1; +} + +int VideoWin::signalOff() +{ + return 1; +} + +int VideoWin::signalOn() +{ + return 1; +} + +int VideoWin::setSource() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::setPosition(int x, int y) +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::sync() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::play() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::stop() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::reset() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::pause() +{ + if (!initted) return 0; + + return 1; +} + +int VideoWin::unPause() // FIXME get rid - same as play!! +{ + if (!initted) return 0; + return 1; +} + +int VideoWin::fastForward() +{ + if (!initted) return 0; + return 1; +} + +int VideoWin::unFastForward() +{ + if (!initted) return 0; + return 1; +} + +int VideoWin::attachFrameBuffer() +{ + if (!initted) return 0; + return 1; +} + +int VideoWin::blank(void) +{ + return 1; +} + +int VideoWin::getFD() +{ + if (!initted) return 0; + + return fdVideo; +} + +ULLONG VideoWin::getCurrentTimestamp() +{ + return 0; +} + +ULONG VideoWin::timecodeToFrameNumber(ULLONG timecode) +{ + if (format == PAL) return (ULONG)(((double)timecode / (double)90000) * (double)25); + else return (ULONG)(((double)timecode / (double)90000) * (double)30); +} + +#ifdef DEV +int VideoWin::test() +{ + return 0; +} + +int VideoWin::test2() +{ + return 0; +} +#endif diff --git a/videowin.h b/videowin.h new file mode 100644 index 0000000..b736954 --- /dev/null +++ b/videowin.h @@ -0,0 +1,69 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef VIDEOWIN_H +#define VIDEOWIN_H + +#include +#include + +#include "defines.h" +#include "video.h" + +class VideoWin : public Video +{ + public: + VideoWin(); + ~VideoWin(); + + int init(UCHAR format); + int shutdown(); + + int setFormat(UCHAR format); + int setConnection(UCHAR connection); + int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching + int setMode(UCHAR mode); + int setTVsize(UCHAR size); // Is the TV a widescreen? + int setDefaultAspect(); + int setSource(); + int setPosition(int x, int y); + int sync(); + int play(); + int stop(); + int pause(); + int unPause(); + int fastForward(); + int unFastForward(); + int reset(); + int blank(); + int signalOn(); + int signalOff(); + int attachFrameBuffer(); // What does this do? + ULONG timecodeToFrameNumber(ULLONG timecode); + int getFD(); + ULLONG getCurrentTimestamp(); + +#ifdef DEV + int test(); + int test2(); +#endif +}; + +#endif -- 2.39.2