Ok, let's go back a few steps. Apparently I really confused svn move by adding

the directory and moving things to it in the same commit.


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@588014 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler
2006-09-24 16:58:17 +00:00
parent 142568de6d
commit d0bfbf8ce4
17 changed files with 0 additions and 0 deletions

24
bindings/c/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/taglib ${CMAKE_SOURCE_DIR}/taglib/toolkit ${CMAKE_SOURCE_DIR}/taglib/mpeg ${CMAKE_SOURCE_DIR}/taglib/ogg ${CMAKE_SOURCE_DIR}/taglib/ogg/vorbis ${CMAKE_SOURCE_DIR}/taglib/ogg/flac ${CMAKE_SOURCE_DIR}/taglib/flac ${CMAKE_SOURCE_DIR}/taglib/mpc ${CMAKE_SOURCE_DIR}/taglib/mpeg/id3v2 )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/taglib_c.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_c.pc )
########### next target ###############
SET(tag_c_LIB_SRCS
tag_c.cpp
)
ADD_LIBRARY(tag_c SHARED ${tag_c_LIB_SRCS})
TARGET_LINK_LIBRARIES(tag_c tag )
SET_TARGET_PROPERTIES(tag_c PROPERTIES VERSION 0.0.0 SOVERSION 0 )
INSTALL(TARGETS tag_c DESTINATION ${LIB_INSTALL_DIR} )
########### install files ###############
INSTALL( FILES taglib_c.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL( FILES tag_c.h DESTINATION ${INCLUDE_INSTALL_DIR}/taglib)

25
bindings/c/Makefile.am Normal file
View File

@ -0,0 +1,25 @@
INCLUDES = \
-I$(top_srcdir)/taglib \
-I$(top_srcdir)/taglib/toolkit \
-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
libtag_c_la_SOURCES = tag_c.cpp
taglib_include_HEADERS = tag_c.h
taglib_includedir = $(includedir)/taglib
libtag_c_la_LDFLAGS = $(all_libraries) -no-undefined -version-info 0:0
libtag_c_la_LIBADD = ../../libtag.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = taglib_c.pc
EXTRA_DIST = $(libtag_c_la_SOURCES) $(taglib_include_HEADERS)

View File

@ -0,0 +1 @@
dnl AC_OUTPUT(taglib/bindings/c/taglib_c.pc)

261
bindings/c/tag_c.cpp Normal file
View File

@ -0,0 +1,261 @@
/***************************************************************************
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************/
#include "tag_c.h"
#include <fileref.h>
#include <tfile.h>
#include <vorbisfile.h>
#include <mpegfile.h>
#include <flacfile.h>
#include <oggflacfile.h>
#include <mpcfile.h>
#include <tag.h>
#include <id3v2framefactory.h>
using namespace TagLib;
static List<char *> strings;
static bool unicodeStrings = true;
static bool stringManagementEnabled = true;
void taglib_set_strings_unicode(BOOL unicode)
{
unicodeStrings = bool(unicode);
}
void taglib_set_string_management_enabled(BOOL management)
{
stringManagementEnabled = bool(management);
}
////////////////////////////////////////////////////////////////////////////////
// TagLib::File wrapper
////////////////////////////////////////////////////////////////////////////////
TagLib_File *taglib_file_new(const char *filename)
{
return reinterpret_cast<TagLib_File *>(FileRef::create(filename));
}
TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type)
{
switch(type) {
case TagLib_File_MPEG:
return reinterpret_cast<TagLib_File *>(new MPEG::File(filename));
case TagLib_File_OggVorbis:
return reinterpret_cast<TagLib_File *>(new Vorbis::File(filename));
case TagLib_File_FLAC:
return reinterpret_cast<TagLib_File *>(new FLAC::File(filename));
case TagLib_File_MPC:
return reinterpret_cast<TagLib_File *>(new MPC::File(filename));
case TagLib_File_OggFlac:
return reinterpret_cast<TagLib_File *>(new Ogg::FLAC::File(filename));
}
return 0;
}
void taglib_file_free(TagLib_File *file)
{
delete reinterpret_cast<File *>(file);
}
TagLib_Tag *taglib_file_tag(const TagLib_File *file)
{
const File *f = reinterpret_cast<const File *>(file);
return reinterpret_cast<TagLib_Tag *>(f->tag());
}
const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file)
{
const File *f = reinterpret_cast<const File *>(file);
return reinterpret_cast<const TagLib_AudioProperties *>(f->audioProperties());
}
BOOL taglib_file_save(TagLib_File *file)
{
return reinterpret_cast<File *>(file)->save();
}
////////////////////////////////////////////////////////////////////////////////
// TagLib::Tag wrapper
////////////////////////////////////////////////////////////////////////////////
char *taglib_tag_title(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
char *s = ::strdup(t->title().toCString(unicodeStrings));
if(stringManagementEnabled)
strings.append(s);
return s;
}
char *taglib_tag_artist(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
char *s = ::strdup(t->artist().toCString(unicodeStrings));
if(stringManagementEnabled)
strings.append(s);
return s;
}
char *taglib_tag_album(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
char *s = ::strdup(t->album().toCString(unicodeStrings));
if(stringManagementEnabled)
strings.append(s);
return s;
}
char *taglib_tag_comment(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
char *s = ::strdup(t->comment().toCString(unicodeStrings));
if(stringManagementEnabled)
strings.append(s);
return s;
}
char *taglib_tag_genre(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
char *s = ::strdup(t->genre().toCString(unicodeStrings));
if(stringManagementEnabled)
strings.append(s);
return s;
}
unsigned int taglib_tag_year(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
return t->year();
}
unsigned int taglib_tag_track(const TagLib_Tag *tag)
{
const Tag *t = reinterpret_cast<const Tag *>(tag);
return t->track();
}
void taglib_tag_set_title(TagLib_Tag *tag, const char *title)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setTitle(String(title, unicodeStrings ? String::UTF8 : String::Latin1));
}
void taglib_tag_set_artist(TagLib_Tag *tag, const char *artist)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setArtist(String(artist, unicodeStrings ? String::UTF8 : String::Latin1));
}
void taglib_tag_set_album(TagLib_Tag *tag, const char *album)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setAlbum(String(album, unicodeStrings ? String::UTF8 : String::Latin1));
}
void taglib_tag_set_comment(TagLib_Tag *tag, const char *comment)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setComment(String(comment, unicodeStrings ? String::UTF8 : String::Latin1));
}
void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setGenre(String(genre, unicodeStrings ? String::UTF8 : String::Latin1));
}
void taglib_tag_set_year(TagLib_Tag *tag, unsigned int year)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setYear(year);
}
void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track)
{
Tag *t = reinterpret_cast<Tag *>(tag);
t->setTrack(track);
}
void taglib_tag_free_strings()
{
if(!stringManagementEnabled)
return;
for(List<char *>::Iterator it = strings.begin(); it != strings.end(); ++it)
free(*it);
strings.clear();
}
////////////////////////////////////////////////////////////////////////////////
// TagLib::AudioProperties wrapper
////////////////////////////////////////////////////////////////////////////////
int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties)
{
const AudioProperties *p = reinterpret_cast<const AudioProperties *>(audioProperties);
return p->length();
}
int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties)
{
const AudioProperties *p = reinterpret_cast<const AudioProperties *>(audioProperties);
return p->bitrate();
}
int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties)
{
const AudioProperties *p = reinterpret_cast<const AudioProperties *>(audioProperties);
return p->sampleRate();
}
int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties)
{
const AudioProperties *p = reinterpret_cast<const AudioProperties *>(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);
}

