dshow-plugin.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. extern "C" struct obs_output_info virtualcam_info;
  14. static bool vcam_installed(bool b64)
  15. {
  16. wchar_t cls_str[CHARS_IN_GUID];
  17. wchar_t temp[MAX_PATH];
  18. HKEY key = nullptr;
  19. StringFromGUID2(CLSID_OBS_VirtualVideo, cls_str, CHARS_IN_GUID);
  20. StringCbPrintf(temp, sizeof(temp), L"CLSID\\%s", cls_str);
  21. DWORD flags = KEY_READ;
  22. flags |= b64 ? KEY_WOW64_64KEY : KEY_WOW64_32KEY;
  23. LSTATUS status = RegOpenKeyExW(HKEY_CLASSES_ROOT, temp, 0, flags, &key);
  24. if (status != ERROR_SUCCESS) {
  25. return false;
  26. }
  27. RegCloseKey(key);
  28. return true;
  29. }
  30. bool obs_module_load(void)
  31. {
  32. RegisterDShowSource();
  33. RegisterDShowEncoders();
  34. obs_register_output(&virtualcam_info);
  35. bool installed = vcam_installed(false);
  36. obs_data_t *obs_settings = obs_data_create();
  37. obs_data_set_bool(obs_settings, "vcamEnabled", installed);
  38. obs_apply_private_data(obs_settings);
  39. obs_data_release(obs_settings);
  40. return true;
  41. }