From 3f3026b349daf79ea832860777459ae8e0522f1c Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Mon, 8 May 2006 20:45:42 +0000 Subject: [PATCH] Add a function to set the default ID3v2 encoding in the C API. BUG:126192 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@538781 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- bindings/c/Makefile.am | 2 ++ bindings/c/tag_c.cpp | 38 +++++++++++++++++++++++++++++++------- bindings/c/tag_c.h | 20 +++++++++++++++++++- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/bindings/c/Makefile.am b/bindings/c/Makefile.am index 359e2c7b..d657a7b0 100644 --- a/bindings/c/Makefile.am +++ b/bindings/c/Makefile.am @@ -4,8 +4,10 @@ INCLUDES = \ -I$(top_srcdir)/taglib/mpeg \ -I$(top_srcdir)/taglib/ogg \ -I$(top_srcdir)/taglib/ogg/vorbis \ + -I$(top_srcdir)/taglib/ogg/flac \ -I$(top_srcdir)/taglib/flac \ -I$(top_srcdir)/taglib/mpc \ + -I$(top_srcdir)/taglib/mpeg/id3v2 \ $(all_includes) lib_LTLIBRARIES = libtag_c.la diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index f1334816..05d8eea6 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -26,18 +26,17 @@ #include #include #include +#include #include #include - -namespace TagLib -{ - static List strings; - static bool unicodeStrings = true; - static bool stringManagementEnabled = true; -} +#include using namespace TagLib; +static List strings; +static bool unicodeStrings = true; +static bool stringManagementEnabled = true; + void taglib_set_strings_unicode(BOOL unicode) { unicodeStrings = bool(unicode); @@ -68,6 +67,8 @@ TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type) return reinterpret_cast(new FLAC::File(filename)); case TagLib_File_MPC: return reinterpret_cast(new MPC::File(filename)); + case TagLib_File_OggFlac: + return reinterpret_cast(new Ogg::FLAC::File(filename)); } return 0; @@ -235,3 +236,26 @@ int taglib_audioproperties_channels(const TagLib_AudioProperties *audioPropertie const AudioProperties *p = reinterpret_cast(audioProperties); return p->channels(); } + +void taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_Encoding encoding) +{ + String::Type type = String::Latin1; + + switch(encoding) + { + case TagLib_ID3v2_Latin1: + type = String::Latin1; + break; + case TagLib_ID3v2_UTF16: + type = String::UTF16; + break; + case TagLib_ID3v2_UTF16BE: + type = String::UTF16BE; + break; + case TagLib_ID3v2_UTF8: + type = String::UTF8; + break; + } + + ID3v2::FrameFactory::instance()->setDefaultTextEncoding(type); +} diff --git a/bindings/c/tag_c.h b/bindings/c/tag_c.h index ea042489..ed9345fc 100644 --- a/bindings/c/tag_c.h +++ b/bindings/c/tag_c.h @@ -75,7 +75,8 @@ typedef enum { TagLib_File_MPEG, TagLib_File_OggVorbis, TagLib_File_FLAC, - TagLib_File_MPC + TagLib_File_MPC, + TagLib_File_OggFlac, } TagLib_File_Type; /*! @@ -243,6 +244,23 @@ int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioPropert */ int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties); +/******************************************************************************* + * Special convenience ID3v2 functions + *******************************************************************************/ + +typedef enum { + TagLib_ID3v2_Latin1, + TagLib_ID3v2_UTF16, + TagLib_ID3v2_UTF16BE, + TagLib_ID3v2_UTF8 +} TagLib_ID3v2_Encoding; + +/*! + * This sets the default encoding for ID3v2 frames that are written to tags. + */ + +void taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_Encoding encoding); + #ifdef __cplusplus } #endif