You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.2KB

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