home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / playerthread.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  3.8 KB  |  154 lines

  1. /* 
  2.  *  Player.h
  3.  *
  4.  *    Copyright (C) Alberto Vigata - July 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24.  
  25. #include "flasktypes.h"
  26. #include "thread.h"
  27. #include ".\video\videowrapper.h"
  28. #include "MasterClock.h"
  29. #include "PostProcessing.h"
  30. #include "flvideosink.h"
  31.  
  32.  
  33. #ifndef PLAYERTHREAD_H
  34. #define PLAYERTHREAD_H
  35.  
  36. // Create worker thread for the player
  37. class CPlayerThread : public CFlThread
  38. {
  39. public:
  40.     //Constructor
  41.     CPlayerThread::CPlayerThread( VideoWrapper *pVideoDecoder, HANDLE hMainWnd, CMasterClock *pMasterClock,
  42.                                   TPPost *ppinit, int idctindex,  bool reconsprogressive, FlVideoSink *pVidSink =NULL)
  43.     {
  44.       m_pMasterClock = pMasterClock;
  45.       m_pVideoDecoder = pVideoDecoder;
  46.       m_hMainWnd = hMainWnd;
  47.       m_lPlayFrameCount = 0;
  48.       m_pp = *ppinit;
  49.       m_pVidSink = pVidSink;
  50.       m_nIdctIndex = idctindex;
  51.       m_bReconsProgressive = reconsprogressive;
  52.       ScheduleCommand(seekBeginning);
  53.     };
  54.  
  55.     void Seek(ui64 nSeekPos)
  56.     {
  57.       SendCommand(seek, nSeekPos);
  58.     }
  59.  
  60.     void SeekKeyFrame(ui64 nSeekPos)
  61.     {
  62.       SignalCommand(seekKeyFrame, nSeekPos);
  63.     }
  64.     void SeekBeginning()
  65.     {
  66.       ScheduleCommand(seekBeginning);
  67.     }
  68.     void SeekEnd()
  69.     {
  70.       ScheduleCommand(seekEnd);
  71.     }
  72.     void NextFrame()
  73.     {
  74.       SignalCommand(nextFrame);
  75.     }
  76.     void PrevFrame()
  77.     {
  78.       SignalCommand(prevFrame);
  79.     }
  80.     void NextKeyFrame()
  81.     {
  82.       ScheduleCommand(nextKeyFrame);
  83.     }
  84.     void PrevKeyFrame()
  85.     {
  86.       ScheduleCommand(prevKeyFrame);
  87.     }
  88.     void FastForward()
  89.     {
  90.       ScheduleCommand(fastForward);
  91.     }    
  92.     void FastRewind()
  93.     {
  94.       ScheduleCommand(fastRewind);
  95.     }    
  96.     void Play()
  97.     {
  98.       ScheduleCommand(play);
  99.     }    
  100.     void PlayBack()
  101.     {
  102.       ScheduleCommand(playBack);
  103.     }
  104.  
  105.     void Stop()
  106.     {
  107.       ScheduleCommand(stop);
  108.     }
  109.  
  110.     ui64 GetFrameStartPos()
  111.     {
  112.       return SendCommand(getFrameStartPos);
  113.     }
  114.  
  115.     enum playerStates 
  116.     {
  117.       stStopped, stPlaying, stPlayingBack, stNextFrame, stPrevFrame, stNextKeyFrame,
  118.         stPrevKeyFrame, stFastForward, stFastRewind
  119.     };
  120.     
  121.     playerStates GetState(){return m_nState;}
  122.     LONG GetPlayFrameCount(){ return m_lPlayFrameCount; }
  123.  
  124.     void SetPPSettings( TPPost *pp )
  125.     {
  126.       SendCommand( ppChange, (ui64)pp );
  127.     }
  128.  
  129. private: 
  130.  
  131.     enum playerCommands
  132.     {
  133.         seek = THREAD_COMMAND_COUNT, seekKeyFrame, seekBeginning, seekEnd, nextFrame,
  134.         prevFrame, nextKeyFrame, prevKeyFrame, 
  135.         fastForward, fastRewind, getFrameStartPos ,play, playBack, stop, ppChange
  136.     };
  137.     HANDLE m_hMainWnd;
  138.  
  139.     // Actual running thread
  140.     DWORD ThreadProc();
  141.     VideoWrapper  *m_pVideoDecoder;
  142.     playerStates   m_nState;
  143.     LONG           m_lPlayFrameCount;
  144.     CMasterClock  *m_pMasterClock;
  145.     TPPost         m_pp;
  146.     ui32           m_nIdctIndex;
  147.     bool           m_bReconsProgressive;
  148.  
  149.     FlVideoSink   *m_pVidSink;
  150.  
  151.  
  152. };
  153.  
  154. #endif