[FFmpeg-devel] [PATCHv6 4/4] libavcodec: v4l2: add support for v4l2 mem2mem codecs

Jorge Ramirez jorge.ramirez-ortiz at linaro.org
Mon Aug 28 11:18:31 EEST 2017


On 08/25/2017 05:35 PM, wm4 wrote:
>> +
>> +    dirp = opendir("/dev");
>> +    if (!dirp)
>> +        return AVERROR(errno);
>> +
>> +    for (entry = readdir(dirp); entry; entry = readdir(dirp)) {
>> +
>> +        if (strncmp(entry->d_name, "video", 5))
>> +            continue;
>> +
>> +        snprintf(node, sizeof(node), "/dev/%s", entry->d_name);
>> +
>> +        av_log(log_ctx, AV_LOG_DEBUG, "probing device %s\n", node);
>> +
>> +        s->devname = node;
>> +        ret = probe_v4l2_driver(s, log_ctx);
>> +        if (!ret)
>> +                break;
>> +    }
> This doesn't really look like a good idea. Even somehow trying to
> enumerate stuff in/sys/class/  sounds better. Just because device
> filename starts with "video" it doesn't need to be relevant, and poking
> random ioctl()s at arbitrary devices doesn't sound very reliable.
>

yes it might seem that way but this is pretty much the standard way of 
opening v4l2 devices (I am not reimplementing the API to my understanding).
for an example already present in ffmpeg  check libavdevice/v4l2.c 
v4l2_get_device_list.




More information about the ffmpeg-devel mailing list