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.

132 lines
4.3 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 IBIK_H
  10. #define IBIK_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 BINK
  22. //-----------------------------------------------------------------------------
  23. struct BIKParams_t
  24. {
  25. BIKParams_t() :
  26. m_nFrameRate( 0 ), m_nFrameScale( 1 ), m_nWidth( 0 ), m_nHeight( 0 ),
  27. m_nSampleRate( 0 ), m_nSampleBits( 0 ), m_nNumChannels( 0 )
  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. };
  47. //-----------------------------------------------------------------------------
  48. // Handle to an BINK
  49. //-----------------------------------------------------------------------------
  50. typedef unsigned short BIKHandle_t;
  51. enum
  52. {
  53. BIKHANDLE_INVALID = (BIKHandle_t)~0
  54. };
  55. //-----------------------------------------------------------------------------
  56. // Handle to an BINK material
  57. //-----------------------------------------------------------------------------
  58. typedef unsigned short BIKMaterial_t;
  59. enum
  60. {
  61. BIKMATERIAL_INVALID = (BIKMaterial_t)~0
  62. };
  63. //-----------------------------------------------------------------------------
  64. // Main AVI interface
  65. //-----------------------------------------------------------------------------
  66. #define BIK_INTERFACE_VERSION "VBik001"
  67. class IBik : public IAppSystem
  68. {
  69. public:
  70. // Create/destroy a BINK material (a materialsystem IMaterial)
  71. virtual BIKMaterial_t CreateMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID ) = 0;
  72. virtual void DestroyMaterial( BIKMaterial_t hMaterial ) = 0;
  73. // Update the frame (if necessary)
  74. virtual bool Update( BIKMaterial_t hMaterial ) = 0;
  75. // Gets the IMaterial associated with an BINK material
  76. virtual IMaterial* GetMaterial( BIKMaterial_t hMaterial ) = 0;
  77. // Returns the max texture coordinate of the BINK
  78. virtual void GetTexCoordRange( BIKMaterial_t hMaterial, float *pMaxU, float *pMaxV ) = 0;
  79. // Returns the frame size of the BINK (stored in a subrect of the material itself)
  80. virtual void GetFrameSize( BIKMaterial_t hMaterial, int *pWidth, int *pHeight ) = 0;
  81. // Returns the frame rate of the BINK
  82. virtual int GetFrameRate( BIKMaterial_t hMaterial ) = 0;
  83. // Returns the total frame count of the BINK
  84. virtual int GetFrameCount( BIKMaterial_t hMaterial ) = 0;
  85. // Sets the frame for an BINK material (use instead of SetTime)
  86. virtual void SetFrame( BIKMaterial_t hMaterial, float flFrame ) = 0;
  87. #ifdef WIN32
  88. #if !defined( _X360 )
  89. // Sets the direct sound device that Bink will decode to
  90. virtual bool SetDirectSoundDevice( void *pDevice ) = 0;
  91. #else
  92. //needs to be called after xaudio is initialized
  93. virtual bool HookXAudio( void ) = 0;
  94. #endif
  95. #elif defined( LINUX )
  96. // Sets the SDL device that Bink will decode to
  97. virtual bool SetSDLDevice( int frequency, uint16 format, int nchannels ) = 0;
  98. // Called to mix in Bink audio. Returns true if audio was mixed in, false otherwise.
  99. virtual bool SDLMixerAudioCallback( void *stream, int len ) = 0;
  100. #endif
  101. // Plays a given Bink file until it completes or the user presses ESC, SPACE, or ENTER
  102. virtual void PlayBinkVideo( const char *filename, void *mainWindow, int width, int height, float forcedMinTime ) = 0;
  103. };
  104. #endif // IBIK_H