plugin_audio_dsp_utils.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (C) 2013 Mamadou DIOP
  2. * Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. */
  19. #ifndef PLUGIN_AUDIO_DSP_UTILS_H
  20. #define PLUGIN_AUDIO_DSP_UTILS_H
  21. #include "plugin_audio_dsp_config.h"
  22. #include <Windows.h>
  23. #include <mfidl.h>
  24. #undef CHECK_HR
  25. // In CHECK_HR(x) When (x) is a function it will be executed twice when used in "TSK_DEBUG_ERROR(x)" and "If(x)"
  26. #define CHECK_HR(x) { HRESULT __hr__ = (x); if (FAILED(__hr__)) { TSK_DEBUG_ERROR("Operation Failed (%08x)", __hr__); goto bail; } }
  27. #if !defined(PLUGIN_AUDIO_DSP_MILLIS_TO_100NS)
  28. # define PLUGIN_AUDIO_DSP_MILLIS_TO_100NS(MILLIS) (((LONGLONG)(MILLIS)) * 10000ui64)
  29. #endif
  30. #undef SafeRelease
  31. #define SafeRelease(ppT) \
  32. { \
  33. if (*ppT) \
  34. { \
  35. (*ppT)->Release(); \
  36. *ppT = NULL; \
  37. } \
  38. }
  39. class AudioDSPUtils
  40. {
  41. public:
  42. static HRESULT Startup();
  43. static HRESULT Shutdown();
  44. static HRESULT CreatePCMAudioType(
  45. UINT32 sampleRate, // Samples per second
  46. UINT32 bitsPerSample, // Bits per sample
  47. UINT32 cChannels, // Number of channels
  48. IMFMediaType **ppType // Receives a pointer to the media type.
  49. );
  50. static HRESULT CreateMediaSample(
  51. DWORD cbData, // Maximum buffer size
  52. IMFSample **ppSample // Receives the sample
  53. );
  54. static HRESULT MoInitMediaType(
  55. UINT32 sampleRate, // Samples per second
  56. UINT32 bitsPerSample, // Bits per sample
  57. UINT32 cChannels, // Number of channels
  58. DMO_MEDIA_TYPE *pType // The media type to initialize. Must be freed using MoFreeMediaType.
  59. );
  60. private:
  61. static bool g_bStarted;
  62. };
  63. #endif /* PLUGIN_AUDIO_DSP_UTILS_H */