aboutsummaryrefslogtreecommitdiffstats
path: root/src/ogg_decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-31 01:21:17 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-31 01:21:17 +0000
commitfd6aa253594e18877ca2380961c0425a7de21b2e (patch)
treeb86fc645573adef9c0de9bd5f22eadffe3d16814 /src/ogg_decode.c
parentd7893a3e76d261b33b83fd9333d85892b3308594 (diff)
downloadmpd-fd6aa253594e18877ca2380961c0425a7de21b2e.tar.gz
mpd-fd6aa253594e18877ca2380961c0425a7de21b2e.tar.xz
mpd-fd6aa253594e18877ca2380961c0425a7de21b2e.zip
mp3 and ogg plugin stuff
git-svn-id: https://svn.musicpd.org/mpd/trunk@1245 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/ogg_plugin.c (renamed from src/ogg_decode.c)106
1 files changed, 96 insertions, 10 deletions
diff --git a/src/ogg_decode.c b/src/inputPlugins/ogg_plugin.c
index 22ae07727..af617378e 100644
--- a/src/ogg_decode.c
+++ b/src/inputPlugins/ogg_plugin.c
@@ -16,18 +16,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ogg_decode.h"
+#include "../inputPlugin.h"
#ifdef HAVE_OGG
-#include "command.h"
-#include "utils.h"
-#include "audio.h"
-#include "log.h"
-#include "pcm_utils.h"
-#include "inputStream.h"
-#include "outputBuffer.h"
-#include "replayGain.h"
+#include "../command.h"
+#include "../utils.h"
+#include "../audio.h"
+#include "../log.h"
+#include "../pcm_utils.h"
+#include "../inputStream.h"
+#include "../outputBuffer.h"
+#include "../replayGain.h"
#include <stdio.h>
#include <unistd.h>
@@ -274,5 +274,91 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
return 0;
}
+MpdTag * oggTagDup(char * utf8file) {
+ MpdTag * ret = NULL;
+ FILE * fp;
+ OggVorbis_File vf;
+ char ** comments;
+ char * temp;
+ char * s1;
+ char * s2;
+
+ fp = fopen(rmp2amp(utf8ToFsCharset(utf8file)),"r");
+ if(!fp) return NULL;
+ if(ov_open(fp,&vf,NULL,0)<0) {
+ fclose(fp);
+ return NULL;
+ }
+
+ ret = newMpdTag();
+ ret->time = (int)(ov_time_total(&vf,-1)+0.5);
+
+ comments = ov_comment(&vf,-1)->user_comments;
+
+ while(*comments) {
+ temp = strdup(*comments);
+ ++comments;
+ if(!(s1 = strtok(temp,"="))) continue;
+ s2 = strtok(NULL,"");
+ if(!s1 || !s2);
+ else if(0==strcasecmp(s1,"artist")) {
+ if(!ret->artist) {
+ stripReturnChar(s2);
+ ret->artist = strdup(s2);
+ }
+ }
+ else if(0==strcasecmp(s1,"title")) {
+ if(!ret->title) {
+ stripReturnChar(s2);
+ ret->title = strdup(s2);
+ }
+ }
+ else if(0==strcasecmp(s1,"album")) {
+ if(!ret->album) {
+ stripReturnChar(s2);
+ ret->album = strdup(s2);
+ }
+ }
+ else if(0==strcasecmp(s1,"tracknumber")) {
+ if(!ret->track) {
+ stripReturnChar(s2);
+ ret->track = strdup(s2);
+ }
+ }
+ free(temp);
+ }
+
+ ov_clear(&vf);
+
+ if(ret) validateUtf8Tag(ret);
+
+ return ret;
+}
+
+char * oggSuffixes[] = {"ogg", NULL};
+char * oggMimeTypes[] = {"application/ogg", NULL};
+
+InputPlugin oggPlugin =
+{
+ "ogg",
+ ogg_decode,
+ NULL,
+ oggTagDup,
+ INPUT_PLUGIN_STREAM_URL | INPUT_PLUGIN_STREAM_FILE,
+ oggSuffixes,
+ oggMimeTypes
+};
+
+#else
+
+InputPlugin oggPlugin =
+{
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL
+};
+
#endif
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */