#include <string>
#include <thread>
#include <chrono>
#ifdef USE_STB_IMAGE_WRITE
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
static void WriteImage(const char* filename, const uint8_t* data,
const uint32_t width, const uint32_t height)
{
stbi_write_png(filename, width, height, 3, data, width * 3);
}
#endif
};
};
};
{
#ifdef EXAMPLE_TLS
puts("Connecting to server...");
puts("Conencted to server");
return true;
}
else
puts("Failed to connect to server");
}
else
puts("Failed to request certificate");
#else
puts("Conencted to server");
return true;
}
else
puts("Failed to connect to server");
#endif
std::this_thread::sleep_for(std::chrono::seconds(1));
return false;
}
{
}
static bool JoinRoom(
context_s& context,
const char *roomName)
{
}
{
void* opaque ) {
puts("Server authenticated your connection");
}
else {
printf("Server failed(%d) to authenticate your connection", response);
}
}, &context);
reinterpret_cast<context_s*
>(opaque)->serverState = state;
}, &context);
void* opaque ) {
printf("Room(%s) with ID(%d) announced\n", roomName, roomID);
}, &context);
const void* optionalData, const uint32_t optionalDataSize,
void* opaque ) {
if (optionalData && optionalDataSize == sizeof(uint16_t)) {
context->
clientRoomID = *
reinterpret_cast<const uint16_t*
>(optionalData);
printf(
"Joined room and got asigned ID(%d)\n", context->
clientRoomID);
}
else {
puts("Failed to join room");
}
}
else
printf("Failed(%d) to join room on command(%d)\n", response, request);
}, &context);
void* opaque ) {
printf("Client(%d) with name(%s) added to room\n", clientID, userName);
}, & context);
printf("Client(%d) removed from room\n", clientID);
}, & context);
puts("Video mode changed");
}, &context);
puts("Video options changed");
}, &context);
#ifdef USE_STB_IMAGE_WRITE
#endif
}, &context);
const uint32_t dataSize, void* opaque ) {
switch (type) {
break;
}
}, &context);
const uint8_t* data, const uint32_t size,
void* opaque ) {
printf("Room(%d) preview image received with format(%d) and size(%d)\n", roomID, imageFormat, size);
}, & context);
while (true) {
break;
break;
puts("Server authenticated your connection");
}
puts("Server failed to authenticate your connection");
std::this_thread::sleep_for(std::chrono::seconds(5));
}
break;
break;
}
break;
break;
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return 0;
}
@ RoomJoinedStateReceivedList
@ StateRequestRoomsPending
@ StateRequestJoinRoomPending
@ RequestRoomListSubscribe
int DeviceCapabilityValue
@ AuthenticationResponseSuccess
@ ServerStateAuthenticateError
@ ServerStateConnectedAndAuthenticated
@ DeviceCapabilityDisplay
uint8_t UserCapabilityValue
void SetEncodedStreamCallback(EncodedStreamFunc func, void *opaque=nullptr)
Encoded Frame or stream callback.
void SetRoomClientRemovedCallback(RoomClientRemovedFunc func, void *opaque=nullptr)
Server room client removed callback.
void SetRoomPreviewImageCallback(RoomPreviewImageFunc func, void *opaque=nullptr)
Room Preview Image callback.
void SetAuthenticateResponseCallback(AuthenticateResponseFunc func, void *opaque=nullptr)
SetAuthenticateResponseCallback callback.
Status SendRequestStr(const Request request, const char *str, const char *option=nullptr)
Sends request string to ASMIRA server.
void SetVideoModeCallback(VideoModeFunc func, void *opaque=nullptr)
Video Mode callback.
void SetFrameCallback(FrameFunc func, void *opaque=nullptr)
Video/Photo Frame callback.
void SetServerStateCallback(ServerStateFunc func, void *opaque=nullptr)
Server state callback.
void SetRoomResponseCallback(RoomResponseFunc func, void *opaque=nullptr)
Server room response callback.
Status SendRequest(const Request request)
Sends request to ASMIRA server.
Status RequestCertificate(const char *address, const uint16_t port, const char *userName, const char *password, CertificateState *certificateStateOut, certificate_t *certificateOut, const int timeout=3000)
Request certificate from ASMIRA server.
Status ConnectSecured(const char *ip, const uint16_t port, const uint32_t timeout, const bool highLatency, const char *username, const char *password, const UserCapabilityValue userCapability, const DeviceCapabilityValue deviceCapability, const char *certificate, const char *displayName=nullptr)
Connect to ASMIRA server.
Status Connect(const char *ip, const uint16_t port, const uint32_t timeout, const bool highLatency, const char *username, const char *password, const UserCapabilityValue userCapability, const DeviceCapabilityValue deviceCapability, const char *displayName=nullptr)
Connect to ASMIRA server.
void SetRoomClientAddedCallback(RoomClientAddedFunc func, void *opaque=nullptr)
Server room client added callback.
void SetRoomAnnounceCallback(RoomAnnounceFunc func, void *opaque=nullptr)
Server room announce callback.
void SetVideoOptionsCallback(VideoOptionsFunc func, void *opaque=nullptr)
Video Options callback.
asdk::ServerState serverState
RoomJoinedState roomJoinedState