VPStreamData.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #if !defined(VPSTREAMDATA_HPP)
  2. #define VPSTREAMDATA_HPP
  3. //______________________________________________________________________________
  4. //
  5. // VPStreamData.hpp
  6. //
  7. //______________________________________________________________________________
  8. // Include Files and Forward Declarations
  9. #include "PlayerModel.hpp"
  10. #include <vector>
  11. #include <iosfwd>
  12. namespace on2vp
  13. {
  14. //______________________________________________________________________________
  15. // Macro, Enumeration, and Constant Definitions
  16. //______________________________________________________________________________
  17. // Type, Struct, and Class Definitions
  18. //--------------------------------------
  19. class StreamData
  20. {
  21. friend std::ostream& operator<<(std::ostream& os, const StreamData& sd);
  22. public:
  23. StreamData();
  24. StreamData(const unsigned char* const pData, unsigned long ulSize);
  25. StreamData(const StreamData& sd);
  26. ~StreamData();
  27. StreamData& operator=(const StreamData& sd);
  28. unsigned long versionOrig() const;
  29. unsigned long sizeOrig() const;
  30. unsigned long version() const;
  31. unsigned long size() const;
  32. const unsigned char* data() const;
  33. int data(const unsigned char* pData, unsigned long ulSize);
  34. // Interpreted data
  35. const PlayerModel& playerModel() const;
  36. PlayerModel& playerModel();
  37. bool encrypted() const;
  38. void encrypted(bool bEncrypted);
  39. private:
  40. class VersionInfo
  41. {
  42. public:
  43. VersionInfo(long lVersion, long lSize, bool bExtra) :
  44. m_lVersion(lVersion),
  45. m_lSize(lSize),
  46. m_bExtra(bExtra)
  47. {
  48. }
  49. long version() const
  50. {
  51. return m_lVersion;
  52. }
  53. long size() const
  54. {
  55. return m_lSize;
  56. }
  57. bool extra() const
  58. {
  59. return m_bExtra;
  60. }
  61. private:
  62. long m_lVersion;
  63. long m_lSize;
  64. bool m_bExtra;
  65. };
  66. enum
  67. {
  68. VersionMax = 6
  69. };
  70. void init_();
  71. int extract_(const unsigned char* pData, unsigned long ulSize);
  72. void update_();
  73. static std::vector<VersionInfo> m_vVersionInfo;
  74. unsigned long m_ulVersionOrig;
  75. unsigned long m_ulSizeOrig;
  76. unsigned char* m_pData;
  77. long m_lDataSize;
  78. // Interpreted data
  79. PlayerModel m_pm;
  80. bool m_bEncrypted;
  81. };
  82. //______________________________________________________________________________
  83. // Object and Function Declarations
  84. //______________________________________________________________________________
  85. // Object and Function Definitions
  86. } // namespace on2vp
  87. #endif // VPSTREAMDATA_HPP