Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // The copyright to the contents herein is the property of Valve, L.L.C.
  4. // The contents may be used and/or copied only with the written permission of
  5. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  6. // the agreement/contract under which the contents have been supplied.
  7. //
  8. //=============================================================================
  9. #ifndef IAVI_H
  10. #define IAVI_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "appframework/IAppSystem.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. struct BGR888_t;
  19. class IMaterial;
  20. //-----------------------------------------------------------------------------
  21. // Parameters for creating a new AVI
  22. //-----------------------------------------------------------------------------
  23. struct AVIParams_t
  24. {
  25. AVIParams_t() :
  26. m_nFrameRate( 0 ), m_nFrameScale( 1 ), m_nWidth( 0 ), m_nHeight( 0 ),
  27. m_nSampleRate( 0 ), m_nSampleBits( 0 ), m_nNumChannels( 0 ), m_bGetCodecFromUser( true )
  28. {
  29. m_pFileName[ 0 ] = 0;
  30. }
  31. char m_pFileName[ 256 ];
  32. char m_pPathID[ 256 ];
  33. // fps = m_nFrameRate / m_nFrameScale
  34. // for integer framerates, set framerate to the fps, and framescale to 1
  35. // for ntsc-style framerates like 29.97 (or 23.976 or 59.94),
  36. // set framerate to 30,000 (or 24,000 or 60,000) and framescale to 1001
  37. // yes, framescale is an odd naming choice, but it matching MS's AVI api
  38. int m_nFrameRate;
  39. int m_nFrameScale;
  40. int m_nWidth;
  41. int m_nHeight;
  42. // Sound/.wav info
  43. int m_nSampleRate;
  44. int m_nSampleBits;
  45. int m_nNumChannels;
  46. // The user will be asked to select a compressor if true, otherwise the
  47. // previous or default will be used.
  48. bool m_bGetCodecFromUser;
  49. };
  50. //-----------------------------------------------------------------------------
  51. // Handle to an AVI
  52. //-----------------------------------------------------------------------------
  53. typedef unsigned short AVIHandle_t;
  54. enum
  55. {
  56. AVIHANDLE_INVALID = (AVIHandle_t)~0
  57. };
  58. //-----------------------------------------------------------------------------
  59. // Handle to an AVI material
  60. //-----------------------------------------------------------------------------
  61. typedef unsigned short AVIMaterial_t;
  62. enum
  63. {
  64. AVIMATERIAL_INVALID = (AVIMaterial_t)~0
  65. };
  66. //-----------------------------------------------------------------------------
  67. // Main AVI interface
  68. //-----------------------------------------------------------------------------
  69. #define AVI_INTERFACE_VERSION "VAvi001"
  70. class IAvi : public IAppSystem
  71. {
  72. public:
  73. // Necessary to call this before any other AVI interface methods
  74. virtual void SetMainWindow( void* hWnd ) = 0;
  75. // Start/stop recording an AVI
  76. virtual AVIHandle_t StartAVI( const AVIParams_t& params ) = 0;
  77. virtual void FinishAVI( AVIHandle_t handle ) = 0;
  78. // Add frames to an AVI
  79. virtual void AppendMovieSound( AVIHandle_t h, short *buf, size_t bufsize ) = 0;
  80. virtual void AppendMovieFrame( AVIHandle_t h, const BGR888_t *pRGBData ) = 0;
  81. // Create/destroy an AVI material (a materialsystem IMaterial)
  82. virtual AVIMaterial_t CreateAVIMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID ) = 0;
  83. virtual void DestroyAVIMaterial( AVIMaterial_t hMaterial ) = 0;
  84. // Sets the time for an AVI material
  85. virtual void SetTime( AVIMaterial_t hMaterial, float flTime ) = 0;
  86. // Gets the IMaterial associated with an AVI material
  87. virtual IMaterial* GetMaterial( AVIMaterial_t hMaterial ) = 0;
  88. // Returns the max texture coordinate of the AVI
  89. virtual void GetTexCoordRange( AVIMaterial_t hMaterial, float *pMaxU, float *pMaxV ) = 0;
  90. // Returns the frame size of the AVI (stored in a subrect of the material itself)
  91. virtual void GetFrameSize( AVIMaterial_t hMaterial, int *pWidth, int *pHeight ) = 0;
  92. // Returns the frame rate of the AVI
  93. virtual int GetFrameRate( AVIMaterial_t hMaterial ) = 0;
  94. // Returns the total frame count of the AVI
  95. virtual int GetFrameCount( AVIMaterial_t hMaterial ) = 0;
  96. // Sets the frame for an AVI material (use instead of SetTime)
  97. virtual void SetFrame( AVIMaterial_t hMaterial, float flFrame ) = 0;
  98. // Plays a given AVI/WMV file until it completes or the user presses ESC, SPACE, or ENTER
  99. virtual void PlayWindowsMediaVideo( const char *filename, void *mainWindow, int width, int height, float forcedMinTime ) = 0;
  100. };
  101. #endif // IAVI_H