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.

174 lines
6.2 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 IQUICKTIME_H
  10. #define IQUICKTIME_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. // Handle to a QUICKTIME
  22. //-----------------------------------------------------------------------------
  23. typedef unsigned short QUICKTIMEHandle_t;
  24. enum
  25. {
  26. QUICKTIMEHANDLE_INVALID = (QUICKTIMEHandle_t)~0
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Handle to an QUICKTIME material
  30. //-----------------------------------------------------------------------------
  31. typedef unsigned short QUICKTIMEMaterial_t;
  32. enum
  33. {
  34. QUICKTIMEMATERIAL_INVALID = (QUICKTIMEMaterial_t)~0
  35. };
  36. typedef unsigned int MovieHandle_t;
  37. const MovieHandle_t cInvalidMovieHandle = (MovieHandle_t) ~0;
  38. enum eVideoSystemStatus
  39. {
  40. cVideoSystem_OK = 0,
  41. cVideoSystem_NotInstalled,
  42. cVideoSystem_NotCurrentVersion,
  43. cVideoSystem_InitializationError,
  44. cVideoSystem_ForceInt32 = 0x7FFFFFFF // Make sure eNum is (at least) an int32
  45. };
  46. enum eVideoSystemFeatures
  47. {
  48. cVideoSystem_NoFeatures = 0x00000000,
  49. cVideoSystem_PlayMoviesFromFile = 0x00000001,
  50. cVideoSystem_RenderVideoFrameToMaterial = 0x00000002,
  51. cVideoSystem_EncodeVideoToFile = 0x00000010,
  52. cVideoSystem_EncodeAudioToFile = 0x00000020,
  53. cVideoSystem_ForceInt32a = 0x7FFFFFFF
  54. };
  55. DEFINE_ENUM_BITWISE_OPERATORS( eVideoSystemFeatures );
  56. enum eVideoEncodeQuality
  57. {
  58. cVEQuality_Min = 0,
  59. cVEQuality_Low = 25,
  60. cVEQuality_Normal = 50,
  61. cVEQuality_High = 75,
  62. cVEQuality_Max = 100
  63. };
  64. // -----------------------------------------------------------------------
  65. // eVideoFrameFormat_t - bit format for quicktime video frames
  66. // -----------------------------------------------------------------------
  67. enum eVideoFrameFormat_t
  68. {
  69. cVFF_Undefined = 0,
  70. cVFF_R8G8B8A8_32Bit,
  71. cVFF_R8G8B8_24Bit,
  72. cVFF_Count, // Auto list counter
  73. cVFF_ForceInt32 = 0x7FFFFFFF // Make sure eNum is (at least) an int32
  74. };
  75. // -----------------------------------------------------------------------
  76. // eAudioSourceFormat_t - Audio encoding source options
  77. // -----------------------------------------------------------------------
  78. enum eAudioSourceFormat_t
  79. {
  80. cASF_Undefined = 0,
  81. cASF_None,
  82. cASF_16BitPCMStereo,
  83. cASF_Count, // Auto list counter
  84. cASF_ForceInt32 = 0x7FFFFFFF // Make sure eNum is (at least) an int32
  85. };
  86. //-----------------------------------------------------------------------------
  87. // IQuickTimeMovieMaker interface
  88. //-----------------------------------------------------------------------------
  89. class IQuickTimeMovieMaker : public IBaseInterface
  90. {
  91. public:
  92. virtual bool CreateNewMovieFile( MovieHandle_t &theMovie, const char *pFilename, int nWidth, int nHeight, int nFps, eVideoEncodeQuality quality, eAudioSourceFormat_t srcAudioFormat = cASF_None, int audioSampleRate = 0 ) = 0;
  93. virtual bool AppendVideoFrame( MovieHandle_t theMovie, unsigned char *pFrame ) = 0;
  94. virtual bool AppendAudioSamples( MovieHandle_t theMovie, void *sampleBuffer, size_t sampleSize ) = 0;
  95. virtual bool FinishMovie( MovieHandle_t theMovie, bool success = true ) = 0;
  96. };
  97. //-----------------------------------------------------------------------------
  98. // Main QUICKTIME interface
  99. //-----------------------------------------------------------------------------
  100. #define QUICKTIME_INTERFACE_VERSION "IQuickTime002"
  101. class IQuickTime : public IAppSystem
  102. {
  103. public:
  104. virtual bool IsVideoSystemAvailable() = 0;
  105. virtual eVideoSystemStatus GetVideoSystemStatus() = 0;
  106. virtual eVideoSystemFeatures GetVideoSystemFeatures() = 0;
  107. // Create/destroy a QUICKTIME material (a materialsystem IMaterial)
  108. virtual QUICKTIMEMaterial_t CreateMaterial( const char *pMaterialName, const char *pFileName, const char *pPathID ) = 0;
  109. virtual void DestroyMaterial( QUICKTIMEMaterial_t hMaterial ) = 0;
  110. // Create/destroy a quicktime movie maker, which will encode audio/video
  111. virtual IQuickTimeMovieMaker *CreateMovieMaker() = 0;
  112. virtual void DestroyMovieMaker( IQuickTimeMovieMaker *&pMovieMaker ) = 0;
  113. // Update the frame (if necessary)
  114. virtual bool Update( QUICKTIMEMaterial_t hMaterial ) = 0;
  115. // Gets the IMaterial associated with an BINK material
  116. virtual IMaterial* GetMaterial( QUICKTIMEMaterial_t hMaterial ) = 0;
  117. // Returns the max texture coordinate of the BINK
  118. virtual void GetTexCoordRange( QUICKTIMEMaterial_t hMaterial, float *pMaxU, float *pMaxV ) = 0;
  119. // Returns the frame size of the QUICKTIME Image Frame (stored in a subrect of the material itself)
  120. virtual void GetFrameSize( QUICKTIMEMaterial_t hMaterial, int *pWidth, int *pHeight ) = 0;
  121. // Returns the frame rate of the QUICKTIME
  122. virtual int GetFrameRate( QUICKTIMEMaterial_t hMaterial ) = 0;
  123. // Sets the frame for an BINK material (use instead of SetTime)
  124. virtual void SetFrame( QUICKTIMEMaterial_t hMaterial, float flFrame ) = 0;
  125. // Returns the total frame count of the BINK
  126. virtual int GetFrameCount( QUICKTIMEMaterial_t hMaterial ) = 0;
  127. virtual bool SetSoundDevice( void *pDevice ) = 0;
  128. // Plays a given MOV file until it completes or the user presses ESC, SPACE, or ENTER
  129. virtual void PlayQuicktimeVideo( const char *filename, void *mainWindow, int windowWidth, int windowHeight, int desktopWidth, int desktopHeight, bool windowed, float forcedMinTime ) = 0;
  130. // Estimates the size of a recorded movie
  131. virtual bool EstimateMovieSize( unsigned long &EstSize, int nWidth, int nHeight, int nFps, float duration, eVideoEncodeQuality quality, eAudioSourceFormat_t srcAudioFormat = cASF_None, int audioSampleRate = 0 ) = 0;
  132. };
  133. #endif // IQUICKTIME_H