]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Windows port
authorChris Tallon <chris@vomp.tv>
Sat, 20 May 2006 20:17:28 +0000 (20:17 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 20 May 2006 20:17:28 +0000 (20:17 +0000)
16 files changed:
audiowin.cc
audiowin.h
box.cc
command.cc
osdwin.cc
osdwin.h
player.cc
remotewin.cc
remotewin.h
stream.cc
stream.h
surface.cc
vdr.cc
videowin.cc
videowin.h
winmain.cc

index d835bb6ee8f1233d8c716819b28a955238714199..189731b28c1573187914fd41f7cdb1ffb961a48e 100644 (file)
-/*
-    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 "audiowin.h"
-#include "videowin.h"
-
-
-
-
-
-AudioWin::AudioWin()
-{
-  initted = 0;
-  firstsynched=false;
-
-
-
-}
-
-AudioWin::~AudioWin()
-{
-
-
-}
-
-int AudioWin::init(UCHAR tstreamType)
-{
-  if (initted) return 0;
-  initted = 1;
-  return 1;
-}
-
-int AudioWin::shutdown()
-{
-  if (!initted) return 0;
-  initted = 0;
-  return 1;
-}
-
-int AudioWin::write(char *buf, int len)
-{
-  return 0; //write(fdAudio, buf, len);
-}
-
-int AudioWin::setStreamType(UCHAR type)
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::setChannel()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::setSource()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::sync()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::play()
-{
-  if (!initted) return 0;
-  firstsynched=false;
-
-  return 1;
-}
-
-int AudioWin::stop()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::pause()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::unPause()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::reset()
-{
-  if (!initted) return 0;
-  return 1;
-}
-
-int AudioWin::setVolume(int tvolume)
-{
-  // parameter: 0 for silence, 20 for full
-  if ((tvolume < 0) || (tvolume > 20)) return 0;
-  return 1;
-}
-
-int AudioWin::mute()
-{
-  if (!initted) return 0;
-  ((VideoWin*)Video::getInstance())->SetAudioState(false);
-  return 1;
-}
-
-int AudioWin::unMute()
-{
-  if (!initted) return 0;
-  ((VideoWin*)Video::getInstance())->SetAudioState(true);
-  return 1;
-}
-
-UINT AudioWin::DeliverMediaSample(MediaPacket packet,
-     UCHAR* buffer,
-     UINT *samplepos)
-{
-  /*First Check, if we have an audio sample*/
-  VideoWin *vw=(VideoWin*)Video::getInstance();
-  IMediaSample* ms=NULL;
-  REFERENCE_TIME reftime1=0;
-  REFERENCE_TIME reftime2=0;
-
-  UINT headerstrip=0;
-  if (packet.disconti) {
-    firstsynched=false;
-    vw->DeliverVideoMediaSample();
-  }
-
-
-
-  /*Inspect PES-Header */
-/*  UINT header_length=buffer[(packet.pos_buffer+8)%bufferlength]+8/*is this right*;
-*/
-  if (*samplepos==0) {//stripheader
-    headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;
-    *samplepos+=headerstrip;
-    if ( packet.synched ) {
-      vw->DeliverAudioMediaSample();//write out old data
-   /*   if (packet.presentation_time<0) { //Preroll?
-        *samplepos=packet.length;//if we have not processed at least one
-        return packet.length;//synched packet ignore it!
-      }*/
-
-      reftime1=packet.presentation_time;
-      reftime2=reftime1+1;
-      firstsynched=true;
-    } else {
-      if (!firstsynched) {//
-        *samplepos=packet.length;//if we have not processed at least one
-        return packet.length;//synched packet ignore it!
-      }
-    }
-  }
-  BYTE *ms_buf;
-  UINT ms_length;
-  UINT ms_pos;
-  UINT haveToCopy;
-  if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
-    //samplepos=0;
-    MILLISLEEP(10);
-    return *samplepos;
-  }
-  ms_pos=ms->GetActualDataLength();
-  ms_length=ms->GetSize();
-  haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
-  if ((ms_length-ms_pos)<1) {
-    vw->DeliverAudioMediaSample(); //we are full!
-    if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample
-      //samplepos=0;
-      MILLISLEEP(10);
-      return *samplepos;
-    }
-    ms_pos=ms->GetActualDataLength();
-    ms_length=ms->GetSize();
-    haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
-  }
-  ms->GetPointer(&ms_buf);
-
-  if (ms_pos==0) {//will only be changed on first packet
-    if (packet.disconti) {
-      ms->SetDiscontinuity(TRUE);
-    } else {
-      ms->SetDiscontinuity(FALSE);
-    }
-    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);
-    }else {
-      ms->SetSyncPoint(FALSE);
-      ms->SetTime(NULL,NULL);
-      ms->SetMediaTime(NULL, NULL);
-    ms->SetPreroll(FALSE);
-     MessageBox(0,"here I'm","Hallo",0);
-    //  ms->SetSyncPoint(TRUE);
-    }
-  }
-
-
-  memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);
-    ms->SetActualDataLength(haveToCopy+ms_pos);
-
-  *samplepos+=haveToCopy;
-
-  return haveToCopy+headerstrip;
-
-}
-
-long long AudioWin::SetStartOffset(long long curreftime, bool *rsync){
-  VideoWin *vw=(VideoWin*)Video::getInstance();
-  return vw->SetStartAudioOffset(curreftime,rsync);
-}
-
-void AudioWin::ResetTimeOffsets() {
-  VideoWin *vw=(VideoWin*)Video::getInstance();
-  return vw->ResetTimeOffsets();
-}
-
-#ifdef DEV
-int AudioWin::test()
-{
-  return 0;
-}
-#endif
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#include "audiowin.h"\r
+#include "videowin.h"\r
+\r
+\r
+\r
+\r
+\r
+AudioWin::AudioWin()\r
+{\r
+  initted = 0;\r
+  firstsynched=false;\r
+  winvolume=0;\r
+  volume=20;\r
+\r
+\r
+\r
+}\r
+\r
+AudioWin::~AudioWin()\r
+{\r
+\r
+\r
+}\r
+\r
+int AudioWin::init(UCHAR tstreamType)\r
+{\r
+  if (initted) return 0;\r
+  initted = 1;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::shutdown()\r
+{\r
+  if (!initted) return 0;\r
+  initted = 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::write(char *buf, int len)\r
+{\r
+  return 0; //write(fdAudio, buf, len);\r
+}\r
+\r
+int AudioWin::setStreamType(UCHAR type)\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::setChannel()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::setSource()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::sync()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::play()\r
+{\r
+  if (!initted) return 0;\r
+  firstsynched=false;\r
+\r
+  return 1;\r
+}\r
+\r
+int AudioWin::stop()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::pause()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::unPause()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::reset()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int AudioWin::setVolume(int tvolume)\r
+{\r
+  // parameter: 0 for silence, 20 for full\r
+  if ((tvolume < 0) || (tvolume > 20)) return 0;\r
+  winvolume=((tvolume-20)*100*30)/20;\r
+  if (tvolume==0) winvolume=-10000;\r
+  ((VideoWin*)Video::getInstance())->SetAudioVolume(winvolume);\r
+\r
+\r
+  return 1;\r
+}\r
+\r
+int AudioWin::mute()\r
+{\r
+  if (!initted) return 0;\r
+  ((VideoWin*)Video::getInstance())->SetAudioState(false);\r
+  ((VideoWin*)Video::getInstance())->SetAudioVolume(-10000);\r
+  return 1;\r
+}\r
+\r
+int AudioWin::unMute()\r
+{\r
+  if (!initted) return 0;\r
+  ((VideoWin*)Video::getInstance())->SetAudioState(true);\r
+  ((VideoWin*)Video::getInstance())->SetAudioVolume(winvolume);\r
+  return 1;\r
+}\r
+\r
+UINT AudioWin::DeliverMediaSample(MediaPacket packet,\r
+     UCHAR* buffer,\r
+     UINT *samplepos)\r
+{\r
+  /*First Check, if we have an audio sample*/\r
+  VideoWin *vw=(VideoWin*)Video::getInstance();\r
+  IMediaSample* ms=NULL;\r
+  REFERENCE_TIME reftime1=0;\r
+  REFERENCE_TIME reftime2=0;\r
+\r
+  UINT headerstrip=0;\r
+  if (packet.disconti) {\r
+    firstsynched=false;\r
+    vw->DeliverVideoMediaSample();\r
+  }\r
+\r
+\r
+\r
+  /*Inspect PES-Header */\r
+/*  UINT header_length=buffer[(packet.pos_buffer+8)%bufferlength]+8/*is this right*;\r
+*/\r
+  if (*samplepos==0) {//stripheader\r
+    headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;\r
+    *samplepos+=headerstrip;\r
+    if ( packet.synched ) {\r
+      vw->DeliverAudioMediaSample();//write out old data\r
+   /*   if (packet.presentation_time<0) { //Preroll?\r
+        *samplepos=packet.length;//if we have not processed at least one\r
+        return packet.length;//synched packet ignore it!\r
+      }*/\r
+\r
+      reftime1=packet.presentation_time;\r
+      reftime2=reftime1+1;\r
+      firstsynched=true;\r
+    } else {\r
+      if (!firstsynched) {//\r
+        *samplepos=packet.length;//if we have not processed at least one\r
+        return packet.length;//synched packet ignore it!\r
+      }\r
+    }\r
+  }\r
+  BYTE *ms_buf;\r
+  UINT ms_length;\r
+  UINT ms_pos;\r
+  UINT haveToCopy;\r
+  if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample\r
+    //samplepos=0;\r
+    MILLISLEEP(10);\r
+    return *samplepos;\r
+  }\r
+  ms_pos=ms->GetActualDataLength();\r
+  ms_length=ms->GetSize();\r
+  haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);\r
+  if ((ms_length-ms_pos)<1) {\r
+    vw->DeliverAudioMediaSample(); //we are full!\r
+    if (!vw->getCurrentAudioMediaSample(&ms) || ms==NULL) {// get the current sample\r
+      //samplepos=0;\r
+      MILLISLEEP(10);\r
+      return *samplepos;\r
+    }\r
+    ms_pos=ms->GetActualDataLength();\r
+    ms_length=ms->GetSize();\r
+    haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);\r
+  }\r
+  ms->GetPointer(&ms_buf);\r
+\r
+  if (ms_pos==0) {//will only be changed on first packet\r
+    if (packet.disconti) {\r
+      ms->SetDiscontinuity(TRUE);\r
+    } else {\r
+      ms->SetDiscontinuity(FALSE);\r
+    }\r
+    if (packet.synched) {\r
+      ms->SetSyncPoint(TRUE);\r
+      ms->SetTime(&reftime1,&reftime2);\r
+\r
+      //ms->SetTime(NULL,NULL);\r
+      ms->SetMediaTime(NULL, NULL);\r
+    if (reftime1<0) ms->SetPreroll(TRUE);\r
+    else ms->SetPreroll(FALSE);\r
+    }else {\r
+      ms->SetSyncPoint(FALSE);\r
+      ms->SetTime(NULL,NULL);\r
+      ms->SetMediaTime(NULL, NULL);\r
+    ms->SetPreroll(FALSE);\r
+     MessageBox(0,"here I'm","Hallo",0);\r
+    //  ms->SetSyncPoint(TRUE);\r
+    }\r
+  }\r
+\r
+\r
+  memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);\r
+    ms->SetActualDataLength(haveToCopy+ms_pos);\r
+\r
+  *samplepos+=haveToCopy;\r
+\r
+  return haveToCopy+headerstrip;\r
+\r
+}\r
+\r
+long long AudioWin::SetStartOffset(long long curreftime, bool *rsync){\r
+  VideoWin *vw=(VideoWin*)Video::getInstance();\r
+  return vw->SetStartAudioOffset(curreftime,rsync);\r
+}\r
+\r
+void AudioWin::ResetTimeOffsets() {\r
+  VideoWin *vw=(VideoWin*)Video::getInstance();\r
+  return vw->ResetTimeOffsets();\r
+}\r
+\r
+#ifdef DEV\r
+int AudioWin::test()\r
+{\r
+  return 0;\r
+}\r
+#endif\r
 \r
