AudioFormat.h 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef NULLSOFT_IN_WMVDRM_AUDIOFORMAT_H
  2. #define NULLSOFT_IN_WMVDRM_AUDIOFORMAT_H
  3. #include <mmreg.h>
  4. #include <wmsdk.h>
  5. class AudioFormat
  6. {
  7. public:
  8. AudioFormat() : waveFormat(0)
  9. {
  10. }
  11. ~AudioFormat()
  12. {
  13. delete [] waveFormat;
  14. }
  15. unsigned long AudioBytesToSamples(unsigned long bytes);
  16. unsigned long AudioSamplesToBytes(unsigned long samples);
  17. unsigned long AudioBytesToMilliseconds(unsigned long bytes);
  18. unsigned long AudioMillisecondsToBytes(DWORD milliseconds);
  19. unsigned long AudioDurationToBytes(QWORD duration);
  20. unsigned long AudioSamplesToMilliseconds(unsigned long samples);
  21. long Channels();
  22. long ValidBits();
  23. long BitSize();
  24. long SampleRate();
  25. //protected:
  26. void Open(WM_MEDIA_TYPE *mediaType)
  27. {
  28. delete[] waveFormat;
  29. waveFormat = (WAVEFORMATEXTENSIBLE *) new unsigned char[mediaType->cbFormat];
  30. memcpy(waveFormat, mediaType->pbFormat, mediaType->cbFormat);
  31. }
  32. void Close()
  33. {
  34. delete [] waveFormat;
  35. waveFormat=0;
  36. }
  37. private:
  38. WAVEFORMATEXTENSIBLE *waveFormat;
  39. };
  40. #endif