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.

144 lines
4.8KB

  1. /*
  2. *
  3. * This file is part of Libav.
  4. *
  5. * Libav is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * Libav is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with Libav; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. /**
  20. * @file
  21. * unbuffered private I/O API
  22. */
  23. #ifndef AVFORMAT_URL_H
  24. #define AVFORMAT_URL_H
  25. #include "avio.h"
  26. #include "libavformat/version.h"
  27. #if !FF_API_OLD_AVIO
  28. #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
  29. extern int (*url_interrupt_cb)(void);
  30. #endif
  31. /**
  32. * Create a URLContext for accessing to the resource indicated by
  33. * url, but do not initiate the connection yet.
  34. *
  35. * @param puc pointer to the location where, in case of success, the
  36. * function puts the pointer to the created URLContext
  37. * @param flags flags which control how the resource indicated by url
  38. * is to be opened
  39. * @return 0 in case of success, a negative value corresponding to an
  40. * AVERROR code in case of failure
  41. */
  42. int ffurl_alloc(URLContext **h, const char *url, int flags);
  43. /**
  44. * Connect an URLContext that has been allocated by ffurl_alloc
  45. */
  46. int ffurl_connect(URLContext *h);
  47. /**
  48. * Create an URLContext for accessing to the resource indicated by
  49. * url, and open it.
  50. *
  51. * @param puc pointer to the location where, in case of success, the
  52. * function puts the pointer to the created URLContext
  53. * @param flags flags which control how the resource indicated by url
  54. * is to be opened
  55. * @return 0 in case of success, a negative value corresponding to an
  56. * AVERROR code in case of failure
  57. */
  58. int ffurl_open(URLContext **h, const char *url, int flags);
  59. /**
  60. * Read up to size bytes from the resource accessed by h, and store
  61. * the read bytes in buf.
  62. *
  63. * @return The number of bytes actually read, or a negative value
  64. * corresponding to an AVERROR code in case of error. A value of zero
  65. * indicates that it is not possible to read more from the accessed
  66. * resource (except if the value of the size argument is also zero).
  67. */
  68. int ffurl_read(URLContext *h, unsigned char *buf, int size);
  69. /**
  70. * Read as many bytes as possible (up to size), calling the
  71. * read function multiple times if necessary.
  72. * This makes special short-read handling in applications
  73. * unnecessary, if the return value is < size then it is
  74. * certain there was either an error or the end of file was reached.
  75. */
  76. int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
  77. /**
  78. * Write size bytes from buf to the resource accessed by h.
  79. *
  80. * @return the number of bytes actually written, or a negative value
  81. * corresponding to an AVERROR code in case of failure
  82. */
  83. int ffurl_write(URLContext *h, const unsigned char *buf, int size);
  84. /**
  85. * Change the position that will be used by the next read/write
  86. * operation on the resource accessed by h.
  87. *
  88. * @param pos specifies the new position to set
  89. * @param whence specifies how pos should be interpreted, it must be
  90. * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
  91. * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
  92. * (return the filesize of the requested resource, pos is ignored).
  93. * @return a negative value corresponding to an AVERROR code in case
  94. * of failure, or the resulting file position, measured in bytes from
  95. * the beginning of the file. You can use this feature together with
  96. * SEEK_CUR to read the current file position.
  97. */
  98. int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
  99. /**
  100. * Close the resource accessed by the URLContext h, and free the
  101. * memory used by it.
  102. *
  103. * @return a negative value if an error condition occurred, 0
  104. * otherwise
  105. */
  106. int ffurl_close(URLContext *h);
  107. /**
  108. * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
  109. * if the operation is not supported by h, or another negative value
  110. * corresponding to an AVERROR error code in case of failure.
  111. */
  112. int64_t ffurl_size(URLContext *h);
  113. /**
  114. * Return the file descriptor associated with this URL. For RTP, this
  115. * will return only the RTP file descriptor, not the RTCP file descriptor.
  116. *
  117. * @return the file descriptor associated with this URL, or <0 on error.
  118. */
  119. int ffurl_get_file_handle(URLContext *h);
  120. /**
  121. * Register the URLProtocol protocol.
  122. *
  123. * @param size the size of the URLProtocol struct referenced
  124. */
  125. int ffurl_register_protocol(URLProtocol *protocol, int size);
  126. #endif //AVFORMAT_URL_H