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.

121 lines
3.8KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "libavutil/avstring.h"
  20. #include "libavutil/mem.h"
  21. #include "url.h"
  22. extern const URLProtocol ff_concat_protocol;
  23. extern const URLProtocol ff_crypto_protocol;
  24. extern const URLProtocol ff_ffrtmpcrypt_protocol;
  25. extern const URLProtocol ff_ffrtmphttp_protocol;
  26. extern const URLProtocol ff_file_protocol;
  27. extern const URLProtocol ff_gopher_protocol;
  28. extern const URLProtocol ff_hls_protocol;
  29. extern const URLProtocol ff_http_protocol;
  30. extern const URLProtocol ff_httpproxy_protocol;
  31. extern const URLProtocol ff_https_protocol;
  32. extern const URLProtocol ff_icecast_protocol;
  33. extern const URLProtocol ff_mmsh_protocol;
  34. extern const URLProtocol ff_mmst_protocol;
  35. extern const URLProtocol ff_md5_protocol;
  36. extern const URLProtocol ff_pipe_protocol;
  37. extern const URLProtocol ff_rtmp_protocol;
  38. extern const URLProtocol ff_rtmpe_protocol;
  39. extern const URLProtocol ff_rtmps_protocol;
  40. extern const URLProtocol ff_rtmpt_protocol;
  41. extern const URLProtocol ff_rtmpte_protocol;
  42. extern const URLProtocol ff_rtmpts_protocol;
  43. extern const URLProtocol ff_rtp_protocol;
  44. extern const URLProtocol ff_sctp_protocol;
  45. extern const URLProtocol ff_srtp_protocol;
  46. extern const URLProtocol ff_tcp_protocol;
  47. extern const URLProtocol ff_tls_gnutls_protocol;
  48. extern const URLProtocol ff_tls_openssl_protocol;
  49. extern const URLProtocol ff_udp_protocol;
  50. extern const URLProtocol ff_unix_protocol;
  51. extern const URLProtocol ff_librtmp_protocol;
  52. extern const URLProtocol ff_librtmpe_protocol;
  53. extern const URLProtocol ff_librtmps_protocol;
  54. extern const URLProtocol ff_librtmpt_protocol;
  55. extern const URLProtocol ff_librtmpte_protocol;
  56. #include "libavformat/protocol_list.c"
  57. const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
  58. {
  59. int i;
  60. /* find the protocol that corresponds to prev */
  61. for (i = 0; url_protocols[i]; i++) {
  62. if (url_protocols[i]->priv_data_class == prev) {
  63. i++;
  64. break;
  65. }
  66. }
  67. /* find next protocol with priv options */
  68. for (; url_protocols[i]; i++)
  69. if (url_protocols[i]->priv_data_class)
  70. return url_protocols[i]->priv_data_class;
  71. return NULL;
  72. }
  73. const char *avio_enum_protocols(void **opaque, int output)
  74. {
  75. const URLProtocol **p = *opaque;
  76. p = p ? p + 1 : url_protocols;
  77. *opaque = p;
  78. if (!*p) {
  79. *opaque = NULL;
  80. return NULL;
  81. }
  82. if ((output && (*p)->url_write) || (!output && (*p)->url_read))
  83. return (*p)->name;
  84. return avio_enum_protocols(opaque, output);
  85. }
  86. const URLProtocol **ffurl_get_protocols(const char *whitelist,
  87. const char *blacklist)
  88. {
  89. const URLProtocol **ret;
  90. int i, ret_idx = 0;
  91. ret = av_mallocz_array(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
  92. if (!ret)
  93. return NULL;
  94. for (i = 0; url_protocols[i]; i++) {
  95. const URLProtocol *up = url_protocols[i];
  96. if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
  97. continue;
  98. if (blacklist && *blacklist && av_match_name(up->name, blacklist))
  99. continue;
  100. ret[ret_idx++] = up;
  101. }
  102. return ret;
  103. }