Counter Strike : Global Offensive Source Code
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.

61 lines
2.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Define the IVoiceCodec interface.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef IVOICECODEC_H
  8. #define IVOICECODEC_H
  9. #pragma once
  10. #include "interface.h"
  11. #define BYTES_PER_SAMPLE 2
  12. // This interface is for voice codecs to implement.
  13. // Codecs are guaranteed to be called with the exact output from Compress into Decompress (ie:
  14. // data won't be stuck together and sent to Decompress).
  15. // Decompress is not guaranteed to be called in any specific order relative to Compress, but
  16. // Codecs maintain state between calls, so it is best to call Compress with consecutive voice data
  17. // and decompress likewise. If you call it out of order, it will sound wierd.
  18. // In the same vein, calling Decompress twice with the same data is a bad idea since the state will be
  19. // expecting the next block of data, not the same block.
  20. class IVoiceCodec
  21. {
  22. protected:
  23. virtual ~IVoiceCodec() {}
  24. public:
  25. // Initialize the object. The uncompressed format is always 8-bit signed mono.
  26. virtual bool Init( int quality )=0;
  27. // Use this to delete the object.
  28. virtual void Release()=0;
  29. // Compress the voice data.
  30. // pUncompressed - 16-bit signed mono voice data.
  31. // maxCompressedBytes - The length of the pCompressed buffer. Don't exceed this.
  32. // bFinal - Set to true on the last call to Compress (the user stopped talking).
  33. // Some codecs like big block sizes and will hang onto data you give them in Compress calls.
  34. // When you call with bFinal, the codec will give you compressed data no matter what.
  35. // Return the number of bytes you filled into pCompressed.
  36. virtual int Compress(const char *pUncompressed, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal)=0;
  37. // Decompress voice data. pUncompressed is 16-bit signed mono.
  38. virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes)=0;
  39. // Some codecs maintain state between Compress and Decompress calls. This should clear that state.
  40. virtual bool ResetState()=0;
  41. };
  42. #endif // IVOICECODEC_H