12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- extern "C"
- {
- #include "libavcodec/avcodec.h"
- #include "libavformat/avformat.h"
- #include "libswscale/swscale.h"
- #include "libavdevice/avdevice.h"
- }
- //'1' Use Dshow
- //'0' Use VFW
- #define USE_DSHOW 0
- //Show Dshow Device
- void show_dshow_device()
- {
- AVFormatContext *pFormatCtx = avformat_alloc_context();
- AVDictionary* options = nullptr;
- av_dict_set(&options,"list_devices","true",0);
- AVInputFormat *iformat = av_find_input_format("dshow");
- printf("========Device Info=============\n");
- avformat_open_input(&pFormatCtx,"video=dummy",iformat,&options);
- printf("================================\n");
- }
- //Show Dshow Device Option
- void show_dshow_device_option()
- {
- AVFormatContext *pFormatCtx = avformat_alloc_context();
- AVDictionary* options = nullptr;
- av_dict_set(&options,"list_options","true",0);
- AVInputFormat *iformat = av_find_input_format("dshow");
- printf("========Device Option Info======\n");
- avformat_open_input(&pFormatCtx,"video=Integrated Camera",iformat,&options);
- printf("================================\n");
- }
- //Show VFW Device
- void show_vfw_device()
- {
- AVFormatContext *pFormatCtx = avformat_alloc_context();
- AVInputFormat *iformat = av_find_input_format("vfwcap");
- printf("========VFW Device Info======\n");
- avformat_open_input(&pFormatCtx,"list",iformat,nullptr);
- printf("=============================\n");
- }
- //Show AVFoundation Device
- void show_avfoundation_device()
- {
- AVFormatContext *pFormatCtx = avformat_alloc_context();
- AVDictionary* options = nullptr;
- av_dict_set(&options,"list_devices","true",0);
- AVInputFormat *iformat = av_find_input_format("avfoundation");
- printf("==AVFoundation Device Info===\n");
- avformat_open_input(&pFormatCtx, "",iformat, &options);
- printf("=============================\n");
- }
- void getDeviceList()
- {
- av_register_all();
- avformat_network_init();
- avdevice_register_all();
-
- //Show Dshow Device
- show_dshow_device();
- //Show Device Options
- show_dshow_device_option();
- //Show VFW Options
- show_vfw_device();
- }
|