集成FreeRtos SDK
更新时间:2023-05-30
开发环境
请确保开发环境满足以下技术要求:
- Windows7、Windows8、Windows10或以上版本
- 安装ARM DS-5 v5.26.2或以上版本。
- 安装msys2-x86_64-20210105或以上版本。
- 安装ActivePerl5.32或以上版本。
- 安装python3.8.7或以上版本。
- 硬件设备:基于ASR3601的小度手表。
SDK下载
进入RTC文档中心,点击“下载专区>SDK&Demo下载”
SDK目录说明
- BRTC.FreeRtos.SDKV0.0.1/include目录 ------ 放置api头文件
- BRTC.FreeRtos.SDKV0.0.1/lib目录 ------ 放置音视频静态库libbrtc.a
- BRTC.FreeRtos.SDKV0.0.1/src目录 ------ 放置api调用的参考demo代码
SDK集成
- 将BRTC.FreeRtos.SDKV0.0.1/include目录加入到CMakeLists.txt中的头文件搜索路径。
- 将BRTC.FreeRtos.SDKV0.0.1/lib目录下的libbrtc.a放到执行目录下。
- application调用sdk api流程可参考BRTC.FreeRtos.SDKV0.0.1/src/demo.c源代码。
- 小度手表app调用sdk api流程可参考BRTC.FreeRtos.SDKV0.0.1/src/lv_app源代码。
- 完成以上步骤后,即可开始调用FreeRtos RTC的API。
API调用流程
1. API 调用流程图
2. API codes使用样例
`
bool rtc_joined_room = false;
static void OnRtcMessage(RtcMessage* msg)
{
printf("myListener got Message: %d\n", msg->msgType);
switch (msg->msgType) {
case RTC_MESSAGE_ROOM_EVENT_LOGIN_OK: {
printf("Login ok!\n");
} break;
case RTC_MESSAGE_ROOM_EVENT_LOGIN_ERROR: {
printf("Login error!\n");
} break;
case RTC_MESSAGE_ROOM_EVENT_LOGIN_TIMEOUT: {
printf("Login timeout!\n");
} break;
case RTC_MESSAGE_ROOM_EVENT_CONNECTION_ERROR: {
printf("Connection error!\n");
} break;
case RTC_MESSAGE_ROOM_EVENT_REMOTE_COMING: {
printf("Feed coming!\n");
} break;
case RTC_ROOM_EVENT_ON_PUBLISHER_JOINED_ROOM: {
printf("Publisher joined room!\n");
rtc_joined_room = true;
} break;
case RTC_ROOM_EVENT_ON_USER_MESSAGE: {
printf("user msg callback:%s\n", msg->extra_info);
} break;
case RTC_ROOM_EVENT_ON_USER_JOINED_ROOM: {
printf("User joined room!\n");
} break;
case RTC_MESSAGE_MEDIA_SIGNAL_ESTABLISH_OK: {
printf("Media signal established ok!\n");
} break;
case RTC_MESSAGE_MEDIA_SIGNAL_ESTABLISH_ERROR: {
printf("Media signal established error!\n");
} break;
case RTC_MESSAGE_MEDIA_SIGNAL_RECEIVE_FISRT_AUDIO: {
printf("It received audio yet!\n");
} break;
case RTC_MESSAGE_MEDIA_SIGNAL_RECEIVE_FISRT_VIDEO: {
printf("It received video yet!\n");
} break;
case RTC_MESSAGE_MEDIA_SIGNAL_NO_RTP_STREAM_TIMEOUT: {
printf("Did't receive rtp stream because of timeout!\n");
} break;
case RTC_MESSAGE_ROOM_EVENT_REMOTE_LEAVING: {
printf("Feed leaving!\n");
} break;
case RTC_MESSAGE_STATE_STREAM_UP: {
printf("Stream up, send/got video now\n");
} break;
default:
break;
}
}
void brtc_video_call_put_image(int width, int height, const unsigned char *src,
int is_semi, int img_type) //回调解码后的视频数据显示
{
printf("put image");
}
const char *s_url = "ws://rtc2.exp.bcelive.com:8186/janus";
static void *client = NULL;
int main(int argc, char* argv[])
{
bool ret =false;
const char appId[] = "APPID_GET_FROM_BAIDU"; //please get a appId from baidu
const char token[] = "no_token";
const char room_name[] = "8000";
const char user_id[] = "1008";
if(client == NULL) {
client = brtc_create_client();
if (client == NULL) {
printf("brtc_create_client failed\n");
return -1;
}
}
if (client) {
brtc_register_message_listener(client, OnRtcMessage);
brtc_set_server_url(client, s_url);
ret = brtc_init_sdk(client, appId, room_name, user_id, token, NULL);
if (!ret) {
printf("brtc_init_sdk failed\n");
return -1;
}
while (!rtc_joined_room);
ret = brtc_login_room(client);
if (!ret) {
printf("brtc_login_room failed\n");
brtc_deInit_sdk(client);
brtc_destroy_client(client);
if(client)
client = NULL;
return -1;
}
while (true) {
printf("Please input q to Quit.\n");
char commandid[512];
memset(commandid, 0, sizeof(commandid));
int ret = scanf("%s", commandid);
printf("scanf %d.\n", ret);
if (ret < 0) {
continue;
}
if (commandid[0] == 'q') {
break;
}
}
ret = brtc_logout_room(client);
if (!ret) {
printf("brtc_logout_room failed\n");
brtc_deInit_sdk(client);
brtc_destroy_client(client);
if(client)
client = NULL;
return -1;
}
brtc_deInit_sdk(client);
brtc_destroy_client(client);
if(client)
client = NULL;
rtc_joined_room = false;
}
return 0;
}
打包应用程序-依赖的文件列表
- libbrtc.a