index 1727b52cf06c4551ddb5e5e9861eda412ac1480d..52690b55a782fc20b3511be3d8cc72ca8d83806c 100644 (file)
@@ -1,64 +1,65 @@
-/*
-    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 AUDIOWIN_H
-#define AUDIOWIN_H
-
-#include "defines.h"
-#include "log.h"
-#include "audio.h"
-
-class AudioWin : public Audio
-{
-  public:
-    AudioWin();
-    ~AudioWin();
-
-    int init(UCHAR streamType);
-    int shutdown();
-
-    int setStreamType(UCHAR streamType);
-    int setChannel();
-    int setSource();
-    int sync();
-    int play();
-    int stop();
-    int pause();
-    int unPause();
-    int reset();
-    int setVolume(int volume);
-    int mute();
-    int unMute();
-    int write(char *buf, int len);
-
-    // 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();
-
-private:
-  bool firstsynched;
-#ifdef DEV
-    int test();
-#endif
-};
-
-#endif
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#ifndef AUDIOWIN_H\r
+#define AUDIOWIN_H\r
+\r
+#include "defines.h"\r
+#include "log.h"\r
+#include "audio.h"\r
+\r
+class AudioWin : public Audio\r
+{\r
+  public:\r
+    AudioWin();\r
+    ~AudioWin();\r
+\r
+    int init(UCHAR streamType);\r
+    int shutdown();\r
+\r
+    int setStreamType(UCHAR streamType);\r
+    int setChannel();\r
+    int setSource();\r
+    int sync();\r
+    int play();\r
+    int stop();\r
+    int pause();\r
+    int unPause();\r
+    int reset();\r
+    int setVolume(int volume);\r
+    int mute();\r
+    int unMute();\r
+    int write(char *buf, int len);\r
+\r
+    // Writing Data to Audiodevice\r
+    virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos);\r
+    virtual long long SetStartOffset(long long curreftime, bool *rsync);\r
+  virtual void ResetTimeOffsets();\r
+\r
+private:\r
+  bool firstsynched;\r
+  long winvolume;\r
+#ifdef DEV\r
+    int test();\r
+#endif\r
+};\r
+\r
+#endif\r
 \r
diff --git a/box.cc b/box.cc
index a0476152f3beea6eeee1f607c2658f26839ebff5..02031552cdc03f40510476516103cdecb882fd78 100644 (file)
--- a/box.cc
+++ b/box.cc
@@ -171,7 +171,9 @@ void Box::drawPara(char* text, int x, int y, Colour& colour)
       textPos++;
     }
 
-    line[linePos++] = '\0';
+//    line[linePos++] = '\0';
+    if (linePos>=0) line[linePos++] = '\0'; //Here is the change
+
     if (printLine || (linePos > 1)) // if some text was put in line
     {
       drawText(line, x, ypos, colour);
index 6a9ac67c173cef3a067501f5fd5298c5be2e8961..540a6526187977d01a1ea0b7ca30f5bd462ffed7 100644 (file)
@@ -359,6 +359,9 @@ void Command::doStandby()
     VDR::getInstance()->disconnect();
     Led::getInstance()->off();
     isStandby = 1;
+#ifdef WIN32
+    stop(); //different behavoiur on windows, we exit
+#endif
   }
 }
 
index 2df6fe1f90ec8d871108c06e6448c316aef0bde2..e3d04cfee2392b9dfce8ce75f46668c9e5150207 100644 (file)
--- a/osdwin.cc
+++ b/osdwin.cc
@@ -218,8 +218,9 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){
                        d3ddevice->StretchRect(present,&sourcerect,d3drtsurf  ,&destrect,D3DTEXF_LINEAR);\r
                }\r
        } else {\r
+               VideoWin* video =(VideoWin*) Video::getInstance();\r
                //Clear Background\r
-               d3ddevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,255),1.0f,0);\r
+               if (!video->isVideoOn()) d3ddevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);\r
        }\r
        //Drawing the OSD\r
        if (d3ddevice->BeginScene()==D3D_OK) {\r
@@ -308,3 +309,11 @@ void OsdWin::setExternalDriving(DsAllocator* dsall) {
        dsallocator=dsall;\r
        external_driving=true;\r
 }\r
+\r
+void OsdWin::Blank() {\r
+       WaitForSingleObject(event,INFINITE);\r
+       BeginPainting();\r
+       d3ddevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);\r
+       EndPainting();\r
+}\r
+\r
index c5451263bf710a06766a22821fa34a71fbbb7e53..ad0b89c931a79b53a3fbb25dbf15e957f8e23cb3 100644 (file)
--- a/osdwin.h
+++ b/osdwin.h
@@ -61,6 +61,7 @@ class OsdWin : public Osd
        void BeginPainting();\r
        void EndPainting();\r
        void setExternalDriving(DsAllocator* dsall);\r
+       void Blank();\r
 private:\r
          LPDIRECT3D9 d3d;\r
          LPDIRECT3DDEVICE9 d3ddevice;\r
index 731019be5e31c7adb0b59d4534ac1fa9bf87597e..4475fdca058584203b396443153a2359d6b364bd 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -372,7 +372,9 @@ void Player::toggleFastForwardInt()
   else
   {
     ffwd = true;
+#ifndef WIN32
     afeed.disable();
+#endif
     audio->systemMuteOn();
     video->fastForward();
   }
@@ -399,7 +401,9 @@ void Player::toggleFastBackwardInt()
   else
   {
     fbwd = false;
+#ifndef WIN32
     afeed.disable();
+#endif
     audio->systemMuteOn();
 
     threadStop();
index 1d6fbc3354ad4e82dfb152d986c957557aadeac9..c4ca8cb5aee7b9b5b31009385fb68cf25c99fb82 100644 (file)
@@ -211,3 +211,9 @@ void RemoteWin::Signal() {
        SetEvent(event);\r
 }\r
 \r
+void RemoteWin::SendPower()\r
+{\r
+       curevent=POWER;\r
+       SetEvent(event);\r
+}\r
+\r
index 4d122355dc6aefde14d5b8201c8ba55b6341ad44..a4b11e403e6f4cd00638742d637b199cd6dd8aec 100644 (file)
@@ -1,58 +1,60 @@
-/*
-    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 REMOTEWIN_H
-#define REMOTEWIN_H
-
-#include <stdio.h>
-
-#include "defines.h"
-#include "log.h"
-#include "remote.h"
-
-#define _WIN32_WINNT 0x501
-#include <winsock2.h>
-#include <windowsx.h>
-
-
-
-class RemoteWin : public Remote
-{
-  public:
-    RemoteWin();
-    ~RemoteWin();
-
-    int init(char *devName);
-    int shutdown();
-    int getDevice();
-    UCHAR getButtonPress(int how);
-    void clearBuffer();
-    void Signal();
-    int ReceiveButtonVK(UINT button);//Windows Message from WND_PROC
-  int ReceiveButtonAP(UINT button);
-
-  private:
-    int initted;
-  bool signal;
-  UCHAR curevent;
-  HANDLE event;
-};
-
-#endif
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#ifndef REMOTEWIN_H\r
+#define REMOTEWIN_H\r
+\r
+#include <stdio.h>\r
+\r
+#include "defines.h"\r
+#include "log.h"\r
+#include "remote.h"\r
+\r
+#define _WIN32_WINNT 0x501\r
+#include <winsock2.h>\r
+#include <windowsx.h> \r
+\r
+\r
+\r
+class RemoteWin : public Remote\r
+{\r
+  public:\r
+    RemoteWin();\r
+    ~RemoteWin();\r
+\r
+    int init(char *devName);\r
+    int shutdown();\r
+    int getDevice();\r
+    UCHAR getButtonPress(int how);\r
+    void clearBuffer();\r
+    void Signal();\r
+    int ReceiveButtonVK(UINT button);//Windows Message from WND_PROC\r
+       int     ReceiveButtonAP(UINT button);\r
+       void SendPower();\r
+\r
+  private: \r
+    int initted;\r
+       bool signal;\r
+       UCHAR curevent;\r
+       HANDLE event;\r
+};\r
+\r
+#endif\r
+\r
index fc8c696e1fa0da77f9495dc1543d69e9dce98331..68232ab9f0177dc91595ed1633566cd631689141 100644 (file)
--- a/stream.cc
+++ b/stream.cc
@@ -36,7 +36,14 @@ Stream::~Stream()
 
 void Stream::shutdown()
 {
-  if (initted) free(outbuf);
+  if (initted) {
+         free(outbuf);
+#ifdef NEW_DEMUXER
+#ifdef WIN32
+  CloseHandle(mutex);
+#endif
+#endif
+  }
   initted = 0;
 
 }
@@ -51,13 +58,22 @@ int Stream::init(DrainTarget* tdt, int bufsize)
   bufferTail = 0;
   bufferMark = -1;
   initted = 1;
+#ifdef NEW_DEMUXER
+#ifndef WIN32
+  pthread_mutex_init(&mutex, NULL);
+#else
+  mutex=CreateMutex(NULL,FALSE,NULL);
+#endif
+#endif
   return 1;
 }
 
 void Stream::flush()
 {
 #ifdef NEW_DEMUXER
+  lock();
   mediapackets.clear();
+  unLock();
   if (draintarget) draintarget->ResetTimeOffsets();
 #endif
   bufferHead = 0;
@@ -141,7 +157,9 @@ int Stream::put(UCHAR* inbuf, int len,ULLONG curpos)
       bufferHead += len;
       ret = len;
       newPacket.pos_buffer=head;
+         lock();
       mediapackets.push_front(newPacket);
+         unLock();
     }
   }
   else if (len <= bufferSize - head)
@@ -154,7 +172,9 @@ int Stream::put(UCHAR* inbuf, int len,ULLONG curpos)
       bufferHead += len;
 
     newPacket.pos_buffer=head;
+       lock();
     mediapackets.push_front(newPacket);
+       unLock();
 
     ret = len;
   }
@@ -165,7 +185,9 @@ int Stream::put(UCHAR* inbuf, int len,ULLONG curpos)
     bufferHead = len;
     ret = len;
     newPacket.pos_buffer=0;
+       lock();
     mediapackets.push_front(newPacket);
+       unLock();
   }
   return ret;
 }
@@ -239,15 +261,19 @@ int Stream::drain()
   int tail = bufferTail;
   int mark = bufferMark;
   if (mark == -1 && tail > head) mark = bufferSize;
+  lock();
   MediaPacket cur_mp=mediapackets.back();
+  unLock();
   written=0;
-  written=dt->DeliverMediaSample(cur_mp,outbuf,&cur_packet_pos);
+  written=draintarget->DeliverMediaSample(cur_mp,outbuf,&cur_packet_pos);
 
   ret+=written;
 
   if (cur_packet_pos==cur_mp.length) {
     cur_packet_pos=0;
+       lock();
     mediapackets.pop_back();
+       unLock();
     if ((((ULONG)tail)+cur_mp.length) < ((ULONG)mark)) {
       bufferTail=tail+cur_mp.length;
     } else {
@@ -260,4 +286,25 @@ int Stream::drain()
   return ret;
 }
 
+void Stream::lock()
+{
+#ifndef WIN32
+  pthread_mutex_lock(&mutex);
+  logger->log("Player", Log::DEBUG, "LOCKED");
+
+#else
+   WaitForSingleObject(mutex, INFINITE );
+#endif
+}
+
+void Stream::unLock()
+{
+#ifndef WIN32
+  logger->log("Player", Log::DEBUG, "UNLOCKING");
+  pthread_mutex_unlock(&mutex);
+#else
+   ReleaseMutex(mutex);
+#endif
+}
+
 #endif
index 33d97c0d8cb2fc789e6978093b43d7fee1af40cf..db7e80ccf4dbb087af2681e441216f165032ca0c 100644 (file)
--- a/stream.h
+++ b/stream.h
@@ -24,6 +24,9 @@
 #include <stdlib.h>
 #ifndef WIN32
 #include <unistd.h>
+#else
+#include <winsock2.h>
+#include <windows.h>
 #endif
 #include <memory.h>
 #include "defines.h"
@@ -51,6 +54,13 @@ class Stream
 #ifdef NEW_DEMUXER
     MediaPacketList mediapackets;
     UINT cur_packet_pos;
+#ifndef WIN32
+    pthread_mutex_t mutex;
+#else
+  HANDLE mutex;
+#endif
+       void lock();
+       void unLock();
 #endif
 
     DrainTarget* draintarget;
index 533917126bdaa5a9765ef80f0116c42e67164c30..04c1d5acb1d62557c82fdf90919c8321ad5f7a24 100644 (file)
@@ -110,7 +110,7 @@ int Surface::drawTextCentre(char* text, int x, int y, ULONG rgba)
 
 int Surface::getCharWidth(char c)
 {
-  return font->width[c];
+  return font->width[(unsigned char) c];
 }
 
 int Surface::getFontHeight()
diff --git a/vdr.cc b/vdr.cc
index b89e58d76a0999530c98d84d56f25f0c0c17c44f..0efd189f47e2d2107a85a736b5366e55ae1b4a81 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -351,7 +351,10 @@ bool VDR::getRecordingsList(RecMan* recman)
     return false;
   }
 
-  recman->setStats(extractULONG(), extractULONG(), extractULONG());
+  ULONG totalSpace = extractULONG();
+  ULONG freeSpace = extractULONG();
+  ULONG percent = extractULONG();
+  recman->setStats(totalSpace, freeSpace, percent);
 
   ULONG start;
   char* name;
index 3462f6c3378cb9b821cf933c0f1286312a9a7434..487c019cb58f652f65f7cf8f24d5beafa2b29467 100644 (file)
-/*
-    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"
-#include "log.h"
-#include "dssourcefilter.h"
-#include "dsallocator.h"
-#include "vdr.h"
-
-void AdjustWindow();
-
-
-
-VideoWin::VideoWin()
-{
-  dsgraphbuilder=NULL;
-  dsmediacontrol=NULL;
-  dsvmrrenderer=NULL;
-  dsrefclock=NULL;
-  dsmediafilter=NULL;
-  sourcefilter=NULL;
-  allocatorvmr=NULL;
-  dsvmrsurfnotify=NULL;
-  filtermutex=CreateMutex(NULL,FALSE,NULL);
-  offsetnotset=true;
-  offsetvideonotset=true;
-  offsetaudionotset=true;
-  startoffset=0;
-  lastrefaudiotime=0;
-  lastrefvideotime=0;
-  lastreftimeBYTE=0;
-  lastreftimeRT=0;
-  firstsynched=false;
-  cur_audio_media_sample=NULL;
-  cur_video_media_sample=NULL;
-  videoon=true;
-  audioon=true;
-  pseudotvsize=0;
-  videoposx=0;
-  videoposy=0;
-
-
-
-}
-
-VideoWin::~VideoWin()
-{
-  CleanupDS();
-  CloseHandle(filtermutex);
-
-
-
-  instance = NULL;
-}
-
-int VideoWin::init(UCHAR tformat)
-{
-  if (initted) return 0;
-
-  initted = 1;
-  tvsize=Video::ASPECT16X9; //Internally Vomp should think we are a 16:9 TV
-  videoposx=0;
-  videoposy=0;
-
-  if (!setFormat(tformat)){ shutdown(); return 0; }
-  return 1;
-}
-
-int VideoWin::setTVsize(UCHAR ttvsize)
-{
-  pseudotvsize=ttvsize;
-  return 1;
-}
-
-int VideoWin::setDefaultAspect()
-{
-  return setAspectRatio(Video::ASPECT4X3);
-}
-
-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;
-  if (format == NTSC)
-  {
-    screenWidth = 720;
-    screenHeight = 480;
-  }
-  if (format == PAL)
-  {
-    screenWidth = 720;
-    screenHeight = 576;
-  }
-
-  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;
-  AdjustWindow();
-  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;
-  videoposx=0;
-  videoposy=0;
-  AdjustWindow();
-
-  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;
-  if (mode==QUARTER || mode==EIGHTH) {
-  videoposx=x;
-  videoposy=y;
-  }
-  return 1;
-}
-
-int VideoWin::sync()
-{
-  if (!initted) return 0;
-
-  return 1;
-}
-
-#ifdef DS_DEBUG // This stuff would not included in vomp due to lincemse restrcitions
-#include "dshelper.h"
-#endif
-
-#define DO_VIDEO
-
-int VideoWin::play()
-{
-  if (!initted) return 0;
-
-  //Build filter graph
-  HRESULT hres;
-
-  if (hres=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,
-    IID_IGraphBuilder,(void**)&dsgraphbuilder)!=S_OK) {
-      return 0;
-   }
-   #ifdef DS_DEBUG
-   AddToRot(dsgraphbuilder,&graphidentifier);
-   #endif
-   //This is just a try to see if building the graph works
-//   dsgraphbuilder->RenderFile(L"D:\\Projekte\\VTP Client\\test.mpa" ,NULL);
-   //So this is the real code, this prevents the feeder from calling noexisting objects!
-   WaitForSingleObject(filtermutex,INFINITE);
-   firstsynched=false;
-   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!");
-     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!");
-       CleanupDS();
-       ReleaseMutex(filtermutex);
-       return 0;
-     }
-   //}
-#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;
-    }
-   }
-#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);
-
-   dsgraphbuilder->QueryInterface(IID_IMediaControl,(void **) &dsmediacontrol);
-
-   dsmediacontrol->Run();
-   ReleaseMutex(filtermutex);
-  return 1;
-}
-
-int VideoWin::stop()
-{
-  if (!initted) return 0;
-
-  CleanupDS();
-
-
-  return 1;
-}
-
-int VideoWin::reset()
-{
-  if (!initted) return 0;
-  videoposx=0;
-  videoposy=0;
-
-  return 1;
-}
-
-int VideoWin::pause()
-{
-  if (!initted) return 0;
-  if (dsmediacontrol) dsmediacontrol->Pause();
-  return 1;
-}
-
-int VideoWin::unPause() // FIXME get rid - same as play!!
-{//No on windows this is not the same, I don't get rid of!
-  if (!initted) return 0;
-  if (dsmediacontrol) dsmediacontrol->Run();
-  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;
-}
-
-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;
-
-}
-
-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);
-}
-
-ULLONG VideoWin::frameNumberToTimecode(ULONG framenumber)
-{
-  if (format == PAL) return (ULLONG)(((double)framenumber * (double)90000) / (double)25);
-  else               return (ULLONG)(((double)framenumber * (double)90000) / (double)30);
-}
-
-void VideoWin::CleanupDS()
-{
-  WaitForSingleObject(filtermutex,INFINITE);
-  if (cur_audio_media_sample) {
-    cur_audio_media_sample->Release();
-    cur_audio_media_sample=NULL;
-  }
-  if (cur_video_media_sample) {
-    cur_video_media_sample->Release();
-    cur_video_media_sample=NULL;
-  }
-  if (dsvmrsurfnotify) {
-    dsvmrsurfnotify->Release();
-    dsvmrsurfnotify=NULL;
-  }
-  if (dsvmrrenderer) {
-    dsvmrrenderer->Release();
-    dsvmrrenderer=NULL;
-  }
-
-  if (allocatorvmr) {
-    allocatorvmr->Release();
-    allocatorvmr=NULL;
-  }
-
-  if (dsrefclock) {
-    dsrefclock->Release();
-    dsrefclock=NULL;
-  }
-  if (dsmediafilter) {
-    dsmediafilter->Release();
-    dsmediafilter=NULL;
-  }
-
-  if (dsmediacontrol) {
-    dsmediacontrol->Stop();
-    dsmediacontrol->Release();
-    dsmediacontrol=NULL;
-  }
-  if (dsgraphbuilder){
-#ifdef DS_DEBUG
-    RemoveFromRot(graphidentifier);
-#endif
-    dsgraphbuilder->Release();
-    dsgraphbuilder=NULL;
-    sourcefilter=NULL; //The Graph Builder destroys our SourceFilter
-  }
-  ReleaseMutex(filtermutex);
-
-}
-
-
-UINT VideoWin::DeliverMediaSample(MediaPacket packet,
-     UCHAR* buffer,
-     UINT *samplepos)
-{
-  /*First Check, if we have an audio sample*/
-#ifdef DO_VIDEO
-  /*First Check, if we have an audio sample*/
-
-  IMediaSample* ms=NULL;
-  REFERENCE_TIME reftime1=0;
-  REFERENCE_TIME reftime2=0;
-
-  UINT headerstrip=0;
-  if (packet.disconti) {
-    firstsynched=false;
-    DeliverVideoMediaSample();
-
-  }
-
-
-  /*Inspect PES-Header */
-
-  if (*samplepos==0) {//stripheader
-    headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;
-    *samplepos+=headerstrip;
-    if ( packet.synched ) {
-      DeliverVideoMediaSample();//write out old data
-   /*   if (packet.presentation_time<0) { //Preroll?
-        *samplepos=packet.length;//if we have not processed at least one
-        return packet.length;//synched packet ignore it!
-      }*/
-
-      reftime1=packet.presentation_time;
-      reftime2=reftime1+1;
-      firstsynched=true;
-    } else {
-      if (!firstsynched) {//
-        *samplepos=packet.length;//if we have not processed at least one
-        return packet.length;//synched packet ignore it!
-      }
-    }
-  }
-  BYTE *ms_buf;
-  UINT ms_length;
-  UINT ms_pos;
-  UINT haveToCopy;
-  if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample
-    samplepos=0;
-    MILLISLEEP(10);
-    return 0;
-  }
-  ms_pos=ms->GetActualDataLength();
-  ms_length=ms->GetSize();
-  haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
-  if ((ms_length-ms_pos)<1) {
-    DeliverVideoMediaSample(); //we are full!
-    if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample
-      samplepos=0;
-      MILLISLEEP(10);
-      return 0;
-    }
-    ms_pos=ms->GetActualDataLength();
-    ms_length=ms->GetSize();
-    haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);
-  }
-  ms->GetPointer(&ms_buf);
-
-
-  if (ms_pos==0) {//will only be changed on first packet
-    if (packet.disconti) {
-      ms->SetDiscontinuity(TRUE);
-    } else {
-      ms->SetDiscontinuity(FALSE);
-    }
-    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);
-    /*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->SetSyncPoint(TRUE);
-    }
-  }
-
-
-  memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);
-    ms->SetActualDataLength(haveToCopy+ms_pos);
-
-  *samplepos+=haveToCopy;
-
-  return haveToCopy+headerstrip;
-
-#else
-
-       *samplepos+=packet.length;
-      MILLISLEEP(0); //yet not implemented//bad idea
-       return packet.length;
-#endif
-}
-
-int VideoWin::getCurrentAudioMediaSample(IMediaSample** ms)
-{
-  //WaitForSingleObject(filtermutex,INFINITE);
-  if (!sourcefilter){
-  //  ReleaseMutex(filtermutex);
-    return 0;
-  }
-  if (cur_audio_media_sample) {
-    *ms=cur_audio_media_sample;//already open
-    return 1;
-  }
-  if (!sourcefilter->getCurrentAudioMediaSample(ms)) {
-  //  ReleaseMutex(filtermutex);
-  }
-  if (*ms) (*ms)->SetActualDataLength(0);
-  cur_audio_media_sample=*ms;
-  //Don't release the mutex before deliver
-  return 1;
-}
-
-int VideoWin::getCurrentVideoMediaSample(IMediaSample** ms)
-{
-  //WaitForSingleObject(filtermutex,INFINITE);
-  if (!sourcefilter){
-  //  ReleaseMutex(filtermutex);
-    return 0;
-  }
-  if (cur_video_media_sample) {
-    *ms=cur_video_media_sample;//already open
-    return 1;
-  }
-  if (!sourcefilter->getCurrentVideoMediaSample(ms)) {
-  //  ReleaseMutex(filtermutex);
-  }
-  if (*ms) (*ms)->SetActualDataLength(0);
-
-  cur_video_media_sample=*ms;
-  //Don't release the mutex before deliver
-  return 1;
-}
-
-int VideoWin::DeliverAudioMediaSample(){
-  if (cur_audio_media_sample) {
-    sourcefilter->DeliverAudioMediaSample(cur_audio_media_sample);
-    cur_audio_media_sample=NULL;
-  }
-  //ReleaseMutex(filtermutex);
-  return 1;
-}
-
-int VideoWin::DeliverVideoMediaSample(){
-  if (cur_video_media_sample) {
-    sourcefilter->DeliverVideoMediaSample(cur_video_media_sample);
-    cur_video_media_sample=NULL;
-  }
-  //ReleaseMutex(filtermutex);
-  return 1;
-}
-
-long long VideoWin::SetStartOffset(long long curreftime, bool *rsync)
-{
-  *rsync=false;
-  if (offsetnotset) {
-    startoffset=curreftime;//offset is set for audio
-    offsetnotset=false;
-    offsetvideonotset=false;
-
-
-  } else {
-    if (offsetvideonotset) {
-      offsetvideonotset=false;
-      *rsync=true;
-    } else {
-      if ( (curreftime-lastrefvideotime)>10000000LL
-        || (curreftime-lastrefvideotime)<-10000000LL) {//if pts jumps to big resync
-        startoffset+=curreftime-lastrefvideotime;
-        lastrefaudiotime+=curreftime-lastrefvideotime;
-        //*rsync=true;
-        offsetaudionotset=true;
-
-      }
-    }
-
-  }
-  lastrefvideotime=curreftime;
-  return startoffset;
-
-}
-
-long long VideoWin::SetStartAudioOffset(long long curreftime, bool *rsync)
-{
-  *rsync=false;
-  if (offsetnotset) {
-    startoffset=curreftime;
-    offsetnotset=false;
-    offsetaudionotset=false;
-  }else {
-    if (offsetaudionotset) {
-      offsetaudionotset=false;
-      *rsync=true;
-    } else {
-      if ( (curreftime-lastrefaudiotime)>10000000LL
-        || (curreftime-lastrefaudiotime)<-10000000LL) {//if pts jumps to big resync
-        startoffset+=curreftime-lastrefaudiotime;
-        lastrefvideotime+=curreftime-lastrefaudiotime;
-        //*rsync=true;
-        offsetvideonotset=true;
-
-      }
-    }
-
-  }
-  lastrefaudiotime=curreftime;
-  return startoffset;
-
-}
-void VideoWin::ResetTimeOffsets() {
-  offsetnotset=true; //called from demuxer
-  offsetvideonotset=true;
-  offsetaudionotset=true;
-  startoffset=0;
-  lastrefaudiotime=0;
-  lastrefvideotime=0;
-  lastreftimeBYTE=0;
-  lastreftimeRT=0;
-
-
-}
-
-
-#ifdef DEV
-int VideoWin::test()
-{
-  return 0;
-}
-
-int VideoWin::test2()
-{
-  return 0;
-}
-#endif
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#include "videowin.h"\r
+#include "log.h"\r
+#include "dssourcefilter.h"\r
+#include "dsallocator.h"\r
+#include "vdr.h"\r
+#include "osdwin.h"\r
+\r
+void AdjustWindow();\r
+\r
+\r
+\r
+VideoWin::VideoWin()\r
+{\r
+  dsgraphbuilder=NULL;\r
+  dsmediacontrol=NULL;\r
+  dsvmrrenderer=NULL;\r
+  dsrefclock=NULL;\r
+  dsmediafilter=NULL;\r
+  dsbasicaudio=NULL;\r
+  sourcefilter=NULL;\r
+  allocatorvmr=NULL;\r
+  cr_time=0;\r
+  dsvmrsurfnotify=NULL;\r
+  filtermutex=CreateMutex(NULL,FALSE,NULL);\r
+  offsetnotset=true;\r
+  offsetvideonotset=true;\r
+  offsetaudionotset=true;\r
+  startoffset=0;\r
+  lastrefaudiotime=0;\r
+  lastrefvideotime=0;\r
+  lastreftimeBYTE=0;\r
+  lastreftimeRT=0;\r
+  firstsynched=false;\r
+  cur_audio_media_sample=NULL;\r
+  cur_video_media_sample=NULL;\r
+  videoon=true;\r
+  audioon=true;\r
+  pseudotvsize=0;\r
+  videoposx=0;\r
+  videoposy=0;\r
+\r
+\r
+\r
+}\r
+\r
+VideoWin::~VideoWin()\r
+{\r
+  CleanupDS();\r
+  CloseHandle(filtermutex);\r
+\r
+\r
+\r
+  instance = NULL;\r
+}\r
+\r
+int VideoWin::init(UCHAR tformat)\r
+{\r
+  if (initted) return 0;\r
+\r
+  initted = 1;\r
+  tvsize=Video::ASPECT16X9; //Internally Vomp should think we are a 16:9 TV\r
+  videoposx=0;\r
+  videoposy=0;\r
+\r
+  if (!setFormat(tformat)){ shutdown(); return 0; }\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setTVsize(UCHAR ttvsize)\r
+{\r
+  pseudotvsize=ttvsize;\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setDefaultAspect()\r
+{\r
+  return setAspectRatio(Video::ASPECT4X3);\r
+}\r
+\r
+int VideoWin::shutdown()\r
+{\r
+  if (!initted) return 0;\r
+  initted = 0;\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setFormat(UCHAR tformat)\r
+{\r
+  if (!initted) return 0;\r
+  if ((tformat != PAL) && (tformat != NTSC)) return 0;\r
+  format = tformat;\r
+  if (format == NTSC)\r
+  {\r
+    screenWidth = 720;\r
+    screenHeight = 480;\r
+  }\r
+  if (format == PAL)\r
+  {\r
+    screenWidth = 720;\r
+    screenHeight = 576;\r
+  }\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setConnection(UCHAR tconnection)\r
+{\r
+  if (!initted) return 0;\r
+  if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0;\r
+  connection = tconnection;\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setAspectRatio(UCHAR taspectRatio)\r
+{\r
+  if (!initted) return 0;\r
+  if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0;\r
+  aspectRatio = taspectRatio;\r
+  AdjustWindow();\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setMode(UCHAR tmode)\r
+{\r
+  if (!initted) return 0;\r
+\r
+  //if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode\r
+\r
+  if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)\r
+      && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;\r
+  mode = tmode;\r
+  videoposx=0;\r
+  videoposy=0;\r
+  AdjustWindow();\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::signalOff()\r
+{\r
+  return 1;\r
+}\r
+\r
+int VideoWin::signalOn()\r
+{\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setSource()\r
+{\r
+  if (!initted) return 0;\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::setPosition(int x, int y)\r
+{\r
+  if (!initted) return 0;\r
+  if (mode==QUARTER || mode==EIGHTH) {\r
+  videoposx=x;\r
+  videoposy=y;\r
+  }\r
+  return 1;\r
+}\r
+\r
+int VideoWin::sync()\r
+{\r
+  if (!initted) return 0;\r
+\r
+  return 1;\r
+}\r
+\r
+#ifdef DS_DEBUG // This stuff would not included in vomp due to lincemse restrcitions\r
+#include "dshelper.h"\r
+#endif\r
+\r
+#define DO_VIDEO\r
+\r
+int VideoWin::play()\r
+{\r
+  if (!initted) return 0;\r
+\r
+  //Build filter graph\r
+  HRESULT hres;\r
+\r
+  if (hres=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,\r
+    IID_IGraphBuilder,(void**)&dsgraphbuilder)!=S_OK) {\r
+      return 0;\r
+   }\r
+   #ifdef DS_DEBUG\r
+   AddToRot(dsgraphbuilder,&graphidentifier);\r
+   #endif\r
+   //This is just a try to see if building the graph works\r
+//   dsgraphbuilder->RenderFile(L"D:\\Projekte\\VTP Client\\test.mpa" ,NULL);\r
+   //So this is the real code, this prevents the feeder from calling noexisting objects!\r
+   WaitForSingleObject(filtermutex,INFINITE);\r
+   firstsynched=false;\r
+   sourcefilter=new DsSourceFilter(); //Creating our Source filter for pushing Data\r
+   // to DirectShow\r
+   if (hres=dsgraphbuilder->AddFilter(sourcefilter,L"Vomp Win Source Filter")!=S_OK) {\r
+   Log::getInstance()->log("VideoWin", Log::WARN , "Failed adding Vomp Source Filter!");\r
+     CleanupDS();\r
+     ReleaseMutex(filtermutex);\r
+     return 0;\r
+   }\r
+   //if (audioon) {\r
+     if (hres=dsgraphbuilder->Render(sourcefilter->GetPin(0)/*audio*/)!=S_OK) {\r
+     Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering audio!");\r
+       CleanupDS();\r
+       ReleaseMutex(filtermutex);\r
+       return 0;\r
+     }\r
+   //}\r
+#ifdef DO_VIDEO\r
+    if (videoon) {\r
+    //We alloc the vmr9 as next step\r
+    if (hres=CoCreateInstance(CLSID_VideoMixingRenderer9,0,\r
+      CLSCTX_INPROC_SERVER,IID_IBaseFilter,(void**) &dsvmrrenderer)!=S_OK) {\r
+      Log::getInstance()->log("VideoWin", Log::WARN ,"Failed creating VMR9 renderer!");\r
+      CleanupDS();\r
+      ReleaseMutex(filtermutex);\r
+    }\r
+      /*VMR 9 stuff**/\r
+    if (hres=dsgraphbuilder->AddFilter(dsvmrrenderer,L"VMR9")!=S_OK) {\r
+      CleanupDS();\r
+      Log::getInstance()->log("VideoWin", Log::WARN ,"Failed adding VMR9 renderer!");\r
+      ReleaseMutex(filtermutex);\r
+      return 0;\r
+    }\r
+    IVMRFilterConfig9* vmrfilconfig;\r
+    if (dsvmrrenderer->QueryInterface(IID_IVMRFilterConfig9,(void**)&vmrfilconfig)!=S_OK) {\r
+      CleanupDS();\r
+      Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Filterconfig interface!");\r
+      ReleaseMutex(filtermutex);\r
+      return 0;\r
+    }\r
+    vmrfilconfig->SetRenderingMode(VMR9Mode_Renderless);\r
+    vmrfilconfig->Release();\r
+\r
+    if (dsvmrrenderer->QueryInterface(IID_IVMRSurfaceAllocatorNotify9,(void**)& dsvmrsurfnotify)!=S_OK) {\r
+      CleanupDS();\r
+      Log::getInstance()->log("VideoWin", Log::WARN ,"Failed getting VMR9 Surface Allocator interface!");\r
+      ReleaseMutex(filtermutex);\r
+      return 0;\r
+    }\r
+    allocatorvmr=new DsAllocator();\r
+    dsvmrsurfnotify->AdviseSurfaceAllocator(NULL,allocatorvmr);\r
+    allocatorvmr->AdviseNotify(dsvmrsurfnotify);\r
+\r
+\r
+\r
+    /*VMR 9 stuff end */\r
+    IFilterGraph2*fg2=NULL;\r
+    if (dsgraphbuilder->QueryInterface(IID_IFilterGraph2,(void**)&fg2)!=S_OK) {\r
+      Log::getInstance()->log("VideoWin", Log::WARN , "Failed querying for FilterGraph2 Interface!");\r
+      CleanupDS();\r
+      ReleaseMutex(filtermutex);\r
+      return 0;\r
+    }\r
+    if (hres=fg2->RenderEx(sourcefilter->GetPin(1)/*video*/,\r
+        AM_RENDEREX_RENDERTOEXISTINGRENDERERS,NULL)!=S_OK) {\r
+      Log::getInstance()->log("VideoWin", Log::WARN , "Failed rendering Video!");\r
+      CleanupDS();\r
+      ReleaseMutex(filtermutex);\r
+      return 0;\r
+    }\r
+   }\r
+#endif\r
+   if (hres=CoCreateInstance(CLSID_SystemClock,NULL,CLSCTX_INPROC_SERVER,\r
+    IID_IReferenceClock,(void**)&dsrefclock)!=S_OK) {\r
+      return 0;\r
+   }\r
+\r
+   dsgraphbuilder->QueryInterface(IID_IMediaFilter,(void **) &dsmediafilter);\r
+   dsmediafilter->SetSyncSource(dsrefclock);\r
+\r
+   dsgraphbuilder->QueryInterface(IID_IMediaControl,(void **) &dsmediacontrol);\r
+   dsgraphbuilder->QueryInterface(IID_IBasicAudio,(void **) &dsbasicaudio);    \r
+\r
+   dsmediacontrol->Run();\r
+   ReleaseMutex(filtermutex);\r
+  return 1;\r
+}\r
+\r
+int VideoWin::stop()\r
+{\r
+  if (!initted) return 0;\r
+\r
+  CleanupDS();\r
+\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::reset()\r
+{\r
+  if (!initted) return 0;\r
+  videoposx=0;\r
+  videoposy=0;\r
+  CleanupDS();\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::pause()\r
+{\r
+  if (!initted) return 0;\r
+  if (dsmediacontrol) dsmediacontrol->Pause();\r
+  return 1;\r
+}\r
+\r
+int VideoWin::unPause() // FIXME get rid - same as play!!\r
+{//No on windows this is not the same, I don't get rid of!\r
+  if (!initted) return 0;\r
+  if (dsmediacontrol) dsmediacontrol->Run();\r
+  return 1;\r
+}\r
+\r
+int VideoWin::fastForward()\r
+{\r
+  if (!initted) return 0;\r
+\r
+  return 1;\r
+}\r
+\r
+int VideoWin::unFastForward()\r
+{\r
+  if (!initted) return 0;\r
+  \r
+  return 1;\r
+}\r
+\r
+int VideoWin::attachFrameBuffer()\r
+{\r
+  if (!initted) return 0;\r
+  return 1;\r
+}\r
+\r
+int VideoWin::blank(void)\r
+{\r
+  ((OsdWin*)Osd::getInstance())->Blank();\r
+  return 1;\r
+}\r
+\r
+ULLONG VideoWin::getCurrentTimestamp()\r
+{\r
+       REFERENCE_TIME startoffset;\r
+       REFERENCE_TIME ncr_time;\r
+\r
+  if (!dsrefclock || !sourcefilter) return 0;\r
+       FILTER_STATE state;\r
+       sourcefilter->GetState(10,&state);\r
+\r
+       if (state==State_Running) dsrefclock->GetTime(&cr_time);\r
+       ncr_time=cr_time;\r
+  startoffset=sourcefilter->getStartOffset();\r
+       ncr_time-=startoffset;\r
+       ncr_time-=lastreftimeRT;\r
+  ULLONG result=frameNumberToTimecode(\r
+    VDR::getInstance()->frameNumberFromPosition(lastreftimeBYTE));\r
+       result+=(ULLONG)(ncr_time/10000LL*90LL);\r
+  return result;\r
+\r
+}\r
+\r
+ULONG VideoWin::timecodeToFrameNumber(ULLONG timecode)\r
+{\r
+  if (format == PAL) return (ULONG)(((double)timecode / (double)90000) * (double)25);\r
+  else               return (ULONG)(((double)timecode / (double)90000) * (double)30);\r
+}\r
+\r
+ULLONG VideoWin::frameNumberToTimecode(ULONG framenumber)\r
+{\r
+  if (format == PAL) return (ULLONG)(((double)framenumber * (double)90000) / (double)25);\r
+  else               return (ULLONG)(((double)framenumber * (double)90000) / (double)30);\r
+}\r
+\r
+void VideoWin::CleanupDS()\r
+{\r
+  WaitForSingleObject(filtermutex,INFINITE);\r
+  if (cur_audio_media_sample) {\r
+    cur_audio_media_sample->Release();\r
+    cur_audio_media_sample=NULL;\r
+  }\r
+  if (cur_video_media_sample) {\r
+    cur_video_media_sample->Release();\r
+    cur_video_media_sample=NULL;\r
+  }\r
+  if (dsbasicaudio) {\r
+         dsbasicaudio->Release();\r
+         dsbasicaudio=NULL;\r
+  }\r
+  if (dsvmrsurfnotify) {\r
+    dsvmrsurfnotify->Release();\r
+    dsvmrsurfnotify=NULL;\r
+  }\r
+  if (dsvmrrenderer) {\r
+    dsvmrrenderer->Release();\r
+    dsvmrrenderer=NULL;\r
+  }\r
+\r
+  if (allocatorvmr) {\r
+    allocatorvmr->Release();\r
+    allocatorvmr=NULL;\r
+  }\r
+\r
+  if (dsrefclock) {\r
+    dsrefclock->Release();\r
+    dsrefclock=NULL;\r
+  }\r
+  if (dsmediafilter) {\r
+    dsmediafilter->Release();\r
+    dsmediafilter=NULL;\r
+  }\r
+\r
+\r
+  if (dsmediacontrol) {\r
+    dsmediacontrol->Stop();\r
+    dsmediacontrol->Release();\r
+    dsmediacontrol=NULL;\r
+  }\r
+  if (dsgraphbuilder){\r
+#ifdef DS_DEBUG\r
+    RemoveFromRot(graphidentifier);\r
+#endif\r
+    dsgraphbuilder->Release();\r
+    dsgraphbuilder=NULL;\r
+    sourcefilter=NULL; //The Graph Builder destroys our SourceFilter\r
+  }\r
+  ReleaseMutex(filtermutex);\r
+\r
+}\r
+\r
+\r
+UINT VideoWin::DeliverMediaSample(MediaPacket packet,\r
+     UCHAR* buffer,\r
+     UINT *samplepos)\r
+{\r
+  /*First Check, if we have an audio sample*/\r
+#ifdef DO_VIDEO\r
+  /*First Check, if we have an audio sample*/\r
+\r
+  IMediaSample* ms=NULL;\r
+  REFERENCE_TIME reftime1=0;\r
+  REFERENCE_TIME reftime2=0;\r
+\r
+  UINT headerstrip=0;\r
+  if (packet.disconti) {\r
+    firstsynched=false;\r
+    DeliverVideoMediaSample();\r
+\r
+  }\r
+\r
+\r
+  /*Inspect PES-Header */\r
+\r
+  if (*samplepos==0) {//stripheader\r
+    headerstrip=buffer[packet.pos_buffer+8]+9/*is this right*/;\r
+    *samplepos+=headerstrip;\r
+    if ( packet.synched ) {\r
+      DeliverVideoMediaSample();//write out old data\r
+   /*   if (packet.presentation_time<0) { //Preroll?\r
+        *samplepos=packet.length;//if we have not processed at least one\r
+        return packet.length;//synched packet ignore it!\r
+      }*/\r
+\r
+      reftime1=packet.presentation_time;\r
+      reftime2=reftime1+1;\r
+      firstsynched=true;\r
+    } else {\r
+      if (!firstsynched) {//\r
+        *samplepos=packet.length;//if we have not processed at least one\r
+        return packet.length;//synched packet ignore it!\r
+      }\r
+    }\r
+  }\r
+  BYTE *ms_buf;\r
+  UINT ms_length;\r
+  UINT ms_pos;\r
+  UINT haveToCopy;\r
+  if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample\r
+    samplepos=0;\r
+    MILLISLEEP(10);\r
+    return 0;\r
+  }\r
+  ms_pos=ms->GetActualDataLength();\r
+  ms_length=ms->GetSize();\r
+  haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);\r
+  if ((ms_length-ms_pos)<1) {\r
+    DeliverVideoMediaSample(); //we are full!\r
+    if (!getCurrentVideoMediaSample(&ms) || ms==NULL) {// get the current sample\r
+      samplepos=0;\r
+      MILLISLEEP(10);\r
+      return 0;\r
+    }\r
+    ms_pos=ms->GetActualDataLength();\r
+    ms_length=ms->GetSize();\r
+    haveToCopy=min(ms_length-ms_pos,packet.length-*samplepos);\r
+  }\r
+  ms->GetPointer(&ms_buf);\r
+\r
+\r
+  if (ms_pos==0) {//will only be changed on first packet\r
+    if (packet.disconti) {\r
+      ms->SetDiscontinuity(TRUE);\r
+    } else {\r
+      ms->SetDiscontinuity(FALSE);\r
+    }\r
+    if (packet.synched) {\r
+      ms->SetSyncPoint(TRUE);\r
+      ms->SetTime(&reftime1,&reftime2);\r
+      //ms->SetTime(NULL,NULL);\r
+      ms->SetMediaTime(NULL, NULL);\r
+    if (reftime1<0) ms->SetPreroll(TRUE);\r
+    else ms->SetPreroll(FALSE);\r
+    /*Timecode handling*/\r
+    lastreftimeRT=reftime1;\r
+    lastreftimeBYTE=packet.recording_byte_pos;\r
+\r
+    }else {\r
+      ms->SetSyncPoint(FALSE);\r
+      ms->SetTime(NULL,NULL);\r
+      ms->SetMediaTime(NULL, NULL);\r
+    ms->SetPreroll(FALSE);\r
+\r
+    //  ms->SetSyncPoint(TRUE);\r
+    }\r
+  }\r
+\r
+\r
+  memcpy(ms_buf+ms_pos,buffer+packet.pos_buffer+*samplepos,haveToCopy);\r
+    ms->SetActualDataLength(haveToCopy+ms_pos);\r
+\r
+  *samplepos+=haveToCopy;\r
+\r
+  return haveToCopy+headerstrip;\r
+\r
+#else\r
+\r
+       *samplepos+=packet.length;\r
+      MILLISLEEP(0); //yet not implemented//bad idea\r
+       return packet.length;\r
+#endif\r
+}\r
+\r
+int VideoWin::getCurrentAudioMediaSample(IMediaSample** ms)\r
+{\r
+  //WaitForSingleObject(filtermutex,INFINITE);\r
+  if (!sourcefilter){\r
+  //  ReleaseMutex(filtermutex);\r
+    return 0;\r
+  }\r
+  if (cur_audio_media_sample) {\r
+    *ms=cur_audio_media_sample;//already open\r
+    return 1;\r
+  }\r
+  if (!sourcefilter->getCurrentAudioMediaSample(ms)) {\r
+  //  ReleaseMutex(filtermutex);\r
+  }\r
+  if (*ms) (*ms)->SetActualDataLength(0);\r
+  cur_audio_media_sample=*ms;\r
+  //Don't release the mutex before deliver\r
+  return 1;\r
+}\r
+\r
+int VideoWin::getCurrentVideoMediaSample(IMediaSample** ms)\r
+{\r
+  //WaitForSingleObject(filtermutex,INFINITE);\r
+  if (!sourcefilter){\r
+  //  ReleaseMutex(filtermutex);\r
+    return 0;\r
+  }\r
+  if (cur_video_media_sample) {\r
+    *ms=cur_video_media_sample;//already open\r
+    return 1;\r
+  }\r
+  if (!sourcefilter->getCurrentVideoMediaSample(ms)) {\r
+  //  ReleaseMutex(filtermutex);\r
+  }\r
+  if (*ms) (*ms)->SetActualDataLength(0);\r
+\r
+  cur_video_media_sample=*ms;\r
+  //Don't release the mutex before deliver\r
+  return 1;\r
+}\r
+\r
+int VideoWin::DeliverAudioMediaSample(){\r
+  if (cur_audio_media_sample) {\r
+    sourcefilter->DeliverAudioMediaSample(cur_audio_media_sample);\r
+    cur_audio_media_sample=NULL;\r
+  }\r
+  //ReleaseMutex(filtermutex);\r
+  return 1;\r
+}\r
+\r
+int VideoWin::DeliverVideoMediaSample(){\r
+  if (cur_video_media_sample) {\r
+    sourcefilter->DeliverVideoMediaSample(cur_video_media_sample);\r
+    cur_video_media_sample=NULL;\r
+  }\r
+  //ReleaseMutex(filtermutex);\r
+  return 1;\r
+}\r
+\r
+long long VideoWin::SetStartOffset(long long curreftime, bool *rsync)\r
+{\r
+  *rsync=false;\r
+  if (offsetnotset) {\r
+    startoffset=curreftime;//offset is set for audio\r
+    offsetnotset=false;\r
+    offsetvideonotset=false;\r
+\r
+\r
+  } else {\r
+    if (offsetvideonotset) {\r
+      offsetvideonotset=false;\r
+      *rsync=true;\r
+    } else {\r
+      if ( (curreftime-lastrefvideotime)>10000000LL\r
+        || (curreftime-lastrefvideotime)<-10000000LL) {//if pts jumps to big resync\r
+        startoffset+=curreftime-lastrefvideotime;\r
+        lastrefaudiotime+=curreftime-lastrefvideotime;\r
+        //*rsync=true;\r
+        offsetaudionotset=true;\r
+\r
+      }\r
+    }\r
+\r
+  }\r
+\r
+  lastrefvideotime=curreftime;\r
+  \r
+  return startoffset;\r
+\r
+}\r
+\r
+long long VideoWin::SetStartAudioOffset(long long curreftime, bool *rsync)\r
+{\r
+  *rsync=false;\r
+  if (offsetnotset) {\r
+    startoffset=curreftime;\r
+    offsetnotset=false;\r
+    offsetaudionotset=false;\r
+  }else {\r
+    if (offsetaudionotset) {\r
+      offsetaudionotset=false;\r
+      *rsync=true;\r
+    } else {\r
+      if ( (curreftime-lastrefaudiotime)>10000000LL\r
+        || (curreftime-lastrefaudiotime)<-10000000LL) {//if pts jumps to big resync\r
+        startoffset+=curreftime-lastrefaudiotime;\r
+        lastrefvideotime+=curreftime-lastrefaudiotime;\r
+        //*rsync=true;\r
+        offsetvideonotset=true;\r
+\r
+      }\r
+    }\r
+\r
+  }\r
+  lastrefaudiotime=curreftime;\r
+  return startoffset;\r
+\r
+}\r
+void VideoWin::ResetTimeOffsets() {\r
+  offsetnotset=true; //called from demuxer\r
+  offsetvideonotset=true;\r
+  offsetaudionotset=true;\r
+  startoffset=0;\r
+  lastrefaudiotime=0;\r
+  lastrefvideotime=0;\r
+  lastreftimeBYTE=0;\r
+  lastreftimeRT=0;\r
+\r
+\r
+}\r
+\r
+void VideoWin::SetAudioVolume(long volume)\r
+{\r
+       if (dsbasicaudio) dsbasicaudio->put_Volume(volume);\r
+}\r
+\r
+#ifdef DEV\r
+int VideoWin::test()\r
+{\r
+  return 0;\r
+}\r
+\r
+int VideoWin::test2()\r
+{\r
+  return 0;\r
+}\r
+#endif\r
 \r
