alldevices.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Register all the grabbing devices.
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libavutil/attributes.h"
  21. #include "libavutil/attributes_internal.h"
  22. #include "libavformat/demux.h"
  23. #include "libavformat/internal.h"
  24. #include "libavformat/mux.h"
  25. #include "avdevice.h"
  26. FF_VISIBILITY_PUSH_HIDDEN
  27. /* devices */
  28. extern const FFInputFormat ff_alsa_demuxer;
  29. extern const FFOutputFormat ff_alsa_muxer;
  30. extern const FFInputFormat ff_android_camera_demuxer;
  31. extern const FFOutputFormat ff_audiotoolbox_muxer;
  32. extern const FFInputFormat ff_avfoundation_demuxer;
  33. extern const FFInputFormat ff_bktr_demuxer;
  34. extern const FFOutputFormat ff_caca_muxer;
  35. extern const FFInputFormat ff_decklink_demuxer;
  36. extern const FFOutputFormat ff_decklink_muxer;
  37. extern const FFInputFormat ff_dshow_demuxer;
  38. extern const FFInputFormat ff_fbdev_demuxer;
  39. extern const FFOutputFormat ff_fbdev_muxer;
  40. extern const FFInputFormat ff_gdigrab_demuxer;
  41. extern const FFInputFormat ff_iec61883_demuxer;
  42. extern const FFInputFormat ff_jack_demuxer;
  43. extern const FFInputFormat ff_kmsgrab_demuxer;
  44. extern const FFInputFormat ff_lavfi_demuxer;
  45. extern const FFInputFormat ff_openal_demuxer;
  46. extern const FFOutputFormat ff_opengl_muxer;
  47. extern const FFInputFormat ff_oss_demuxer;
  48. extern const FFOutputFormat ff_oss_muxer;
  49. extern const FFInputFormat ff_pulse_demuxer;
  50. extern const FFOutputFormat ff_pulse_muxer;
  51. extern const FFOutputFormat ff_sdl2_muxer;
  52. extern const FFInputFormat ff_sndio_demuxer;
  53. extern const FFOutputFormat ff_sndio_muxer;
  54. extern const FFInputFormat ff_v4l2_demuxer;
  55. extern const FFOutputFormat ff_v4l2_muxer;
  56. extern const FFInputFormat ff_vfwcap_demuxer;
  57. extern const FFInputFormat ff_xcbgrab_demuxer;
  58. extern const FFOutputFormat ff_xv_muxer;
  59. /* external libraries */
  60. extern const FFInputFormat ff_libcdio_demuxer;
  61. extern const FFInputFormat ff_libdc1394_demuxer;
  62. FF_VISIBILITY_POP_HIDDEN
  63. #include "libavdevice/outdev_list.c"
  64. #include "libavdevice/indev_list.c"
  65. av_cold void avdevice_register_all(void)
  66. {
  67. avpriv_register_devices(outdev_list, indev_list);
  68. }
  69. static av_cold const void *next_input(const AVInputFormat *prev, AVClassCategory c2)
  70. {
  71. const AVClass *pc;
  72. const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
  73. AVClassCategory category = AV_CLASS_CATEGORY_NA;
  74. const FFInputFormat *fmt = NULL;
  75. int i = 0;
  76. while (prev && (fmt = indev_list[i])) {
  77. i++;
  78. if (prev == &fmt->p)
  79. break;
  80. }
  81. do {
  82. fmt = indev_list[i++];
  83. if (!fmt)
  84. break;
  85. pc = fmt->p.priv_class;
  86. if (!pc)
  87. continue;
  88. category = pc->category;
  89. } while (category != c1 && category != c2);
  90. return fmt;
  91. }
  92. static av_cold const void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
  93. {
  94. const AVClass *pc;
  95. const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
  96. AVClassCategory category = AV_CLASS_CATEGORY_NA;
  97. const FFOutputFormat *fmt = NULL;
  98. int i = 0;
  99. while (prev && (fmt = outdev_list[i])) {
  100. i++;
  101. if (prev == &fmt->p)
  102. break;
  103. }
  104. do {
  105. fmt = outdev_list[i++];
  106. if (!fmt)
  107. break;
  108. pc = fmt->p.priv_class;
  109. if (!pc)
  110. continue;
  111. category = pc->category;
  112. } while (category != c1 && category != c2);
  113. return fmt;
  114. }
  115. av_cold const AVInputFormat *av_input_audio_device_next(const AVInputFormat *d)
  116. {
  117. return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
  118. }
  119. av_cold const AVInputFormat *av_input_video_device_next(const AVInputFormat *d)
  120. {
  121. return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
  122. }
  123. av_cold const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
  124. {
  125. return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
  126. }
  127. av_cold const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
  128. {
  129. return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
  130. }