alldevices.c 4.3 KB

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