运行firefly_rkmedia_demo下的例程ffrtsp_demo_test
#ffrtsp_demo_test
然后使用VLC打开
VLC提示打开失败。
备注:
1.摄像头、电脑、RV1126
开发板在同一个局域网,互相ping是通的;
2.电脑使用VLC打开摄像头,播放正常;
执行时,屏幕没有打印字符串“FFRTSP_Send start”,估计ffrtsp_get的回调函数FFRTSP_Send()没有执行。
demo代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "ffrtsp/ffrtsp.hh"
#define RTSP_PORT 8554
//#define SAVE_FILE
struct RTSP_PUSH_INFO ffrtsp_push[MAXFFRTSPChn];
int FFRTSP_Send(u_int8_t* framebuff,unsigned framesize,bool * quit,int cur_chn)
{
printf("FFRTSP_Send startn");
if (ffrtsp_push[cur_chn].fp == NULL)
return -1;
#ifdef SAVE_FILE
char save_file_path[30] = "test_rtsp_";
char str[10] = {0};
sprintf(str, "%d", cur_chn);
strcat(save_file_path,str);
FILE *fp = fopen(save_file_path, "a+b");
fwrite(framebuff, framesize, 1, fp);
fclose(fp);
fp = NULL;
#else
fwrite(framebuff,framesize, 1, ffrtsp_push[cur_chn].fp);
#endif
}
static void *rtspgetbuff(void *data) {
ffrtspGet(*(struct FFRTSPGet *)data);
}
static void *rtsppushbuff(void *data) {
ffrtsph264Push((struct RTSP_PUSH_INFO *)data); //h265 需要用 ffrtsph265Push
}
int main(int argc, char **argv){
struct FFRTSPGet ffrtsp_get;
ffrtsp_get.count = argc - 1;
ffrtsp_get.callback = FFRTSP_Send;
pthread_t rtsppush_thread[MAXFFRTSPChn];
int i = 0;
for(i = 0; i < argc - 1; i++) {
ffrtsp_get.ffrtsp_get_info.url = argv[i + 1];
ffrtsp_push.idex = i;
ffrtsp_push.port = RTSP_PORT + i;
pthread_create(&rtsppush_thread, NULL, rtsppushbuff, (void *)&ffrtsp_push);
}
pthread_t rtspget_thread;
pthread_create(&rtspget_thread, NULL, rtspgetbuff, (void *)&ffrtsp_get);
while (1) {
usleep(3000 * 1000);
}
return 0;
}
原作者:jamspan