DSUtils.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #ifndef PLUGIN_DSHOW_DUTILS_H
  19. #define PLUGIN_DSHOW_DUTILS_H
  20. #include "plugin_dshow_config.h"
  21. #include <strmif.h>
  22. // --------------------------------------------------------------------------------
  23. #define SAFE_RELEASE(x) if ((x)) { (x)->Release(); (x) = NULL; }
  24. #define SAFE_DELETE_PTR(x) if ((x)) { delete (x); (x) = NULL; }
  25. #define SAFE_DELETE_ARRAY(x) if ((x)) { delete[] (x); (x) = NULL; }
  26. // In CHECK_HR(x) When (x) is a function it will be executed twice when used in "TSK_DEBUG_ERROR(x)" and "If(x)"
  27. #define CHECK_HR(x) { HRESULT __hr__ = (x); if (FAILED(__hr__)) { TSK_DEBUG_ERROR("Operation Failed (%08x)", __hr__); goto bail; } }
  28. #define DS_NANOS_TO_100NS(NANOS) (((LONGLONG)(NANOS)) / 100ui64)
  29. #define DS_MICROS_TO_100NS(MICROS) (((LONGLONG)(MICROS)) * 10ui64)
  30. #define DS_MILLIS_TO_100NS(MILLIS) (((LONGLONG)(MILLIS)) * 10000ui64)
  31. #define DS_SECONDS_TO_100NS(SEC) (((LONGLONG)(SEC)) * 10000000ui64)
  32. #define DS_SECONDS_FROM_100NS(SEC) (10000000ui64/(SEC))
  33. #define COCREATE(cls, iid, target) \
  34. CoCreateInstance(cls, NULL, CLSCTX_INPROC_SERVER, iid, reinterpret_cast<void**>(&target))
  35. #define QUERY(source, iid, target) \
  36. source->QueryInterface(iid, reinterpret_cast<void**>(&target))
  37. // --------------------------------------------------------------------------------
  38. #define FILTER_WEBCAM _T("WEBCAM")
  39. #define FILTER_SCREENCAST _T("SCREENCAST")
  40. #define FILTER_FRAMERATE _T("TDSHOW_FRAMERATE")
  41. #define FILTER_OUTPUT _T("TDSHOW_OUTPUT")
  42. #define FITLER_SAMPLE_GRABBER _T("SAMPLE_GRABBER")
  43. #define FILTER_AVI_DECOMPRESSOR _T("AVI_DECOMPRESSOR")
  44. #define FILTER_COLORSPACE_CONVERTOR _T("COLORSPACE_CONVERTOR")
  45. #define FILTER_NULL_RENDERER _T("NULL_RENDERER")
  46. #define FILTER_VIDEO_RENDERER _T("VIDEO_RENDERER")
  47. #define FILTER_VIDEO_MIXING_RENDERER _T("VIDEO_MIXING_RENDERER")
  48. #define FILTER_COLOR_CONVERTOR_565 _T("COLOR_CONVERTOR_565")
  49. // --------------------------------------------------------------------------------
  50. HWND GetMainWindow();
  51. bool IsMainThread();
  52. bool IsD3D9Supported();
  53. IPin *GetPin(IBaseFilter *pFilter, PIN_DIRECTION dir);
  54. HRESULT ConnectFilters(IGraphBuilder *graphBuilder, IBaseFilter *source, IBaseFilter *destination, AM_MEDIA_TYPE *mediaType = NULL);
  55. HRESULT DisconnectFilters(IGraphBuilder *graphBuilder, IBaseFilter *source, IBaseFilter *destination);
  56. bool DisconnectAllFilters(IGraphBuilder *graphBuilder);
  57. bool RemoveAllFilters(IGraphBuilder *graphBuilder);
  58. int createOnCurrentThead(HWND hWnd, void** ppRet, BOOL display, BOOL screnCast);
  59. int createOnUIThead(HWND hWnd, void** ppRet, BOOL display, BOOL screnCast);
  60. #endif /* PLUGIN_DSHOW_DUTILS_H */