|
|
@@ -38,15 +38,15 @@ AVTool::MediaInfo* Decoder::detectMediaInfo(const QString& url)
|
|
|
|
|
|
// 性能优化:统一使用LowLatencyConfig配置参数
|
|
|
AVDictionary* formatOpts = nullptr;
|
|
|
- av_dict_set(&formatOpts, "probesize", LowLatencyConfig::PROBE_SIZE, 0); // 使用配置文件中的探测大小
|
|
|
- av_dict_set(&formatOpts, "analyzeduration", LowLatencyConfig::ANALYZE_DURATION, 0); // 使用配置文件中的分析时长
|
|
|
+ av_dict_set(&formatOpts, "probesize", LowLatencyConfig::PROBE_SIZE_STR, 0); // 使用字符串版本配置
|
|
|
+ av_dict_set(&formatOpts, "analyzeduration", LowLatencyConfig::ANALYZE_DURATION_STR, 0); // 使用字符串版本配置
|
|
|
av_dict_set(&formatOpts, "fflags", LowLatencyConfig::FFLAGS, 0); // 使用配置文件中的标志
|
|
|
- av_dict_set(&formatOpts, "max_delay", LowLatencyConfig::MAX_DELAY, 0); // 使用配置文件中的最大延迟
|
|
|
+ av_dict_set(&formatOpts, "max_delay", LowLatencyConfig::MAX_DELAY_STR, 0); // 使用字符串版本配置
|
|
|
av_dict_set(&formatOpts, "rtsp_transport", LowLatencyConfig::RTSP_TRANSPORT, 0);
|
|
|
av_dict_set(&formatOpts, "rtsp_flags", LowLatencyConfig::RTSP_FLAGS, 0);
|
|
|
- av_dict_set(&formatOpts, "stimeout", LowLatencyConfig::STIMEOUT, 0);
|
|
|
+ av_dict_set(&formatOpts, "stimeout", LowLatencyConfig::STIMEOUT_STR, 0); // 使用字符串版本配置
|
|
|
av_dict_set(&formatOpts, "user_agent", LowLatencyConfig::USER_AGENT, 0);
|
|
|
- av_dict_set(&formatOpts, "buffer_size", LowLatencyConfig::BUFFER_SIZE, 0); // 使用配置文件中的缓冲区大小
|
|
|
+ av_dict_set(&formatOpts, "buffer_size", LowLatencyConfig::BUFFER_SIZE_STR, 0); // 使用字符串版本配置
|
|
|
|
|
|
ret = avformat_open_input(&fmtCtx, url.toUtf8().constData(), nullptr, &formatOpts);
|
|
|
if (ret < 0) {
|
|
|
@@ -61,9 +61,9 @@ AVTool::MediaInfo* Decoder::detectMediaInfo(const QString& url)
|
|
|
// 性能优化:统一使用LowLatencyConfig配置参数
|
|
|
if (fmtCtx) {
|
|
|
fmtCtx->flags |= AVFMT_FLAG_NOBUFFER;
|
|
|
- fmtCtx->max_delay = std::atoi(LowLatencyConfig::MAX_DELAY); // 使用配置文件中的最大延迟
|
|
|
- fmtCtx->probesize = std::atoi(LowLatencyConfig::PROBE_SIZE); // 使用配置文件中的探测大小
|
|
|
- fmtCtx->max_analyze_duration = std::atoi(LowLatencyConfig::ANALYZE_DURATION); // 使用配置文件中的分析时长
|
|
|
+ fmtCtx->max_delay = LowLatencyConfig::MAX_DELAY; // 直接使用整数值,消除std::atoi转换
|
|
|
+ fmtCtx->probesize = LowLatencyConfig::PROBE_SIZE; // 直接使用整数值,消除std::atoi转换
|
|
|
+ fmtCtx->max_analyze_duration = LowLatencyConfig::ANALYZE_DURATION; // 直接使用整数值,消除std::atoi转换
|
|
|
}
|
|
|
|
|
|
ret = avformat_find_stream_info(fmtCtx, nullptr);
|
|
|
@@ -253,13 +253,13 @@ int Decoder::decode(const QString& url)
|
|
|
|
|
|
//用于获取流时长
|
|
|
AVDictionary* formatOpts = nullptr;
|
|
|
- av_dict_set(&formatOpts, "probesize", LowLatencyConfig::PROBE_SIZE, 0);
|
|
|
- av_dict_set(&formatOpts, "analyzeduration", LowLatencyConfig::ANALYZE_DURATION, 0);
|
|
|
+ av_dict_set(&formatOpts, "probesize", LowLatencyConfig::PROBE_SIZE_STR, 0);
|
|
|
+ av_dict_set(&formatOpts, "analyzeduration", LowLatencyConfig::ANALYZE_DURATION_STR, 0);
|
|
|
av_dict_set(&formatOpts, "rtsp_transport", LowLatencyConfig::RTSP_TRANSPORT, 0);
|
|
|
av_dict_set(&formatOpts, "fflags", LowLatencyConfig::FFLAGS, 0);
|
|
|
- av_dict_set(&formatOpts, "max_delay", LowLatencyConfig::MAX_DELAY, 0);
|
|
|
+ av_dict_set(&formatOpts, "max_delay", LowLatencyConfig::MAX_DELAY_STR, 0);
|
|
|
av_dict_set(&formatOpts, "rtsp_flags", LowLatencyConfig::RTSP_FLAGS, 0);
|
|
|
- av_dict_set(&formatOpts, "stimeout", LowLatencyConfig::STIMEOUT, 0);
|
|
|
+ av_dict_set(&formatOpts, "stimeout", LowLatencyConfig::STIMEOUT_STR, 0);
|
|
|
av_dict_set(&formatOpts, "user_agent", LowLatencyConfig::USER_AGENT, 0);
|
|
|
|
|
|
ret = avformat_open_input(&m_fmtCtx, url.toUtf8().constData(), nullptr, &formatOpts);
|
|
|
@@ -275,7 +275,7 @@ int Decoder::decode(const QString& url)
|
|
|
// 低延迟:关闭内部缓冲,使用配置文件参数
|
|
|
if (m_fmtCtx) {
|
|
|
m_fmtCtx->flags |= AVFMT_FLAG_NOBUFFER;
|
|
|
- m_fmtCtx->max_delay = std::atoi(LowLatencyConfig::MAX_DELAY); // 使用配置文件中的最大延迟
|
|
|
+ m_fmtCtx->max_delay = LowLatencyConfig::MAX_DELAY; // 直接使用整数值,消除std::atoi转换
|
|
|
}
|
|
|
|
|
|
ret = avformat_find_stream_info(m_fmtCtx, nullptr);
|