Basic usage of ASMIRA SDK.
#include <chrono>
#include <thread>
struct context_t {
bool roomListReceived = false;
bool roomJoined = false;
uint32_t framesReceived = 0;
};
int main()
{
context_t context;
if (!context.sdk) {
puts("Failed to initialize the ASMIRA SDK");
return 1;
}
void* opaque) {
reinterpret_cast<context_t*>(opaque)->serverState = serverState;
}, &context);
void*) {
puts("Authenticated");
else
printf("Login refused (0x%x)\n", response);
});
context.sdk->SetRoomAnnounceCallback([](const char* roomName, const uint32_t roomID,
printf("Room \"%s\" (id %u)%s%s\n", roomName, roomID,
reinterpret_cast<context_t*>(opaque)->roomListReceived = true;
}, &context);
context.sdk->SetRoomResponseCallback([](
const asdk::Request request,
const void*, const uint32_t, void* opaque) {
reinterpret_cast<context_t*>(opaque)->roomJoined =
}, &context);
context.sdk->SetFrameCallback([](
const asdk::frame_t* frame,
void* opaque) {
context_t* context = reinterpret_cast<context_t*>(opaque);
if (++context->framesReceived == 1)
printf(
"First frame: %dx%d\n", frame->
width, frame->
height);
}, &context);
if (context.sdk->Connect("127.0.0.1", 30100, 5000, true, "test", "password",
printf("Connect failed: %s\n", context.sdk->errorStr);
context.sdk->Unload();
return 1;
}
bool subscribed = false;
bool joinRequested = false;
puts("Authentication failed");
break;
}
if (!subscribed)
else if (context.roomListReceived && !joinRequested)
}
if (context.roomJoined && context.framesReceived > 0)
break;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
printf("Received %u frames\n", context.framesReceived);
context.sdk->Disconnect();
context.sdk->Unload();
return 0;
}
AuthenticationResponse
Outcome of a login attempt, reported by AuthenticateResponseFunc.
ServerState
State of the connection to the server, reported by ServerStateFunc.
@ AuthenticationResponseSuccess
@ ServerStateAuthenticateError
@ ServerStateConnectedAndAuthenticated
@ DeviceCapabilityBasic
Common baseline: H.265 video, Speex audio, microphone, WebP photo mode, ROI, chat and a display.
sdk_t * Initialize()
Loads the SDK shared library and creates an SDK handle.
Request
Request sent with sdk_t::SendRequest or sdk_t::SendRequestStr.
RoomResponse
Server answer to a Request, reported by RoomResponseFunc.
@ RequestRoomListSubscribe
TimePointSteady TimeNowSteady()
Current steady clock reading, unaffected by clock adjustments.
long long TimeSpentSteady(const TimePointSteady &time)
Milliseconds elapsed since a TimeNowSteady() reading.
std::chrono::steady_clock::time_point TimePointSteady
A decoded video or photo frame, delivered by FrameFunc.
int32_t height
Frame resolution height in pixels.
int32_t width
Frame resolution width in pixels.