我正在尝试从使用RTSP over HTTP的Axis IP摄像机进行流媒体传输。我可以得到正常的RTSP流工作,但是我找不到任何关于如何设置流的隧道模式的信息或文档。通过将控制传输设置为RTSP_MODE_TUNNEL,源代码支持此功能。我的问题很简单,如何在以下代码中实现它?
int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);
我尝试了以下方法:
pFormatCtx = avformat_alloc_context();
pFormatCtx->priv_data = malloc(sizeof(RTSPState));
RTSPState *rt = pFormatCtx->priv_data;
rt->control_transport = RTSP_MODE_TUNNEL;
int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);
但是对于我来说它简单地忽略了它(仍然继续使用RTP)。我也尝试过这个方法。
int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);
RTSPState *rt = pFormatCtx->priv_data;
rt->control_transport = RTSP_MODE_TUNNEL;
我该如何解决这个问题?我认为由于ENUM已经存在,所以可能是一些非常简单的东西。
有效的解决方案是
AVDictionary *opts = 0;
int ret = av_dict_set(&opts, "rtsp_transport", "http", 0);
ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip:80/axis-media/media.amp" UTF8String], NULL, &opts);
av_dict_free(&opts);