MPD
input_stream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2010 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
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.
9  *
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.
14  *
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.
18  */
19 
20 #ifndef MPD_INPUT_STREAM_H
21 #define MPD_INPUT_STREAM_H
22 
23 #include "check.h"
24 
25 #include <glib.h>
26 
27 #include <stddef.h>
28 #include <stdbool.h>
29 #include <sys/types.h>
30 
31 #if !GLIB_CHECK_VERSION(2,14,0)
32 typedef gint64 goffset;
33 #endif
34 
35 struct input_stream {
39  const struct input_plugin *plugin;
40 
45  char *uri;
46 
51  bool ready;
52 
56  bool seekable;
57 
62 
67 
71  char *mime;
72 };
73 
74 static inline void
75 input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
76  const char *uri)
77 {
78  is->plugin = plugin;
79  is->uri = g_strdup(uri);
80  is->ready = false;
81  is->seekable = false;
82  is->size = -1;
83  is->offset = 0;
84  is->mime = NULL;
85 }
86 
87 static inline void
89 {
90  g_free(is->uri);
91  g_free(is->mime);
92 }
93 
100 struct input_stream *
101 input_stream_open(const char *uri, GError **error_r);
102 
106 void
107 input_stream_close(struct input_stream *is);
108 
117 bool
118 input_stream_seek(struct input_stream *is, goffset offset, int whence,
119  GError **error_r);
120 
124 bool input_stream_eof(struct input_stream *is);
125 
132 struct tag *
133 input_stream_tag(struct input_stream *is);
134 
143 int input_stream_buffer(struct input_stream *is, GError **error_r);
144 
154 size_t
155 input_stream_read(struct input_stream *is, void *ptr, size_t size,
156  GError **error_r);
157 
158 #endif