20 lines
620 B
C++
Raw Normal View History

2024-05-19 02:43:10 +08:00
#include "LoopbackCapture.h"
2024-08-11 22:45:33 +08:00
#define DECLARE extern "C" __declspec(dllexport)
DECLARE void StartCaptureAsync(void (*datacb)(void *ptr, size_t size), void (*handlecb)(HANDLE))
2024-05-19 02:43:10 +08:00
{
2024-08-11 22:45:33 +08:00
auto mutex = CreateSemaphoreW(NULL, 0, 1, NULL);
handlecb(mutex);
2024-05-19 02:43:10 +08:00
CLoopbackCapture loopbackCapture;
2024-08-11 22:45:33 +08:00
loopbackCapture.StartCaptureAsync(GetCurrentProcessId(), false);
WaitForSingleObject(mutex, INFINITE);
CloseHandle(mutex);
2024-05-19 02:43:10 +08:00
loopbackCapture.StopCaptureAsync();
2024-08-11 22:45:33 +08:00
datacb(loopbackCapture.buffer.data(), loopbackCapture.buffer.size());
}
DECLARE void StopCaptureAsync(HANDLE m)
{
ReleaseSemaphore(m, 1, NULL);
2024-05-19 02:43:10 +08:00
}