MPD

src/input_stream.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_INPUT_STREAM_H
00021 #define MPD_INPUT_STREAM_H
00022 
00023 #include "check.h"
00024 
00025 #include <glib.h>
00026 
00027 #include <stddef.h>
00028 #include <stdbool.h>
00029 #include <sys/types.h>
00030 
00031 #if !GLIB_CHECK_VERSION(2,14,0)
00032 typedef gint64 goffset;
00033 #endif
00034 
00035 struct input_stream {
00039         const struct input_plugin *plugin;
00040 
00045         char *uri;
00046 
00051         bool ready;
00052 
00056         bool seekable;
00057 
00061         goffset size;
00062 
00066         goffset offset;
00067 
00071         char *mime;
00072 };
00073 
00074 static inline void
00075 input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
00076                   const char *uri)
00077 {
00078         is->plugin = plugin;
00079         is->uri = g_strdup(uri);
00080         is->ready = false;
00081         is->seekable = false;
00082         is->size = -1;
00083         is->offset = 0;
00084         is->mime = NULL;
00085 }
00086 
00087 static inline void
00088 input_stream_deinit(struct input_stream *is)
00089 {
00090         g_free(is->uri);
00091         g_free(is->mime);
00092 }
00093 
00100 struct input_stream *
00101 input_stream_open(const char *uri, GError **error_r);
00102 
00106 void
00107 input_stream_close(struct input_stream *is);
00108 
00117 bool
00118 input_stream_seek(struct input_stream *is, goffset offset, int whence,
00119                   GError **error_r);
00120 
00124 bool input_stream_eof(struct input_stream *is);
00125 
00132 struct tag *
00133 input_stream_tag(struct input_stream *is);
00134 
00143 int input_stream_buffer(struct input_stream *is, GError **error_r);
00144 
00154 size_t
00155 input_stream_read(struct input_stream *is, void *ptr, size_t size,
00156                   GError **error_r);
00157 
00158 #endif