[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23123 - in Extractor: src/plugins src/plugins/testdata tes
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23123 - in Extractor: src/plugins src/plugins/testdata test |
Date: |
Mon, 6 Aug 2012 00:42:00 +0200 |
Author: grothoff
Date: 2012-08-06 00:42:00 +0200 (Mon, 06 Aug 2012)
New Revision: 23123
Added:
Extractor/src/plugins/test_flac.c
Extractor/src/plugins/testdata/flac_kraftwerk.flac
Removed:
Extractor/test/kraftwerk1.flac
Extractor/test/test.rpm
Modified:
Extractor/src/plugins/
Extractor/src/plugins/Makefile.am
Extractor/src/plugins/flac_extractor.c
Log:
porting FLAC code to new API
Property changes on: Extractor/src/plugins
___________________________________________________________________
Modified: svn:ignore
- test_gif
test_mime
test_ogg
thumbnailextractorqt.loT
Makefile.in
Makefile
.deps
+ test_rpm
test_flac
test_gif
test_mime
test_ogg
thumbnailextractorqt.loT
Makefile.in
Makefile
.deps
Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am 2012-08-05 21:54:27 UTC (rev 23122)
+++ Extractor/src/plugins/Makefile.am 2012-08-05 22:42:00 UTC (rev 23123)
@@ -14,7 +14,8 @@
EXTRA_DIST = template_extractor.c \
testdata/ogg_courseclear.ogg \
testdata/gif_image.gif \
- testdata/rpm_test.rpm
+ testdata/rpm_test.rpm \
+ testdata/flac_kraftwerk.flac
if HAVE_VORBISFILE
PLUGIN_OGG=libextractor_ogg.la
@@ -36,11 +37,17 @@
TEST_RPM=test_rpm
endif
+if HAVE_FLAC
+PLUGIN_FLAC=libextractor_flac.la
+TEST_FLAC=test_flac
+endif
+
plugin_LTLIBRARIES = \
$(PLUGIN_OGG) \
$(PLUGIN_MIME) \
$(PLUGIN_GIF) \
- $(PLUGIN_RPM)
+ $(PLUGIN_RPM) \
+ $(PLUGIN_FLAC)
if HAVE_ZZUF
fuzz_tests=fuzz_default.sh
@@ -50,7 +57,8 @@
$(TEST_OGG) \
$(TEST_MIME) \
$(TEST_GIF) \
- $(TEST_RPM)
+ $(TEST_RPM) \
+ $(TEST_FLAC)
TESTS = \
$(fuzz_tests) \
@@ -66,6 +74,7 @@
$(top_builddir)/src/main/libextractor.la
+
libextractor_ogg_la_SOURCES = \
ogg_extractor.c
libextractor_ogg_la_LDFLAGS = \
@@ -122,4 +131,17 @@
$(top_builddir)/src/plugins/libtest.la
+libextractor_flac_la_SOURCES = \
+ flac_extractor.c
+libextractor_flac_la_LDFLAGS = \
+ $(PLUGINFLAGS)
+libextractor_flac_la_LIBADD = \
+ $(top_builddir)/src/main/libextractor.la \
+ -lFLAC
+test_flac_SOURCES = \
+ test_flac.c
+test_flac_LDADD = \
+ $(top_builddir)/src/plugins/libtest.la
+
+
Modified: Extractor/src/plugins/flac_extractor.c
===================================================================
--- Extractor/src/plugins/flac_extractor.c 2012-08-05 21:54:27 UTC (rev
23122)
+++ Extractor/src/plugins/flac_extractor.c 2012-08-05 22:42:00 UTC (rev
23123)
@@ -217,9 +217,12 @@
/**
- * FIXME.
+ * Give meta data to extractor.
+ *
+ * @param t type of the meta data
+ * @param s meta data value in utf8 format
*/
-#define ADD (t,s) do { if (ctx->ret == 0) ctx->ret = ctx->proc (ctx->proc_cls,
"flac", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0)
+#define ADD(t,s) do { ec->proc (ec->cls, "flac", t, EXTRACTOR_METAFORMAT_UTF8,
"text/plain", s, strlen (s) + 1); } while (0)
/**
@@ -235,7 +238,7 @@
{
char * d;
- if (NULL == (d = malloc(n+1)))
+ if (NULL == (d = malloc (n + 1)))
return NULL;
memcpy (d, s, n);
d[n] = '\0';
@@ -244,7 +247,14 @@
/**
- * FIXME.
+ * Check if a mapping exists for the given meta data value
+ * and if so give the result to LE.
+ *
+ * @param type type of the meta data according to FLAC
+ * @param type_length number of bytes in 'type'
+ * @param value meta data as UTF8 string (non 0-terminated)
+ * @param value_length number of bytes in value
+ * @param ec extractor context
*/
static void
check (const char *type,
@@ -269,6 +279,7 @@
continue;
ADD (tmap[i].type, tmp);
free (tmp);
+ break;
}
}
@@ -293,12 +304,12 @@
const char * eq;
unsigned int len;
unsigned int ilen;
-
+ char buf[128];
+
switch (metadata->type)
{
case FLAC__METADATA_TYPE_STREAMINFO:
{
- char buf[512];
snprintf (buf, sizeof (buf),
_("%u Hz, %u channels"),
metadata->data.stream_info.sample_rate,
@@ -322,7 +333,7 @@
eq = (const char*) entry->entry;
len = entry->length;
ilen = 0;
- while ( ('=' != *eq) && (*eq != '\0') &&
+ while ( ('=' != *eq) && ('\0' != *eq) &&
(ilen < len) )
{
eq++;
@@ -336,14 +347,12 @@
ilen,
eq,
len - ilen,
- ctx);
+ ec);
}
break;
}
case FLAC__METADATA_TYPE_PICTURE:
{
- if (0 != ctx->ret)
- break;
switch (metadata->data.picture.type)
{
case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER:
@@ -387,7 +396,7 @@
EXTRACTOR_METAFORMAT_BINARY,
metadata->data.picture.mime_type,
(const char*) metadata->data.picture.data,
- metadata->data.picture.data_length))
+ metadata->data.picture.data_length);
break;
}
case FLAC__METADATA_TYPE_PADDING:
Added: Extractor/src/plugins/test_flac.c
===================================================================
--- Extractor/src/plugins/test_flac.c (rev 0)
+++ Extractor/src/plugins/test_flac.c 2012-08-05 22:42:00 UTC (rev 23123)
@@ -0,0 +1,77 @@
+/*
+ This file is part of libextractor.
+ (C) 2012 Vidyut Samanta and Christian Grothoff
+
+ libextractor 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, or (at your
+ option) any later version.
+
+ libextractor 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 libextractor; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file plugins/test_flac.c
+ * @brief testcase for flac plugin
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "test_lib.h"
+
+
+
+/**
+ * Main function for the FLAC testcase.
+ *
+ * @param argc number of arguments (ignored)
+ * @param argv arguments (ignored)
+ * @return 0 on success
+ */
+int
+main (int argc, char *argv[])
+{
+ struct SolutionData kraftwerk_sol[] =
+ {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/flac",
+ strlen ("audio/flac") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44100 Hz, 2 channels",
+ strlen ("44100 Hz, 2 channels") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Test Title",
+ strlen ("Test Title") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] =
+ {
+ { "testdata/flac_kraftwerk.flac",
+ kraftwerk_sol },
+ { NULL, NULL }
+ };
+ return ET_main ("flac", ps);
+}
+
+/* end of test_flac.c */
Copied: Extractor/src/plugins/testdata/flac_kraftwerk.flac (from rev 23117,
Extractor/test/kraftwerk1.flac)
===================================================================
(Binary files differ)
Deleted: Extractor/test/kraftwerk1.flac
===================================================================
(Binary files differ)
Deleted: Extractor/test/test.rpm
===================================================================
(Binary files differ)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23123 - in Extractor: src/plugins src/plugins/testdata test,
gnunet <=