mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Add DVT screenshot bindings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/location_simulation.hpp>
|
||||
#include <idevice++/dvt/location_simulation.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/process_control.hpp>
|
||||
#include <idevice++/dvt/process_control.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/remote_server.hpp>
|
||||
#include <idevice++/dvt/remote_server.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
37
cpp/src/dvt/screenshot.cpp
Normal file
37
cpp/src/dvt/screenshot.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/dvt/screenshot.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
Result<ScreenshotClient, FfiError> ScreenshotClient::create(RemoteServer& server) {
|
||||
ScreenshotClientHandle* out = nullptr;
|
||||
FfiError e(::screenshot_client_new(server.raw(), &out));
|
||||
if (e) {
|
||||
return Err(e);
|
||||
}
|
||||
return Ok(ScreenshotClient::adopt(out));
|
||||
}
|
||||
|
||||
Result<std::vector<uint8_t>, FfiError> ScreenshotClient::capture() {
|
||||
uint8_t* data = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
FfiError e(::screenshot_client_clear(handle_.get(), &data, &len));
|
||||
if (e) {
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
// Copy into a C++ buffer
|
||||
std::vector<uint8_t> out(len);
|
||||
if (len > 0 && data != nullptr) {
|
||||
std::memcpy(out.data(), data, len);
|
||||
}
|
||||
|
||||
// Free Rust-allocated data
|
||||
::idevice_data_free(data, len);
|
||||
|
||||
return Ok(std::move(out));
|
||||
}
|
||||
|
||||
} // namespace IdeviceFFI
|
||||
Reference in New Issue
Block a user