1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Compatibility with older libavdevice

By not using avdevice_list_input_sources
This commit is contained in:
tux3 2015-05-14 18:40:12 +02:00
parent d53b426750
commit 95e4a20f05
3 changed files with 43 additions and 3 deletions

View File

@ -70,9 +70,47 @@ QVector<QPair<QString, QString>> CameraDevice::getDeviceList()
if (!getDefaultInputFormat())
return devices;
AVDeviceInfoList* devlist;
avdevice_list_input_sources(iformat, nullptr, nullptr, &devlist);
// Alloc an input device context
AVFormatContext *s;
if (!(s = avformat_alloc_context()))
return devices;
if (!iformat->priv_class || !AV_IS_INPUT_DEVICE(iformat->priv_class->category))
{
avformat_free_context(s);
return devices;
}
s->iformat = iformat;
if (s->iformat->priv_data_size > 0)
{
s->priv_data = av_mallocz(s->iformat->priv_data_size);
if (!s->priv_data)
{
avformat_free_context(s);
return devices;
}
if (s->iformat->priv_class)
{
*(const AVClass**)s->priv_data= s->iformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
}
else
{
s->priv_data = NULL;
}
// List the devices for this context
AVDeviceInfoList* devlist;
AVDictionary *tmp = nullptr;
av_dict_copy(&tmp, nullptr, 0);
if (av_opt_set_dict2(s, &tmp, AV_OPT_SEARCH_CHILDREN) < 0)
{
av_dict_free(&tmp);
avformat_free_context(s);
}
avdevice_list_devices(s, &devlist);
// Convert the list to a QVector
devices.resize(devlist->nb_devices);
for (int i=0; i<devlist->nb_devices; i++)
{
@ -80,6 +118,7 @@ QVector<QPair<QString, QString>> CameraDevice::getDeviceList()
devices[i].first = dev->device_name;
devices[i].second = dev->device_description;
}
avdevice_free_list_devices(&devlist);
return devices;
}

View File

@ -216,6 +216,7 @@ void CameraSource::stream()
while (!freelistLock.compare_exchange_weak(expected, true))
expected = false;
}
int freeFreelistSlot = getFreelistSlotLockless();
auto frameFreeCb = std::bind(&CameraSource::freelistCallback, this, freeFreelistSlot);
std::shared_ptr<VideoFrame> vframe = std::make_shared<VideoFrame>(frame, frameFreeCb);

View File

@ -151,7 +151,7 @@ bool VideoFrame::convertToYUV420()
}
else if (frameRGB24)
{
sourceFrame = frameOther;
sourceFrame = frameRGB24;
}
else
{