aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mp3_plugin.c (renamed from src/mp3_decode.c)71
-rw-r--r--src/inputPlugins/ogg_plugin.c (renamed from src/ogg_decode.c)106
2 files changed, 151 insertions, 26 deletions
diff --git a/src/mp3_decode.c b/src/inputPlugins/mp3_plugin.c
index 467a656df..5d34a1068 100644
--- a/src/mp3_decode.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -16,28 +16,27 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "mp3_decode.h"
+#include "../inputPlugin.h"
#ifdef HAVE_MAD
-#include "pcm_utils.h"
+#include "../pcm_utils.h"
#ifdef USE_MPD_MAD
-#include "libmad/mad.h"
+#include "../libmad/mad.h"
#else
#include <mad.h>
#endif
#ifdef HAVE_ID3TAG
#ifdef USE_MPD_ID3TAG
-#include "libid3tag/id3tag.h"
+#include "../libid3tag/id3tag.h"
#else
#include <id3tag.h>
#endif
#endif
-#include "playerData.h"
-#include "log.h"
-#include "utils.h"
-#include "inputStream.h"
-#include "outputBuffer.h"
+#include "../log.h"
+#include "../utils.h"
+#include "../tag.h"
+#include "../path.h"
#include <stdio.h>
#include <string.h>
@@ -419,10 +418,10 @@ int getMp3TotalTime(char * file) {
}
int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
- DecoderControl * dc, int ignoreCrc)
+ DecoderControl * dc)
{
initMp3DecodeData(data, inStream);
- if(ignoreCrc) data->stream.options |= MAD_OPTION_IGNORECRC;
+ data->stream.options |= MAD_OPTION_IGNORECRC;
if(decodeFirstFrame(data, dc)<0) {
mp3DecodeDataFinalize(data);
return -1;
@@ -565,12 +564,10 @@ void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, AudioFormat * af) {
af->channels = MAD_NCHANNELS(&(data->frame).header);
}
-int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream,
- int ignoreCrc)
-{
+int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
mp3DecodeData data;
- if(openMp3FromInputStream(inStream, &data, dc, ignoreCrc) < 0) {
+ if(openMp3FromInputStream(inStream, &data, dc) < 0) {
closeInputStream(inStream);
if(!dc->stop) {
ERROR("Input does not appear to be a mp3 bit stream.\n");
@@ -616,5 +613,47 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream,
return 0;
}
+MpdTag * mp3_tagDup(char * utf8file) {
+ MpdTag * ret = NULL;
+ int time;
+
+ ret = id3Dup(utf8file);
+
+ time = getMp3TotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
+
+ if(time>=0) {
+ if(!ret) ret = newMpdTag();
+ ret->time = time;
+ }
+
+ if(ret) validateUtf8Tag(ret);
+
+ return ret;
+}
+
+char * mp3_suffixes[] = {"mp3", NULL};
+char * mp3_mimeTypes[] = {"audio/mpeg", NULL};
+
+InputPlugin mp3Plugin =
+{
+ "mp3",
+ mp3_decode,
+ NULL,
+ mp3_tagDup,
+ INPUT_PLUGIN_STREAM_FILE | INPUT_PLUGIN_STREAM_URL,
+ mp3_suffixes,
+ mp3_mimeTypes
+};
+#else
+
+InputPlugin mp3Plugin =
+{
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL
+};
+
#endif
-/* vim:set shiftwidth=8 tabstop=8 expandtab: */
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: */