From bd2b4ececa57b0ca5f3a8ba0f6459bca537ccda4 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 19 May 2006 21:29:49 +0000 Subject: [PATCH] A little convergence to NEW_DEMUXER --- Makefile | 2 +- afeed.cc | 17 +---- afeed.h | 13 +--- afeedr.cc | 85 ---------------------- afeedr.h | 64 ----------------- audio.h | 6 +- audiomvp.cc | 23 +++--- audiomvp.h | 6 +- audiowin.cc | 19 ++--- audiowin.h | 3 +- demuxer.cc | 29 ++------ demuxer.h | 14 +--- draintarget.cc | 9 +-- draintarget.h | 42 ++++++----- main.cc | 21 ++---- player.cc | 12 ++-- stream.cc | 17 +++-- stream.h | 13 ++-- vfeed.cc | 18 +---- vfeed.h | 13 +--- video.h | 5 +- videomvp.cc | 22 +++--- videomvp.h | 5 +- videowin.cc | 191 ++++++++++++++++++++++++------------------------- videowin.h | 17 +++-- 25 files changed, 222 insertions(+), 444 deletions(-) delete mode 100644 afeedr.cc delete mode 100644 afeedr.h diff --git a/Makefile b/Makefile index 2086636..9ee421c 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ CROSSLIBS = ../jpeg-6b/libjpeg.a OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o \ message.o messagequeue.o \ vdr.o recman.o recording.o channel.o rectimer.o event.o directory.o \ - player.o vfeed.o afeed.o afeedr.o \ + player.o vfeed.o afeed.o \ demuxer.o demuxervdr.o stream.o draintarget.o \ viewman.o box.o region.o colour.o view.o \ vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \ diff --git a/afeed.cc b/afeed.cc index fc0b4ce..7bc8fbf 100644 --- a/afeed.cc +++ b/afeed.cc @@ -26,19 +26,10 @@ AFeed::AFeed(Callback* tcb) audioEnabled = 1; } -#ifndef NEW_DEMUXER -int AFeed::init(int tfd) +int AFeed::init() { - fd = tfd; return 1; } -#else -int AFeed::init(DrainTarget* tdt) -{ - dt = tdt; - return 1; -} -#endif int AFeed::shutdown() { @@ -77,11 +68,7 @@ void AFeed::threadMethod() if (audioEnabled) { -#ifndef NEW_DEMUXER - alen = Demuxer::getInstance()->writeAudio(fd); // FIXME ? -#else - alen = Demuxer::getInstance()->writeAudio(dt); // FIXME ? -#endif + alen = Demuxer::getInstance()->writeAudio(); if (alen) { diff --git a/afeed.h b/afeed.h index f67770b..76ec466 100644 --- a/afeed.h +++ b/afeed.h @@ -27,7 +27,6 @@ #include "log.h" #include "demuxer.h" #include "callback.h" -#include "draintarget.h" #ifdef WIN32 #include "threadwin.h" @@ -40,11 +39,8 @@ class AFeed : public Thread_TYPE { public: AFeed(Callback* tcb); -#ifndef NEW_DEMUXER - int init(int fd); -#else - int init(DrainTarget* tdt); -#endif + + int init(); int shutdown(); int start(); @@ -56,11 +52,6 @@ class AFeed : public Thread_TYPE void threadMethod(); void threadPostStopCleanup() {}; int audioEnabled; -#ifndef NEW_DEMUXER - int fd; -#else - DrainTarget* dt; -#endif Callback& cb; }; diff --git a/afeedr.cc b/afeedr.cc deleted file mode 100644 index f88c996..0000000 --- a/afeedr.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* - 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 "afeedr.h" - -AFeedR::AFeedR(Callback* tcb, Stream* tstream) -: cb(*tcb), stream(*tstream) -{ -} - -#ifndef NEW_DEMUXER -int AFeedR::init(int tfd) -{ - fd = tfd; - return 1; -} -#else -int AFeedR::init(DrainTarget* tdt) -{ - dt = tdt; - return 1; -} -#endif - - -int AFeedR::shutdown() -{ - // FIXME - return 1; -} - -int AFeedR::start() -{ - return threadStart(); -} - -void AFeedR::stop() -{ - threadCancel(); -} - -void AFeedR::threadMethod() -{ - Log::getInstance()->log("AFeedR", Log::DEBUG, "Started"); - - int alen; - - while(1) - { -#ifndef NEW_DEMUXER - alen = stream.drain(fd); -#else - alen = stream.drain(dt); - threadCheckExit(); -#endif - - if (alen) - { - Log::getInstance()->log("AFeedR", Log::DEBUG, "Written %i", alen); - cb.call(this); - } - else - { - MILLISLEEP(100); - } - } -} - diff --git a/afeedr.h b/afeedr.h deleted file mode 100644 index 9967420..0000000 --- a/afeedr.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - 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 AFEEDR_H -#define AFEEDR_H - -#include -#include - -#include "log.h" -#include "callback.h" -#include "stream.h" -#include "draintarget.h" - -#ifdef WIN32 -#include "threadwin.h" -#else -#include "threadp.h" -#endif - -class AFeedR : public Thread_TYPE -{ - public: - AFeedR(Callback* tcb, Stream* tstream); -#ifndef NEW_DEMUXER - int init(int fd); -#else - int init(DrainTarget* tdt); -#endif - int shutdown(); - - int start(); - void stop(); - - private: - void threadMethod(); - void threadPostStopCleanup() {}; -#ifndef NEW_DEMUXER - int fd; -#else - DrainTarget* dt; -#endif - Callback& cb; - Stream& stream; -}; - -#endif diff --git a/audio.h b/audio.h index 23751d8..a240121 100644 --- a/audio.h +++ b/audio.h @@ -57,8 +57,10 @@ class Audio : public DrainTarget virtual int setVolume(int volume)=0; virtual int mute()=0; virtual int unMute()=0; - virtual int write(char *buf, int len)=0; - virtual int getFD()=0; // FIXME MVP specific + +#ifndef NEW_DEMUXER + virtual int write(UCHAR* buffer, ULONG length)=0; +#endif int volumeUp(); int volumeDown(); diff --git a/audiomvp.cc b/audiomvp.cc index f1bfe70..f7a4ab4 100644 --- a/audiomvp.cc +++ b/audiomvp.cc @@ -79,18 +79,6 @@ int AudioMVP::shutdown() return 1; } -int AudioMVP::getFD() -{ - if (!initted) return 0; - - return fdAudio; -} - -int AudioMVP::write(char *buf, int len) -{ - return 0; //write(fdAudio, buf, len); -} - int AudioMVP::setStreamType(UCHAR type) { if (!initted) return 0; @@ -241,7 +229,8 @@ int AudioMVP::test() #endif -// unused +#ifdef NEW_DEMUXER + UINT AudioMVP::DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos) { return 0; @@ -251,3 +240,11 @@ void AudioMVP::ResetTimeOffsets() { } +#else + +int AudioMVP::write(UCHAR* buffer, ULONG length) +{ + return ::write(fdAudio, buffer, length); +} + +#endif diff --git a/audiomvp.h b/audiomvp.h index cf29478..0178514 100644 --- a/audiomvp.h +++ b/audiomvp.h @@ -54,13 +54,15 @@ class AudioMVP : public Audio int setVolume(int volume); int mute(); int unMute(); - int write(char *buf, int len); - int getFD(); +#ifdef NEW_DEMUXER //Writing Data to Audiodevice -- unused in MVP code so far virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos); virtual long long SetStartOffset(long long curreftime, bool *rsync) { return 0; }; virtual void ResetTimeOffsets(); +#else + int write(UCHAR* buffer, ULONG length); +#endif #ifdef DEV int test(); diff --git a/audiowin.cc b/audiowin.cc index 40b51b6..d835bb6 100644 --- a/audiowin.cc +++ b/audiowin.cc @@ -29,14 +29,14 @@ AudioWin::AudioWin() { initted = 0; firstsynched=false; - + } AudioWin::~AudioWin() { - + } @@ -54,11 +54,6 @@ int AudioWin::shutdown() return 1; } -int AudioWin::getFD() -{ - return 0; -} - int AudioWin::write(char *buf, int len) { return 0; //write(fdAudio, buf, len); @@ -216,17 +211,17 @@ UINT AudioWin::DeliverMediaSample(MediaPacket packet, if (packet.synched) { ms->SetSyncPoint(TRUE); ms->SetTime(&reftime1,&reftime2); - + //ms->SetTime(NULL,NULL); ms->SetMediaTime(NULL, NULL); - if (reftime1<0) ms->SetPreroll(TRUE); - else ms->SetPreroll(FALSE); + if (reftime1<0) ms->SetPreroll(TRUE); + else ms->SetPreroll(FALSE); }else { ms->SetSyncPoint(FALSE); ms->SetTime(NULL,NULL); ms->SetMediaTime(NULL, NULL); - ms->SetPreroll(FALSE); - MessageBox(0,"here I'm","Hallo",0); + ms->SetPreroll(FALSE); + MessageBox(0,"here I'm","Hallo",0); // ms->SetSyncPoint(TRUE); } } diff --git a/audiowin.h b/audiowin.h index 2e6eb1a..1727b52 100644 --- a/audiowin.h +++ b/audiowin.h @@ -47,12 +47,11 @@ class AudioWin : public Audio int mute(); int unMute(); int write(char *buf, int len); - int getFD(); // Writing Data to Audiodevice virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos); virtual long long SetStartOffset(long long curreftime, bool *rsync); - virtual void ResetTimeOffsets(); + virtual void ResetTimeOffsets(); private: bool firstsynched; diff --git a/demuxer.cc b/demuxer.cc index d8be631..89c41e4 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -61,21 +61,17 @@ Demuxer* Demuxer::getInstance() return instance; } -int Demuxer::init(Callback* tcallback) +int Demuxer::init(Callback* tcallback, DrainTarget* audio, DrainTarget* video) { if (!initted) { - if ( !videostream.init(demuxMemoryV) || - !audiostream.init(demuxMemoryA)) + if ( !videostream.init(video, demuxMemoryV) || + !audiostream.init(audio, demuxMemoryA)) { Log::getInstance()->log("Demuxer", Log::CRIT, "Failed to initialize demuxer"); shutdown(); return 0; } -#ifdef NEW_DEMUXER - videostream.setDrainTarget(Video::getInstance()); - audiostream.setDrainTarget(Audio::getInstance()); -#endif } reset(); @@ -143,27 +139,16 @@ void Demuxer::setAspectRatio(enum AspectRatio ar) else arcnt = 0; } -#ifndef NEW_DEMUXER -int Demuxer::writeAudio(int fd) -{ - return audiostream.drain(fd); -} -int Demuxer::writeVideo(int fd) +int Demuxer::writeAudio() { - return videostream.drain(fd); -} -#else -int Demuxer::writeAudio(DrainTarget* dt) -{ - return audiostream.drain(dt); + return audiostream.drain(); } -int Demuxer::writeVideo(DrainTarget* dt) +int Demuxer::writeVideo() { - return videostream.drain(dt); + return videostream.drain(); } -#endif Demuxer::PESPacket::PESPacket() { diff --git a/demuxer.h b/demuxer.h index b28f273..ba64324 100644 --- a/demuxer.h +++ b/demuxer.h @@ -38,9 +38,6 @@ however, no code was copied verbatim. #include "callback.h" #include "draintarget.h" -#include "audio.h" -#include "video.h" - class Demuxer { public: //MS Visual C++ need this, private does not work for DemuxerVDR, Marten @@ -69,20 +66,15 @@ public: //MS Visual C++ need this, private does not work for DemuxerVDR, Marten Demuxer(); virtual ~Demuxer(); static Demuxer* getInstance(); - int init(Callback* callback); + int init(Callback* callback, DrainTarget* audio, DrainTarget* video); void reset(); virtual void flush(); void flushAudio(); void seek(); void setVideoStream(int id); void setAudioStream(int id); -#ifndef NEW_DEMUXER - int writeAudio(int fd); - int writeVideo(int fd); -#else - int writeAudio(DrainTarget* dt); - int writeVideo(DrainTarget* dt); -#endif + int writeAudio(); + int writeVideo(); virtual int scan(UCHAR* buf, int len) = 0; virtual int findVideoPTS(UCHAR* buf, int len, ULLONG* dest) = 0; diff --git a/draintarget.cc b/draintarget.cc index 8dd74a4..26c9d96 100644 --- a/draintarget.cc +++ b/draintarget.cc @@ -17,11 +17,12 @@ along with VOMP; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "draintarget.h" -DrainTarget::DrainTarget(){ +#include "draintarget.h" +DrainTarget::DrainTarget() +{ } -DrainTarget::~DrainTarget(){ - +DrainTarget::~DrainTarget() +{ } diff --git a/draintarget.h b/draintarget.h index 7923b2e..380979b 100644 --- a/draintarget.h +++ b/draintarget.h @@ -25,9 +25,10 @@ #include +#ifdef NEW_DEMUXER - -struct MediaPacket{ +struct MediaPacket +{ ULLONG recording_byte_pos; //position in recording ULLONG pts; ULONG pos_buffer; //position in stream buffer @@ -42,23 +43,32 @@ using namespace std; typedef list MediaPacketList; +#endif + +class DrainTarget +{ + public: + DrainTarget(); + virtual ~DrainTarget(); + +#ifdef NEW_DEMUXER -class DrainTarget { -public: - DrainTarget(); - virtual ~DrainTarget(); - virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, - UINT *samplepos)=0; + virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos)=0; -/* This function behaviour should be: -Try to deliver the Data from packet.pos_buffer+samplepos to packet.pos_buffer+packet.length, -with considering the bufferwraparound according to buffersize. -Then increasing samplepos, so that on the next call delivering can proceed. So if writebytes are -writen samplepos=samplepos+writebytes! -If samplepos>=packet.length is returned, the next packet can be used for the next call.*/ + /* This function behaviour should be: + Try to deliver the Data from packet.pos_buffer+samplepos to packet.pos_buffer+packet.length, + with considering the bufferwraparound according to buffersize. + Then increasing samplepos, so that on the next call delivering can proceed. So if writebytes are + writen samplepos=samplepos+writebytes! + If samplepos>=packet.length is returned, the next packet can be used for the next call.*/ + + virtual long long SetStartOffset(long long curreftime, bool *rsync)=0; + virtual void ResetTimeOffsets()=0; + +#else + virtual int write(UCHAR* buffer, ULONG length)=0; +#endif - virtual long long SetStartOffset(long long curreftime, bool *rsync)=0; - virtual void ResetTimeOffsets()=0; }; diff --git a/main.cc b/main.cc index 7c8e147..b5f56e8 100644 --- a/main.cc +++ b/main.cc @@ -34,21 +34,12 @@ #include "viewman.h" #include "command.h" -#ifdef WIN32 - #include "mtdwin.h" - #include "remotewin.h" - #include "ledwin.h" - #include "osdwin.h" - #include "audiowin.h" - #include "videowin.h" -#else - #include "mtdmvp.h" - #include "remotemvp.h" - #include "ledmvp.h" - #include "osdmvp.h" - #include "audiomvp.h" - #include "videomvp.h" -#endif +#include "mtdmvp.h" +#include "remotemvp.h" +#include "ledmvp.h" +#include "osdmvp.h" +#include "audiomvp.h" +#include "videomvp.h" #ifndef WIN32 void sighandler(int signalReceived); diff --git a/player.cc b/player.cc index 997dcff..731019b 100644 --- a/player.cc +++ b/player.cc @@ -79,19 +79,15 @@ int Player::init() demuxer = new DemuxerVDR(); if (!demuxer) return 0; - if (!demuxer->init(this)) + if (!demuxer->init(this, audio, video)) { logger->log("Player", Log::ERR, "Demuxer failed to init"); shutdown(); return 0; } -#ifndef NEW_DEMUXER - vfeed.init(video->getFD()); - afeed.init(audio->getFD()); -#else - vfeed.init(video); - afeed.init(audio); -#endif + + vfeed.init(); + afeed.init(); video->stop(); video->blank(); diff --git a/stream.cc b/stream.cc index f226d8f..fc8c696 100644 --- a/stream.cc +++ b/stream.cc @@ -23,9 +23,9 @@ Stream::Stream() { initted = 0; + draintarget=NULL; #ifdef NEW_DEMUXER cur_packet_pos=0; - draintarget=NULL; #endif } @@ -41,10 +41,11 @@ void Stream::shutdown() } -int Stream::init(int bufsize) +int Stream::init(DrainTarget* tdt, int bufsize) { outbuf = (UCHAR*) malloc(bufsize); if (!outbuf) return 0; + draintarget = tdt; bufferSize = bufsize; bufferHead = 0; bufferTail = 0; @@ -172,7 +173,7 @@ int Stream::put(UCHAR* inbuf, int len,ULLONG curpos) #ifndef NEW_DEMUXER -int Stream::drain(int fd) +int Stream::drain() { int ret = 0; int head = bufferHead; @@ -186,7 +187,7 @@ int Stream::drain(int fd) { // Drain up to the marker. #ifndef WIN32 - written = write(fd, outbuf + tail, (mark - tail)); + written = draintarget->write(outbuf + tail, (mark - tail)); #else written=mark-tail; MILLISLEEP(1); @@ -207,7 +208,7 @@ int Stream::drain(int fd) if (tail == head) return ret; // Empty #ifndef WIN32 - written = write(fd, outbuf + tail, (head - tail)); + written = draintarget->write(outbuf + tail, (head - tail)); #else written=(head - tail); MILLISLEEP(1); @@ -217,12 +218,14 @@ int Stream::drain(int fd) bufferTail = tail + written; return ret; } + #else -int Stream::drain(DrainTarget* dt) + +int Stream::drain() { int ret = 0; int written=1; - draintarget=dt; +// draintarget=dt; // this is now set in init, is this ok? diff --git a/stream.h b/stream.h index c3abce6..33d97c0 100644 --- a/stream.h +++ b/stream.h @@ -36,29 +36,24 @@ class Stream public: Stream(); ~Stream(); - int init(int bufsize); + int init(DrainTarget* tdt, int bufsize); void shutdown(); void flush(); #ifndef NEW_DEMUXER int put(UCHAR* inbuf, int len); #else - int put(UCHAR* inbuf, int len,ULLONG curpos); + int put(UCHAR* inbuf, int len,ULLONG curpos); #endif -#ifndef NEW_DEMUXER - int drain(int fd); -#else - int drain(DrainTarget* fd); - void setDrainTarget(DrainTarget *dt) {if (dt) draintarget=dt;}; -#endif + int drain(); private: #ifdef NEW_DEMUXER MediaPacketList mediapackets; UINT cur_packet_pos; - DrainTarget* draintarget; #endif + DrainTarget* draintarget; int initted; UCHAR* outbuf; int bufferSize; diff --git a/vfeed.cc b/vfeed.cc index 7b64904..4fd4657 100644 --- a/vfeed.cc +++ b/vfeed.cc @@ -25,19 +25,10 @@ VFeed::VFeed(Callback* tcb) { } -#ifndef NEW_DEMUXER -int VFeed::init(int tfd) +int VFeed::init() { - fd = tfd; return 1; } -#else -int VFeed::init(DrainTarget* tdt) -{ - dt = tdt; - return 1; -} -#endif int VFeed::shutdown() { @@ -68,12 +59,9 @@ void VFeed::threadMethod() while(1) { -#ifndef NEW_DEMUXER - vlen = Demuxer::getInstance()->writeVideo(fd); // FIXME -#else threadCheckExit(); - vlen = Demuxer::getInstance()->writeVideo(dt); // FIXME -#endif + vlen = Demuxer::getInstance()->writeVideo(); + if (vlen) { // Log::getInstance()->log("VFeed", Log::DEBUG, "Written %i", vlen); diff --git a/vfeed.h b/vfeed.h index b1cb204..54975ef 100644 --- a/vfeed.h +++ b/vfeed.h @@ -27,7 +27,6 @@ #include "log.h" #include "demuxer.h" #include "callback.h" -#include "draintarget.h" #ifdef WIN32 #include "threadwin.h" @@ -39,11 +38,7 @@ class VFeed : public Thread_TYPE { public: VFeed(Callback* tcb); -#ifndef NEW_DEMUXER - int init(int fd); -#else - int init(DrainTarget *tdt); -#endif + int init(); int shutdown(); @@ -54,12 +49,6 @@ class VFeed : public Thread_TYPE private: void threadMethod(); void threadPostStopCleanup() {}; -#ifndef NEW_DEMUXER - int fd; -#else - DrainTarget *dt; -#endif - Callback& cb; }; diff --git a/video.h b/video.h index 69de304..dbb20d5 100644 --- a/video.h +++ b/video.h @@ -55,9 +55,12 @@ class Video: public DrainTarget 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; +#ifndef NEW_DEMUXER + virtual int write(UCHAR* buffer, ULONG length)=0; +#endif + virtual void turnVideoOn(){}; virtual void turnVideoOff(){}; virtual ULLONG frameNumberToTimecode(ULONG timecode) { return 0; }; diff --git a/videomvp.cc b/videomvp.cc index 6e7c61b..43e84a7 100644 --- a/videomvp.cc +++ b/videomvp.cc @@ -323,13 +323,6 @@ int VideoMVP::blank(void) return 1; } -int VideoMVP::getFD() -{ - if (!initted) return 0; - - return fdVideo; -} - ULLONG VideoMVP::getCurrentTimestamp() { sync_data_t timestamps; @@ -373,7 +366,10 @@ int VideoMVP::test2() } #endif -// unused + + +#ifdef NEW_DEMUXER + UINT VideoMVP::DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos) { return 0; @@ -382,3 +378,13 @@ UINT VideoMVP::DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *sampl void VideoMVP::ResetTimeOffsets() { } + +#else + +int VideoMVP::write(UCHAR* buffer, ULONG length) +{ + return ::write(fdVideo, buffer, length); +} + +#endif + diff --git a/videomvp.h b/videomvp.h index f2a2aaf..3f626d2 100644 --- a/videomvp.h +++ b/videomvp.h @@ -66,13 +66,16 @@ class VideoMVP : public Video int signalOff(); int attachFrameBuffer(); // What does this do? ULONG timecodeToFrameNumber(ULLONG timecode); - int getFD(); ULLONG getCurrentTimestamp(); +#ifdef NEW_DEMUXER //Writing Data to Videodevice virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos); virtual long long SetStartOffset(long long curreftime, bool *rsync) { return 0; }; virtual void ResetTimeOffsets(); +#else + int write(UCHAR* buffer, ULONG length); +#endif #ifdef DEV int test(); diff --git a/videowin.cc b/videowin.cc index c1e3356..3462f6c 100644 --- a/videowin.cc +++ b/videowin.cc @@ -55,7 +55,7 @@ VideoWin::VideoWin() pseudotvsize=0; videoposx=0; videoposy=0; - + } @@ -64,7 +64,7 @@ VideoWin::~VideoWin() { CleanupDS(); CloseHandle(filtermutex); - + instance = NULL; @@ -175,8 +175,8 @@ int VideoWin::setPosition(int x, int y) { if (!initted) return 0; if (mode==QUARTER || mode==EIGHTH) { - videoposx=x; - videoposy=y; + videoposx=x; + videoposy=y; } return 1; } @@ -200,7 +200,7 @@ int VideoWin::play() //Build filter graph HRESULT hres; - + if (hres=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder,(void**)&dsgraphbuilder)!=S_OK) { return 0; @@ -216,14 +216,14 @@ int VideoWin::play() sourcefilter=new DsSourceFilter(); //Creating our Source filter for pushing Data // to DirectShow if (hres=dsgraphbuilder->AddFilter(sourcefilter,L"Vomp Win Source Filter")!=S_OK) { - Log::getInstance()->log("VideoWin", Log::WARN , "Failed adding Vomp Source Filter!"); + Log::getInstance()->log("VideoWin", Log::WARN , "Failed adding Vomp Source Filter!"); CleanupDS(); ReleaseMutex(filtermutex); return 0; } //if (audioon) { if (hres=dsgraphbuilder->Render(sourcefilter->GetPin(0)/*audio*/)!=S_OK) { - Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering audio!"); + Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering audio!"); CleanupDS(); ReleaseMutex(filtermutex); return 0; @@ -231,64 +231,64 @@ int VideoWin::play() //} #ifdef DO_VIDEO if (videoon) { - //We alloc the vmr9 as next step - if (hres=CoCreateInstance(CLSID_VideoMixingRenderer9,0, - CLSCTX_INPROC_SERVER,IID_IBaseFilter,(void**) &dsvmrrenderer)!=S_OK) { - Log::getInstance()->log("VideoWin", Log::WARN ,"Failed creating VMR9 renderer!"); - CleanupDS(); - ReleaseMutex(filtermutex); - } - /*VMR 9 stuff**/ - if (hres=dsgraphbuilder->AddFilter(dsvmrrenderer,L"VMR9")!=S_OK) { - CleanupDS(); - Log::getInstance()->log("VideoWin", Log::WARN ,"Failed adding VMR9 renderer!"); - ReleaseMutex(filtermutex); - return 0; - } - IVMRFilterConfig9* vmrfilconfig; - if (dsvmrrenderer->QueryInterface(IID_IVMRFilterConfig9,(void**)&vmrfilconfig)!=S_OK) { - CleanupDS(); - Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Filterconfig interface!"); - ReleaseMutex(filtermutex); - return 0; - } - vmrfilconfig->SetRenderingMode(VMR9Mode_Renderless); - vmrfilconfig->Release(); - - if (dsvmrrenderer->QueryInterface(IID_IVMRSurfaceAllocatorNotify9,(void**)& dsvmrsurfnotify)!=S_OK) { - CleanupDS(); - Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Surface Allocator interface!"); - ReleaseMutex(filtermutex); - return 0; - } - allocatorvmr=new DsAllocator(); - dsvmrsurfnotify->AdviseSurfaceAllocator(NULL,allocatorvmr); - allocatorvmr->AdviseNotify(dsvmrsurfnotify); - - - - /*VMR 9 stuff end */ - IFilterGraph2*fg2=NULL; - if (dsgraphbuilder->QueryInterface(IID_IFilterGraph2,(void**)&fg2)!=S_OK) { - Log::getInstance()->log("VideoWin", Log::WARN , "Failed querying for FilterGraph2 Interface!"); - CleanupDS(); - ReleaseMutex(filtermutex); - return 0; - } - if (hres=fg2->RenderEx(sourcefilter->GetPin(1)/*video*/, - AM_RENDEREX_RENDERTOEXISTINGRENDERERS,NULL)!=S_OK) { - Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering Video!"); - CleanupDS(); - ReleaseMutex(filtermutex); - return 0; - } + //We alloc the vmr9 as next step + if (hres=CoCreateInstance(CLSID_VideoMixingRenderer9,0, + CLSCTX_INPROC_SERVER,IID_IBaseFilter,(void**) &dsvmrrenderer)!=S_OK) { + Log::getInstance()->log("VideoWin", Log::WARN ,"Failed creating VMR9 renderer!"); + CleanupDS(); + ReleaseMutex(filtermutex); + } + /*VMR 9 stuff**/ + if (hres=dsgraphbuilder->AddFilter(dsvmrrenderer,L"VMR9")!=S_OK) { + CleanupDS(); + Log::getInstance()->log("VideoWin", Log::WARN ,"Failed adding VMR9 renderer!"); + ReleaseMutex(filtermutex); + return 0; + } + IVMRFilterConfig9* vmrfilconfig; + if (dsvmrrenderer->QueryInterface(IID_IVMRFilterConfig9,(void**)&vmrfilconfig)!=S_OK) { + CleanupDS(); + Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Filterconfig interface!"); + ReleaseMutex(filtermutex); + return 0; + } + vmrfilconfig->SetRenderingMode(VMR9Mode_Renderless); + vmrfilconfig->Release(); + + if (dsvmrrenderer->QueryInterface(IID_IVMRSurfaceAllocatorNotify9,(void**)& dsvmrsurfnotify)!=S_OK) { + CleanupDS(); + Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Surface Allocator interface!"); + ReleaseMutex(filtermutex); + return 0; + } + allocatorvmr=new DsAllocator(); + dsvmrsurfnotify->AdviseSurfaceAllocator(NULL,allocatorvmr); + allocatorvmr->AdviseNotify(dsvmrsurfnotify); + + + + /*VMR 9 stuff end */ + IFilterGraph2*fg2=NULL; + if (dsgraphbuilder->QueryInterface(IID_IFilterGraph2,(void**)&fg2)!=S_OK) { + Log::getInstance()->log("VideoWin", Log::WARN , "Failed querying for FilterGraph2 Interface!"); + CleanupDS(); + ReleaseMutex(filtermutex); + return 0; + } + if (hres=fg2->RenderEx(sourcefilter->GetPin(1)/*video*/, + AM_RENDEREX_RENDERTOEXISTINGRENDERERS,NULL)!=S_OK) { + Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering Video!"); + CleanupDS(); + ReleaseMutex(filtermutex); + return 0; + } } #endif if (hres=CoCreateInstance(CLSID_SystemClock,NULL,CLSCTX_INPROC_SERVER, IID_IReferenceClock,(void**)&dsrefclock)!=S_OK) { return 0; } - + dsgraphbuilder->QueryInterface(IID_IMediaFilter,(void **) &dsmediafilter); dsmediafilter->SetSyncSource(dsrefclock); @@ -355,27 +355,20 @@ int VideoWin::blank(void) return 1; } -int VideoWin::getFD() +ULLONG VideoWin::getCurrentTimestamp() { - if (!initted) return 0; + REFERENCE_TIME cr_time,startoffset; - return fdVideo; -} + if (!dsrefclock || !sourcefilter) return 0; -ULLONG VideoWin::getCurrentTimestamp() -{ - REFERENCE_TIME cr_time,startoffset; - - if (!dsrefclock || !sourcefilter) return 0; - - dsrefclock->GetTime(&cr_time); - startoffset=sourcefilter->getStartOffset(); - cr_time-=startoffset; - cr_time-=lastreftimeRT; - ULLONG result=frameNumberToTimecode( - VDR::getInstance()->frameNumberFromPosition(lastreftimeBYTE)); - result+=(ULLONG)(cr_time/10000LL*90LL); - return result; + dsrefclock->GetTime(&cr_time); + startoffset=sourcefilter->getStartOffset(); + cr_time-=startoffset; + cr_time-=lastreftimeRT; + ULLONG result=frameNumberToTimecode( + VDR::getInstance()->frameNumberFromPosition(lastreftimeBYTE)); + result+=(ULLONG)(cr_time/10000LL*90LL); + return result; } @@ -403,26 +396,26 @@ void VideoWin::CleanupDS() cur_video_media_sample=NULL; } if (dsvmrsurfnotify) { - dsvmrsurfnotify->Release(); - dsvmrsurfnotify=NULL; + dsvmrsurfnotify->Release(); + dsvmrsurfnotify=NULL; } if (dsvmrrenderer) { - dsvmrrenderer->Release(); - dsvmrrenderer=NULL; + dsvmrrenderer->Release(); + dsvmrrenderer=NULL; } - + if (allocatorvmr) { - allocatorvmr->Release(); - allocatorvmr=NULL; + allocatorvmr->Release(); + allocatorvmr=NULL; } - + if (dsrefclock) { - dsrefclock->Release(); - dsrefclock=NULL; + dsrefclock->Release(); + dsrefclock=NULL; } if (dsmediafilter) { - dsmediafilter->Release(); - dsmediafilter=NULL; + dsmediafilter->Release(); + dsmediafilter=NULL; } if (dsmediacontrol) { @@ -522,18 +515,18 @@ UINT VideoWin::DeliverMediaSample(MediaPacket packet, ms->SetTime(&reftime1,&reftime2); //ms->SetTime(NULL,NULL); ms->SetMediaTime(NULL, NULL); - if (reftime1<0) ms->SetPreroll(TRUE); - else ms->SetPreroll(FALSE); - /*Timecode handling*/ - lastreftimeRT=reftime1; - lastreftimeBYTE=packet.recording_byte_pos; + if (reftime1<0) ms->SetPreroll(TRUE); + else ms->SetPreroll(FALSE); + /*Timecode handling*/ + lastreftimeRT=reftime1; + lastreftimeBYTE=packet.recording_byte_pos; }else { ms->SetSyncPoint(FALSE); ms->SetTime(NULL,NULL); ms->SetMediaTime(NULL, NULL); - ms->SetPreroll(FALSE); - + ms->SetPreroll(FALSE); + // ms->SetSyncPoint(TRUE); } } @@ -620,8 +613,8 @@ long long VideoWin::SetStartOffset(long long curreftime, bool *rsync) startoffset=curreftime;//offset is set for audio offsetnotset=false; offsetvideonotset=false; - - + + } else { if (offsetvideonotset) { offsetvideonotset=false; @@ -680,7 +673,7 @@ void VideoWin::ResetTimeOffsets() { lastreftimeBYTE=0; lastreftimeRT=0; - + } diff --git a/videowin.h b/videowin.h index 9897112..5e01c3d 100644 --- a/videowin.h +++ b/videowin.h @@ -48,10 +48,10 @@ class VideoWin : public Video int setFormat(UCHAR format); int setConnection(UCHAR connection); int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching - UCHAR getAspectRatio(){return aspectRatio;}; - UCHAR getMode(){return mode;}; - UCHAR getPseudoTVsize() {return pseudotvsize;}; - int setMode(UCHAR mode); + UCHAR getAspectRatio(){return aspectRatio;}; + UCHAR getMode(){return mode;}; + UCHAR getPseudoTVsize() {return pseudotvsize;}; + int setMode(UCHAR mode); int setTVsize(UCHAR size); // Is the TV a widescreen? int setDefaultAspect(); int setSource(); @@ -69,8 +69,7 @@ class VideoWin : public Video int signalOff(); int attachFrameBuffer(); // What does this do? ULONG timecodeToFrameNumber(ULLONG timecode); - ULLONG frameNumberToTimecode(ULONG framenumber); - int getFD(); + ULLONG frameNumberToTimecode(ULONG framenumber); ULLONG getCurrentTimestamp(); //Writing Data to Videodevice @@ -84,15 +83,15 @@ class VideoWin : public Video virtual long long SetStartOffset(long long curreftime, bool *rsync); long long SetStartAudioOffset(long long curreftime, bool *rsync); - virtual void ResetTimeOffsets(); + virtual void ResetTimeOffsets(); void SetAudioState(bool state){audioon=state;}; void turnVideoOn(){videoon=true;}; void turnVideoOff(){videoon=false;}; - unsigned int getPosx() {return videoposx;}; - unsigned int getPosy() {return videoposy;}; + unsigned int getPosx() {return videoposx;}; + unsigned int getPosy() {return videoposy;}; #ifdef DEV int test(); -- 2.39.5