alldevices.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 "libavformat/internal.h"
  21. #include "libavformat/mux.h"
  22. #include "avdevice.h"
  23. /* devices */
  24. extern const AVInputFormat ff_alsa_demuxer;
  25. extern const FFOutputFormat ff_alsa_muxer;
  26. extern const AVInputFormat ff_android_camera_demuxer;
  27. extern const FFOutputFormat ff_audiotoolbox_muxer;
  28. extern const AVInputFormat ff_avfoundation_demuxer;
  29. extern const AVInputFormat ff_bktr_demuxer;
  30. extern const FFOutputFormat ff_caca_muxer;
  31. extern const AVInputFormat ff_decklink_demuxer;
  32. extern const FFOutputFormat ff_decklink_muxer;
  33. extern const AVInputFormat ff_dshow_demuxer;
  34. extern const AVInputFormat ff_fbdev_demuxer;
  35. extern const FFOutputFormat ff_fbdev_muxer;
  36. extern const AVInputFormat ff_gdigrab_demuxer;
  37. extern const AVInputFormat ff_iec61883_demuxer;
  38. extern const AVInputFormat ff_jack_demuxer;
  39. extern const AVInputFormat ff_kmsgrab_demuxer;
  40. extern const AVInputFormat ff_lavfi_demuxer;
  41. extern const AVInputFormat ff_openal_demuxer;
  42. extern const FFOutputFormat ff_opengl_muxer;
  43. extern const AVInputFormat ff_oss_demuxer;
  44. extern const FFOutputFormat ff_oss_muxer;
  45. extern const AVInputFormat ff_pulse_demuxer;
  46. extern const FFOutputFormat ff_pulse_muxer;
  47. extern const FFOutputFormat ff_sdl2_muxer;
  48. extern const AVInputFormat ff_sndio_demuxer;
  49. extern const FFOutputFormat ff_sndio_muxer;
  50. extern const AVInputFormat ff_v4l2_demuxer;
  51. extern const FFOutputFormat ff_v4l2_muxer;
  52. extern const AVInputFormat ff_vfwcap_demuxer;
  53. extern const AVInputFormat ff_xcbgrab_demuxer;
  54. extern const FFOutputFormat ff_xv_muxer;
  55. /* external libraries */
  56. extern const AVInputFormat ff_libcdio_demuxer;
  57. extern const AVInputFormat ff_libdc1394_demuxer;
  58. #include "libavdevice/outdev_list.c"
  59. #include "libavdevice/indev_list.c"
  60. void avdevice_register_all(void)
  61. {
  62. avpriv_register_devices(outdev_list, indev_list);
  63. }
  64. static const void *next_input(const AVInputFormat *prev, AVClassCategory c2)
  65. {
  66. const AVClass *pc;
  67. const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
  68. AVClassCategory category = AV_CLASS_CATEGORY_NA;
  69. const AVInputFormat *fmt = NULL;
  70. int i = 0;
  71. while (prev && (fmt = indev_list[i])) {
  72. i++;
  73. if (prev == fmt)
  74. break;
  75. }
  76. do {
  77. fmt = indev_list[i++];
  78. if (!fmt)
  79. break;
  80. pc = fmt->priv_class;
  81. if (!pc)
  82. continue;
  83. category = pc->category;
  84. } while (category != c1 && category != c2);
  85. return fmt;
  86. }
  87. static const void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
  88. {
  89. const AVClass *pc;
  90. const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
  91. AVClassCategory category = AV_CLASS_CATEGORY_NA;
  92. const FFOutputFormat *fmt = NULL;
  93. int i = 0;
  94. while (prev && (fmt = outdev_list[i])) {
  95. i++;
  96. if (prev == &fmt->p)
  97. break;
  98. }
  99. do {
  100. fmt = outdev_list[i++];
  101. if (!fmt)
  102. break;
  103. pc = fmt->p.priv_class;
  104. if (!pc)
  105. continue;
  106. category = pc->category;
  107. } while (category != c1 && category != c2);
  108. return fmt;
  109. }
  110. const AVInputFormat *av_input_audio_device_next(const AVInputFormat *d)
  111. {
  112. return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
  113. }
  114. const AVInputFormat *av_input_video_device_next(const AVInputFormat *d)
  115. {
  116. return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
  117. }
  118. const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
  119. {
  120. return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
  121. }
  122. const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
  123. {
  124. return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
  125. }