#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "trro_remote.h"
int main() {
TRRO_registerSignalStateCallback(nullptr, [](void *context, SignalState state) {
if(state == kTrroReady) {
printf("init success \\n");
}
if (state == kTrroAuthFailed) {
printf("device_id or password is incorrect\\n");
}
if (state == kTrroKickout) {
printf("the device is kicked by server, may be there is another device using the same device id\\n");
}
});
int ret = TRRO_initJsonPath("./config.json");
if(TRRO_SUCCED != ret) {
if (ret == -TRRO_SIGNAL_CONNECT_OUTTIME) {
printf("init process: wait for connecting\\n");
} else {
printf("init fail ret %d\\n", ret);
}
}
TRRO_registerOnState(this, [](void* context, const char* gwid, int stream_id, int conn_fd, int state) {
printf("###### onstate gwid %s, streamid %d conn_fd %d state %d\\n", gwid, stream_id, conn_fd, state);
});
TRRO_registerOnMediaState(this, [](void* context, int windows_id, int fps, int bps, int rtt, long long decd, int jitter,
long long packets_lost, long long packets_received, int stun) {
printf("onMediaState window id %d fps %d bps %d rtt %d decd %lld rb %d lost %lld rec %lld stun %d\\n",windows_id, fps, bps, rtt, decd, jitter, packets_lost, packets_received, stun);
});
TRRO_registerAllLatencyCallback(this, [](void* context, const char* gwid, int windows_id, long long latency1, long long latency2, long long gateway_time, int vcct) {
printf("allLatency %s, %d, latency1 %lld latency2 %lld video time %lld, vcct %d\\n", gwid, windows_id, latency1, latency2, gateway_time, vcct);
});
TRRO_registerRemoteFrameCallback(this, [](void * context, const char * gwid, int stream_id, int conn_id, const char* data, int width, int height, long long videotime) {
});
int confds[8] = {0,1,2,3,4,5,6,7};
WindowIdType window_hwnds[8] = { nullptr};
TRRO_setWindows(confds, window_hwnds, 8);
int stream_num = 4;
int stream_indexs[4] = {0,1,2,3};
TRRO_connect("field_deviceId1", "", stream_num , &stream_indexs[0], &confds[0]);
TRRO_connect("field_deviceId2", "", stream_num , &stream_indexs[0], &confds[4]);
while(true){
sleep(3000);
TRRO_disconnectAll();
TRRO_destroy();
break;
}
return 0;
}