參考鏈接
- FFmpeg源代碼簡單分析:libavdevice的avdevice_register_all()_雷霄驊的博客-CSDN博客
libavdevice的avdevice_register_all()
- FFmpeg中libavdevice注冊設備的函數avdevice_register_all()。
- avdevice_register_all()在編程中的使用示例可以參考文章:最簡單的基于FFmpeg的AVDevice例子(讀取攝像頭)_雷霄驊的博客-CSDN博客_ffmpeg 查找攝像頭
- 在使用libavdevice之前,必須先運行avdevice_register_all()對設備進行注冊,否則就會出錯。? 目前的機制 已經不需要使用這個函數進行設備注冊了
- 源代碼如下所示
void avdevice_register_all(void)
{avpriv_register_devices(outdev_list, indev_list);
}
void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[])
{atomic_store_explicit(&outdev_list_intptr, (uintptr_t)o, memory_order_relaxed);atomic_store_explicit(&indev_list_intptr, (uintptr_t)i, memory_order_relaxed);
}
#define atomic_store_explicit(object, desired, order) \atomic_store(object, desired)
- ?從代碼中可以看出,avdevice_register_all()調用3個函數進行設備組建的注冊:REGISTER_INDEV(),REGISTER_OUTDEV(),REGISTER_INOUTDEV()。上述3個函數實際上是預定義的3個宏:
- REGISTER_INDEV():注冊輸入設備。實際上調用了av_register_input_format()將輸入設備注冊成一個AVInputFormat。
- REGISTER_OUTDEV():注冊輸出設備。實際上調用了av_register_output_format()將輸出設備注冊成一個AVOutputFormat。
- REGISTER_INOUTDEV():注冊輸入設備和輸出設備。實際上將上述兩個宏定義合并了。
請使用手機"掃一掃"x