dshow-plugin.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <obs-module.h>
  2. #include <strsafe.h>
  3. #include <strmif.h>
  4. #ifdef VIRTUALCAM_AVAILABLE
  5. #include "virtualcam-guid.h"
  6. #endif
  7. OBS_DECLARE_MODULE()
  8. OBS_MODULE_USE_DEFAULT_LOCALE("win-dshow", "en-US")
  9. MODULE_EXPORT const char *obs_module_description(void)
  10. {
  11. return "Windows DirectShow source/encoder";
  12. }
  13. extern void RegisterDShowSource();
  14. extern void RegisterDShowEncoders();
  15. #ifdef VIRTUALCAM_AVAILABLE
  16. extern "C" struct obs_output_info virtualcam_info;
  17. static bool vcam_installed(bool b64)
  18. {
  19. wchar_t cls_str[CHARS_IN_GUID];
  20. wchar_t temp[MAX_PATH];
  21. HKEY key = nullptr;
  22. StringFromGUID2(CLSID_OBS_VirtualVideo, cls_str, CHARS_IN_GUID);
  23. StringCbPrintf(temp, sizeof(temp), L"CLSID\\%s", cls_str);
  24. DWORD flags = KEY_READ;
  25. flags |= b64 ? KEY_WOW64_64KEY : KEY_WOW64_32KEY;
  26. LSTATUS status = RegOpenKeyExW(HKEY_CLASSES_ROOT, temp, 0, flags, &key);
  27. if (status != ERROR_SUCCESS) {
  28. return false;
  29. }
  30. RegCloseKey(key);
  31. return true;
  32. }
  33. #endif
  34. bool obs_module_load(void)
  35. {
  36. RegisterDShowSource();
  37. RegisterDShowEncoders();
  38. #ifdef VIRTUALCAM_AVAILABLE
  39. if (vcam_installed(false))
  40. obs_register_output(&virtualcam_info);
  41. #endif
  42. return true;
  43. }