Permalink
Browse files

Add extra music tag parsers from Amarok

  • Loading branch information...
paulcbetts committed Dec 11, 2007
1 parent d90278e commit c68ec57e4ef8f1fe58eef910165a7d4bb341b7f6
Showing with 8,660 additions and 0 deletions.
  1. +38 −0 ext/taglib/taglib/aac/aacfiletyperesolver.cpp
  2. +84 −0 ext/taglib/taglib/audible/audibleproperties.cpp
  3. +161 −0 ext/taglib/taglib/audible/audibletag.cpp
  4. +120 −0 ext/taglib/taglib/audible/taglib_audiblefile.cpp
  5. +42 −0 ext/taglib/taglib/audible/taglib_audiblefiletyperesolver.cpp
  6. +150 −0 ext/taglib/taglib/m4a/boxfactory.cpp
  7. +89 −0 ext/taglib/taglib/m4a/itunesalbbox.cpp
  8. +89 −0 ext/taglib/taglib/m4a/itunesartbox.cpp
  9. +89 −0 ext/taglib/taglib/m4a/itunescmtbox.cpp
  10. +89 −0 ext/taglib/taglib/m4a/itunescvrbox.cpp
  11. +63 −0 ext/taglib/taglib/m4a/itunesdatabox.cpp
  12. +89 −0 ext/taglib/taglib/m4a/itunesdaybox.cpp
  13. +93 −0 ext/taglib/taglib/m4a/itunesdiskbox.cpp
  14. +89 −0 ext/taglib/taglib/m4a/itunesgenbox.cpp
  15. +89 −0 ext/taglib/taglib/m4a/itunesgrpbox.cpp
  16. +89 −0 ext/taglib/taglib/m4a/itunesnambox.cpp
  17. +93 −0 ext/taglib/taglib/m4a/itunestmpobox.cpp
  18. +93 −0 ext/taglib/taglib/m4a/itunestrknbox.cpp
  19. +89 −0 ext/taglib/taglib/m4a/ituneswrtbox.cpp
  20. +75 −0 ext/taglib/taglib/m4a/mp4audioproperties.cpp
  21. +146 −0 ext/taglib/taglib/m4a/mp4audiosampleentry.cpp
  22. +374 −0 ext/taglib/taglib/m4a/mp4file.cpp
  23. +84 −0 ext/taglib/taglib/m4a/mp4fourcc.cpp
  24. +75 −0 ext/taglib/taglib/m4a/mp4hdlrbox.cpp
  25. +97 −0 ext/taglib/taglib/m4a/mp4ilstbox.cpp
  26. +76 −0 ext/taglib/taglib/m4a/mp4isobox.cpp
  27. +67 −0 ext/taglib/taglib/m4a/mp4isofullbox.cpp
  28. +196 −0 ext/taglib/taglib/m4a/mp4itunestag.cpp
  29. +111 −0 ext/taglib/taglib/m4a/mp4mdiabox.cpp
  30. +86 −0 ext/taglib/taglib/m4a/mp4metabox.cpp
  31. +104 −0 ext/taglib/taglib/m4a/mp4minfbox.cpp
  32. +86 −0 ext/taglib/taglib/m4a/mp4moovbox.cpp
  33. +140 −0 ext/taglib/taglib/m4a/mp4mvhdbox.cpp
  34. +89 −0 ext/taglib/taglib/m4a/mp4propsproxy.cpp
  35. +59 −0 ext/taglib/taglib/m4a/mp4sampleentry.cpp
  36. +50 −0 ext/taglib/taglib/m4a/mp4skipbox.cpp
  37. +105 −0 ext/taglib/taglib/m4a/mp4stblbox.cpp
  38. +91 −0 ext/taglib/taglib/m4a/mp4stsdbox.cpp
  39. +168 −0 ext/taglib/taglib/m4a/mp4tagsproxy.cpp
  40. +86 −0 ext/taglib/taglib/m4a/mp4trakbox.cpp
  41. +95 −0 ext/taglib/taglib/m4a/mp4udtabox.cpp
  42. +42 −0 ext/taglib/taglib/m4a/taglib_mp4filetyperesolver.cpp
  43. +197 −0 ext/taglib/taglib/mp4/mp4file.cpp
  44. +120 −0 ext/taglib/taglib/mp4/mp4properties.cpp
  45. +127 −0 ext/taglib/taglib/mp4/mp4tag.cpp
  46. +48 −0 ext/taglib/taglib/mp4/taglib_mp4filetyperesolver.cpp
  47. +997 −0 ext/taglib/taglib/rmff/rmff.cpp
  48. +213 −0 ext/taglib/taglib/rmff/taglib_realmediafile.cpp
  49. +53 −0 ext/taglib/taglib/rmff/taglib_realmediafiletyperesolver.cpp
  50. +111 −0 ext/taglib/taglib/speex/speexfile.cpp
  51. +171 −0 ext/taglib/taglib/speex/speexproperties.cpp
  52. +44 −0 ext/taglib/taglib/speex/taglib_speexfiletyperesolver.cpp
  53. +137 −0 ext/taglib/taglib/tplugins.cpp
  54. +44 −0 ext/taglib/taglib/trueaudio/taglib_trueaudiofiletyperesolver.cpp
  55. +307 −0 ext/taglib/taglib/trueaudio/ttafile.cpp
  56. +134 −0 ext/taglib/taglib/trueaudio/ttaproperties.cpp
  57. +113 −0 ext/taglib/taglib/wav/wavfile.cpp
  58. +42 −0 ext/taglib/taglib/wav/wavfiletyperesolver.cpp
  59. +107 −0 ext/taglib/taglib/wav/wavproperties.cpp
  60. +44 −0 ext/taglib/taglib/wavpack/taglib_wavpackfiletyperesolver.cpp
  61. +311 −0 ext/taglib/taglib/wavpack/wvfile.cpp
  62. +141 −0 ext/taglib/taglib/wavpack/wvproperties.cpp
  63. +47 −0 ext/taglib/taglib/wma/taglib_wmafiletyperesolver.cpp
  64. +231 −0 ext/taglib/taglib/wma/wmaattribute.cpp
  65. +388 −0 ext/taglib/taglib/wma/wmafile.cpp
  66. +83 −0 ext/taglib/taglib/wma/wmaproperties.cpp
  67. +210 −0 ext/taglib/taglib/wma/wmatag.cpp