268
bindings/c/tag_c.h Normal file
View File

@ -0,0 +1,268 @@
/***************************************************************************
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************/
#ifndef TAGLIB_TAG_C
#define TAGLIB_TAG_C
/* Do not include this in the main TagLib documentation. */
#ifndef DO_NOT_DOCUMENT
#ifdef __cplusplus
extern "C" {
#endif
#ifndef BOOL
#define BOOL int
#endif
/*******************************************************************************
* [ TagLib C Binding ]
*
* This is an interface to TagLib's "simple" API, meaning that you can read and
* modify media files in a generic, but not specialized way. This is a rough
* representation of TagLib::File and TagLib::Tag, for which the documentation
* is somewhat more complete and worth consulting.
*******************************************************************************/
/*
* These are used for type provide some type safety to the C API (as opposed to
* using void *, but pointers to them are simply cast to the coresponding C++
* types in the implementation.
*/
typedef struct { int dummy; } TagLib_File;
typedef struct { int dummy; } TagLib_Tag;
typedef struct { int dummy; } TagLib_AudioProperties;
/*!
* By default all strings coming into or out of TagLib's C API are in UTF8.
* However, it may be desirable for TagLib to operate on Latin1 (ISO-8859-1)
* strings in which case this should be set to FALSE.
*/
void taglib_set_strings_unicode(BOOL unicode);
/*!
* TagLib can keep track of strings that are created when outputting tag values
* and clear them using taglib_tag_clear_strings(). This is enabled by default.
* However if you wish to do more fine grained management of strings, you can do
* so by setting \a management to FALSE.
*/
void taglib_set_string_management_enabled(BOOL management);
/*******************************************************************************
* File API
******************************************************************************/
typedef enum {
TagLib_File_MPEG,
TagLib_File_OggVorbis,
TagLib_File_FLAC,
TagLib_File_MPC,
TagLib_File_OggFlac,
} TagLib_File_Type;
/*!
* Creates a TagLib file based on \a filename. TagLib will try to guess the file
* type.
*
* \returns NULL if the file type cannot be determined or the file cannot
* be opened.
*/
TagLib_File *taglib_file_new(const char *filename);
/*!
* Creates a TagLib file based on \a filename. Rather than attempting to guess
* the type, it will use the one specified by \a type.
*/
TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type);
/*!
* Frees and closes the file.
*/
void taglib_file_free(TagLib_File *file);
/*!
* Returns a pointer to the tag associated with this file. This will be freed
* automatically when the file is freed.
*/
TagLib_Tag *taglib_file_tag(const TagLib_File *file);
/*!
* Returns a pointer to the the audio properties associated with this file. This
* will be freed automatically when the file is freed.
*/
const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file);
/*!
* Saves the \a file to disk.
*/
BOOL taglib_file_save(TagLib_File *file);
/******************************************************************************
* Tag API
******************************************************************************/
/*!
* Returns a string with this tag's title.
*
* \note By default this string should be UTF8 encoded and its memory should be
* freed using taglib_tag_free_strings().
*/
char *taglib_tag_title(const TagLib_Tag *tag);
/*!
* Returns a string with this tag's artist.
*
* \note By default this string should be UTF8 encoded and its memory should be
* freed using taglib_tag_free_strings().
*/
char *taglib_tag_artist(const TagLib_Tag *tag);
/*!
* Returns a string with this tag's album name.
*
* \note By default this string should be UTF8 encoded and its memory should be
* freed using taglib_tag_free_strings().
*/
char *taglib_tag_album(const TagLib_Tag *tag);
/*!
* Returns a string with this tag's comment.
*
* \note By default this string should be UTF8 encoded and its memory should be
* freed using taglib_tag_free_strings().
*/
char *taglib_tag_comment(const TagLib_Tag *tag);
/*!
* Returns a string with this tag's genre.
*
* \note By default this string should be UTF8 encoded and its memory should be
* freed using taglib_tag_free_strings().
*/
char *taglib_tag_genre(const TagLib_Tag *tag);
/*!
* Returns the tag's year or 0 if year is not set.
*/
unsigned int taglib_tag_year(const TagLib_Tag *tag);
/*!
* Returns the tag's track number or 0 if track number is not set.
*/
unsigned int taglib_tag_track(const TagLib_Tag *tag);
/*!
* Sets the tag's title.
*
* \note By default this string should be UTF8 encoded.
*/
void taglib_tag_set_title(TagLib_Tag *tag, const char *title);
/*!
* Sets the tag's artist.
*
* \note By default this string should be UTF8 encoded.
*/
void taglib_tag_set_artist(TagLib_Tag *tag, const char *artist);
/*!
* Sets the tag's album.
*
* \note By default this string should be UTF8 encoded.
*/
void taglib_tag_set_album(TagLib_Tag *tag, const char *album);
/*!
* Sets the tag's comment.
*
* \note By default this string should be UTF8 encoded.
*/
void taglib_tag_set_comment(TagLib_Tag *tag, const char *comment);
/*!
* Sets the tag's genre.
*
* \note By default this string should be UTF8 encoded.
*/
void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre);
/*!
* Sets the tag's year. 0 indicates that this field should be cleared.
*/
void taglib_tag_set_year(TagLib_Tag *tag, unsigned int year);
/*!
* Sets the tag's track number. 0 indicates that this field should be cleared.
*/
void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track);
/*!
* Frees all of the strings that have been created by the tag.
*/
void taglib_tag_free_strings();
/******************************************************************************
* Audio Properties API
******************************************************************************/
/*!
* Returns the lenght of the file in seconds.
*/
int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties);
/*!
* Returns the bitrate of the file in kb/s.
*/
int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties);
/*!
* Returns the sample rate of the file in Hz.
*/
int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties);
/*!
* Returns the number of channels in the audio stream.
*/
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
#endif /* DO_NOT_DOCUMENT */
#endif

View File

@ -0,0 +1,12 @@
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${CMAKE_INSTALL_PREFIX}
libdir=${LIB_INSTALL_DIR}
includedir=${INCLUDE_INSTALL_DIR}
Name: TagLib C Bindings
Description: Audio meta-data library (C bindings)
Requires: taglib
Version: 1.4
Libs: -L${libdir} -ltag_c
Cflags: -I${includedir}/taglib

11
bindings/c/taglib_c.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: TagLib C Bindings
Description: Audio meta-data library (C bindings)
Requires: taglib
Version: 1.4
Libs: -L${libdir} -ltag_c
Cflags: -I${includedir}/taglib