2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MPD_INPUT_STREAM_H
21 #define MPD_INPUT_STREAM_H
29 #include <sys/types.h>
31 #if !GLIB_CHECK_VERSION(2,14,0)
32 typedef gint64 goffset
;
37 * the plugin which implements this input stream
39 const struct input_plugin
*plugin
;
42 * The absolute URI which was used to open this stream. May
43 * be NULL if this is unknown.
48 * indicates whether the stream is ready for reading and
49 * whether the other attributes in this struct are valid
54 * if true, then the stream is fully seekable
59 * the size of the resource, or -1 if unknown
64 * the current offset within the stream
69 * the MIME content type of the resource, or NULL if unknown
75 input_stream_init(struct input_stream
*is
, const struct input_plugin
*plugin
,
79 is
->uri
= g_strdup(uri
);
88 input_stream_deinit(struct input_stream
*is
)
95 * Opens a new input stream. You may not access it until the "ready"
98 * @return an #input_stream object on success, NULL on error
100 struct input_stream
*
101 input_stream_open(const char *uri
, GError
**error_r
);
104 * Close the input stream and free resources.
107 input_stream_close(struct input_stream
*is
);
110 * Seeks to the specified position in the stream. This will most
111 * likely fail if the "seekable" flag is false.
113 * @param is the input_stream object
114 * @param offset the relative offset
115 * @param whence the base of the seek, one of SEEK_SET, SEEK_CUR, SEEK_END
118 input_stream_seek(struct input_stream
*is
, goffset offset
, int whence
,
122 * Returns true if the stream has reached end-of-file.
124 bool input_stream_eof(struct input_stream
*is
);
127 * Reads the tag from the stream.
129 * @return a tag object which must be freed with tag_free(), or NULL
130 * if the tag has not changed since the last call
133 input_stream_tag(struct input_stream
*is
);
136 * Reads some of the stream into its buffer. The following return
137 * codes are defined: -1 = error, 1 = something was buffered, 0 =
138 * nothing was buffered.
140 * The semantics of this function are not well-defined, and it will
141 * eventually be removed.
143 int input_stream_buffer(struct input_stream
*is
, GError
**error_r
);
146 * Reads data from the stream into the caller-supplied buffer.
147 * Returns 0 on error or eof (check with input_stream_eof()).
149 * @param is the input_stream object
150 * @param ptr the buffer to read into
151 * @param size the maximum number of bytes to read
152 * @return the number of bytes read
155 input_stream_read(struct input_stream
*is
, void *ptr
, size_t size
,