2024-05-19 02:43:10 +08:00
|
|
|
|
|
|
|
#include "LoopbackCapture.h"
|
2024-08-11 22:45:33 +08:00
|
|
|
|
2024-11-04 23:10:41 +08:00
|
|
|
DECLARE_API 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());
|
|
|
|
}
|
|
|
|
|
2024-11-04 23:10:41 +08:00
|
|
|
DECLARE_API void StopCaptureAsync(HANDLE m)
|
2024-08-11 22:45:33 +08:00
|
|
|
{
|
|
|
|
ReleaseSemaphore(m, 1, NULL);
|
2024-05-19 02:43:10 +08:00
|
|
|
}
|