Index: app/MetadataReader.c =================================================================== --- app/MetadataReader.c (revision 0) +++ app/MetadataReader.c (revision 0) @@ -0,0 +1,81 @@ + +/* MetadataReader.c + * Copyright (C) 2007 Peter Lemenkov + * + * This file is part of AlsaPlayer. + * + * AlsaPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * AlsaPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +*/ + +#include "MetadataReader.h" +#include +#include + +int get_stream_info (char* uri, stream_info* si) +{ + int seconds; + int minutes; + TagLib_File *file; + TagLib_Tag *tag; + const TagLib_AudioProperties *properties; + + if (!uri) + return 0; + + taglib_set_strings_unicode(0); + + file = taglib_file_new(uri); + + if(file == NULL){ + printf ("Unsupported file type [%s]\n", uri); + return 0; + } + + tag = taglib_file_tag(file); + + properties = taglib_file_audioproperties(file); + + snprintf(si->path, SI_MAX_FIELD_LEN, "%s", uri); + snprintf(si->title, SI_MAX_FIELD_LEN, "%s", taglib_tag_title(tag)); + snprintf(si->artist, SI_MAX_FIELD_LEN, "%s", taglib_tag_artist(tag)); + snprintf(si->album, SI_MAX_FIELD_LEN, "%s", taglib_tag_album(tag)); + snprintf(si->year, 9, "%i", taglib_tag_year(tag)); // 10 - sizeof (trailing zero) + snprintf(si->comment, SI_MAX_FIELD_LEN, "%s", taglib_tag_comment(tag)); + snprintf(si->track, 9, "%i", taglib_tag_track(tag)); + snprintf(si->genre, SI_MAX_FIELD_LEN, "%s", taglib_tag_genre(tag)); + + si->bitrate = taglib_audioproperties_bitrate(properties); + si->sample_rate = taglib_audioproperties_samplerate(properties); + si->channels = taglib_audioproperties_channels(properties); + + taglib_tag_free_strings(); + taglib_file_free(file); + +// FIXME don't forget to remove + printf("-- TAG --\n"); + printf("title - \"%s\"\n", si->title); + printf("artist - \"%s\"\n", si->artist); + printf("album - \"%s\"\n", si->album); + printf("year - \"%s\"\n", si->year); + printf("comment - \"%s\"\n", si->comment); + printf("track - \"%s\"\n", si->track); + printf("genre - \"%s\"\n", si->genre); + printf("-- AUDIO --\n"); + printf("bitrate - %i\n", si->bitrate); + printf("sample rate - %i\n", si->sample_rate); + printf("channels - %i\n", si->channels); + + return 1; +} Index: app/CorePlayer.cpp =================================================================== --- app/CorePlayer.cpp (revision 1305) +++ app/CorePlayer.cpp (working copy) @@ -51,6 +51,8 @@ #include "utilities.h" #include "alsaplayer_error.h" +#include "MetadataReader.h" + extern void exit_sighandler(int); static char addon_dir[1024]; @@ -387,11 +389,13 @@ if (the_plugin->channels == NULL) { alsaplayer_error("No channels function"); error_count++; - } + } + if (the_plugin->stream_info == NULL) { alsaplayer_error("No stream_info function"); - error_count++; +// error_count++; // we don't require this function since generic metadata parsing } + if (the_plugin->shutdown == NULL) { alsaplayer_error("No shutdown function"); error_count++; @@ -555,8 +559,15 @@ memset(info, 0, sizeof(stream_info)); Lock(); - if (plugin && plugin->stream_info && info && the_object) { - result = plugin->stream_info(the_object, info); + if (plugin && info && the_object) { + if (plugin->stream_info) { + // plugin provides its own metadata parser + result = plugin->stream_info(the_object, info); + } + else{ + // we'll use generic metadata parser + result = get_stream_info (the_object->path, info); + } } Unlock(); @@ -877,6 +888,10 @@ return false; } + // Copy path into input_object structure for future use + the_object->path = (char*)malloc (strlen(path)); + sprintf (the_object->path, "%s", path); + the_object->ready = 1; plugin = best_plugin; Index: app/Makefile.am =================================================================== --- app/Makefile.am (revision 1305) +++ app/Makefile.am (working copy) @@ -17,7 +17,7 @@ endif -LIBS = -lpthread -ldl $(SUN_LIBS) +LIBS = -lpthread -ldl -ltag_c $(SUN_LIBS) COMMON_FLAGS = @DFLAGS@ -D_REENTRANT \ -DADDON_DIR=\"$(ADDON_DIR)\" \ @@ -41,7 +41,7 @@ alsaplayer_SOURCES = AlsaSubscriber.cpp \ AlsaNode.cpp Effects.cpp \ Main.cpp CorePlayer.cpp Playlist.cpp \ - SampleBuffer.cpp \ + MetadataReader.c SampleBuffer.cpp \ reverbst.cpp \ fft.c convolve.c utilities.c \ ControlSocket.cpp \ Index: input/mad/mad_engine.c =================================================================== --- input/mad/mad_engine.c (revision 1305) +++ input/mad/mad_engine.c (working copy) @@ -25,10 +25,6 @@ #include "config.h" #endif -#ifdef HAVE_GLIB2 -#include -#endif - #include #include #include @@ -50,10 +46,6 @@ * since we compile them with regular gcc */ #endif -#ifndef HAVE_LIBMAD /* Needed if we use our own (outdated) copy */ -#include "frame.h" -#include "synth.h" -#endif #include #ifdef __cplusplus @@ -95,8 +87,6 @@ int seekable; int seeking; int eof; - int parse_id3; - int parsed_id3; char str[17]; }; @@ -409,414 +399,6 @@ return obj->nr_frames; } -/* TODO: Move all id3 code into the separated file. */ - -/* Strip spaces from right to left */ -static void rstrip (char *s) { - int len = strlen (s); - - while (len && s[len-1] == ' ') { - len --; - s[len] = '\0'; - } -} - -/* Convert from synchsafe integer */ -static unsigned int from_synchsafe4 (unsigned char *buf) -{ - return (buf [3]) + (buf [2] << 7) + (buf [1] << 14) + (buf [0] << 21); -} - -static unsigned int from_synchsafe3 (unsigned char *buf) -{ - return (buf [3]) + (buf [2] << 7) + (buf [1] << 14); -} - -/* Fill filed */ -static void fill_from_id3v2 (char *dst, char *src, int max, int size) -{ - // it can be iso8851-1==0 utf16==1 utf16be==2 and utf8==3 - if (( *src < 0) || (*src > 3)) - return; - - char *conv = NULL; - - int min = size-1 > max ? max : size-1; - -#ifdef HAVE_GLIB2 - if (*src == 0) - conv = g_convert((const gchar *)src+1, (gssize) size, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); - else if (*src == 1) - conv = g_convert((const gchar *)src+1, (gssize) size, "UTF-8", "UTF-16", NULL, NULL, NULL); - else if (*src == 2) - conv = g_convert((const gchar *)src+1, (gssize) size, "UTF-8", "UTF-16BE", NULL, NULL, NULL); - else - conv = g_strndup(src+1, size); -#else -// alsaplayer_error ("Warning: Without glib2 you get different encodings."); - conv = strndup(src+1, size); -#endif - - if (!conv) // convert error - return; - - strncpy (dst, conv, min); - - if (conv) - free(conv); - -} - -static char *genres[] = { - "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", - "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", - "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", - "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", - "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", - "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", - "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", - "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-industrial", - "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", - "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", - "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", - "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", - "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", - "Folk/Rock", "National Folk", "Swing", "Fast-Fusion", "Bebob", "Latin", - "Revival", "Celtic", "Bluegrass", "Avantegarde", "Gothic Rock", - "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", - "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", - "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", - "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", - "Folklore", "Ballad", "Power Ballad", "Rythmic Soul", "Freestyle", "Duet", - "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall", "Goa", - "Drum & Bass", "Club House", "Hardcore", "Terror", "Indie", "BritPop", - "NegerPunk", "Polsk Punk", "Beat", "Christian Gangsta", "Heavy Metal", - "Black Metal", "Crossover", "Contemporary C", "Christian Rock", "Merengue", - "Salsa", "Thrash Metal", "Anime", "JPop", "SynthPop"}; - -/* Trying to fill info from id3 tagged file */ -static void parse_id3 (const char *path, stream_info *info) -{ - void *fd; - unsigned char buf [2024]; - unsigned char g; - - /* Open stream */ - fd = reader_open (path, NULL, NULL); - if (!fd) return; - - /* --------------------------------------------------- */ - /* Trying to load id3v2 tags */ - if (reader_read (buf, 10, fd) != 10) { - reader_close (fd); - return; - } - - if (memcmp(buf, "ID3", 3) == 0) { - /* Parse id3v2 tags */ - - /* Header */ - unsigned char major_version = buf [3]; - int f_unsynchronization = buf [5] & (1<<7); - int f_extended_header = buf [5] & (1<<6); - int f_experimental = buf [5] & (1<<5); - int header_size = from_synchsafe4 (buf + 6); - int name_size = buf [3] == 2 ? 3 : 4; - int ext_size = 0; - - if (f_extended_header) { -// alsaplayer_error ("FIXME: Extended header found in mp3." -// "Please contact alsaplayer team.\n" -// "Filename: %s", path); - // reader_close (fd); - // return; - ext_size = 1; //stupid but should do - } - - if (f_unsynchronization) { - alsaplayer_error ("FIXME: f_unsynchronization is set." - "Please contact alsaplayer team.\n" - "Filename: %s", path); - reader_close (fd); - return; - } - - if (f_experimental) { - alsaplayer_error ("FIXME: f_experimental is set." - "Please contact alsaplayer team.\n" - "Filename: %s", path); - reader_close (fd); - return; - } - - if (ext_size) { - char b[4]; - if (reader_read (b, 4, fd) != 4) { - reader_close(fd); - return; - } - if (major_version == 2) - ext_size = from_synchsafe3 (b); - else - ext_size = from_synchsafe4 (b); - - if (reader_seek (fd, ext_size - 4, SEEK_CUR) < 0) { - reader_close (fd); - return; - } - - } - - /* -- -- read frames -- -- */ - while (reader_tell (fd) <= header_size + 10) { - unsigned int size; - - - /* Get name of this frame */ - if (reader_read (buf, name_size, fd) != (unsigned)name_size) { - reader_close (fd); - return; - } - - if (buf [0] == '\0') break; - if (buf [0] < 'A') break; - if (buf [0] > 'Z') break; - - /* Get size */ - if (major_version == 2) { - char sb [3]; - - if (reader_read (sb, 3, fd) != 3) { - reader_close (fd); - return; - } - - size = from_synchsafe3 (sb); - } else { - char sb [4]; - - if (reader_read (sb, 4, fd) != 4) { - reader_close (fd); - return; - } - - size = from_synchsafe4 (sb); - } - - /* skip frame flags */ -// if (reader_seek (fd, 1, SEEK_CUR) == -1) { -// reader_close (fd); -// return; -// } - - int start = 0; - // read them - char b[2]; - if (reader_read (b, 2, fd) != 2) { - reader_close (fd); - return; - } else { - - if (b[1] & (1 << 6)) { -// printf ("Grouping added\n"); - start++; - } - if (b[1] & (1 << 3)) { -// printf ("Compression added\n"); - } - if (b[1] & (1 << 2)) { -// printf ("Encryption added\n"); - } - if (b[1] & (1 << 1)) { -// printf ("Unsynch added\n"); - } - if (b[1] & (1 << 0)) { -// printf ("Length added\n"); - start+=4; - } - } - - - - if (size>=1024) { - /* I will not support such long tags... - * Only if someone ask for it... - * not now... */ - - if (reader_seek (fd, size, SEEK_CUR) == -1) { - reader_close (fd); - return; - } - - continue; - } - - - /* read info */ - if (reader_read (buf + name_size, size, fd) != size) { - reader_close (fd); - return; - } - - /* !!! Ok. There we have frame name and data. */ - /* Lets use it. */ - if (name_size == 4) { - if (memcmp (buf, "TIT2", 4)==0) - fill_from_id3v2 (info->title, buf + name_size + start, - sizeof (info->title), size - start); - else if (memcmp (buf, "TPE1", 4)==0) - fill_from_id3v2 (info->artist, buf + name_size + start, - sizeof (info->artist), size - start); - else if (memcmp (buf, "TALB", 4)==0) - fill_from_id3v2 (info->album, buf + name_size + start, - sizeof (info->album), size - start); - else if (memcmp (buf, "TYER", 4)==0) - fill_from_id3v2 (info->year, buf + name_size + start, - sizeof (info->year), size - start); - else if (memcmp (buf, "COMM", 4)==0) - fill_from_id3v2 (info->comment, buf + name_size + start, - sizeof (info->comment), size - start); - else if (memcmp (buf, "TRCK", 4)==0) - fill_from_id3v2 (info->track, buf + name_size + start, - sizeof (info->track), size - start); - else if (memcmp (buf, "TCON", 4)==0) { - /* Genre */ - /* TODO: Optimize duplicated code */ - unsigned int gindex; - - if (sscanf (buf + name_size + start +1, "(%u)", &gindex)==1) { - if (gindex==255) - *info->genre = '\0'; - else if (sizeof (genres)/sizeof(char*) <= gindex) - snprintf (info->genre, sizeof (info->genre), "(%u)", gindex); - else - snprintf (info->genre, sizeof (info->genre), "%s", genres[gindex]); - } else - fill_from_id3v2 (info->genre, buf + name_size + start, - sizeof (info->genre), size - start); - } - } /* end of 'if name_size == 4' */ - - } /* end of frames read */ - - /* end parsing */ - reader_close (fd); - return; - } /* end of id3v2 parsing */ - - /* --------------------------------------------------- */ - /* Trying to load id3v1 tags */ - if (reader_seek (fd, -128, SEEK_END) == -1) { - reader_close (fd); - return; - } - - if (reader_read (buf, 128, fd) != 128) { - reader_close (fd); - return; - } - - if (memcmp(buf, "TAG", 3) == 0) { - /* ID3v1 frame found */ - - /* title */ - strncpy (info->title, buf + 3, 30); - rstrip (info->title); - - /* artist */ - strncpy (info->artist, buf + 33, 30); - rstrip (info->artist); - - /* album */ - strncpy (info->album, buf + 63, 30); - rstrip (info->album); - - /* year */ - strncpy (info->year, buf + 93, 4); - rstrip (info->year); - - /* comment */ - strncpy (info->comment, buf + 97, 28); - rstrip (info->comment); - - /* track number */ - if (buf [125] == '\0') - snprintf (info->track, sizeof (info->track), "%u", buf [126]); - - /* genre */ - g = buf [127]; - if (g==255) - *info->genre = '\0'; - else if (sizeof (genres)/sizeof(char*) <= g) - snprintf (info->genre, sizeof (info->genre), "(%u)", g); - else - snprintf (info->genre, sizeof (info->genre), "%s", genres[g]); - } /* end of id3v1 parsing */ - - reader_close (fd); -} - -static int mad_stream_info(input_object *obj, stream_info *info) -{ - struct mad_local_data *data; - unsigned len; - char metadata[256]; - char *s, *p; - - if (!obj || !info) - return 0; - - data = (struct mad_local_data *)obj->local_data; - - if (data) { - if (!data->parse_id3) { - sprintf(data->sinfo.title, "%s", data->filename); - } else if (!data->parsed_id3) { - if (reader_seekable(data->mad_fd)) { - parse_id3 (data->path, &data->sinfo); - if ((len = strlen(data->sinfo.title))) { - s = data->sinfo.title + (len - 1); - while (s != data->sinfo.title && *s == ' ') - *(s--) = '\0'; - } - if ((len = strlen(data->sinfo.artist))) { - s = data->sinfo.artist + (len - 1); - while (s != data->sinfo.artist && *s == ' ') - *(s--) = '\0'; - } - } - strncpy (data->sinfo.path, data->path, sizeof(data->sinfo.path)); - data->parsed_id3 = 1; - } - memset(metadata, 0, sizeof(metadata)); - if ((len = reader_metadata(data->mad_fd, sizeof(metadata), metadata))) { - //alsaplayer_error("Metadata: %s", metadata); - if ((s = strstr(metadata, "StreamTitle='"))) { - s += 13; - if ((p = strstr(s, "'"))) { - *p = '\0'; - snprintf(data->sinfo.title, 128, "%s", s); - } else { - alsaplayer_error("Malformed metadata: \"%s\"", metadata); - } - } - } - /* Restore permanently filled info */ - memcpy (info, &data->sinfo, sizeof (data->sinfo)); - - /* Compose path, stream_type and status fields */ - sprintf(info->stream_type, "MP3 %dKHz %s %-3ldkbit", - data->frame.header.samplerate / 1000, - obj->nr_channels == 2 ? "stereo" : "mono", - data->frame.header.bitrate / 1000); - - if (data->seeking) - sprintf(info->status, "Seeking..."); - } - return 1; -} - - static int mad_sample_rate(input_object *obj) { struct mad_local_data *data; @@ -1132,8 +714,6 @@ } strcpy(data->path, path); - data->parse_id3 = prefs_get_bool(ap_prefs, "mad", "parse_id3", 1); - return 1; } @@ -1193,7 +773,7 @@ mad_plugin.frame_to_sec = mad_frame_to_sec; mad_plugin.sample_rate = mad_sample_rate; mad_plugin.channels = mad_channels; - mad_plugin.stream_info = mad_stream_info; + mad_plugin.stream_info = NULL; return &mad_plugin; } Index: input/mad/Makefile.am =================================================================== --- input/mad/Makefile.am (revision 1305) +++ input/mad/Makefile.am (working copy) @@ -8,15 +8,8 @@ mad_insources = endif -if HAVE_LIBMAD -if HAVE_GLIB2 -extra_cflags = @GLIB2_CFLAGS@ -extra_libs = @GLIB2_LIBS@ -else extra_cflags = extra_libs = -endif -endif EXTRA_DIST = xing.c xing.h mad_engine.c Index: input/vorbis/vorbis_engine.c =================================================================== --- input/vorbis/vorbis_engine.c (revision 1305) +++ input/vorbis/vorbis_engine.c (working copy) @@ -267,65 +267,6 @@ return frames; } - -int vorbis_stream_info(input_object *obj, stream_info *info) -{ - struct vorbis_local_data *data; - vorbis_comment *comment; - vorbis_info *vi; - const char *t, *a, *l, *g, *y, *n, *c; - - if (!obj || !info) - return 0; - - data = (struct vorbis_local_data *)obj->local_data; - - if (data) { - strncpy (info->path, data->path, sizeof (info->path)); - if (obj->flags & P_SEEK && (comment = ov_comment(&data->vf, -1)) != NULL) { - t = vorbis_comment_query(comment, "title", 0); - a = vorbis_comment_query(comment, "artist", 0); - l = vorbis_comment_query(comment, "album", 0); - g = vorbis_comment_query(comment, "genre", 0); - y = vorbis_comment_query(comment, "date", 0); - n = vorbis_comment_query(comment, "tracknumber", 0); - c = vorbis_comment_query(comment, "description", 0); - - snprintf(info->title, sizeof(info->title), "%s", t ? t : ""); - snprintf(info->artist, sizeof(info->artist), "%s", a ? a : ""); - snprintf(info->album, sizeof(info->album), "%s", l ? l : ""); - snprintf(info->genre, sizeof(info->genre), "%s", g ? g : ""); - snprintf(info->year, sizeof(info->year), "%s", y ? y : ""); - snprintf(info->track, sizeof(info->track), "%s", n ? n : ""); - snprintf(info->comment, sizeof(info->comment), "%s", c ? c : ""); - } else { - snprintf(info->title, sizeof(info->title), "%s", data->path); - info->artist [0] = '\0'; - info->album [0] = '\0'; - info->genre [0] = '\0'; - info->year [0] = '\0'; - info->track [0] = '\0'; - info->comment [0] = '\0'; - } - - vi = ov_info(&data->vf, -1); - if (vi) { - long br = ov_bitrate_instant(&data->vf); - if (br > 0) - data->bitrate_instant = br; - sprintf(info->stream_type, "Vorbis %dKHz %s %-3dkbit", - (int)(vi->rate / 1000), - obj->nr_channels == 1 ? "mono":"stereo", - (int)(data->bitrate_instant / 1000)); - } else { - strcpy(info->stream_type, "Unkown OGG VORBIS"); - } - info->status[0] = 0; - } - return 1; -} - - static int vorbis_init(void) { return 1; @@ -495,7 +436,7 @@ vorbis_plugin.frame_to_sec = vorbis_frame_to_sec; vorbis_plugin.sample_rate = vorbis_sample_rate; vorbis_plugin.channels = vorbis_channels; - vorbis_plugin.stream_info = vorbis_stream_info; + vorbis_plugin.stream_info = NULL; return &vorbis_plugin; } Index: input/flac/FlacTag.cpp =================================================================== --- input/flac/FlacTag.cpp (revision 1305) +++ input/flac/FlacTag.cpp (working copy) @@ -1,85 +0,0 @@ -//----------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. This is the public interface -// class for tags. It's the default tag implementation for flac streams with -// no tag info. Other tag implementations (e.g. id3, ogg) are provided by -// subclasses of this class. -// -// Copyright (c) 2002 by Drew Hess -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//---------------------------------------------------------------------------- - -#include "FlacTag.h" -#include "FlacId3Tag.h" -#include "FlacMetadataTag.h" - - -using namespace std; - -namespace Flac -{ - -// static -bool -FlacTag::hasTag (const std::string & path) -{ - return FlacId3Tag::hasId3 (path) || FlacMetadataTag::hasMetadata (path); - -} // FlacTag::hasTag - - -// static -FlacTag * -FlacTag::newTag (const std::string & name) -{ - try - { - if (FlacId3Tag::hasId3 (name)) - return new FlacId3Tag (name); - else if (FlacMetadataTag::hasMetadata (name)) - return new FlacMetadataTag (name); - - return new FlacTag (name); - } - catch (...) - { - return 0; - } - -} // FlacTag::newTag - - -// static -FlacTag -FlacTag::tag (const std::string & name) -{ - if (FlacId3Tag::hasId3 (name)) - return FlacId3Tag (name); - if (FlacMetadataTag::hasMetadata (name)) - return FlacMetadataTag (name); - - return FlacTag (name); - -} // FlacTag::tag - - -FlacTag::FlacTag (const std::string & name) - : _name (name) -{ -} // FlacTag::FlacTag - -} // namespace Flac Index: input/flac/FlacMetadataTag.cpp =================================================================== --- input/flac/FlacMetadataTag.cpp (revision 1305) +++ input/flac/FlacMetadataTag.cpp (working copy) @@ -1,156 +0,0 @@ -//--------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. Supports flac -// VORBIS_COMMENT metadata blocks via libFLAC. -// -// Copyright (c) 2003 by Tim Evans -// -// Based on FlacId3v1Tag.cpp by Drew Hess . -// -// Changes: -// June 05, 2005 (Hubert Chan ) -// - don't use fixed-length buffers -// - use an array instead of a long if-else chain -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//-------------------------------------------------------------------------- - - -#include "FlacMetadataTag.h" - -#include -#include "reader.h" - -extern "C" { -#include -} - - -static bool -find_vorbis_comment_metadata (const char *filename, - FLAC__StreamMetadata **metadata) -{ - FLAC__Metadata_SimpleIterator *flac = FLAC__metadata_simple_iterator_new (); - if (!flac) - return false; - if (!FLAC__metadata_simple_iterator_init (flac, filename, true, false)) { - FLAC__metadata_simple_iterator_delete (flac); - return false; - } - - bool status = false; - FLAC__MetadataType type; - do { - type = FLAC__metadata_simple_iterator_get_block_type (flac); - if (type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { - status = true; - if (metadata) - *metadata = FLAC__metadata_simple_iterator_get_block (flac); - break; - } - } - while (FLAC__metadata_simple_iterator_next (flac)); - - FLAC__metadata_simple_iterator_delete (flac); - return status; -} - - -// Split the comment into key and value. Key and value are newly allocated -// strings and should be deleted after they are no longer needed. -// Returns true if the split was successful; false otherwise. -static bool -parse_comment (const FLAC__StreamMetadata_VorbisComment_Entry *comment, - char **key, char **value) -{ - FLAC__byte *sep; - size_t key_len, value_len; - - if ((sep = (FLAC__byte *) memchr(comment->entry, '=', comment->length)) - == NULL) - return false; - - key_len = sep - comment->entry; - value_len = comment->length - key_len - 1; - - (*key) = new char[key_len+1]; - memcpy (*key, comment->entry, key_len); - (*key)[key_len] = '\0'; - - (*value) = new char[value_len+1]; - memcpy (*value, sep + 1, value_len); - (*value)[value_len] = '\0'; - - return true; -} - - -namespace Flac -{ - -const FlacMetadataTag::field_mapping_t FlacMetadataTag::field_mappings[] = -{ - { "TITLE", &FlacMetadataTag::_title }, - { "ARTIST", &FlacMetadataTag::_artist }, - { "TRACKNUMBER", &FlacMetadataTag::_track }, - { "ALBUM", &FlacMetadataTag::_album }, - { "YEAR", &FlacMetadataTag::_year }, - { "DESCRIPTION", &FlacMetadataTag::_comment }, - { NULL, NULL } -}; - - -// static -bool -FlacMetadataTag::hasMetadata (const std::string & name) -{ - return find_vorbis_comment_metadata (name.c_str (), NULL); - -} // FlacMetadataTag::hasMetadata - - -FlacMetadataTag::FlacMetadataTag (const std::string & name) - : FlacTag (name) -{ - FLAC__StreamMetadata *metadata; - FLAC__StreamMetadata_VorbisComment_Entry *comment; - unsigned int i,j; - char *key, *value; - - if (!find_vorbis_comment_metadata (name.c_str (), &metadata)) - return; - - for (i=0; idata.vorbis_comment.num_comments; i++) { - comment = &metadata->data.vorbis_comment.comments[i]; - if (parse_comment(comment, &key, &value)) { - // look through the field mappings to see which field we have, and - // put it in the appropriate member - for (j=0; field_mappings[j].name != NULL; j++) { - if (strcmp (field_mappings[j].name, key) == 0) - { - (this->*(field_mappings[j].value)) = value; - } - } - delete key; - delete value; - } - } - - FLAC__metadata_object_delete (metadata); - -} // FlacMetadataTag::FlacMetadataTag - -} // namespace Flac Index: input/flac/FlacTag.h =================================================================== --- input/flac/FlacTag.h (revision 1305) +++ input/flac/FlacTag.h (working copy) @@ -1,156 +0,0 @@ -//----------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. This is the public interface -// class for tags. It's the default tag implementation for flac streams with -// no tag info. Other tag implementations (e.g. id3, ogg) are provided by -// subclasses of this class. -// -// Copyright (c) 2002 by Drew Hess -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//-------------------------------------------------------------------------- - -#ifndef _FLAC_TAG_H_ -#define _FLAC_TAG_H_ - -#include - -namespace Flac -{ - -class FlacTag -{ - public: - - //----------------------------------------------------------- - // Does the stream whose name is given have a recognized tag? - //----------------------------------------------------------- - - static bool hasTag (const std::string & name); - - - //----------------------------------------------------------- - // Factory method to construct the proper tag implementation. - // Returns a pointer to the new tag, or 0 if no tag could - // be created. - //----------------------------------------------------------- - - static FlacTag * newTag (const std::string & name); - - - //------------------------------------------------------------- - // Factory method similar to above, but this returns an object. - // Throws an exception if no tag could be created. - //------------------------------------------------------------- - - static FlacTag tag (const std::string & name); - - - //----------------------------------------------------------------- - // Create a flac tag object from the flac stream whose name is - // given. - //----------------------------------------------------------------- - - FlacTag (const std::string & name); - - virtual ~FlacTag (); - - - //-------------------------------------------------------------------- - // Access methods for tag fields. - // - // Any tags which are not present in the stream are returned as empty - // strings. - //-------------------------------------------------------------------- - - const std::string artist (); - const std::string title (); - const std::string track (); - const std::string album (); - const std::string year (); - const std::string comment (); - const std::string genre (); - - - protected: - - const std::string _name; - std::string _artist; - std::string _title; - std::string _track; - std::string _album; - std::string _year; - std::string _comment; - std::string _genre; - -}; // class FlacTag - - -//---------------- -// Inline methods. -//---------------- - -inline -FlacTag::~FlacTag () -{ -} - -inline const std::string -FlacTag::artist () -{ - return _artist; -} - -inline const std::string -FlacTag::title () -{ - return _title; -} - -inline const std::string -FlacTag::track () -{ - return _track; -} - -inline const std::string -FlacTag::album () -{ - return _album; -} - -inline const std::string -FlacTag::year () -{ - return _year; -} - -inline const std::string -FlacTag::comment () -{ - return _comment; -} - -inline const std::string -FlacTag::genre () -{ - return _genre; -} - -} // namespace Flac - -#endif // _FLAC_TAG_H_ - Index: input/flac/FlacId3Tag.h =================================================================== --- input/flac/FlacId3Tag.h (revision 1305) +++ input/flac/FlacId3Tag.h (working copy) @@ -1,68 +0,0 @@ -//--------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. Supports id3v1 tags -// without any additional libraries. Supports the id3v1 subset of -// fields for id3v2 tags if libid3tag is available. -// -// Copyright (c) 2002 by Drew Hess -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//-------------------------------------------------------------------------- - - -#ifndef _FLAC_ID3_TAG_H_ -#define _FLAC_ID3_TAG_H_ - -#include "FlacTag.h" - -namespace Flac -{ - -class FlacId3Tag : public FlacTag -{ - public: - - FlacId3Tag (const std::string & name); - - virtual ~FlacId3Tag (); - - protected: - - //-------------------------------------------------------------- - // Return true if the flac stream whose name is given has an id3 - // tag. - //-------------------------------------------------------------- - - static bool hasId3 (const std::string & name); - - friend class FlacTag; - -}; // class FlacId3Tag - - -//---------------- -// Inline methods. -//---------------- - -inline -FlacId3Tag::~FlacId3Tag () -{ -} - -} // namespace Flac - -#endif // _FLAC_ID3_TAG_H_ - Index: input/flac/FlacMetadataTag.h =================================================================== --- input/flac/FlacMetadataTag.h (revision 1305) +++ input/flac/FlacMetadataTag.h (working copy) @@ -1,80 +0,0 @@ -//--------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. Supports flac -// VORBIS_COMMENT metadata blocks via libFLAC. Based on FlacId3Tag.h. -// -// Copyright (c) 2003 by Tim Evans -// -// Based on FlacId3Tag.h by Drew Hess . -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//-------------------------------------------------------------------------- - - -#ifndef _FLAC_METADATA_TAG_H_ -#define _FLAC_METADATA_TAG_H_ - -#include "FlacTag.h" - -namespace Flac -{ - -class FlacMetadataTag : public FlacTag -{ - - // Map metadata names to the variable that they refer to - typedef struct - { - char *name; - std::string FlacMetadataTag::* value; - } - field_mapping_t; - - static const field_mapping_t field_mappings[]; - - public: - - FlacMetadataTag (const std::string & name); - - virtual ~FlacMetadataTag (); - - protected: - - //-------------------------------------------------------------- - // Return true if the flac stream whose name is given has a - // metadata tag. - //-------------------------------------------------------------- - - static bool hasMetadata (const std::string & name); - - friend class FlacTag; - -}; // class FlacMeatadataTag - - -//---------------- -// Inline methods. -//---------------- - -inline -FlacMetadataTag::~FlacMetadataTag () -{ -} - -} // namespace Flac - -#endif // _FLAC_METADATA_TAG_H_ - Index: input/flac/FlacId3v1Tag.cpp =================================================================== --- input/flac/FlacId3v1Tag.cpp (revision 1305) +++ input/flac/FlacId3v1Tag.cpp (working copy) @@ -1,106 +0,0 @@ -//--------------------------------------------------------------------------- -// Provide read-only access to flac stream tags. Supports id3v1 tags -// without any additional libraries. -// -// Copyright (c) 2002 by Drew Hess -// -// code theft from Josh Coalson's flac xmms plugin (C) 2001 by Josh Coalson -// -/* This file is part of AlsaPlayer. - * - * AlsaPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * AlsaPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -//-------------------------------------------------------------------------- - - -#include "FlacId3Tag.h" - -#include -#include -#include "reader.h" - -static bool -findId3Tag (reader_type * f, char * tag) -{ - if (reader_seek (f, -128, SEEK_END) != 0) - return false; - if (reader_read (tag, 128, f) != 128) - return false; - return strncmp (tag, "TAG", 3) == 0 ? true : false; - -} // findId3Tag - - -namespace Flac -{ - -typedef struct { - char raw[128]; - char title[31]; - char artist[31]; - char album[31]; - char comment[31]; - char year[5]; - char track[4]; - char genre[4]; -} id3v1_struct; - -// static -bool -FlacId3Tag::hasId3 (const std::string & name) -{ - static char tag[128]; - - reader_type * f = reader_open (name.c_str (), NULL, NULL); - if (!f) - return false; - - bool status = findId3Tag (f, tag); - reader_close (f); - return status; - -} // FlacId3Tag::hasId3 - - -FlacId3Tag::FlacId3Tag (const std::string & name) - : FlacTag (name) -{ - reader_type * f = reader_open (name.c_str (), NULL, NULL); - if (!f) - return; - - id3v1_struct tag; - memset ((void *) & tag, 0, sizeof (id3v1_struct)); - if (!findId3Tag (f, tag.raw)) - return; - - memcpy(tag.title, tag.raw+3, 30); - memcpy(tag.artist, tag.raw+33, 30); - memcpy(tag.album, tag.raw+63, 30); - memcpy(tag.year, tag.raw+93, 4); - memcpy(tag.comment, tag.raw+97, 30); - sprintf (tag.genre, "%u", (unsigned char) tag.raw[127]); - sprintf (tag.track, "%u", (unsigned char) tag.raw[126]); - - _artist = tag.artist; - _title = tag.title; - _track = tag.track; - _album = tag.album; - _year = tag.year; - _comment = tag.comment; - _genre = tag.genre; - -} // FlacId3Tag::FlacId3Tag - -} // namespace Flac Index: input/flac/FlacStream.cpp =================================================================== --- input/flac/FlacStream.cpp (revision 1305) +++ input/flac/FlacStream.cpp (working copy) @@ -23,7 +23,6 @@ #include "FlacEngine.h" #include "FlacStream.h" -#include "FlacTag.h" #include #include @@ -86,7 +85,6 @@ _sampPerBlock (0), _totalSamp (0), _decoder (0), - _tag (0), _name (name) { } // FlacStream::FlacStream @@ -102,8 +100,6 @@ } delete _engine; _engine = 0; - delete _tag; - _tag = 0; reader_close (_datasource); } // FlacStream::~FlacStream Index: input/flac/FlacPlugin.cpp =================================================================== --- input/flac/FlacPlugin.cpp (revision 1305) +++ input/flac/FlacPlugin.cpp (working copy) @@ -38,7 +38,6 @@ #include "FlacStream.h" #include "FlacEngine.h" #include "FlacSeekableStream.h" -#include "FlacTag.h" #ifdef HAVE_LIBOGGFLC #include "OggFlacStream.h" #endif @@ -169,14 +168,6 @@ { obj->frame_size = f->engine ()->apFrameSize (); - // attach a song info tag - - if (Flac::FlacTag::hasTag (f->name ())) - { - Flac::FlacTag * t = Flac::FlacTag::newTag (f->name ()); - f->setTag (t); - } - if (strncasecmp (name, "http://", 7) == 0) obj->flags |= P_STREAMBASED; else @@ -206,62 +197,6 @@ } } - -static int -flac_stream_info (input_object * obj, stream_info * info) -{ - if (!obj || !info) - return 0; - - Flac::FlacStream * f = (Flac::FlacStream *) obj->local_data; - if (!f) - return 0; - - sprintf (info->stream_type, "%d-bit %dKhz %s flac", - f->bps (), f->sampleRate () / 1000, - f->channels () == 1 ? "mono" : - f->channels () == 2 ? "stereo" : "multi-channel"); - - Flac::FlacTag * t = f->tag (); - if (t && ! t->title ().empty ()) - { - // strncpy limits come from looking at input_plugin.h; these should - // really be defined as constants somewhere - - strncpy (info->artist, t->artist ().c_str (), 128); - strncpy (info->title, t->title ().c_str (), 128); - strncpy (info->album, t->album ().c_str (), 128); - strncpy (info->genre, t->genre ().c_str (), 128); - strncpy (info->year, t->year ().c_str (), 10); - strncpy (info->track, t->track ().c_str (), 10); - strncpy (info->comment, t->comment ().c_str (), 128); - } - else - { - // use stream name - char * fname = strrchr (f->name ().c_str (), '/'); - if (fname) - { - fname++; - strncpy (info->title, fname, 128); - } - else - info->title[0] = 0; - - info->artist[0] = 0; - info->title[0] = 0; - info->album[0] = 0; - info->genre[0] = 0; - info->year[0] = 0; - info->track[0] = 0; - info->comment[0] = 0; - } - info->status[0] = 0; - - return 1; -} - - static float flac_can_handle (const char * name) { @@ -344,7 +279,7 @@ flac_plugin.frame_to_sec = flac_frame_to_centisec; flac_plugin.sample_rate = flac_sample_rate; flac_plugin.channels = flac_channels; - flac_plugin.stream_info = flac_stream_info; + flac_plugin.stream_info = NULL; return & flac_plugin; } Index: input/flac/FlacStream.h =================================================================== --- input/flac/FlacStream.h (revision 1305) +++ input/flac/FlacStream.h (working copy) @@ -45,7 +45,6 @@ { class FlacEngine; -class FlacTag; class FlacStream { @@ -92,20 +91,6 @@ FlacEngine * engine () const; - //---------------------------------------------------------------------- - // Get a pointer to the FlacTag for this stream, or 0 if there is none. - //---------------------------------------------------------------------- - - FlacTag * tag () const; - - - //---------------------------------- - // Set the FlacTag for this stream. - //---------------------------------- - - void setTag (FlacTag * tag); - - //----------------------------------- // Get the name of the flac stream. //----------------------------------- @@ -252,7 +237,6 @@ private: FLAC__StreamDecoder * _decoder; - FlacTag * _tag; const std::string _name; @@ -263,24 +247,12 @@ // Inline methods. //---------------- -inline FlacTag * -FlacStream::tag () const -{ - return _tag; -} - inline FlacEngine * FlacStream::engine () const { return _engine; } -inline void -FlacStream::setTag (FlacTag * tag) -{ - _tag = tag; -} - inline const std::string & FlacStream::name () const { Index: input/flac/Makefile.am =================================================================== --- input/flac/Makefile.am (revision 1305) +++ input/flac/Makefile.am (working copy) @@ -11,10 +11,9 @@ flac_inltlibs = libflac_in.la flac_inldflags = -export-dynamic -avoid-version -flac_insources = FlacEngine.cpp FlacPlugin.cpp FlacStream.cpp FlacTag.cpp \ - FlacSeekableStream.cpp FlacEngine.h FlacId3Tag.h \ - FlacMetadataTag.cpp FlacMetadataTag.h \ - FlacSeekableStream.h FlacStream.h FlacTag.h FlacId3v1Tag.cpp \ +flac_insources = FlacEngine.cpp FlacPlugin.cpp FlacStream.cpp \ + FlacSeekableStream.cpp FlacEngine.h \ + FlacSeekableStream.h FlacStream.h \ $(oggflac_insources) else @@ -25,10 +24,9 @@ endif -EXTRA_DIST = FlacEngine.cpp FlacPlugin.cpp FlacStream.cpp FlacTag.cpp \ - FlacId3v1Tag.cpp FlacEngine.h FlacStream.h FlacId3Tag.h \ - FlacTag.h FlacSeekableStream.cpp FlacSeekableStream.h \ - FlacMetadataTag.cpp FlacMetadataTag.h \ +EXTRA_DIST = FlacEngine.cpp FlacPlugin.cpp FlacStream.cpp \ + FlacEngine.h FlacStream.h \ + FlacSeekableStream.cpp FlacSeekableStream.h \ OggFlacStream.cpp OggFlacStream.h lib_LTLIBRARIES = $(flac_inltlibs) Index: input/mpg123/mpg123_engine.c =================================================================== --- input/mpg123/mpg123_engine.c (revision 1305) +++ input/mpg123/mpg123_engine.c (working copy) @@ -406,7 +406,7 @@ return 1; } - +/* int mpeg_stream_info(input_object *obj, stream_info *info) { struct mpeg_local_data *data; @@ -427,8 +427,8 @@ } return 1; } +*/ - static void mpeg_shutdown() { } @@ -453,8 +453,8 @@ mpeg_frame_to_sec, mpeg_sample_rate, mpeg_channels, - mpeg_stream_info, NULL, + NULL, NULL }; Index: input/cdda/cdda_engine.c =================================================================== --- input/cdda/cdda_engine.c (revision 1305) +++ input/cdda/cdda_engine.c (working copy) @@ -1295,33 +1295,8 @@ return 1; } - static input_plugin cdda_plugin; -/* - = { - INPUT_PLUGIN_VERSION, - 0, - "CDDA player v1.1", - "Andy Lo A Foe ", - NULL, - cdda_init, - cdda_shutdown, - NULL, - cdda_can_handle, - cdda_open, - cdda_close, - cdda_play_frame, - cdda_frame_seek, - cdda_frame_size, - cdda_nr_frames, - cdda_frame_to_sec, - cdda_sample_rate, - cdda_channels, - cdda_stream_info, - cdda_nr_tracks, - cdda_track_seek - }; - */ + #ifdef __cplusplus extern "C" { #endif Index: alsaplayer/MetadataReader.h =================================================================== --- alsaplayer/MetadataReader.h (revision 0) +++ alsaplayer/MetadataReader.h (revision 0) @@ -0,0 +1,38 @@ + +/* MetadataReader.h + * Copyright (C) 2007 Peter Lemenkov + * + * This file is part of AlsaPlayer. + * + * AlsaPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * AlsaPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +*/ + +#ifndef __MetadataReader_h__ +#define __MetadataReader_h__ + +#include "stream_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int get_stream_info (char* uri, stream_info* si); + +#ifdef __cplusplus +} +#endif + +#endif // __MetadataReader_h__ + Index: alsaplayer/stream_info.h =================================================================== --- alsaplayer/stream_info.h (revision 0) +++ alsaplayer/stream_info.h (revision 0) @@ -0,0 +1,102 @@ + +/* stream_info.h + * Copyright (C) 2007 Peter Lemenkov + * + * This file is part of AlsaPlayer. + * + * AlsaPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * AlsaPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * +*/ + +#ifndef __stream_info_h__ +#define __stream_info_h__ + +#define SI_MAX_FIELD_LEN 128 + +// some arch don't define PATH_MAX +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/** + * This structure is used to describe a stream/song + */ +typedef struct _stream_info +{ + /** + * Should describe what type of stream this is (MP3, OGG, etc). May + * also contain format data and things like sample rate. Text + */ + char stream_type[SI_MAX_FIELD_LEN+1]; + /** + * Author of the stream. Usually the name of the Artist or Band + */ + char artist[SI_MAX_FIELD_LEN+1]; + /** + * The song title. + */ + char title[SI_MAX_FIELD_LEN+1]; + /** + * The album name. + */ + char album[SI_MAX_FIELD_LEN+1]; + /** + * The genre of this song + */ + char genre[SI_MAX_FIELD_LEN+1]; + /** + * The year of this song + */ + char year[10]; + /** + * The track number of this song + */ + char track[10]; + /** + * The comment of this song + */ + char comment[SI_MAX_FIELD_LEN+1]; + /** + * The status of the plugin. Can have something like "Seeking..." + * or perhaps "Buffering" depending on what the plugin instance is + * doing. + */ + char status[SI_MAX_FIELD_LEN+1]; + /** + * The path of the stream + */ + char path[PATH_MAX+1]; + /** + * The number of channels + */ + int channels; + /** + * The number of tracks + */ + int tracks; + /** + * The current track; + */ + int current_track; + /** + * The sampling rate + */ + int sample_rate; + /** + * The bitrate + */ + int bitrate; +} stream_info; + +#endif // __stream_info_h__ Index: alsaplayer/input_plugin.h =================================================================== --- alsaplayer/input_plugin.h (revision 1305) +++ alsaplayer/input_plugin.h (working copy) @@ -23,6 +23,8 @@ #ifndef __input_plugin_h__ #define __input_plugin_h__ +#include "stream_info.h" + #include /** @@ -125,78 +127,6 @@ pthread_mutex_t object_mutex; } input_object; - -/** - * This structure is used to pass information about a stream/song from - * the plugin to the host. - */ -typedef struct _stream_info -{ - /** - * Should describe what type of stream this is (MP3, OGG, etc). May - * also contain format data and things like sample rate. Text - */ - char stream_type[128]; - /** - * Author of the stream. Usually the name of the Artist or Band - */ - char artist[128]; - /** - * The song title. - */ - char title[128]; - /** - * The album name. - */ - char album[128]; - /** - * The genre of this song - */ - char genre[128]; - /** - * The year of this song - */ - char year[10]; - /** - * The track number of this song - */ - char track[10]; - /** - * The comment of this song - */ - char comment[128]; - /** - * The status of the plugin. Can have something like "Seeking..." - * or perhaps "Buffering" depending on what the plugin instance is - * doing. - */ - char status[32]; - /** - * The path of the stream - */ - char path[1024]; - /** - * The number of channels - */ - int channels; - /** - * The number of tracks - */ - int tracks; - /** - * The current track; - */ - int current_track; - /** - * The sampling rate - */ - int sample_rate; - /** - * The bitrate - */ - int bitrate; -} stream_info; - /** * input plugin binary version. Must be set to INPUT_PLUGIN_VERSION */