dshow-plugin.cpp 1.3 KB

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