@@ -0,0 +1,38 @@
+/***************************************************************************
+ copyright : (C) 2006 by Martin Aumueller
+ email : aumuell@reserv.at
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "aacfiletyperesolver.h"
+#include <mpegfile.h>
+
+#include <string.h>
+
+TagLib::File *AACFileTypeResolver::createFile(const char *fileName,
+ bool readProperties,
+ TagLib::AudioProperties::ReadStyle propertiesStyle) const
+{
+ const char *ext = strrchr(fileName, '.');
+ if(ext && !strcasecmp(ext, ".aac"))
+ {
+ return new TagLib::MPEG::File(fileName, readProperties, propertiesStyle);
+ }
+
+ return 0;
+}
@@ -0,0 +1,84 @@
+/***************************************************************************
+ copyright : (C) 2005 by Martin Aumueller
+ email : aumuell@reserv.at
+
+ copyright : (C) 2005 by Andy Leadbetter
+ email : andrew.leadbetter@gmail.com
+ (original mp4 implementation)
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "audibleproperties.h"
+
+#include <tstring.h>
+
+#include "taglib_audiblefile.h"
+
+#include <netinet/in.h> // ntohl
+
+using namespace TagLib;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+Audible::Properties::Properties(Properties::ReadStyle style) : AudioProperties(style)
+{
+ m_length = 0;
+ m_bitrate = 0;
+ m_sampleRate = 0;
+ m_channels = 0;
+}
+
+Audible::Properties::~Properties()
+{
+}
+
+int Audible::Properties::length() const
+{
+ return m_length;
+}
+
+int Audible::Properties::bitrate() const
+{
+ return m_bitrate;
+}
+
+int Audible::Properties::sampleRate() const
+{
+ return m_sampleRate;
+}
+
+int Audible::Properties::channels() const
+{
+ return m_channels;
+}
+
+#define LENGTH_OFF 61
+
+void Audible::Properties::readAudibleProperties( FILE *fp, int off )
+{
+ fseek(fp, off+LENGTH_OFF, SEEK_SET );
+ fread(&m_length, sizeof(m_length), 1, fp);
+ m_length = ntohl(m_length);
+ //fprintf(stderr, "len (sec): %d\n", m_length);
+ m_bitrate = 0;
+ m_sampleRate = 0;
+ m_channels = 1;
+}
@@ -0,0 +1,161 @@
+/***************************************************************************
+ copyright : (C) 2005 by Martin Aumueller
+ email : aumuell@reserv.at
+
+ copyright : (C) 2005 by Andy Leadbetter
+ email : andrew.leadbetter@gmail.com
+ (original mp4 implementation)
+ ***************************************************************************/
+
+/***************************************************************************
+ * This library is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version *
+ * 2.1 as published by the Free Software Foundation. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "audibletag.h"
+
+#include <tag.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <netinet/in.h> // ntohl
+
+using namespace TagLib;
+
+Audible::Tag::Tag() : TagLib::Tag::Tag() {
+ m_title = String::null;
+ m_artist = String::null;
+ m_album = String::null;
+ m_comment = String::null;
+ m_genre = String::null;
+ m_year = 0;
+ m_track = 0;
+ m_userID = 0;
+ m_tagsEndOffset = -1;
+}
+
+Audible::Tag::~Tag() {
+}
+
+bool Audible::Tag::isEmpty() const {
+ return m_title == String::null &&
+ m_artist == String::null &&
+ m_album == String::null &&
+ m_comment == String::null &&
+ m_genre == String::null &&
+ m_year == 0 &&
+ m_track == 0 &&
+ m_userID == 0;
+}
+
+void Audible::Tag::duplicate(const Tag *source, Tag *target, bool overwrite) {
+ // No nonstandard information stored yet
+ Tag::duplicate(source, target, overwrite);
+}
+
+#define OFF_PRODUCT_ID 197
+#define OFF_TAGS 189
+
+void Audible::Tag::readTags( FILE *fp )
+{
+ char buf[1023];
+ fseek(fp, OFF_PRODUCT_ID, SEEK_SET);
+ fread(buf, strlen("product_id"), 1, fp);
+ if(memcmp(buf, "product_id", strlen("product_id")))
+ {
+ buf[20]='\0';
+ fprintf(stderr, "no valid Audible aa file: %s\n", buf);
+ return;
+ }
+
+ // Now parse tag.
+
+ fseek(fp, OFF_TAGS, SEEK_SET);
+ char *name, *value;
+
+ m_tagsEndOffset = OFF_TAGS;
+
+ bool lasttag = false;
+ while(!lasttag)
+ {
+ lasttag = !readTag(fp, &name, &value);
+ if(!strcmp(name, "title"))
+ {
+ m_title = String(value, String::Latin1);
+ }
+ else if(!strcmp(name, "author"))
+ {
+ m_artist = String(value, String::Latin1);
+ }
+ else if(!strcmp(name, "long_description"))
+ {
+ m_comment = String(value, String::Latin1);
+ }
+ else if(!strcmp(name, "description"))
+ {
+ if( m_comment.isNull() )
+ m_comment = String(value, String::Latin1);
+ }
+ else if(!strcmp(name, "pubdate"))
+ {
+ m_year = 0;
+ char *p = strrchr(value, '-');
+ if(p)
+ m_year = strtol(p+1, NULL, 10);
+ }
+ else if(!strcmp(name, "user_id"))
+ {
+ m_userID = strtol(value, NULL, 10);
+ }
+
+ delete[] name;
+ delete[] value;
+ }
+
+ m_album = String("", String::Latin1);
+ m_track = 0;
+ m_genre = String("Audiobook", String::Latin1);
+}
+
+bool Audible::Tag::readTag( FILE *fp, char **name, char **value)
+{
+ uint32_t nlen;
+ fread(&nlen, sizeof(nlen), 1, fp);
+ nlen = ntohl(nlen);
+ //fprintf(stderr, "tagname len=%x\n", (unsigned)nlen);
+ *name = new char[nlen+1];
+ (*name)[nlen] = '\0';
+
+ uint32_t vlen;
+ fread(&vlen, sizeof(vlen), 1, fp);
+ vlen = ntohl(vlen);
+ //fprintf(stderr, "tag len=%x\n", (unsigned)vlen);
+ *value = new char[vlen+1];
+ (*value)[vlen] = '\0';
+
+ fread(*name, nlen, 1, fp);
+ fread(*value, vlen, 1, fp);
+ char lasttag;
+ fread(&lasttag, 1, 1, fp);
+ //fprintf(stderr, "%s: \"%s\"\n", *name, *value);
+
+ m_tagsEndOffset += 2 * 4 + nlen + vlen + 1;
+
+ return !lasttag;
+}
+
+int Audible::Tag::getTagsEndOffset()
+{
+ return m_tagsEndOffset;
+}
Oops, something went wrong.

0 comments on commit c68ec57

Please sign in to comment.