stream.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __DIRECT__STREAM_H__
  24. #define __DIRECT__STREAM_H__
  25. #include <stdio.h>
  26. #include <sys/time.h>
  27. #include <direct/types.h>
  28. /*
  29. * Create a stream wrapper.
  30. *
  31. * 'filename' can be a plain file name or one of the following:
  32. * http://<host>[:<port>]/<path>
  33. * unsv://<host>[:<port>]/<path>
  34. * ftp://<host>[:<port>]/<path>
  35. * rtsp://<host>[:<port>]/<path>
  36. * tcp://<host>:<port>
  37. * udp://<host>:<port>
  38. * file:/<path>
  39. * fd:/<fileno>
  40. * stdin:/
  41. */
  42. DirectResult direct_stream_create ( const char *filename,
  43. DirectStream **ret_stream );
  44. /*
  45. * Duplicate the stream (never fails).
  46. */
  47. DirectStream *direct_stream_dup ( DirectStream *stream );
  48. /*
  49. * Return the file descriptor associated to the stream.
  50. */
  51. int direct_stream_fileno ( DirectStream *stream );
  52. /*
  53. * True if stream is seekable.
  54. */
  55. bool direct_stream_seekable( DirectStream *stream );
  56. /*
  57. * True if stream originates from a remote host.
  58. */
  59. bool direct_stream_remote ( DirectStream *stream );
  60. /*
  61. * Get the mime description of the stream.
  62. * Returns NULL if the information is not available.
  63. */
  64. const char* direct_stream_mime ( DirectStream *stream );
  65. /*
  66. * Get stream length.
  67. */
  68. unsigned int direct_stream_length ( DirectStream *stream );
  69. /*
  70. * Get stream position.
  71. */
  72. unsigned int direct_stream_offset ( DirectStream *stream );
  73. /*
  74. * Wait for data to be available.
  75. * If 'timeout' is NULL, the function blocks indefinitely.
  76. * Set the 'timeout' to 0 to make the function return immediatly.
  77. */
  78. DirectResult direct_stream_wait ( DirectStream *stream,
  79. unsigned int length,
  80. struct timeval *timeout );
  81. /*
  82. * Peek 'length' bytes of data at offset 'offset' from the stream.
  83. */
  84. DirectResult direct_stream_peek ( DirectStream *stream,
  85. unsigned int length,
  86. int offset,
  87. void *buf,
  88. unsigned int *read_out );
  89. /*
  90. * Fetch 'length' bytes of data from the stream.
  91. */
  92. DirectResult direct_stream_read ( DirectStream *stream,
  93. unsigned int length,
  94. void *buf,
  95. unsigned int *read_out );
  96. /*
  97. * Seek to the specified absolute offset within the stream.
  98. */
  99. DirectResult direct_stream_seek ( DirectStream *stream,
  100. unsigned int offset );
  101. /*
  102. * Destroy the stream wrapper.
  103. */
  104. void direct_stream_destroy ( DirectStream *stream );
  105. #endif /* __DIRECT__STREAM_H__ */