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.

108 lines
3.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef BASERECORDINGSESSIONBLOCK_H
  5. #define BASERECORDINGSESSIONBLOCK_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "replay/replayhandle.h"
  11. #include "replay/basereplayserializeable.h"
  12. #include "genericpersistentmanager.h"
  13. #include "baserecordingsession.h"
  14. #include "utlstring.h"
  15. #include "compression.h"
  16. //----------------------------------------------------------------------------------------
  17. class KeyValues;
  18. class CBaseReplayContext;
  19. class IReplayContext;
  20. //----------------------------------------------------------------------------------------
  21. class CBaseRecordingSessionBlock : public CBaseReplaySerializeable
  22. {
  23. typedef CBaseReplaySerializeable BaseClass;
  24. public:
  25. CBaseRecordingSessionBlock( IReplayContext *pContext );
  26. //
  27. // IReplaySerializeable
  28. //
  29. virtual const char *GetSubKeyTitle() const;
  30. virtual const char *GetPath() const;
  31. virtual bool Read( KeyValues *pIn );
  32. virtual void Write( KeyValues *pOut );
  33. virtual void OnDelete();
  34. enum RemoteStatus_t
  35. {
  36. STATUS_INVALID = -2,
  37. STATUS_ERROR = -1,
  38. STATUS_WRITING,
  39. STATUS_READYFORDOWNLOAD,
  40. MAX_STATUS
  41. };
  42. static const char *GetRemoteStatusStringSafe( RemoteStatus_t nStatus );
  43. enum Error_t
  44. {
  45. ERROR_NONE,
  46. ERROR_NOTONDISK, // The replay was lost somehow - eg a server crash before the replay had a chance to write to disk
  47. ERROR_WRITEFAILED, // The disk write somehow failed
  48. };
  49. bool ReadHash( KeyValues *pIn, const char *pHashName );
  50. void WriteHash( KeyValues *pOut, const char *pHashName ) const;
  51. bool HasValidHash() const;
  52. // Get a filled out sub key specifically for writing to the session info file
  53. void WriteSessionInfoDataToBuffer( CUtlBuffer &buf ) const;
  54. RemoteStatus_t m_nRemoteStatus; // This represents the block's status on the server
  55. Error_t m_nHttpError;
  56. int32 m_iReconstruction; // For client-side reconstruction of sessions, this represents the index of the given block
  57. ReplayHandle_t m_hSession; // What session is this partial replay a part of?
  58. uint32 m_uFileSize; // Size in bytes of the binary block file (if compressed, this represents the compressed file size)
  59. uint32 m_uUncompressedSize; // If compressed, this represents the uncompressed file size
  60. char m_szFullFilename[512]; // Filename for the .block file itself.
  61. // NOTE: On the server, full path info is written - on client, only filename is written
  62. CompressorType_t m_nCompressorType; // What type of compressor/decompressor was/should be used, if any? Can be COMPRESSORTYPE_INVALID if not compressed.
  63. uint8 m_aHash[16]; // Server sets this and client compares to validate downloaded block data
  64. bool m_bHashValid; // Do we have a valid hash?
  65. IReplayContext *m_pContext;
  66. };
  67. //----------------------------------------------------------------------------------------
  68. //
  69. // For serializing blocks - format version implied in header.
  70. //
  71. // In case this format changes, we have some legroom (m_aUnused).
  72. //
  73. struct RecordingSessionBlockSpec_t
  74. {
  75. int32 m_iReconstruction;
  76. uint8 m_uRemoteStatus;
  77. uint8 m_aHash[16];
  78. int8 m_nCompressorType;
  79. uint32 m_uFileSize;
  80. uint32 m_uUncompressedSize;
  81. uint8 m_aUnused[8];
  82. };
  83. #define MIN_SESSION_INFO_PAYLOAD_SIZE sizeof( RecordingSessionBlockSpec_t )
  84. //----------------------------------------------------------------------------------------
  85. #endif // BASERECORDINGSESSIONBLOCK_H