home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DMO / DMOSample / state.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  1.4 KB  |  58 lines

  1. //------------------------------------------------------------------------------
  2. // File: State.h
  3. //
  4. // Desc: DirectShow sample code - definition of CStreamState class.
  5. //       Provides state machine for picture start codes and timestamps.
  6. //
  7. // Copyright (c) 2000-2001 Microsoft Corporation.  All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10.  
  11. //  We need to know:
  12. //
  13. //    - The time stamp to associate with a picture start code
  14. //    - The next time stamp
  15. //
  16. //  State:
  17. //
  18. //       m_cbBytes - number of valid bytes of start code so far
  19. //       m_arTS[4] - array of all the timestamps
  20. //                   m_cbBytes+1 entries are valid
  21.  
  22.  
  23.  
  24. //  Not really invalid but unlikely enough for sample code.
  25. static const REFERENCE_TIME INVALID_TIME = _I64_MAX;
  26.  
  27.  
  28. class CStreamState
  29. {
  30. private:
  31.  
  32.     DWORD m_cbBytes;
  33.     struct {
  34.         bool           bValid;
  35.         REFERENCE_TIME rt;
  36.     } m_arTS[4];
  37.     REFERENCE_TIME m_rt;
  38.     BYTE m_bGOPData[4];
  39.     DWORD m_dwTimeCode;
  40.     DWORD m_dwNextTimeCode;
  41.  
  42. public:
  43.     CStreamState()
  44.     {
  45.         Reset();
  46.     }
  47.     //  Returns true if a start code was identifed
  48.     bool NextByte(BYTE bData);
  49.     void TimeStamp(REFERENCE_TIME rt);
  50.     REFERENCE_TIME PictureTime(DWORD *pdwTimeCode) const
  51.     {
  52.         *pdwTimeCode = m_dwTimeCode;
  53.         return m_rt;
  54.     }
  55.     void Reset();
  56. };
  57.  
  58.