index 5e01c3df5d5f266d55f1b4a75b483e870d1e5e7f..c6b6db8d182adcd0e3647ed43a360fefdcdd926d 100644 (file)
-/*
-    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 <stdio.h>
-#include <string.h>
-#include <winsock2.h>
-#include <dshow.h>
-#include <d3d9.h>
-#include <vmr9.h>
-
-#include "defines.h"
-#include "video.h"
-
-#define DS_DEBUG
-
-class DsSourceFilter;
-class DsAllocator;
-
-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
-  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();
-    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);
-  ULLONG frameNumberToTimecode(ULONG framenumber);
-    ULLONG getCurrentTimestamp();
-
-    //Writing Data to Videodevice
-    virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos);
-
-    int getCurrentAudioMediaSample(IMediaSample** ms);
-    int DeliverAudioMediaSample();
-
-    int getCurrentVideoMediaSample(IMediaSample** ms);
-    int DeliverVideoMediaSample();
-
-    virtual long long SetStartOffset(long long curreftime, bool *rsync);
-    long long SetStartAudioOffset(long long curreftime, bool *rsync);
-  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;};
-
-#ifdef DEV
-    int test();
-    int test2();
-#endif
-private:
-  IMediaControl* dsmediacontrol;
-  IGraphBuilder* dsgraphbuilder;
-  IMediaSample* cur_audio_media_sample;
-  IMediaSample* cur_video_media_sample;
-  IBaseFilter* dsvmrrenderer;
-  IVMRSurfaceAllocatorNotify9  *dsvmrsurfnotify;
-  IReferenceClock *dsrefclock;
-  IMediaFilter* dsmediafilter;
-
-  DsSourceFilter* sourcefilter;
-  DsAllocator* allocatorvmr;
-  HANDLE filtermutex;
-  void CleanupDS();
-  bool offsetnotset;
-  bool offsetvideonotset;
-  bool offsetaudionotset;
-  long long startoffset;
-  long long lastrefvideotime;
-  long long lastrefaudiotime;
-
-  bool firstsynched;
-  bool audioon;
-  bool videoon;
-  UCHAR pseudotvsize;
-  REFERENCE_TIME lastreftimeRT;
-  ULLONG lastreftimeBYTE;
-  unsigned int videoposx;
-  unsigned int videoposy;
-#ifdef DS_DEBUG
-  DWORD graphidentifier;
-#endif
-};
-
-#endif
+/*\r
+    Copyright 2004-2005 Chris Tallon\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+#ifndef VIDEOWIN_H\r
+#define VIDEOWIN_H\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <winsock2.h>\r
+#include <dshow.h>\r
+#include <d3d9.h>\r
+#include <vmr9.h>\r
+\r
+#include "defines.h"\r
+#include "video.h"\r
+\r
+//#define DS_DEBUG\r
+\r
+class DsSourceFilter;\r
+class DsAllocator;\r
+\r
+class VideoWin : public Video\r
+{\r
+  public:\r
+    VideoWin();\r
+    ~VideoWin();\r
+\r
+    int init(UCHAR format);\r
+    int shutdown();\r
+\r
+    int setFormat(UCHAR format);\r
+    int setConnection(UCHAR connection);\r
+    int setAspectRatio(UCHAR aspectRatio);   // This one does the pin 8 scart widescreen switching\r
+  UCHAR getAspectRatio(){return aspectRatio;};\r
+  UCHAR getMode(){return mode;};\r
+  UCHAR getPseudoTVsize() {return pseudotvsize;};\r
+  int setMode(UCHAR mode);\r
+    int setTVsize(UCHAR size);               // Is the TV a widescreen?\r
+    int setDefaultAspect();\r
+    int setSource();\r
+    int setPosition(int x, int y);\r
+    int sync();\r
+    int play();\r
+    int stop();\r
+    int pause();\r
+    int unPause();\r
+    int fastForward();\r
+    int unFastForward();\r
+    int reset();\r
+    int blank();\r
+    int signalOn();\r
+    int signalOff();\r
+    int attachFrameBuffer(); // What does this do?\r
+    ULONG timecodeToFrameNumber(ULLONG timecode);\r
+  ULLONG frameNumberToTimecode(ULONG framenumber);\r
+    ULLONG getCurrentTimestamp();\r
+\r
+    //Writing Data to Videodevice\r
+    virtual UINT DeliverMediaSample(MediaPacket packet, UCHAR* buffer, UINT *samplepos);\r
+\r
+    int getCurrentAudioMediaSample(IMediaSample** ms);\r
+    int DeliverAudioMediaSample();\r
+\r
+    int getCurrentVideoMediaSample(IMediaSample** ms);\r
+    int DeliverVideoMediaSample();\r
+\r
+    virtual long long SetStartOffset(long long curreftime, bool *rsync);\r
+    long long SetStartAudioOffset(long long curreftime, bool *rsync);\r
+  virtual void ResetTimeOffsets();\r
+\r
+    void SetAudioState(bool state){audioon=state;};\r
+       void SetAudioVolume(long volume);\r
+\r
+    void turnVideoOn(){videoon=true;};\r
+    void turnVideoOff(){videoon=false;};\r
+\r
+  unsigned int getPosx() {return videoposx;};\r
+  unsigned int getPosy() {return videoposy;};\r
+  bool isVideoOn() {return videoon;};\r
+\r
+#ifdef DEV\r
+    int test();\r
+    int test2();\r
+#endif\r
+private:\r
+  IMediaControl* dsmediacontrol;\r
+\r
+  IGraphBuilder* dsgraphbuilder;\r
+  IMediaSample* cur_audio_media_sample;\r
+  IMediaSample* cur_video_media_sample;\r
+  IBaseFilter* dsvmrrenderer;\r
+  IVMRSurfaceAllocatorNotify9  *dsvmrsurfnotify;\r
+  IReferenceClock *dsrefclock;\r
+  IMediaFilter* dsmediafilter;\r
+  IBasicAudio* dsbasicaudio;\r
+  REFERENCE_TIME cr_time;\r
+\r
+  DsSourceFilter* sourcefilter;\r
+  DsAllocator* allocatorvmr;\r
+  HANDLE filtermutex;\r
+  void CleanupDS();\r
+  bool offsetnotset;\r
+  bool offsetvideonotset;\r
+  bool offsetaudionotset;\r
+  long long startoffset;\r
+  long long lastrefvideotime;\r
+  long long lastrefaudiotime;\r
+\r
+  bool firstsynched;\r
+  bool audioon;\r
+  bool videoon;\r
+  UCHAR pseudotvsize;\r
+  REFERENCE_TIME lastreftimeRT;\r
+  ULLONG lastreftimeBYTE;\r
+  unsigned int videoposx;\r
+  unsigned int videoposy;\r
+#ifdef DS_DEBUG\r
+  DWORD graphidentifier;\r
+#endif\r
+};\r
+\r
+#endif\r
 \r
index e6e945926f36cd40f9b6152bdb30442581272834..4bd2d3155bed3621b8c03a3540276c52a28ab0b4 100644 (file)
@@ -447,8 +447,8 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)
    case WM_DESTROY: {\r
           //TODO: call command\r
           logger->log("Core", Log::NOTICE, "Window closed, shutting down...");\r
-       command->stop(); // FIXME this is probably not safe - use the messaging system / is that even safe?\r
-          ((RemoteWin*)Remote::getInstance())->Signal();\r
+        \r
+          ((RemoteWin*)Remote::getInstance())->SendPower();\r
           PostQuitMessage(0);\r
        }break;\r
    case WM_SIZING: {\r
@@ -506,6 +506,14 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam)
                        return DefWindowProc(wind, msg, wparam, lparam);\r
                }\r
                break;\r
+       case WM_SYSCOMMAND:\r
+               if (wparam==SC_MAXIMIZE) {\r
+                       ToggleFullscreen();\r
+                       return 0;\r
+               } else {\r
+                       return DefWindowProc(wind,msg,wparam, lparam);\r
+               }\r
+               break;\r
     default:\r
         return DefWindowProc(wind, msg, wparam, lparam);\r
     }\r