Simple Analysis of FFmpeg source code: avdevice_register_all () of libavdevice (),
This document briefly records the function avdevice_register_all () of the libavdevice registration device in FFmpeg (). For examples of avdevice_register_all () in programming, refer to the article:
The simplest FFmpeg-based AVDevice example (read camera)
Before using libavdevice, you must first run avdevice_register_all () to register the device. Otherwise, an error occurs. The registration method of avdevice_register_all () is similar to that of av_register_all () and avcodec_register_all. Refer to the following articles:
Simple Analysis of FFmpeg source code: av_register_all ()
The avdevice_register_all () code is as follows.
/** Lei Xiaohua * http://blog.csdn.net/leixiaohua1020 */# include "config. h "# include" avdevice. h "// output device # define REGISTER_OUTDEV (X, x) \ {\ extern AVOutputFormat ff _ # x ##_ muxer; \ if (CONFIG _ # X # _ OUTDEV) \ av_register_output_format (& ff _ # x ##_ muxer); \} // enter the device # define REGISTER_INDEV (X, x) \{\ extern AVInputFormat ff _ # x ##_ demuxer; \ if (CONFIG _ # X ##_ INDEV) \ av_register_input_format (& ff _ # x ###_ demuxer); \} // input/output device # define REGISTER_INOUTDEV (X, x) REGISTER_OUTDEV (X, x ); REGISTER_INDEV (X, x) void avdevice_register_all (void) {static int initialized; if (initialized) return; initialized = 1;/* devices */REGISTER_INOUTDEV (ALSA, alsa ); revoke (AVFOUNDATION, avfoundation); REGISTER_INDEV (BKTR, bktr); REGISTER_OUTDEV (CACA, caca); REGISTER_OUTDEV (DECKLINK, decklink); parse (DSHOW, dshow); parse (DV1394, dv1394); values (FBDEV, fbdev); REGISTER_INDEV (GDIGRAB, gdigrab); REGISTER_INDEV (83, 83); values (JACK, jack); REGISTER_INDEV (LAVFI, lavfi ); REGISTER_INDEV (OPENAL, openal); REGISTER_OUTDEV (OPENGL, opengl); Round (OSS, oss); Round (PULSE, pulse); REGISTER_INDEV (QTKIT, qtkit); REGISTER_OUTDEV (SDL, sdl); audio (SNDIO, sndio); audio (V4L2, v4l2); // audio (V4L, v4l REGISTER_INDEV (VFWCAP, vfwcap); REGISTER_INDEV (X11GRAB, x11grab ); REGISTER_OUTDEV (XV, xv);/* external libraries */REGISTER_INDEV (LIBCDIO, libcdio); REGISTER_INDEV (LIBDC1394, libdc1394 );}
The Code shows that avdevice_register_all () calls three functions to register a device: REGISTER_INDEV (), REGISTER_OUTDEV (), and REGISTER_INOUTDEV (). The above three functions are actually three predefined macros:
REGISTER_INDEV (): registers the input device. In fact, av_register_input_format () is called to register the input device as an AVInputFormat.
REGISTER_OUTDEV (): registers the output device. In fact, av_register_output_format () is called to register the output device as an AVOutputFormat.
REGISTER_INOUTDEV (): registers the input and output devices. In fact, the two macro definitions are merged.
Lei Xiaohua
Leixiaohua1020@126.com
Http://blog.csdn.net/leixiaohua1020