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.

130 lines
4.4KB

  1. /*
  2. *
  3. * This file is part of FFmpeg.
  4. *
  5. * FFmpeg 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. * FFmpeg 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 FFmpeg; 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. /**
  27. * Create a URLContext for accessing to the resource indicated by
  28. * url, but do not initiate the connection yet.
  29. *
  30. * @param puc pointer to the location where, in case of success, the
  31. * function puts the pointer to the created URLContext
  32. * @param flags flags which control how the resource indicated by url
  33. * is to be opened
  34. * @return 0 in case of success, a negative value corresponding to an
  35. * AVERROR code in case of failure
  36. */
  37. int ffurl_alloc(URLContext **h, const char *url, int flags);
  38. /**
  39. * Connect an URLContext that has been allocated by ffurl_alloc
  40. */
  41. int ffurl_connect(URLContext *h);
  42. /**
  43. * Create an URLContext for accessing to the resource indicated by
  44. * url, and open it.
  45. *
  46. * @param puc pointer to the location where, in case of success, the
  47. * function puts the pointer to the created URLContext
  48. * @param flags flags which control how the resource indicated by url
  49. * is to be opened
  50. * @return 0 in case of success, a negative value corresponding to an
  51. * AVERROR code in case of failure
  52. */
  53. int ffurl_open(URLContext **h, const char *url, int flags);
  54. /**
  55. * Read up to size bytes from the resource accessed by h, and store
  56. * the read bytes in buf.
  57. *
  58. * @return The number of bytes actually read, or a negative value
  59. * corresponding to an AVERROR code in case of error. A value of zero
  60. * indicates that it is not possible to read more from the accessed
  61. * resource (except if the value of the size argument is also zero).
  62. */
  63. int ffurl_read(URLContext *h, unsigned char *buf, int size);
  64. /**
  65. * Read as many bytes as possible (up to size), calling the
  66. * read function multiple times if necessary.
  67. * This makes special short-read handling in applications
  68. * unnecessary, if the return value is < size then it is
  69. * certain there was either an error or the end of file was reached.
  70. */
  71. int ffurl_read_complete(URLContext *h, unsigned char *buf, int size);
  72. /**
  73. * Write size bytes from buf to the resource accessed by h.
  74. *
  75. * @return the number of bytes actually written, or a negative value
  76. * corresponding to an AVERROR code in case of failure
  77. */
  78. int ffurl_write(URLContext *h, const unsigned char *buf, int size);
  79. /**
  80. * Change the position that will be used by the next read/write
  81. * operation on the resource accessed by h.
  82. *
  83. * @param pos specifies the new position to set
  84. * @param whence specifies how pos should be interpreted, it must be
  85. * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
  86. * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
  87. * (return the filesize of the requested resource, pos is ignored).
  88. * @return a negative value corresponding to an AVERROR code in case
  89. * of failure, or the resulting file position, measured in bytes from
  90. * the beginning of the file. You can use this feature together with
  91. * SEEK_CUR to read the current file position.
  92. */
  93. int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
  94. /**
  95. * Close the resource accessed by the URLContext h, and free the
  96. * memory used by it.
  97. *
  98. * @return a negative value if an error condition occurred, 0
  99. * otherwise
  100. */
  101. int ffurl_close(URLContext *h);
  102. /**
  103. * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
  104. * if the operation is not supported by h, or another negative value
  105. * corresponding to an AVERROR error code in case of failure.
  106. */
  107. int64_t ffurl_size(URLContext *h);
  108. /**
  109. * Return the file descriptor associated with this URL. For RTP, this
  110. * will return only the RTP file descriptor, not the RTCP file descriptor.
  111. *
  112. * @return the file descriptor associated with this URL, or <0 on error.
  113. */
  114. int ffurl_get_file_handle(URLContext *h);
  115. #endif //AVFORMAT_URL_H