1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * This project's homepage is: http://www.musicpd.org
5 * Common functions used for Ogg data streams (Ogg-Vorbis and OggFLAC)
6 * (c) 2005 by Eric Wong <normalperson@yhbt.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "../inputPlugin.h"
24 #if defined(HAVE_OGGFLAC) || defined(HAVE_OGGVORBIS)
27 #include "_ogg_common.h"
31 ogg_stream_type
ogg_stream_type_detect(InputStream
* inStream
)
33 /* oggflac detection based on code in ogg123 and this post
34 * http://lists.xiph.org/pipermail/flac/2004-December/000393.html
35 * ogg123 trunk still doesn't have this patch as of June 2005 */
36 unsigned char buf
[41];
37 size_t r
, to_read
= 41;
39 seekInputStream(inStream
, 0, SEEK_SET
);
42 r
= readFromInputStream(inStream
, buf
, 1, to_read
);
46 if (!r
&& !inputStreamAtEOF(inStream
))
52 seekInputStream(inStream
, 0, SEEK_SET
);
54 if (r
>= 32 && memcmp(buf
, "OggS", 4) == 0 && ((memcmp
73 #endif /* defined(HAVE_OGGFLAC || defined(HAVE_OGGVORBIS) */