mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix attempt for #2438
This commit is contained in:
parent
7f5f807bde
commit
b1f8d3f912
|
@ -50,6 +50,7 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options)
|
||||||
openDeviceLock.lock();
|
openDeviceLock.lock();
|
||||||
AVFormatContext* fctx = nullptr;
|
AVFormatContext* fctx = nullptr;
|
||||||
CameraDevice* dev = openDevices.value(devName);
|
CameraDevice* dev = openDevices.value(devName);
|
||||||
|
int aduration;
|
||||||
if (dev)
|
if (dev)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -72,12 +73,25 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options)
|
||||||
if (avformat_open_input(&fctx, devName.toStdString().c_str(), format, options)<0)
|
if (avformat_open_input(&fctx, devName.toStdString().c_str(), format, options)<0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
// Fix avformat_find_stream_info hanging on garbage input
|
||||||
|
#if FF_API_PROBESIZE_32
|
||||||
|
aduration = fctx->max_analyze_duration2 = 0;
|
||||||
|
#else
|
||||||
|
aduration = fctx->max_analyze_duration = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (avformat_find_stream_info(fctx, NULL) < 0)
|
if (avformat_find_stream_info(fctx, NULL) < 0)
|
||||||
{
|
{
|
||||||
avformat_close_input(&fctx);
|
avformat_close_input(&fctx);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FF_API_PROBESIZE_32
|
||||||
|
fctx->max_analyze_duration2 = aduration;
|
||||||
|
#else
|
||||||
|
fctx->max_analyze_duration = aduration;
|
||||||
|
#endif
|
||||||
|
|
||||||
dev = new CameraDevice{devName, fctx};
|
dev = new CameraDevice{devName, fctx};
|
||||||
openDevices[devName] = dev;
|
openDevices[devName] = dev;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user