feat: added project files
This commit is contained in:
parent
13a2db3f75
commit
c956386b6e
|
@ -0,0 +1,2 @@
|
||||||
|
ncmdump*.exe
|
||||||
|
ncmdump
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Win32",
|
||||||
|
"includePath": [
|
||||||
|
"${default}"
|
||||||
|
],
|
||||||
|
"windowsSdkVersion": "10.0.19041.0",
|
||||||
|
"compilerPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\Hostx64\\x64\\cl.exe",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"intelliSenseMode": "windows-msvc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
win32:
|
||||||
|
g++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag -Ltaglib/lib -Itaglib/include -static -O
|
||||||
|
strip ncmdump.exe
|
||||||
|
|
||||||
|
linux:
|
||||||
|
g++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag
|
||||||
|
strip ncmdump
|
||||||
|
|
||||||
|
macos:
|
||||||
|
g++ main.cpp cJSON.cpp aes.cpp ncmcrypt.cpp -o ncmdump -ltag
|
||||||
|
strip ncmdump
|
|
@ -0,0 +1,305 @@
|
||||||
|
#include "aes.h"
|
||||||
|
|
||||||
|
unsigned char AES::sBox[] =
|
||||||
|
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||||
|
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0
|
||||||
|
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1
|
||||||
|
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, //2
|
||||||
|
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, //3
|
||||||
|
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, //4
|
||||||
|
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, //5
|
||||||
|
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, //6
|
||||||
|
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, //7
|
||||||
|
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, //8
|
||||||
|
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, //9
|
||||||
|
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, //a
|
||||||
|
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, //b
|
||||||
|
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //c
|
||||||
|
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //d
|
||||||
|
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //e
|
||||||
|
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 //f
|
||||||
|
};
|
||||||
|
unsigned char AES::invSBox[] =
|
||||||
|
{ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
|
||||||
|
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, //0
|
||||||
|
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, //1
|
||||||
|
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, //2
|
||||||
|
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, //3
|
||||||
|
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, //4
|
||||||
|
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, //5
|
||||||
|
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, //6
|
||||||
|
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, //7
|
||||||
|
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, //8
|
||||||
|
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, //9
|
||||||
|
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, //a
|
||||||
|
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, //b
|
||||||
|
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, //c
|
||||||
|
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, //d
|
||||||
|
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, //e
|
||||||
|
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d //f
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char AES::rcon[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
|
||||||
|
|
||||||
|
AES::AES()
|
||||||
|
{
|
||||||
|
//If no key is input,use the default key
|
||||||
|
unsigned char key[16] = {
|
||||||
|
0x0f, 0x15, 0x71, 0xc9,
|
||||||
|
0x47, 0xd9, 0xe8, 0x59,
|
||||||
|
0x0c, 0xb7, 0xad, 0xd6,
|
||||||
|
0xaf, 0x7f, 0x67, 0x98
|
||||||
|
};
|
||||||
|
setKey(key);
|
||||||
|
keyExpansion();
|
||||||
|
}
|
||||||
|
|
||||||
|
AES::AES(const unsigned char *key){
|
||||||
|
setKey(key);
|
||||||
|
keyExpansion();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::setKey(const unsigned char key[]){
|
||||||
|
mNb = 4;
|
||||||
|
mNk = 4;
|
||||||
|
mNr = 10;
|
||||||
|
memcpy(mKey, key, mNk * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::keyExpansion() {
|
||||||
|
//the first mNk words will be filled in mW derictly
|
||||||
|
for (int i = 0; i < mNk; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
//arranged vertically
|
||||||
|
mW[i][j] = mKey[j+i*4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//generate the secret key words
|
||||||
|
for (int i = mNk; i < mNb*(mNr + 1); i++){
|
||||||
|
//last secret key word
|
||||||
|
unsigned char pre_w[4];
|
||||||
|
|
||||||
|
for (int k = 0; k < 4; k++){
|
||||||
|
pre_w[k] = mW[i-1][k];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i%mNk == 0){
|
||||||
|
rotWord(pre_w);
|
||||||
|
subWord(pre_w);
|
||||||
|
pre_w[0] = pre_w[0] ^= rcon[i / mNk - 1];
|
||||||
|
}
|
||||||
|
else if ((mNk>6)&&(i%mNk==4)){
|
||||||
|
subWord(pre_w);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < 4; k++){
|
||||||
|
mW[i][k] = pre_w[k] ^ mW[i-mNk][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::subBytes(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = sBox[state[i][j]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::shiftRows(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
unsigned char t[4];
|
||||||
|
for (int i = 1; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
t[j] = state[i][(i + j) % 4];
|
||||||
|
}
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = t[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::mixColumns(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
unsigned char t[4];
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
t[i] = state[i][j];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
state[i][j] = GF28Multi(t[i], 0x02)
|
||||||
|
^ GF28Multi(t[(i + 1) % 4], 0x03)
|
||||||
|
^ GF28Multi(t[(i + 2) % 4], 0x01)
|
||||||
|
^ GF28Multi(t[(i + 3) % 4], 0x01);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::addRoundKey(unsigned char state[][4], unsigned char w[][4])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] ^= w[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::invSubBytes(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = invSBox[state[i][j]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::invShiftRows(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
unsigned char t[4];
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
t[j] = state[i][(j-i + 4) % 4];
|
||||||
|
}
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = t[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::invMixColumns(unsigned char state[][4])
|
||||||
|
{
|
||||||
|
unsigned char t[4];
|
||||||
|
//calculate columns by columns
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
t[i] = state[i][j];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
state[i][j] = GF28Multi(t[i], 0x0e)
|
||||||
|
^ GF28Multi(t[(i+1)%4],0x0b)
|
||||||
|
^ GF28Multi(t[(i+2)%4],0x0d)
|
||||||
|
^ GF28Multi(t[(i+3)%4],0x09);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AES::rotWord(unsigned char w[])
|
||||||
|
{
|
||||||
|
unsigned char t;
|
||||||
|
t = w[0];
|
||||||
|
w[0] = w[1];
|
||||||
|
w[1] = w[2];
|
||||||
|
w[2] = w[3];
|
||||||
|
w[3] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::subWord(unsigned char w[])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
w[i] = sBox[w[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//calculate the least significant unsigned char only for we only need
|
||||||
|
//the least significant byte
|
||||||
|
unsigned char AES::GF28Multi(unsigned char s,unsigned char a){
|
||||||
|
unsigned char t[4];
|
||||||
|
unsigned char result = 0;
|
||||||
|
t[0] = s;
|
||||||
|
|
||||||
|
//calculate s*{02},s*{03},s*{04}
|
||||||
|
for (int i = 1; i < 4; i++){
|
||||||
|
t[i] = t[i - 1] << 1;
|
||||||
|
if (t[i - 1] & 0x80){
|
||||||
|
t[i] ^= 0x1b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//multiply a and s bit by bit and sum together
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
if ((a >> i) & 0x01){
|
||||||
|
result ^= t[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::encrypt(const unsigned char data[16], unsigned char out[16])
|
||||||
|
{
|
||||||
|
unsigned char state[4][4];
|
||||||
|
unsigned char key[4][4];
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = data[i+j*4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeyAt(key, 0);
|
||||||
|
|
||||||
|
addRoundKey(state, key);
|
||||||
|
|
||||||
|
for (int i = 1; i <= mNr; i++){
|
||||||
|
subBytes(state);
|
||||||
|
shiftRows(state);
|
||||||
|
if (i != mNr){
|
||||||
|
mixColumns(state);
|
||||||
|
}
|
||||||
|
getKeyAt(key, i);
|
||||||
|
addRoundKey(state, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
out[i+j*4] = state[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES::decrypt(const unsigned char data[16], unsigned char out[16])
|
||||||
|
{
|
||||||
|
unsigned char state[4][4];
|
||||||
|
unsigned char key[4][4];
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
state[i][j] = data[i+j*4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeyAt(key, mNr);
|
||||||
|
addRoundKey(state,key);
|
||||||
|
|
||||||
|
for (int i = (mNr - 1); i >= 0; i--){
|
||||||
|
invShiftRows(state);
|
||||||
|
invSubBytes(state);
|
||||||
|
getKeyAt(key, i);
|
||||||
|
addRoundKey(state,key);
|
||||||
|
if (i){
|
||||||
|
invMixColumns(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
out[i + j * 4] = state[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the secret key for round "index",which will
|
||||||
|
//be arranged vetically
|
||||||
|
void AES::getKeyAt(unsigned char key[][4], int index){
|
||||||
|
for (int i = index*4; i < index*4+4; i++){
|
||||||
|
for (int j = 0; j < 4; j++){
|
||||||
|
key[j][i-index*4] = mW[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AES::~AES()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class AES {
|
||||||
|
|
||||||
|
public:
|
||||||
|
AES();
|
||||||
|
AES(const unsigned char *key);
|
||||||
|
virtual ~AES();
|
||||||
|
void encrypt(const unsigned char data[16], unsigned char out[16]);
|
||||||
|
void decrypt(const unsigned char data[16], unsigned char out[16]);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
int mNb;
|
||||||
|
|
||||||
|
//word length of the secret key used in one turn
|
||||||
|
int mNk;
|
||||||
|
|
||||||
|
//number of turns
|
||||||
|
int mNr;
|
||||||
|
|
||||||
|
//the secret key,which can be 16bytes,24bytes or 32bytes
|
||||||
|
unsigned char mKey[32];
|
||||||
|
|
||||||
|
//the extended key,which can be 176bytes,208bytes,240bytes
|
||||||
|
unsigned char mW[60][4];
|
||||||
|
|
||||||
|
static unsigned char sBox[];
|
||||||
|
static unsigned char invSBox[];
|
||||||
|
//constant
|
||||||
|
static unsigned char rcon[];
|
||||||
|
void setKey(const unsigned char *key);
|
||||||
|
|
||||||
|
void subBytes(unsigned char state[][4]);
|
||||||
|
void shiftRows(unsigned char state[][4]);
|
||||||
|
void mixColumns(unsigned char state[][4]);
|
||||||
|
void addRoundKey(unsigned char state[][4], unsigned char w[][4]);
|
||||||
|
|
||||||
|
void invSubBytes(unsigned char state[][4]);
|
||||||
|
void invShiftRows(unsigned char state[][4]);
|
||||||
|
void invMixColumns(unsigned char state[][4]);
|
||||||
|
|
||||||
|
void keyExpansion();
|
||||||
|
|
||||||
|
//
|
||||||
|
unsigned char GF28Multi(unsigned char s, unsigned char a);
|
||||||
|
|
||||||
|
void rotWord(unsigned char w[]);
|
||||||
|
void subWord(unsigned char w[]);
|
||||||
|
|
||||||
|
//get the secret key
|
||||||
|
void getKeyAt(unsigned char key[][4],int i);
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,96 @@
|
||||||
|
#ifndef _MACARON_BASE64_H_
|
||||||
|
#define _MACARON_BASE64_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
static const char sEncodingTable[] = {
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||||
|
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||||
|
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||||
|
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
|
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||||
|
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char kDecodingTable[] = {
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
|
||||||
|
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||||
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
|
||||||
|
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||||
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
|
||||||
|
};
|
||||||
|
|
||||||
|
class Base64 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
static std::string Encode(const std::string data) {
|
||||||
|
size_t in_len = data.size();
|
||||||
|
size_t out_len = 4 * ((in_len + 2) / 3);
|
||||||
|
std::string ret(out_len, '\0');
|
||||||
|
size_t i;
|
||||||
|
char *p = const_cast<char*>(ret.c_str());
|
||||||
|
|
||||||
|
for (i = 0; i < in_len - 2; i += 3) {
|
||||||
|
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F];
|
||||||
|
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int) (data[i + 1] & 0xF0) >> 4)];
|
||||||
|
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2) | ((int) (data[i + 2] & 0xC0) >> 6)];
|
||||||
|
*p++ = sEncodingTable[data[i + 2] & 0x3F];
|
||||||
|
}
|
||||||
|
if (i < in_len) {
|
||||||
|
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F];
|
||||||
|
if (i == (in_len - 1)) {
|
||||||
|
*p++ = sEncodingTable[((data[i] & 0x3) << 4)];
|
||||||
|
*p++ = '=';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int) (data[i + 1] & 0xF0) >> 4)];
|
||||||
|
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2)];
|
||||||
|
}
|
||||||
|
*p++ = '=';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string Decode(const std::string& input, std::string& out) {
|
||||||
|
size_t in_len = input.size();
|
||||||
|
if (in_len % 4 != 0) return "Input data size is not a multiple of 4";
|
||||||
|
|
||||||
|
size_t out_len = in_len / 4 * 3;
|
||||||
|
if (input[in_len - 1] == '=') out_len--;
|
||||||
|
if (input[in_len - 2] == '=') out_len--;
|
||||||
|
|
||||||
|
out.resize(out_len);
|
||||||
|
|
||||||
|
for (size_t i = 0, j = 0; i < in_len;) {
|
||||||
|
uint32_t a = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
|
||||||
|
uint32_t b = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
|
||||||
|
uint32_t c = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
|
||||||
|
uint32_t d = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
|
||||||
|
|
||||||
|
uint32_t triple = (a << 3 * 6) + (b << 2 * 6) + (c << 1 * 6) + (d << 0 * 6);
|
||||||
|
|
||||||
|
if (j < out_len) out[j++] = (triple >> 2 * 8) & 0xFF;
|
||||||
|
if (j < out_len) out[j++] = (triple >> 1 * 8) & 0xFF;
|
||||||
|
if (j < out_len) out[j++] = (triple >> 0 * 8) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _MACARON_BASE64_H_ */
|
|
@ -0,0 +1,277 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cJSON__h
|
||||||
|
#define cJSON__h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* project version */
|
||||||
|
#define CJSON_VERSION_MAJOR 1
|
||||||
|
#define CJSON_VERSION_MINOR 7
|
||||||
|
#define CJSON_VERSION_PATCH 7
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* cJSON Types: */
|
||||||
|
#define cJSON_Invalid (0)
|
||||||
|
#define cJSON_False (1 << 0)
|
||||||
|
#define cJSON_True (1 << 1)
|
||||||
|
#define cJSON_NULL (1 << 2)
|
||||||
|
#define cJSON_Number (1 << 3)
|
||||||
|
#define cJSON_String (1 << 4)
|
||||||
|
#define cJSON_Array (1 << 5)
|
||||||
|
#define cJSON_Object (1 << 6)
|
||||||
|
#define cJSON_Raw (1 << 7) /* raw json */
|
||||||
|
|
||||||
|
#define cJSON_IsReference 256
|
||||||
|
#define cJSON_StringIsConst 512
|
||||||
|
|
||||||
|
/* The cJSON structure: */
|
||||||
|
typedef struct cJSON
|
||||||
|
{
|
||||||
|
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||||
|
struct cJSON *next;
|
||||||
|
struct cJSON *prev;
|
||||||
|
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||||
|
struct cJSON *child;
|
||||||
|
|
||||||
|
/* The type of the item, as above. */
|
||||||
|
int type;
|
||||||
|
|
||||||
|
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||||
|
char *valuestring;
|
||||||
|
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||||
|
int valueint;
|
||||||
|
/* The item's number, if type==cJSON_Number */
|
||||||
|
double valuedouble;
|
||||||
|
|
||||||
|
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||||
|
char *string;
|
||||||
|
} cJSON;
|
||||||
|
|
||||||
|
typedef struct cJSON_Hooks
|
||||||
|
{
|
||||||
|
void *(*malloc_fn)(size_t sz);
|
||||||
|
void (*free_fn)(void *ptr);
|
||||||
|
} cJSON_Hooks;
|
||||||
|
|
||||||
|
typedef int cJSON_bool;
|
||||||
|
|
||||||
|
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||||
|
#define __WINDOWS__
|
||||||
|
#endif
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
|
||||||
|
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options:
|
||||||
|
|
||||||
|
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||||
|
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||||
|
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||||
|
|
||||||
|
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||||
|
|
||||||
|
setting default visibility to hidden by adding
|
||||||
|
-fvisibility=hidden (for gcc)
|
||||||
|
or
|
||||||
|
-xldscope=hidden (for sun cc)
|
||||||
|
to CFLAGS
|
||||||
|
|
||||||
|
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||||
|
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||||
|
#define CJSON_EXPORT_SYMBOLS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CJSON_HIDE_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) type __stdcall
|
||||||
|
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall
|
||||||
|
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||||
|
#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall
|
||||||
|
#endif
|
||||||
|
#else /* !WIN32 */
|
||||||
|
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||||
|
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||||
|
#else
|
||||||
|
#define CJSON_PUBLIC(type) type
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||||
|
* This is to prevent stack overflows. */
|
||||||
|
#ifndef CJSON_NESTING_LIMIT
|
||||||
|
#define CJSON_NESTING_LIMIT 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* returns the version of cJSON as a string */
|
||||||
|
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||||
|
|
||||||
|
/* Supply malloc, realloc and free functions to cJSON */
|
||||||
|
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||||
|
|
||||||
|
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||||
|
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||||
|
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||||
|
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||||
|
|
||||||
|
/* Render a cJSON entity to text for transfer/storage. */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||||
|
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||||
|
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||||
|
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||||
|
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||||
|
/* Delete a cJSON entity and all subentities. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
|
||||||
|
|
||||||
|
/* Returns the number of items in an array (or object). */
|
||||||
|
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||||
|
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||||
|
/* Get item "string" from object. Case insensitive. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||||
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||||
|
|
||||||
|
/* Check if the item is a string and return its valuestring */
|
||||||
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
|
||||||
|
|
||||||
|
/* These functions check the type of an item */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||||
|
|
||||||
|
/* These calls create a cJSON item of the appropriate type. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||||
|
/* raw json */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||||
|
|
||||||
|
/* Create a string where valuestring references a string so
|
||||||
|
* it will not be freed by cJSON_Delete */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||||
|
/* Create an object/arrray that only references it's elements so
|
||||||
|
* they will not be freed by cJSON_Delete */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||||
|
|
||||||
|
/* These utilities create an Array of count items. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
|
||||||
|
|
||||||
|
/* Append item to the specified array/object. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||||
|
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||||
|
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||||
|
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||||
|
* writing to `item->string` */
|
||||||
|
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||||
|
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||||
|
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||||
|
|
||||||
|
/* Remove/Detatch items from Arrays/Objects. */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||||
|
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||||
|
|
||||||
|
/* Update array items. */
|
||||||
|
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||||
|
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||||
|
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||||
|
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||||
|
|
||||||
|
/* Duplicate a cJSON item */
|
||||||
|
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||||
|
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||||
|
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||||
|
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||||
|
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||||
|
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||||
|
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||||
|
|
||||||
|
|
||||||
|
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||||
|
|
||||||
|
/* Helper functions for creating and adding items to an object at the same time.
|
||||||
|
* They return the added item or NULL on failure. */
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||||
|
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||||
|
|
||||||
|
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||||
|
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||||
|
/* helper for the cJSON_SetNumberValue macro */
|
||||||
|
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||||
|
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||||
|
|
||||||
|
/* Macro for iterating over an array or object */
|
||||||
|
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||||
|
|
||||||
|
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||||
|
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||||
|
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "ncmcrypt.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
if (argc <= 1) {
|
||||||
|
std::cout << "Please input file path!" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int i;
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
NeteaseCrypt crypt(argv[i]);
|
||||||
|
crypt.Dump();
|
||||||
|
crypt.FixMetadata();
|
||||||
|
|
||||||
|
std::cout << crypt.dumpFilepath() << std::endl;
|
||||||
|
}
|
||||||
|
} catch (std::invalid_argument e) {
|
||||||
|
std::cout << "Exception: " << e.what() << std::endl;
|
||||||
|
} catch (...) {
|
||||||
|
std::cout << "Unexcept exception!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,379 @@
|
||||||
|
#include "ncmcrypt.h"
|
||||||
|
#include "aes.h"
|
||||||
|
#include "base64.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
#define TAGLIB_STATIC
|
||||||
|
#include <taglib/mpegfile.h>
|
||||||
|
#include <taglib/flacfile.h>
|
||||||
|
#include <taglib/attachedpictureframe.h>
|
||||||
|
#include <taglib/id3v2tag.h>
|
||||||
|
#include <taglib/tag.h>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
const unsigned char NeteaseCrypt::sCoreKey[17] = {0x68, 0x7A, 0x48, 0x52, 0x41, 0x6D, 0x73, 0x6F, 0x35, 0x6B, 0x49, 0x6E, 0x62, 0x61, 0x78, 0x57, 0};
|
||||||
|
const unsigned char NeteaseCrypt::sModifyKey[17] = {0x23, 0x31, 0x34, 0x6C, 0x6A, 0x6B, 0x5F, 0x21, 0x5C, 0x5D, 0x26, 0x30, 0x55, 0x3C, 0x27, 0x28, 0};
|
||||||
|
|
||||||
|
const unsigned char NeteaseCrypt::mPng[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
|
||||||
|
|
||||||
|
static void aesEcbDecrypt(const unsigned char *key, std::string& src, std::string& dst) {
|
||||||
|
int n, i;
|
||||||
|
|
||||||
|
unsigned char out[16];
|
||||||
|
|
||||||
|
n = src.length() >> 4;
|
||||||
|
|
||||||
|
dst.clear();
|
||||||
|
|
||||||
|
AES aes(key);
|
||||||
|
|
||||||
|
for (i = 0; i < n-1; i++) {
|
||||||
|
aes.decrypt((unsigned char*)src.c_str() + (i << 4), out);
|
||||||
|
dst += std::string((char*)out, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
aes.decrypt((unsigned char*)src.c_str() + (i << 4), out);
|
||||||
|
char pad = out[15];
|
||||||
|
if (pad > 16) {
|
||||||
|
pad = 0;
|
||||||
|
}
|
||||||
|
dst += std::string((char*)out, 16-pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void replace(std::string& str, const std::string& from, const std::string& to) {
|
||||||
|
if(from.empty())
|
||||||
|
return;
|
||||||
|
size_t start_pos = 0;
|
||||||
|
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||||
|
str.replace(start_pos, from.length(), to);
|
||||||
|
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string fileNameWithoutExt(const std::string& str)
|
||||||
|
{
|
||||||
|
size_t lastPath = str.find_last_of("/\\");
|
||||||
|
std::string path = str.substr(lastPath+1);
|
||||||
|
size_t lastExt = path.find_last_of(".");
|
||||||
|
return path.substr(0, lastExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
NeteaseMusicMetadata::~NeteaseMusicMetadata() {
|
||||||
|
cJSON_Delete(mRaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
NeteaseMusicMetadata::NeteaseMusicMetadata(cJSON* raw) {
|
||||||
|
if (!raw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *swap;
|
||||||
|
int artistLen, i;
|
||||||
|
|
||||||
|
mRaw = raw;
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "musicName");
|
||||||
|
if (swap) {
|
||||||
|
mName = std::string(cJSON_GetStringValue(swap));
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "album");
|
||||||
|
if (swap) {
|
||||||
|
mAlbum = std::string(cJSON_GetStringValue(swap));
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "artist");
|
||||||
|
if (swap) {
|
||||||
|
artistLen = cJSON_GetArraySize(swap);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (i = 0; i < artistLen-1; i++) {
|
||||||
|
mArtist += std::string(cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetArrayItem(swap, i), 0)));
|
||||||
|
mArtist += "/";
|
||||||
|
}
|
||||||
|
mArtist += std::string(cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetArrayItem(swap, i), 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "bitrate");
|
||||||
|
if (swap) {
|
||||||
|
mBitrate = swap->valueint;
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "duration");
|
||||||
|
if (swap) {
|
||||||
|
mDuration = swap->valueint;
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = cJSON_GetObjectItem(raw, "format");
|
||||||
|
if (swap) {
|
||||||
|
mFormat = std::string(cJSON_GetStringValue(swap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NeteaseCrypt::openFile(std::string const& path) {
|
||||||
|
try {
|
||||||
|
mFile.open(path, std::ios::in | std::ios::binary);
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NeteaseCrypt::isNcmFile() {
|
||||||
|
unsigned int header;
|
||||||
|
|
||||||
|
mFile.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||||
|
if (header != (unsigned int)0x4e455443) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mFile.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||||
|
if (header != (unsigned int)0x4d414446) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NeteaseCrypt::read(char *s, std::streamsize n) {
|
||||||
|
mFile.read(s, n);
|
||||||
|
|
||||||
|
int gcount = mFile.gcount();
|
||||||
|
|
||||||
|
if (gcount <= 0) {
|
||||||
|
throw std::invalid_argument("can't read file");
|
||||||
|
}
|
||||||
|
|
||||||
|
return gcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeteaseCrypt::buildKeyBox(unsigned char *key, int keyLen) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 256; ++i) {
|
||||||
|
mKeyBox[i] = (unsigned char)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char swap = 0;
|
||||||
|
unsigned char c = 0;
|
||||||
|
unsigned char last_byte = 0;
|
||||||
|
unsigned char key_offset = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
swap = mKeyBox[i];
|
||||||
|
c = ((swap + last_byte + key[key_offset++]) & 0xff);
|
||||||
|
if (key_offset >= keyLen) key_offset = 0;
|
||||||
|
mKeyBox[i] = mKeyBox[c]; mKeyBox[c] = swap;
|
||||||
|
last_byte = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string NeteaseCrypt::mimeType(std::string& data) {
|
||||||
|
if (memcmp(data.c_str(), mPng, 8) == 0) {
|
||||||
|
return std::string("image/png");
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string("image/jpeg");
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeteaseCrypt::FixMetadata() {
|
||||||
|
if (mDumpFilepath.length() <= 0) {
|
||||||
|
throw std::invalid_argument("must dump before");
|
||||||
|
}
|
||||||
|
|
||||||
|
TagLib::File *audioFile;
|
||||||
|
TagLib::Tag *tag;
|
||||||
|
TagLib::ByteVector vector(mImageData.c_str(), mImageData.length());
|
||||||
|
|
||||||
|
if (mFormat == NeteaseCrypt::MP3) {
|
||||||
|
audioFile = new TagLib::MPEG::File(mDumpFilepath.c_str());
|
||||||
|
tag = dynamic_cast<TagLib::MPEG::File*>(audioFile)->ID3v2Tag(true);
|
||||||
|
|
||||||
|
if (mImageData.length() > 0) {
|
||||||
|
TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
|
||||||
|
|
||||||
|
frame->setMimeType(mimeType(mImageData));
|
||||||
|
frame->setPicture(vector);
|
||||||
|
|
||||||
|
dynamic_cast<TagLib::ID3v2::Tag*>(tag)->addFrame(frame);
|
||||||
|
}
|
||||||
|
} else if (mFormat == NeteaseCrypt::FLAC) {
|
||||||
|
audioFile = new TagLib::FLAC::File(mDumpFilepath.c_str());
|
||||||
|
tag = audioFile->tag();
|
||||||
|
|
||||||
|
if (mImageData.length() > 0) {
|
||||||
|
TagLib::FLAC::Picture *cover = new TagLib::FLAC::Picture;
|
||||||
|
cover->setMimeType(mimeType(mImageData));
|
||||||
|
cover->setType(TagLib::FLAC::Picture::FrontCover);
|
||||||
|
cover->setData(vector);
|
||||||
|
|
||||||
|
dynamic_cast<TagLib::FLAC::File*>(audioFile)->addPicture(cover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mMetaData != NULL) {
|
||||||
|
tag->setTitle(TagLib::String(mMetaData->name(), TagLib::String::UTF8));
|
||||||
|
tag->setArtist(TagLib::String(mMetaData->artist(), TagLib::String::UTF8));
|
||||||
|
tag->setAlbum(TagLib::String(mMetaData->album(), TagLib::String::UTF8));
|
||||||
|
}
|
||||||
|
|
||||||
|
tag->setComment(TagLib::String("Create by netease copyright protected dump tool. author 5L", TagLib::String::UTF8));
|
||||||
|
|
||||||
|
audioFile->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeteaseCrypt::Dump() {
|
||||||
|
int n, i;
|
||||||
|
|
||||||
|
// mDumpFilepath.clear();
|
||||||
|
// mDumpFilepath.resize(1024);
|
||||||
|
|
||||||
|
// if (mMetaData) {
|
||||||
|
// mDumpFilepath = mMetaData->name();
|
||||||
|
|
||||||
|
// replace(mDumpFilepath, "\\", "\");
|
||||||
|
// replace(mDumpFilepath, "/", "/");
|
||||||
|
// replace(mDumpFilepath, "?", "?");
|
||||||
|
// replace(mDumpFilepath, ":", ":");
|
||||||
|
// replace(mDumpFilepath, "*", "*");
|
||||||
|
// replace(mDumpFilepath, "\"", """);
|
||||||
|
// replace(mDumpFilepath, "<", "<");
|
||||||
|
// replace(mDumpFilepath, ">", ">");
|
||||||
|
// replace(mDumpFilepath, "|", "|");
|
||||||
|
// } else {
|
||||||
|
mDumpFilepath = fileNameWithoutExt(mFilepath);
|
||||||
|
// }
|
||||||
|
|
||||||
|
n = 0x8000;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
unsigned char buffer[n];
|
||||||
|
|
||||||
|
std::ofstream output;
|
||||||
|
|
||||||
|
while (!mFile.eof()) {
|
||||||
|
n = read((char*)buffer, n);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
int j = (i + 1) & 0xff;
|
||||||
|
buffer[i] ^= mKeyBox[(mKeyBox[j] + mKeyBox[(mKeyBox[j] + j) & 0xff]) & 0xff];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output.is_open()) {
|
||||||
|
// identify format
|
||||||
|
// ID3 format mp3
|
||||||
|
if (buffer[0] == 0x49 && buffer[1] == 0x44 && buffer[2] == 0x33) {
|
||||||
|
mDumpFilepath += ".mp3";
|
||||||
|
mFormat = NeteaseCrypt::MP3;
|
||||||
|
} else {
|
||||||
|
mDumpFilepath += ".flac";
|
||||||
|
mFormat = NeteaseCrypt::FLAC;
|
||||||
|
}
|
||||||
|
|
||||||
|
output.open(mDumpFilepath, output.out | output.binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
output.write((char*)buffer, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
output.flush();
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
NeteaseCrypt::~NeteaseCrypt() {
|
||||||
|
if (mMetaData != NULL) {
|
||||||
|
delete mMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
mFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
NeteaseCrypt::NeteaseCrypt(std::string const& path) {
|
||||||
|
if (!openFile(path)) {
|
||||||
|
throw std::invalid_argument("can't open file");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNcmFile()) {
|
||||||
|
throw std::invalid_argument("not netease protected file");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mFile.seekg(2, mFile.cur)) {
|
||||||
|
throw std::invalid_argument("can't seek file");
|
||||||
|
}
|
||||||
|
|
||||||
|
mFilepath = path;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
unsigned int n;
|
||||||
|
read(reinterpret_cast<char *>(&n), sizeof(n));
|
||||||
|
|
||||||
|
if (n <= 0) {
|
||||||
|
throw std::invalid_argument("broken ncm file");
|
||||||
|
}
|
||||||
|
|
||||||
|
char keydata[n];
|
||||||
|
read(keydata, n);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
keydata[i] ^= 0x64;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rawKeyData(keydata, n);
|
||||||
|
std::string mKeyData;
|
||||||
|
|
||||||
|
aesEcbDecrypt(sCoreKey, rawKeyData, mKeyData);
|
||||||
|
|
||||||
|
buildKeyBox((unsigned char*)mKeyData.c_str()+17, mKeyData.length()-17);
|
||||||
|
|
||||||
|
read(reinterpret_cast<char *>(&n), sizeof(n));
|
||||||
|
|
||||||
|
if (n <= 0) {
|
||||||
|
printf("[Warn] `%s` missing metadata infomation can't fix some infomation!\n", path.c_str());
|
||||||
|
|
||||||
|
mMetaData = NULL;
|
||||||
|
} else {
|
||||||
|
char modifyData[n];
|
||||||
|
read(modifyData, n);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
modifyData[i] ^= 0x63;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string swapModifyData;
|
||||||
|
std::string modifyOutData;
|
||||||
|
std::string modifyDecryptData;
|
||||||
|
|
||||||
|
swapModifyData = std::string(modifyData + 22, n - 22);
|
||||||
|
|
||||||
|
// escape `163 key(Don't modify):`
|
||||||
|
Base64::Decode(swapModifyData, modifyOutData);
|
||||||
|
|
||||||
|
aesEcbDecrypt(sModifyKey, modifyOutData, modifyDecryptData);
|
||||||
|
|
||||||
|
// escape `music:`
|
||||||
|
modifyDecryptData = std::string(modifyDecryptData.begin()+6, modifyDecryptData.end());
|
||||||
|
|
||||||
|
// std::cout << modifyDecryptData << std::endl;
|
||||||
|
|
||||||
|
mMetaData = new NeteaseMusicMetadata(cJSON_Parse(modifyDecryptData.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip crc32 & unuse charset
|
||||||
|
if (!mFile.seekg(9, mFile.cur)) {
|
||||||
|
throw std::invalid_argument("can't seek file");
|
||||||
|
}
|
||||||
|
|
||||||
|
read(reinterpret_cast<char *>(&n), sizeof(n));
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
char *imageData = (char*)malloc(n);
|
||||||
|
read(imageData, n);
|
||||||
|
|
||||||
|
mImageData = std::string(imageData, n);
|
||||||
|
} else {
|
||||||
|
printf("[Warn] `%s` missing album can't fix album image!\n", path.c_str());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "aes.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
class NeteaseMusicMetadata {
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string mAlbum;
|
||||||
|
std::string mArtist;
|
||||||
|
std::string mFormat;
|
||||||
|
std::string mName;
|
||||||
|
int mDuration;
|
||||||
|
int mBitrate;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cJSON* mRaw;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NeteaseMusicMetadata(cJSON*);
|
||||||
|
~NeteaseMusicMetadata();
|
||||||
|
const std::string& name() const { return mName; }
|
||||||
|
const std::string& album() const { return mAlbum; }
|
||||||
|
const std::string& artist() const { return mArtist; }
|
||||||
|
const std::string& format() const { return mFormat; }
|
||||||
|
const int duration() const { return mDuration; }
|
||||||
|
const int bitrate() const { return mBitrate; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class NeteaseCrypt {
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const unsigned char sCoreKey[17];
|
||||||
|
static const unsigned char sModifyKey[17];
|
||||||
|
static const unsigned char mPng[8];
|
||||||
|
enum NcmFormat { MP3, FLAC };
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string mFilepath;
|
||||||
|
std::string mDumpFilepath;
|
||||||
|
NcmFormat mFormat;
|
||||||
|
std::string mImageData;
|
||||||
|
std::ifstream mFile;
|
||||||
|
unsigned char mKeyBox[256];
|
||||||
|
NeteaseMusicMetadata* mMetaData;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isNcmFile();
|
||||||
|
bool openFile(std::string const&);
|
||||||
|
int read(char *s, std::streamsize n);
|
||||||
|
void buildKeyBox(unsigned char *key, int keyLen);
|
||||||
|
std::string mimeType(std::string& data);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string& filepath() const { return mFilepath; }
|
||||||
|
const std::string& dumpFilepath() const { return mDumpFilepath; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
NeteaseCrypt(std::string const&);
|
||||||
|
~NeteaseCrypt();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Dump();
|
||||||
|
void FixMetadata();
|
||||||
|
};
|
|
@ -0,0 +1,36 @@
|
||||||
|
@echo off
|
||||||
|
goto beginning
|
||||||
|
*
|
||||||
|
* It is what it is, you can do with it as you please.
|
||||||
|
*
|
||||||
|
* Just don't blame me if it teaches your computer to smoke!
|
||||||
|
*
|
||||||
|
* -Enjoy
|
||||||
|
* fh :)_~
|
||||||
|
*
|
||||||
|
:beginning
|
||||||
|
if /i "%1#" == "--libs#" goto doit
|
||||||
|
if /i "%1#" == "--cflags#" goto doit
|
||||||
|
if /i "%1#" == "--version#" goto doit
|
||||||
|
if /i "%1#" == "--prefix#" goto doit
|
||||||
|
|
||||||
|
echo "usage: %0 [OPTIONS]"
|
||||||
|
echo [--libs]
|
||||||
|
echo [--cflags]
|
||||||
|
echo [--version]
|
||||||
|
echo [--prefix]
|
||||||
|
goto theend
|
||||||
|
|
||||||
|
*
|
||||||
|
* NOTE: Windows does not assume libraries are prefixed with 'lib'.
|
||||||
|
* NOTE: If '-llibtag' is the last element, it is easily appended in the users installation/makefile process
|
||||||
|
* to allow for static, shared or debug builds.
|
||||||
|
* It would be preferable if the top level CMakeLists.txt provided the library name during config. ??
|
||||||
|
:doit
|
||||||
|
if /i "%1#" == "--libs#" echo -LC:/taglib/lib -llibtag
|
||||||
|
if /i "%1#" == "--cflags#" echo -IC:/taglib/include -IC:/taglib/include/taglib
|
||||||
|
if /i "%1#" == "--version#" echo 1.12
|
||||||
|
if /i "%1#" == "--prefix#" echo C:/taglib
|
||||||
|
|
||||||
|
:theend
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_AIFFFILE_H
|
||||||
|
#define TAGLIB_AIFFFILE_H
|
||||||
|
|
||||||
|
#include "rifffile.h"
|
||||||
|
#include "id3v2tag.h"
|
||||||
|
#include "aiffproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace RIFF {
|
||||||
|
|
||||||
|
//! An implementation of AIFF metadata
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is implementation of AIFF metadata.
|
||||||
|
*
|
||||||
|
* This supports an ID3v2 tag as well as reading stream from the ID3 RIFF
|
||||||
|
* chunk as well as properties from the file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace AIFF {
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with AIFF specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for AIFF files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to AIFF files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::RIFF::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an AIFF file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an AIFF file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Tag for this file.
|
||||||
|
*
|
||||||
|
* \note This always returns a valid pointer regardless of whether or not
|
||||||
|
* the file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \see hasID3v2Tag()
|
||||||
|
*/
|
||||||
|
virtual ID3v2::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* This method forwards to ID3v2::Tag::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* This method forwards to ID3v2::Tag::setProperties().
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the AIFF::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Saves the file.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save using a specific ID3v2 version (e.g. v3)
|
||||||
|
*/
|
||||||
|
bool save(ID3v2::Version version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v2Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v2Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Check if the given \a stream can be opened as an AIFF file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
friend class Properties;
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,166 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_AIFFPROPERTIES_H
|
||||||
|
#define TAGLIB_AIFFPROPERTIES_H
|
||||||
|
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace RIFF {
|
||||||
|
|
||||||
|
namespace AIFF {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for AIFF
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an AIFF stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of AIFF::Properties with the data read from the
|
||||||
|
* ByteVector \a data.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Properties(const ByteVector &data, ReadStyle style);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an instance of AIFF::Properties with the data read from the
|
||||||
|
* AIFF::File \a file.
|
||||||
|
*/
|
||||||
|
Properties(File *file, ReadStyle style);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this AIFF::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample.
|
||||||
|
*/
|
||||||
|
int bitsPerSample() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of bitsPerSample().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED int sampleWidth() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of sample frames
|
||||||
|
*/
|
||||||
|
unsigned int sampleFrames() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is in AIFF-C format, false if AIFF format.
|
||||||
|
*/
|
||||||
|
bool isAiffC() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the compression type of the AIFF-C file. For example, "NONE" for
|
||||||
|
* not compressed, "ACE2" for ACE 2-to-1.
|
||||||
|
*
|
||||||
|
* If the file is in AIFF format, always returns an empty vector.
|
||||||
|
*
|
||||||
|
* \see isAiffC()
|
||||||
|
*/
|
||||||
|
ByteVector compressionType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the concrete compression name of the AIFF-C file.
|
||||||
|
*
|
||||||
|
* If the file is in AIFF format, always returns an empty string.
|
||||||
|
*
|
||||||
|
* \see isAiffC()
|
||||||
|
*/
|
||||||
|
String compressionName() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(File *file);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,235 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2010 by Alex Novichkov
|
||||||
|
email : novichko@atnet.ru
|
||||||
|
|
||||||
|
copyright : (C) 2006 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
(original WavPack implementation)
|
||||||
|
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.org
|
||||||
|
(original MPC 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_APEFILE_H
|
||||||
|
#define TAGLIB_APEFILE_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "apeproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
|
||||||
|
namespace ID3v1 { class Tag; }
|
||||||
|
namespace APE { class Tag; }
|
||||||
|
|
||||||
|
//! An implementation of APE metadata
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is implementation of APE metadata.
|
||||||
|
*
|
||||||
|
* This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream
|
||||||
|
* properties from the file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with APE specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for APE files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to APE files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This set of flags is used for various operations and is suitable for
|
||||||
|
* being OR-ed together.
|
||||||
|
*/
|
||||||
|
enum TagTypes {
|
||||||
|
//! Empty set. Matches no tag types.
|
||||||
|
NoTags = 0x0000,
|
||||||
|
//! Matches ID3v1 tags.
|
||||||
|
ID3v1 = 0x0001,
|
||||||
|
//! Matches APE tags.
|
||||||
|
APE = 0x0002,
|
||||||
|
//! Matches all tag types.
|
||||||
|
AllTags = 0xffff
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an APE file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an APE file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
|
||||||
|
* or a combination of the two.
|
||||||
|
*/
|
||||||
|
virtual TagLib::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* If the file contains both an APE and an ID3v1 tag, only APE
|
||||||
|
* will be converted to the PropertyMap.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties. Forwards to the actual Tag's
|
||||||
|
* removeUnsupportedProperties() function.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* Creates an APEv2 tag if necessary. A potentially existing ID3v1
|
||||||
|
* tag will be updated as well.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the APE::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Saves the file.
|
||||||
|
*
|
||||||
|
* \note According to the official Monkey's Audio SDK, an APE file
|
||||||
|
* can only have either ID3V1 or APE tags, so a parameter is used here.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid ID3v1 tag. If \a create is true it will create
|
||||||
|
* an ID3v1 tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v1Tag()
|
||||||
|
*/
|
||||||
|
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the APE tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid APE tag. If \a create is true it will create
|
||||||
|
* an APE tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an APE tag. Use hasAPETag() to check if the file
|
||||||
|
* on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasAPETag()
|
||||||
|
*/
|
||||||
|
APE::Tag *APETag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will remove the tags that match the OR-ed together TagTypes from the
|
||||||
|
* file. By default it removes all tags.
|
||||||
|
*
|
||||||
|
* \note This will also invalidate pointers to the tags
|
||||||
|
* as their memory will be freed.
|
||||||
|
* \note In order to make the removal permanent save() still needs to be called
|
||||||
|
*/
|
||||||
|
void strip(int tags = AllTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \see APETag()
|
||||||
|
*/
|
||||||
|
bool hasAPETag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v1Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an APE
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,173 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_APEFOOTER_H
|
||||||
|
#define TAGLIB_APEFOOTER_H
|
||||||
|
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
|
//! An implementation of APE footers
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class implements APE footers (and headers). It attempts to follow, both
|
||||||
|
* semantically and programmatically, the structure specified in
|
||||||
|
* the APE v2.0 standard. The API is based on the properties of APE footer and
|
||||||
|
* headers specified there.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Footer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty APE footer.
|
||||||
|
*/
|
||||||
|
Footer();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an APE footer based on \a data. parse() is called
|
||||||
|
* immediately.
|
||||||
|
*/
|
||||||
|
Footer(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the footer.
|
||||||
|
*/
|
||||||
|
virtual ~Footer();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the version number. (Note: This is the 1000 or 2000.)
|
||||||
|
*/
|
||||||
|
unsigned int version() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if a header is present in the tag.
|
||||||
|
*/
|
||||||
|
bool headerPresent() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if a footer is present in the tag.
|
||||||
|
*/
|
||||||
|
bool footerPresent() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true this is actually the header.
|
||||||
|
*/
|
||||||
|
bool isHeader() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets whether the header should be rendered or not
|
||||||
|
*/
|
||||||
|
void setHeaderPresent(bool b) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of items in the tag.
|
||||||
|
*/
|
||||||
|
unsigned int itemCount() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the item count to \a s.
|
||||||
|
* \see itemCount()
|
||||||
|
*/
|
||||||
|
void setItemCount(unsigned int s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the tag size in bytes. This is the size of the frame content and footer.
|
||||||
|
* The size of the \e entire tag will be this plus the header size, if present.
|
||||||
|
*
|
||||||
|
* \see completeTagSize()
|
||||||
|
*/
|
||||||
|
unsigned int tagSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the tag size, including if present, the header
|
||||||
|
* size.
|
||||||
|
*
|
||||||
|
* \see tagSize()
|
||||||
|
*/
|
||||||
|
unsigned int completeTagSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the tag size to \a s.
|
||||||
|
* \see tagSize()
|
||||||
|
*/
|
||||||
|
void setTagSize(unsigned int s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the footer. Presently this is always 32 bytes.
|
||||||
|
*/
|
||||||
|
static unsigned int size();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the string used to identify an APE tag inside of a file.
|
||||||
|
* Presently this is always "APETAGEX".
|
||||||
|
*/
|
||||||
|
static ByteVector fileIdentifier();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data that will be used as the footer. 32 bytes,
|
||||||
|
* starting from \a data will be used.
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the footer back to binary format.
|
||||||
|
*/
|
||||||
|
ByteVector renderFooter() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the header corresponding to the footer. If headerPresent is
|
||||||
|
* set to false, it returns an empty ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector renderHeader() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Called by setData() to parse the footer data. It makes this information
|
||||||
|
* available through the public API.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Called by renderFooter and renderHeader
|
||||||
|
*/
|
||||||
|
ByteVector render(bool isHeader) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Footer(const Footer &);
|
||||||
|
Footer &operator=(const Footer &);
|
||||||
|
|
||||||
|
class FooterPrivate;
|
||||||
|
FooterPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,224 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_APEITEM_H
|
||||||
|
#define TAGLIB_APEITEM_H
|
||||||
|
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
|
//! An implementation of APE-items
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class provides the features of items in the APEv2 standard.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Enum of types an Item can have. The value of 3 is reserved.
|
||||||
|
*/
|
||||||
|
enum ItemTypes {
|
||||||
|
//! Item contains text information coded in UTF-8
|
||||||
|
Text = 0,
|
||||||
|
//! Item contains binary information
|
||||||
|
Binary = 1,
|
||||||
|
//! Item is a locator of external stored information
|
||||||
|
Locator = 2
|
||||||
|
};
|
||||||
|
/*!
|
||||||
|
* Constructs an empty item.
|
||||||
|
*/
|
||||||
|
Item();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a text item with \a key and \a value.
|
||||||
|
*/
|
||||||
|
// BIC: Remove this, StringList has a constructor from a single string
|
||||||
|
Item(const String &key, const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a text item with \a key and \a values.
|
||||||
|
*/
|
||||||
|
Item(const String &key, const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an item with \a key and \a value.
|
||||||
|
* If \a binary is true a Binary item will be created, otherwise \a value will be interpreted as text
|
||||||
|
*/
|
||||||
|
Item(const String &key, const ByteVector &value, bool binary);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an item as a copy of \a item.
|
||||||
|
*/
|
||||||
|
Item(const Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the item.
|
||||||
|
*/
|
||||||
|
virtual ~Item();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the contents of \a item into this item.
|
||||||
|
*/
|
||||||
|
Item &operator=(const Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of this item by the content of \a item.
|
||||||
|
*/
|
||||||
|
void swap(Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the key.
|
||||||
|
*/
|
||||||
|
String key() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the binary value.
|
||||||
|
* If the item type is not \a Binary, always returns an empty ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector binaryData() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the binary value to \a value
|
||||||
|
* The item's type will also be set to \a Binary
|
||||||
|
*/
|
||||||
|
void setBinaryData(const ByteVector &value);
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
/* Remove in next binary incompatible release */
|
||||||
|
ByteVector value() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the key for the item to \a key.
|
||||||
|
*/
|
||||||
|
void setKey(const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text value of the item to \a value and clears any previous contents.
|
||||||
|
*
|
||||||
|
* \see toString()
|
||||||
|
*/
|
||||||
|
void setValue(const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text value of the item to the list of values in \a value and clears
|
||||||
|
* any previous contents.
|
||||||
|
*
|
||||||
|
* \see toStringList()
|
||||||
|
*/
|
||||||
|
void setValues(const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends \a value to create (or extend) the current list of text values.
|
||||||
|
*
|
||||||
|
* \see toString()
|
||||||
|
*/
|
||||||
|
void appendValue(const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends \a values to extend the current list of text values.
|
||||||
|
*
|
||||||
|
* \see toStringList()
|
||||||
|
*/
|
||||||
|
void appendValues(const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the full item.
|
||||||
|
*/
|
||||||
|
int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the value as a single string. In case of multiple strings,
|
||||||
|
* the first is returned. If the data type is not \a Text, always returns
|
||||||
|
* an empty String.
|
||||||
|
*/
|
||||||
|
String toString() const;
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
/* Remove in next binary incompatible release */
|
||||||
|
StringList toStringList() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the list of text values. If the data type is not \a Text, always
|
||||||
|
* returns an empty StringList.
|
||||||
|
*/
|
||||||
|
StringList values() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the item to a ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parse the item from the ByteVector \a data.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector& data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the item to read-only.
|
||||||
|
*/
|
||||||
|
void setReadOnly(bool readOnly);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Return true if the item is read-only.
|
||||||
|
*/
|
||||||
|
bool isReadOnly() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the type of the item to \a type.
|
||||||
|
*
|
||||||
|
* \see ItemTypes
|
||||||
|
*/
|
||||||
|
void setType(ItemTypes type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the type of the item.
|
||||||
|
*/
|
||||||
|
ItemTypes type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns if the item has any real content.
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ItemPrivate;
|
||||||
|
ItemPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2010 by Alex Novichkov
|
||||||
|
email : novichko@atnet.ru
|
||||||
|
|
||||||
|
copyright : (C) 2006 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
(original WavPack 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_APEPROPERTIES_H
|
||||||
|
#define TAGLIB_APEPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for APE
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an APE stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of APE::Properties with the data read from the
|
||||||
|
* APE::File \a file.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Properties(File *file, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an instance of APE::Properties with the data read from the
|
||||||
|
* APE::File \a file.
|
||||||
|
*/
|
||||||
|
Properties(File *file, long streamLength, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this APE::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample.
|
||||||
|
*/
|
||||||
|
int bitsPerSample() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the total number of audio samples in file.
|
||||||
|
*/
|
||||||
|
unsigned int sampleFrames() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns APE version.
|
||||||
|
*/
|
||||||
|
int version() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(File *file, long streamLength);
|
||||||
|
|
||||||
|
void analyzeCurrent(File *file);
|
||||||
|
void analyzeOld(File *file);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,208 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_APETAG_H
|
||||||
|
#define TAGLIB_APETAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
#include "apeitem.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of the APE tagging format
|
||||||
|
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
|
class Footer;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A mapping between a list of item names, or keys, and the associated item.
|
||||||
|
*
|
||||||
|
* \see APE::Tag::itemListMap()
|
||||||
|
*/
|
||||||
|
typedef Map<const String, Item> ItemListMap;
|
||||||
|
|
||||||
|
|
||||||
|
//! An APE tag implementation
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an APE tag with default values.
|
||||||
|
*/
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an APE tag and parse the data in \a file with APE footer at
|
||||||
|
* \a tagOffset.
|
||||||
|
*/
|
||||||
|
Tag(TagLib::File *file, long footerLocation);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Tag instance.
|
||||||
|
*/
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the in memory values to a ByteVector suitable for writing to
|
||||||
|
* the file.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the string "APETAGEX" suitable for usage in locating the tag in a
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
static ByteVector fileIdentifier();
|
||||||
|
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual String title() const;
|
||||||
|
virtual String artist() const;
|
||||||
|
virtual String album() const;
|
||||||
|
virtual String comment() const;
|
||||||
|
virtual String genre() const;
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
virtual void setTitle(const String &s);
|
||||||
|
virtual void setArtist(const String &s);
|
||||||
|
virtual void setAlbum(const String &s);
|
||||||
|
virtual void setComment(const String &s);
|
||||||
|
virtual void setGenre(const String &s);
|
||||||
|
virtual void setYear(unsigned int i);
|
||||||
|
virtual void setTrack(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified tag dictionary interface -- export function.
|
||||||
|
* APE tags are perfectly compatible with the dictionary interface because they
|
||||||
|
* support both arbitrary tag names and multiple values. Currently only
|
||||||
|
* APE items of type *Text* are handled by the dictionary interface; all *Binary*
|
||||||
|
* and *Locator* items will be put into the unsupportedData list and can be
|
||||||
|
* deleted on request using removeUnsupportedProperties(). The same happens
|
||||||
|
* to Text items if their key is invalid for PropertyMap (which should actually
|
||||||
|
* never happen).
|
||||||
|
*
|
||||||
|
* The only conversion done by this export function is to rename the APE tags
|
||||||
|
* TRACK to TRACKNUMBER, YEAR to DATE, and ALBUM ARTIST to ALBUMARTIST, respectively,
|
||||||
|
* in order to be compliant with the names used in other formats.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified tag dictionary interface -- import function. The same
|
||||||
|
* comments as for the export function apply; additionally note that the APE tag
|
||||||
|
* specification requires keys to have between 2 and 16 printable ASCII characters
|
||||||
|
* with the exception of the fixed strings "ID3", "TAG", "OGGS", and "MP+".
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Check if the given String is a valid APE tag key.
|
||||||
|
*/
|
||||||
|
static bool checkKey(const String&);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the tag's footer.
|
||||||
|
*/
|
||||||
|
Footer *footer() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the item list map. This is an ItemListMap of
|
||||||
|
* all of the items in the tag.
|
||||||
|
*
|
||||||
|
* This is the most powerful structure for accessing the items of the tag.
|
||||||
|
*
|
||||||
|
* APE tags are case-insensitive, all keys in this map have been converted
|
||||||
|
* to upper case.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use setItem() and removeItem().
|
||||||
|
*/
|
||||||
|
const ItemListMap &itemListMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes the \a key item from the tag
|
||||||
|
*/
|
||||||
|
void removeItem(const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Adds to the text item specified by \a key the data \a value. If \a replace
|
||||||
|
* is true, then all of the other values on the same key will be removed
|
||||||
|
* first. If a binary item exists for \a key it will be removed first.
|
||||||
|
*/
|
||||||
|
void addValue(const String &key, const String &value, bool replace = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the binary data for the key specified by \a item to \a value
|
||||||
|
* This will convert the item to type \a Binary if it isn't already and
|
||||||
|
* all of the other values on the same key will be removed.
|
||||||
|
*/
|
||||||
|
void setData(const String &key, const ByteVector &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the \a key item to the value of \a item. If an item with the \a key is already
|
||||||
|
* present, it will be replaced.
|
||||||
|
*/
|
||||||
|
void setItem(const String &key, const Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the tag does not contain any data.
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads from the file specified in the constructor.
|
||||||
|
*/
|
||||||
|
void read();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parses the body of the tag in \a data.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,208 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2005-2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ASFATTRIBUTE_H
|
||||||
|
#define TAGLIB_ASFATTRIBUTE_H
|
||||||
|
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "asfpicture.h"
|
||||||
|
|
||||||
|
namespace TagLib
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace ASF
|
||||||
|
{
|
||||||
|
|
||||||
|
class File;
|
||||||
|
class Picture;
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Attribute
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enum of types an Attribute can have.
|
||||||
|
*/
|
||||||
|
enum AttributeTypes {
|
||||||
|
UnicodeType = 0,
|
||||||
|
BytesType = 1,
|
||||||
|
BoolType = 2,
|
||||||
|
DWordType = 3,
|
||||||
|
QWordType = 4,
|
||||||
|
WordType = 5,
|
||||||
|
GuidType = 6
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty attribute.
|
||||||
|
*/
|
||||||
|
Attribute();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a UnicodeType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a BytesType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(const ByteVector &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a Picture \a value.
|
||||||
|
*
|
||||||
|
* This attribute is compatible with the ID3 frame, APIC. The ID3 specification for the APIC frame stipulates that,
|
||||||
|
* while there may be any number of APIC frames associated with a file,
|
||||||
|
* only one may be of type 1 and only one may be of type 2.
|
||||||
|
*
|
||||||
|
* The specification also states that the description of the picture can be no longer than 64 characters, but can be empty.
|
||||||
|
* WM/Picture attributes added with TagLib::ASF are not automatically validated to conform to ID3 specifications.
|
||||||
|
* You must add code in your application to perform validations if you want to maintain complete compatibility with ID3.
|
||||||
|
*/
|
||||||
|
Attribute(const Picture &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a DWordType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(unsigned int value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a QWordType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(unsigned long long value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a WordType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(unsigned short value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an attribute with \a key and a BoolType \a value.
|
||||||
|
*/
|
||||||
|
Attribute(bool value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an attribute as a copy of \a other.
|
||||||
|
*/
|
||||||
|
Attribute(const Attribute &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the contents of \a other into this item.
|
||||||
|
*/
|
||||||
|
Attribute &operator=(const Attribute &other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the Attribute by the content of \a other.
|
||||||
|
*/
|
||||||
|
void swap(Attribute &other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the attribute.
|
||||||
|
*/
|
||||||
|
virtual ~Attribute();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns type of the value.
|
||||||
|
*/
|
||||||
|
AttributeTypes type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the BoolType \a value.
|
||||||
|
*/
|
||||||
|
unsigned short toBool() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the WordType \a value.
|
||||||
|
*/
|
||||||
|
unsigned short toUShort() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the DWordType \a value.
|
||||||
|
*/
|
||||||
|
unsigned int toUInt() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the QWordType \a value.
|
||||||
|
*/
|
||||||
|
unsigned long long toULongLong() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the UnicodeType \a value.
|
||||||
|
*/
|
||||||
|
String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the BytesType \a value.
|
||||||
|
*/
|
||||||
|
ByteVector toByteVector() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Picture \a value.
|
||||||
|
*/
|
||||||
|
Picture toPicture() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the language number, or 0 is no stream number was set.
|
||||||
|
*/
|
||||||
|
int language() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the language number.
|
||||||
|
*/
|
||||||
|
void setLanguage(int value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the stream number, or 0 is no stream number was set.
|
||||||
|
*/
|
||||||
|
int stream() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the stream number.
|
||||||
|
*/
|
||||||
|
void setStream(int value);
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
/* THIS IS PRIVATE, DON'T TOUCH IT! */
|
||||||
|
String parse(ASF::File &file, int kind = 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! Returns the size of the stored data
|
||||||
|
int dataSize() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class File;
|
||||||
|
|
||||||
|
ByteVector render(const String &name, int kind = 0) const;
|
||||||
|
|
||||||
|
class AttributePrivate;
|
||||||
|
AttributePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,138 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2005-2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ASFFILE_H
|
||||||
|
#define TAGLIB_ASFFILE_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "asfproperties.h"
|
||||||
|
#include "asftag.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! An implementation of ASF (WMA) metadata
|
||||||
|
namespace ASF {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for ASF files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to ASF files.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an ASF file from \a file.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an ASF file from \a stream.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ASF tag of the file.
|
||||||
|
*
|
||||||
|
* ASF::Tag implements the tag interface, so this serves as the
|
||||||
|
* reimplementation of TagLib::File::tag().
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the ASF::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*/
|
||||||
|
virtual Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties. Forwards to the actual Tag's
|
||||||
|
* removeUnsupportedProperties() function.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the ASF audio properties for this file.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an ASF
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void read();
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,222 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2010 by Anton Sergunov
|
||||||
|
email : setosha@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ASFPICTURE_H
|
||||||
|
#define ASFPICTURE_H
|
||||||
|
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "attachedpictureframe.h"
|
||||||
|
|
||||||
|
namespace TagLib
|
||||||
|
{
|
||||||
|
namespace ASF
|
||||||
|
{
|
||||||
|
|
||||||
|
//! An ASF attached picture interface implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ASF attached pictures interface. Pictures may be
|
||||||
|
* included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture
|
||||||
|
* attribute in a single tag). These pictures are usually in either JPEG or
|
||||||
|
* PNG format.
|
||||||
|
* \see Attribute::toPicture()
|
||||||
|
* \see Attribute::Attribute(const Picture& picture)
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT Picture {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This describes the function or content of the picture.
|
||||||
|
*/
|
||||||
|
enum Type {
|
||||||
|
//! A type not enumerated below
|
||||||
|
Other = 0x00,
|
||||||
|
//! 32x32 PNG image that should be used as the file icon
|
||||||
|
FileIcon = 0x01,
|
||||||
|
//! File icon of a different size or format
|
||||||
|
OtherFileIcon = 0x02,
|
||||||
|
//! Front cover image of the album
|
||||||
|
FrontCover = 0x03,
|
||||||
|
//! Back cover image of the album
|
||||||
|
BackCover = 0x04,
|
||||||
|
//! Inside leaflet page of the album
|
||||||
|
LeafletPage = 0x05,
|
||||||
|
//! Image from the album itself
|
||||||
|
Media = 0x06,
|
||||||
|
//! Picture of the lead artist or soloist
|
||||||
|
LeadArtist = 0x07,
|
||||||
|
//! Picture of the artist or performer
|
||||||
|
Artist = 0x08,
|
||||||
|
//! Picture of the conductor
|
||||||
|
Conductor = 0x09,
|
||||||
|
//! Picture of the band or orchestra
|
||||||
|
Band = 0x0A,
|
||||||
|
//! Picture of the composer
|
||||||
|
Composer = 0x0B,
|
||||||
|
//! Picture of the lyricist or text writer
|
||||||
|
Lyricist = 0x0C,
|
||||||
|
//! Picture of the recording location or studio
|
||||||
|
RecordingLocation = 0x0D,
|
||||||
|
//! Picture of the artists during recording
|
||||||
|
DuringRecording = 0x0E,
|
||||||
|
//! Picture of the artists during performance
|
||||||
|
DuringPerformance = 0x0F,
|
||||||
|
//! Picture from a movie or video related to the track
|
||||||
|
MovieScreenCapture = 0x10,
|
||||||
|
//! Picture of a large, coloured fish
|
||||||
|
ColouredFish = 0x11,
|
||||||
|
//! Illustration related to the track
|
||||||
|
Illustration = 0x12,
|
||||||
|
//! Logo of the band or performer
|
||||||
|
BandLogo = 0x13,
|
||||||
|
//! Logo of the publisher (record company)
|
||||||
|
PublisherLogo = 0x14
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty picture.
|
||||||
|
*/
|
||||||
|
Picture();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an picture as a copy of \a other.
|
||||||
|
*/
|
||||||
|
Picture(const Picture& other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the picture.
|
||||||
|
*/
|
||||||
|
virtual ~Picture();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the contents of \a other into this picture.
|
||||||
|
*/
|
||||||
|
Picture& operator=(const Picture& other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the Picture by the content of \a other.
|
||||||
|
*/
|
||||||
|
void swap(Picture &other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if Picture stores valid picture
|
||||||
|
*/
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
* \see setMimeType(const String &)
|
||||||
|
* \see picture()
|
||||||
|
* \see setPicture(const ByteArray&)
|
||||||
|
*/
|
||||||
|
String mimeType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
* \see setMimeType(const String &)
|
||||||
|
* \see picture()
|
||||||
|
* \see setPicture(const ByteArray&)
|
||||||
|
*/
|
||||||
|
void setMimeType(const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the type of the image.
|
||||||
|
*
|
||||||
|
* \see Type
|
||||||
|
* \see setType()
|
||||||
|
*/
|
||||||
|
Type type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the type for the image.
|
||||||
|
*
|
||||||
|
* \see Type
|
||||||
|
* \see type()
|
||||||
|
*/
|
||||||
|
void setType(const ASF::Picture::Type& t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a text description of the image.
|
||||||
|
*
|
||||||
|
* \see setDescription()
|
||||||
|
*/
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets a textual description of the image to \a desc.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
void setDescription(const String &desc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the image data as a ByteVector.
|
||||||
|
*
|
||||||
|
* \note ByteVector has a data() method that returns a const char * which
|
||||||
|
* should make it easy to export this data to external programs.
|
||||||
|
*
|
||||||
|
* \see setPicture()
|
||||||
|
* \see mimeType()
|
||||||
|
*/
|
||||||
|
ByteVector picture() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the image data to \a p. \a p should be of the type specified in
|
||||||
|
* this frame's mime-type specification.
|
||||||
|
*
|
||||||
|
* \see picture()
|
||||||
|
* \see mimeType()
|
||||||
|
* \see setMimeType()
|
||||||
|
*/
|
||||||
|
void setPicture(const ByteVector &p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns picture as binary raw data \a value
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns picture as binary raw data \a value
|
||||||
|
*/
|
||||||
|
int dataSize() const;
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
/* THIS IS PRIVATE, DON'T TOUCH IT! */
|
||||||
|
void parse(const ByteVector& );
|
||||||
|
static Picture fromInvalid();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
class PicturePrivate;
|
||||||
|
PicturePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ASFPICTURE_H
|
|
@ -0,0 +1,186 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2005-2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ASFPROPERTIES_H
|
||||||
|
#define TAGLIB_ASFPROPERTIES_H
|
||||||
|
|
||||||
|
#include "audioproperties.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ASF {
|
||||||
|
|
||||||
|
//! An implementation of ASF audio properties
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Audio codec types can be used in ASF file.
|
||||||
|
*/
|
||||||
|
enum Codec
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Couldn't detect the codec.
|
||||||
|
*/
|
||||||
|
Unknown = 0,
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Windows Media Audio 1
|
||||||
|
*/
|
||||||
|
WMA1,
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Windows Media Audio 2 or above
|
||||||
|
*/
|
||||||
|
WMA2,
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Windows Media Audio 9 Professional
|
||||||
|
*/
|
||||||
|
WMA9Pro,
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Windows Media Audio 9 Lossless
|
||||||
|
*/
|
||||||
|
WMA9Lossless,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates an instance of ASF::Properties.
|
||||||
|
*/
|
||||||
|
Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this ASF::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample.
|
||||||
|
*/
|
||||||
|
int bitsPerSample() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the codec used in the file.
|
||||||
|
*
|
||||||
|
* \see codecName()
|
||||||
|
* \see codecDescription()
|
||||||
|
*/
|
||||||
|
Codec codec() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the concrete codec name, for example "Windows Media Audio 9.1"
|
||||||
|
* used in the file if available, otherwise an empty string.
|
||||||
|
*
|
||||||
|
* \see codec()
|
||||||
|
* \see codecDescription()
|
||||||
|
*/
|
||||||
|
String codecName() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the codec description, typically contains the encoder settings,
|
||||||
|
* for example "VBR Quality 50, 44kHz, stereo 1-pass VBR" if available,
|
||||||
|
* otherwise an empty string.
|
||||||
|
*
|
||||||
|
* \see codec()
|
||||||
|
* \see codecName()
|
||||||
|
*/
|
||||||
|
String codecDescription() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file is encrypted.
|
||||||
|
*/
|
||||||
|
bool isEncrypted() const;
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
// deprecated
|
||||||
|
void setLength(int value);
|
||||||
|
|
||||||
|
void setLengthInMilliseconds(int value);
|
||||||
|
void setBitrate(int value);
|
||||||
|
void setSampleRate(int value);
|
||||||
|
void setChannels(int value);
|
||||||
|
void setBitsPerSample(int value);
|
||||||
|
void setCodec(int value);
|
||||||
|
void setCodecName(const String &value);
|
||||||
|
void setCodecDescription(const String &value);
|
||||||
|
void setEncrypted(bool value);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,210 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2005-2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ASFTAG_H
|
||||||
|
#define TAGLIB_ASFTAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "asfattribute.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ASF {
|
||||||
|
|
||||||
|
typedef List<Attribute> AttributeList;
|
||||||
|
typedef Map<String, AttributeList> AttributeListMap;
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag {
|
||||||
|
|
||||||
|
friend class File;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track name.
|
||||||
|
*/
|
||||||
|
virtual String title() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the artist name.
|
||||||
|
*/
|
||||||
|
virtual String artist() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the album name; if no album name is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String album() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track comment.
|
||||||
|
*/
|
||||||
|
virtual String comment() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the genre name; if no genre is present in the tag String::null
|
||||||
|
* will be returned.
|
||||||
|
*/
|
||||||
|
virtual String genre() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the rating.
|
||||||
|
*/
|
||||||
|
virtual String rating() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the genre name; if no genre is present in the tag String::null
|
||||||
|
* will be returned.
|
||||||
|
*/
|
||||||
|
virtual String copyright() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the year; if there is no year set, this will return 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track number; if there is no track number set, this will
|
||||||
|
* return 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the title to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setTitle(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the artist to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setArtist(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the album to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared.
|
||||||
|
*/
|
||||||
|
virtual void setAlbum(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the comment to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setComment(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the rating to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setRating(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the copyright to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setCopyright(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the genre to \a s.
|
||||||
|
*/
|
||||||
|
virtual void setGenre(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
|
||||||
|
*/
|
||||||
|
virtual void setYear(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
|
||||||
|
*/
|
||||||
|
virtual void setTrack(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the tag does not contain any data. This should be
|
||||||
|
* reimplemented in subclasses that provide more than the basic tagging
|
||||||
|
* abilities in this class.
|
||||||
|
*/
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
AttributeListMap &attributeListMap();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the item list map. This is an AttributeListMap of
|
||||||
|
* all of the items in the tag.
|
||||||
|
*/
|
||||||
|
// BIC: return by value
|
||||||
|
const AttributeListMap &attributeListMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return True if a value for \a attribute is currently set.
|
||||||
|
*/
|
||||||
|
bool contains(const String &name) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes the \a key attribute from the tag
|
||||||
|
*/
|
||||||
|
void removeItem(const String &name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The list of values for the key \a name, or an empty list if no
|
||||||
|
* values have been set.
|
||||||
|
*/
|
||||||
|
AttributeList attribute(const String &name) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the \a key attribute to the value of \a attribute. If an attribute
|
||||||
|
* with the \a key is already present, it will be replaced.
|
||||||
|
*/
|
||||||
|
void setAttribute(const String &name, const Attribute &attribute);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets multiple \a values to the key \a name.
|
||||||
|
*/
|
||||||
|
void setAttribute(const String &name, const AttributeList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the \a key attribute to the value of \a attribute. If an attribute
|
||||||
|
* with the \a key is already present, it will be added to the list.
|
||||||
|
*/
|
||||||
|
void addAttribute(const String &name, const Attribute &attribute);
|
||||||
|
|
||||||
|
PropertyMap properties() const;
|
||||||
|
void removeUnsupportedProperties(const StringList& properties);
|
||||||
|
PropertyMap setProperties(const PropertyMap &properties);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,230 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ATTACHEDPICTUREFRAME_H
|
||||||
|
#define TAGLIB_ATTACHEDPICTUREFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "id3v2header.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An ID3v2 attached picture frame implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ID3v2 attached pictures. Pictures may be
|
||||||
|
* included in tags, one per APIC frame (but there may be multiple APIC
|
||||||
|
* frames in a single tag). These pictures are usually in either JPEG or
|
||||||
|
* PNG format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT AttachedPictureFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This describes the function or content of the picture.
|
||||||
|
*/
|
||||||
|
enum Type {
|
||||||
|
//! A type not enumerated below
|
||||||
|
Other = 0x00,
|
||||||
|
//! 32x32 PNG image that should be used as the file icon
|
||||||
|
FileIcon = 0x01,
|
||||||
|
//! File icon of a different size or format
|
||||||
|
OtherFileIcon = 0x02,
|
||||||
|
//! Front cover image of the album
|
||||||
|
FrontCover = 0x03,
|
||||||
|
//! Back cover image of the album
|
||||||
|
BackCover = 0x04,
|
||||||
|
//! Inside leaflet page of the album
|
||||||
|
LeafletPage = 0x05,
|
||||||
|
//! Image from the album itself
|
||||||
|
Media = 0x06,
|
||||||
|
//! Picture of the lead artist or soloist
|
||||||
|
LeadArtist = 0x07,
|
||||||
|
//! Picture of the artist or performer
|
||||||
|
Artist = 0x08,
|
||||||
|
//! Picture of the conductor
|
||||||
|
Conductor = 0x09,
|
||||||
|
//! Picture of the band or orchestra
|
||||||
|
Band = 0x0A,
|
||||||
|
//! Picture of the composer
|
||||||
|
Composer = 0x0B,
|
||||||
|
//! Picture of the lyricist or text writer
|
||||||
|
Lyricist = 0x0C,
|
||||||
|
//! Picture of the recording location or studio
|
||||||
|
RecordingLocation = 0x0D,
|
||||||
|
//! Picture of the artists during recording
|
||||||
|
DuringRecording = 0x0E,
|
||||||
|
//! Picture of the artists during performance
|
||||||
|
DuringPerformance = 0x0F,
|
||||||
|
//! Picture from a movie or video related to the track
|
||||||
|
MovieScreenCapture = 0x10,
|
||||||
|
//! Picture of a large, coloured fish
|
||||||
|
ColouredFish = 0x11,
|
||||||
|
//! Illustration related to the track
|
||||||
|
Illustration = 0x12,
|
||||||
|
//! Logo of the band or performer
|
||||||
|
BandLogo = 0x13,
|
||||||
|
//! Logo of the publisher (record company)
|
||||||
|
PublisherLogo = 0x14
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty picture frame. The description, content and text
|
||||||
|
* encoding should be set manually.
|
||||||
|
*/
|
||||||
|
AttachedPictureFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an AttachedPicture frame based on \a data.
|
||||||
|
*/
|
||||||
|
explicit AttachedPictureFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the AttahcedPictureFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~AttachedPictureFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a string containing the description and mime-type
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding used for the description.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the text encoding used for the description.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
*/
|
||||||
|
String mimeType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
*/
|
||||||
|
void setMimeType(const String &m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the type of the image.
|
||||||
|
*
|
||||||
|
* \see Type
|
||||||
|
* \see setType()
|
||||||
|
*/
|
||||||
|
Type type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the type for the image.
|
||||||
|
*
|
||||||
|
* \see Type
|
||||||
|
* \see type()
|
||||||
|
*/
|
||||||
|
void setType(Type t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a text description of the image.
|
||||||
|
*
|
||||||
|
* \see setDescription()
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see setTextEncoding()
|
||||||
|
*/
|
||||||
|
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets a textual description of the image to \a desc.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see setTextEncoding()
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setDescription(const String &desc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the image data as a ByteVector.
|
||||||
|
*
|
||||||
|
* \note ByteVector has a data() method that returns a const char * which
|
||||||
|
* should make it easy to export this data to external programs.
|
||||||
|
*
|
||||||
|
* \see setPicture()
|
||||||
|
* \see mimeType()
|
||||||
|
*/
|
||||||
|
ByteVector picture() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the image data to \a p. \a p should be of the type specified in
|
||||||
|
* this frame's mime-type specification.
|
||||||
|
*
|
||||||
|
* \see picture()
|
||||||
|
* \see mimeType()
|
||||||
|
* \see setMimeType()
|
||||||
|
*/
|
||||||
|
void setPicture(const ByteVector &p);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
class AttachedPictureFramePrivate;
|
||||||
|
AttachedPictureFramePrivate *d;
|
||||||
|
|
||||||
|
private:
|
||||||
|
AttachedPictureFrame(const AttachedPictureFrame &);
|
||||||
|
AttachedPictureFrame &operator=(const AttachedPictureFrame &);
|
||||||
|
AttachedPictureFrame(const ByteVector &data, Header *h);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//! support for ID3v2.2 PIC frames
|
||||||
|
class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
private:
|
||||||
|
AttachedPictureFrameV22(const ByteVector &data, Header *h);
|
||||||
|
friend class FrameFactory;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,127 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_AUDIOPROPERTIES_H
|
||||||
|
#define TAGLIB_AUDIOPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A simple, abstract interface to common audio properties
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The values here are common to most audio formats. For more specific, codec
|
||||||
|
* dependent values, please see see the subclasses APIs. This is meant to
|
||||||
|
* compliment the TagLib::File and TagLib::Tag APIs in providing a simple
|
||||||
|
* interface that is sufficient for most applications.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reading audio properties from a file can sometimes be very time consuming
|
||||||
|
* and for the most accurate results can often involve reading the entire
|
||||||
|
* file. Because in many situations speed is critical or the accuracy of the
|
||||||
|
* values is not particularly important this allows the level of desired
|
||||||
|
* accuracy to be set.
|
||||||
|
*/
|
||||||
|
enum ReadStyle {
|
||||||
|
//! Read as little of the file as possible
|
||||||
|
Fast,
|
||||||
|
//! Read more of the file and make better values guesses
|
||||||
|
Average,
|
||||||
|
//! Read as much of the file as needed to report accurate values
|
||||||
|
Accurate
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this AudioProperties instance.
|
||||||
|
*/
|
||||||
|
virtual ~AudioProperties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds.
|
||||||
|
*/
|
||||||
|
virtual int length() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the most appropriate bit rate for the file in kb/s. For constant
|
||||||
|
* bitrate formats this is simply the bitrate of the file. For variable
|
||||||
|
* bitrate formats this is either the average or nominal bitrate.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an audio properties instance. This is protected as this class
|
||||||
|
* should not be instantiated directly, but should be instantiated via its
|
||||||
|
* subclasses and can be fetched from the FileRef or File APIs.
|
||||||
|
*
|
||||||
|
* \see ReadStyle
|
||||||
|
*/
|
||||||
|
AudioProperties(ReadStyle style);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AudioProperties(const AudioProperties &);
|
||||||
|
AudioProperties &operator=(const AudioProperties &);
|
||||||
|
|
||||||
|
class AudioPropertiesPrivate;
|
||||||
|
AudioPropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,249 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2013 by Lukas Krejci
|
||||||
|
email : krejclu6@fel.cvut.cz
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_CHAPTERFRAME
|
||||||
|
#define TAGLIB_CHAPTERFRAME
|
||||||
|
|
||||||
|
#include "id3v2tag.h"
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ID3v2 chapter frames. The purpose of this
|
||||||
|
* frame is to describe a single chapter within an audio file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 chapter frames
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT ChapterFrame : public ID3v2::Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Creates a chapter frame based on \a data. \a tagHeader is required as
|
||||||
|
* the internal frames are parsed based on the tag version.
|
||||||
|
*/
|
||||||
|
ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a chapter frame with the element ID \a elementID, start time
|
||||||
|
* \a startTime, end time \a endTime, start offset \a startOffset,
|
||||||
|
* end offset \a endOffset and optionally a list of embedded frames,
|
||||||
|
* whose ownership will then be taken over by this Frame, in
|
||||||
|
* \a embeddedFrames;
|
||||||
|
*
|
||||||
|
* All times are in milliseconds.
|
||||||
|
*/
|
||||||
|
ChapterFrame(const ByteVector &elementID,
|
||||||
|
unsigned int startTime, unsigned int endTime,
|
||||||
|
unsigned int startOffset, unsigned int endOffset,
|
||||||
|
const FrameList &embeddedFrames = FrameList());
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the frame.
|
||||||
|
*/
|
||||||
|
virtual ~ChapterFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the element ID of the frame. Element ID
|
||||||
|
* is a null terminated string, however it's not human-readable.
|
||||||
|
*
|
||||||
|
* \see setElementID()
|
||||||
|
*/
|
||||||
|
ByteVector elementID() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns time of chapter's start (in milliseconds).
|
||||||
|
*
|
||||||
|
* \see setStartTime()
|
||||||
|
*/
|
||||||
|
unsigned int startTime() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns time of chapter's end (in milliseconds).
|
||||||
|
*
|
||||||
|
* \see setEndTime()
|
||||||
|
*/
|
||||||
|
unsigned int endTime() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns zero based byte offset (count of bytes from the beginning
|
||||||
|
* of the audio file) of chapter's start.
|
||||||
|
*
|
||||||
|
* \note If returned value is 0xFFFFFFFF, start time should be used instead.
|
||||||
|
* \see setStartOffset()
|
||||||
|
*/
|
||||||
|
unsigned int startOffset() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns zero based byte offset (count of bytes from the beginning
|
||||||
|
* of the audio file) of chapter's end.
|
||||||
|
*
|
||||||
|
* \note If returned value is 0xFFFFFFFF, end time should be used instead.
|
||||||
|
* \see setEndOffset()
|
||||||
|
*/
|
||||||
|
unsigned int endOffset() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the element ID of the frame to \a eID. If \a eID isn't
|
||||||
|
* null terminated, a null char is appended automatically.
|
||||||
|
*
|
||||||
|
* \see elementID()
|
||||||
|
*/
|
||||||
|
void setElementID(const ByteVector &eID);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets time of chapter's start (in milliseconds) to \a sT.
|
||||||
|
*
|
||||||
|
* \see startTime()
|
||||||
|
*/
|
||||||
|
void setStartTime(const unsigned int &sT);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets time of chapter's end (in milliseconds) to \a eT.
|
||||||
|
*
|
||||||
|
* \see endTime()
|
||||||
|
*/
|
||||||
|
void setEndTime(const unsigned int &eT);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets zero based byte offset (count of bytes from the beginning
|
||||||
|
* of the audio file) of chapter's start to \a sO.
|
||||||
|
*
|
||||||
|
* \see startOffset()
|
||||||
|
*/
|
||||||
|
void setStartOffset(const unsigned int &sO);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets zero based byte offset (count of bytes from the beginning
|
||||||
|
* of the audio file) of chapter's end to \a eO.
|
||||||
|
*
|
||||||
|
* \see endOffset()
|
||||||
|
*/
|
||||||
|
void setEndOffset(const unsigned int &eO);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the frame list map. This is an FrameListMap of
|
||||||
|
* all of the frames embedded in the CHAP frame.
|
||||||
|
*
|
||||||
|
* This is the most convenient structure for accessing the CHAP frame's
|
||||||
|
* embedded frames. Many frame types allow multiple instances of the same
|
||||||
|
* frame type so this is a map of lists. In most cases however there will
|
||||||
|
* only be a single frame of a certain type.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addEmbeddedFrame() and removeEmbeddedFrame().
|
||||||
|
*
|
||||||
|
* \see embeddedFrameList()
|
||||||
|
*/
|
||||||
|
const FrameListMap &embeddedFrameListMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the embedded frame list. This is an FrameList
|
||||||
|
* of all of the frames embedded in the CHAP frame in the order that they
|
||||||
|
* were parsed.
|
||||||
|
*
|
||||||
|
* This can be useful if for example you want iterate over the CHAP frame's
|
||||||
|
* embedded frames in the order that they occur in the CHAP frame.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addEmbeddedFrame() and removeEmbeddedFrame().
|
||||||
|
*/
|
||||||
|
const FrameList &embeddedFrameList() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the embedded frame list for frames with the id \a frameID
|
||||||
|
* or an empty list if there are no embedded frames of that type. This
|
||||||
|
* is just a convenience and is equivalent to:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* embeddedFrameListMap()[frameID];
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \see embeddedFrameListMap()
|
||||||
|
*/
|
||||||
|
const FrameList &embeddedFrameList(const ByteVector &frameID) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Add an embedded frame to the CHAP frame. At this point the CHAP frame
|
||||||
|
* takes ownership of the embedded frame and will handle freeing its memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void addEmbeddedFrame(Frame *frame);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove an embedded frame from the CHAP frame. If \a del is true the frame's
|
||||||
|
* memory will be freed; if it is false, it must be deleted by the user.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void removeEmbeddedFrame(Frame *frame, bool del = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove all embedded frames of type \a id from the CHAP frame and free their
|
||||||
|
* memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void removeEmbeddedFrames(const ByteVector &id);
|
||||||
|
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* CHAP frames each have a unique element ID. This searches for a CHAP
|
||||||
|
* frame with the element ID \a eID and returns a pointer to it. This
|
||||||
|
* can be used to link CTOC and CHAP frames together.
|
||||||
|
*
|
||||||
|
* \see elementID()
|
||||||
|
*/
|
||||||
|
static ChapterFrame *findByElementID(const Tag *tag, const ByteVector &eID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h);
|
||||||
|
ChapterFrame(const ChapterFrame &);
|
||||||
|
ChapterFrame &operator=(const ChapterFrame &);
|
||||||
|
|
||||||
|
class ChapterFramePrivate;
|
||||||
|
ChapterFramePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,179 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_COMMENTSFRAME_H
|
||||||
|
#define TAGLIB_COMMENTSFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 comments
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements the ID3v2 comment format. An ID3v2 comment consists of
|
||||||
|
* a language encoding, a description and a single text field.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT CommentsFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct an empty comment frame that will use the text encoding
|
||||||
|
* \a encoding.
|
||||||
|
*/
|
||||||
|
explicit CommentsFrame(String::Type encoding = String::Latin1);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a comment based on the data in \a data.
|
||||||
|
*/
|
||||||
|
explicit CommentsFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this CommentFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~CommentsFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text of this comment.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the language encoding as a 3 byte encoding as specified by
|
||||||
|
* <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a>.
|
||||||
|
*
|
||||||
|
* \note Most taggers simply ignore this value.
|
||||||
|
*
|
||||||
|
* \see setLanguage()
|
||||||
|
*/
|
||||||
|
ByteVector language() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the description of this comment.
|
||||||
|
*
|
||||||
|
* \note Most taggers simply ignore this value.
|
||||||
|
*
|
||||||
|
* \see setDescription()
|
||||||
|
*/
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text of this comment.
|
||||||
|
*
|
||||||
|
* \see setText()
|
||||||
|
*/
|
||||||
|
String text() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the language using the 3 byte language code from
|
||||||
|
* <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a> to
|
||||||
|
* \a languageCode.
|
||||||
|
*
|
||||||
|
* \see language()
|
||||||
|
*/
|
||||||
|
void setLanguage(const ByteVector &languageCode);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the description of the comment to \a s.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
void setDescription(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text portion of the comment to \a s.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
virtual void setText(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding that will be used in rendering this frame.
|
||||||
|
* This defaults to the type that was either specified in the constructor
|
||||||
|
* or read from the frame when parsed.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text encoding to be used when rendering this frame to
|
||||||
|
* \a encoding.
|
||||||
|
*
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parses this frame as PropertyMap with a single key.
|
||||||
|
* - if description() is empty or "COMMENT", the key will be "COMMENT"
|
||||||
|
* - if description() is not a valid PropertyMap key, the frame will be
|
||||||
|
* marked unsupported by an entry "COMM/<description>" in the unsupportedData()
|
||||||
|
* attribute of the returned map.
|
||||||
|
* - otherwise, the key will be "COMMENT:<description>"
|
||||||
|
* - The single value will be the frame's text().
|
||||||
|
*/
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Comments each have a unique description. This searches for a comment
|
||||||
|
* frame with the description \a d and returns a pointer to it. If no
|
||||||
|
* frame is found that matches the given description null is returned.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
static CommentsFrame *findByDescription(const Tag *tag, const String &d);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
CommentsFrame(const ByteVector &data, Header *h);
|
||||||
|
CommentsFrame(const CommentsFrame &);
|
||||||
|
CommentsFrame &operator=(const CommentsFrame &);
|
||||||
|
|
||||||
|
class CommentsFramePrivate;
|
||||||
|
CommentsFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,185 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2014 by Urs Fleisch
|
||||||
|
email : ufleisch@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_EVENTTIMINGCODESFRAME_H
|
||||||
|
#define TAGLIB_EVENTTIMINGCODESFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! ID3v2 event timing codes frame
|
||||||
|
/*!
|
||||||
|
* An implementation of ID3v2 event timing codes.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT EventTimingCodesFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specifies the timestamp format used.
|
||||||
|
*/
|
||||||
|
enum TimestampFormat {
|
||||||
|
//! The timestamp is of unknown format.
|
||||||
|
Unknown = 0x00,
|
||||||
|
//! The timestamp represents the number of MPEG frames since
|
||||||
|
//! the beginning of the audio stream.
|
||||||
|
AbsoluteMpegFrames = 0x01,
|
||||||
|
//! The timestamp represents the number of milliseconds since
|
||||||
|
//! the beginning of the audio stream.
|
||||||
|
AbsoluteMilliseconds = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Event types defined in id3v2.4.0-frames.txt 4.5. Event timing codes.
|
||||||
|
*/
|
||||||
|
enum EventType {
|
||||||
|
Padding = 0x00,
|
||||||
|
EndOfInitialSilence = 0x01,
|
||||||
|
IntroStart = 0x02,
|
||||||
|
MainPartStart = 0x03,
|
||||||
|
OutroStart = 0x04,
|
||||||
|
OutroEnd = 0x05,
|
||||||
|
VerseStart = 0x06,
|
||||||
|
RefrainStart = 0x07,
|
||||||
|
InterludeStart = 0x08,
|
||||||
|
ThemeStart = 0x09,
|
||||||
|
VariationStart = 0x0a,
|
||||||
|
KeyChange = 0x0b,
|
||||||
|
TimeChange = 0x0c,
|
||||||
|
MomentaryUnwantedNoise = 0x0d,
|
||||||
|
SustainedNoise = 0x0e,
|
||||||
|
SustainedNoiseEnd = 0x0f,
|
||||||
|
IntroEnd = 0x10,
|
||||||
|
MainPartEnd = 0x11,
|
||||||
|
VerseEnd = 0x12,
|
||||||
|
RefrainEnd = 0x13,
|
||||||
|
ThemeEnd = 0x14,
|
||||||
|
Profanity = 0x15,
|
||||||
|
ProfanityEnd = 0x16,
|
||||||
|
NotPredefinedSynch0 = 0xe0,
|
||||||
|
NotPredefinedSynch1 = 0xe1,
|
||||||
|
NotPredefinedSynch2 = 0xe2,
|
||||||
|
NotPredefinedSynch3 = 0xe3,
|
||||||
|
NotPredefinedSynch4 = 0xe4,
|
||||||
|
NotPredefinedSynch5 = 0xe5,
|
||||||
|
NotPredefinedSynch6 = 0xe6,
|
||||||
|
NotPredefinedSynch7 = 0xe7,
|
||||||
|
NotPredefinedSynch8 = 0xe8,
|
||||||
|
NotPredefinedSynch9 = 0xe9,
|
||||||
|
NotPredefinedSynchA = 0xea,
|
||||||
|
NotPredefinedSynchB = 0xeb,
|
||||||
|
NotPredefinedSynchC = 0xec,
|
||||||
|
NotPredefinedSynchD = 0xed,
|
||||||
|
NotPredefinedSynchE = 0xee,
|
||||||
|
NotPredefinedSynchF = 0xef,
|
||||||
|
AudioEnd = 0xfd,
|
||||||
|
AudioFileEnds = 0xfe
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Single entry of time stamp and event.
|
||||||
|
*/
|
||||||
|
struct SynchedEvent {
|
||||||
|
SynchedEvent(unsigned int ms, EventType t) : time(ms), type(t) {}
|
||||||
|
unsigned int time;
|
||||||
|
EventType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* List of synchronized events.
|
||||||
|
*/
|
||||||
|
typedef TagLib::List<SynchedEvent> SynchedEventList;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an empty event timing codes frame.
|
||||||
|
*/
|
||||||
|
explicit EventTimingCodesFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a event timing codes frame based on the data in \a data.
|
||||||
|
*/
|
||||||
|
explicit EventTimingCodesFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this EventTimingCodesFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~EventTimingCodesFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a null string.
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the timestamp format.
|
||||||
|
*/
|
||||||
|
TimestampFormat timestampFormat() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the events with the time stamps.
|
||||||
|
*/
|
||||||
|
SynchedEventList synchedEvents() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the timestamp format.
|
||||||
|
*
|
||||||
|
* \see timestampFormat()
|
||||||
|
*/
|
||||||
|
void setTimestampFormat(TimestampFormat f);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text with the time stamps.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
void setSynchedEvents(const SynchedEventList &e);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
EventTimingCodesFrame(const ByteVector &data, Header *h);
|
||||||
|
EventTimingCodesFrame(const EventTimingCodesFrame &);
|
||||||
|
EventTimingCodesFrame &operator=(const EventTimingCodesFrame &);
|
||||||
|
|
||||||
|
class EventTimingCodesFramePrivate;
|
||||||
|
EventTimingCodesFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,287 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FILEREF_H
|
||||||
|
#define TAGLIB_FILEREF_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
|
||||||
|
//! This class provides a simple abstraction for creating and handling files
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* FileRef exists to provide a minimal, generic and value-based wrapper around
|
||||||
|
* a File. It is lightweight and implicitly shared, and as such suitable for
|
||||||
|
* pass-by-value use. This hides some of the uglier details of TagLib::File
|
||||||
|
* and the non-generic portions of the concrete file implementations.
|
||||||
|
*
|
||||||
|
* This class is useful in a "simple usage" situation where it is desirable
|
||||||
|
* to be able to get and set some of the tag information that is similar
|
||||||
|
* across file types.
|
||||||
|
*
|
||||||
|
* Also note that it is probably a good idea to plug this into your mime
|
||||||
|
* type system rather than using the constructor that accepts a file name using
|
||||||
|
* the FileTypeResolver.
|
||||||
|
*
|
||||||
|
* \see FileTypeResolver
|
||||||
|
* \see addFileTypeResolver()
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT FileRef
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! A class for pluggable file type resolution.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class is used to add extend TagLib's very basic file name based file
|
||||||
|
* type resolution.
|
||||||
|
*
|
||||||
|
* This can be accomplished with:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
*
|
||||||
|
* class MyFileTypeResolver : FileTypeResolver
|
||||||
|
* {
|
||||||
|
* TagLib::File *createFile(TagLib::FileName *fileName, bool, AudioProperties::ReadStyle) const
|
||||||
|
* {
|
||||||
|
* if(someCheckForAnMP3File(fileName))
|
||||||
|
* return new TagLib::MPEG::File(fileName);
|
||||||
|
* return 0;
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* FileRef::addFileTypeResolver(new MyFileTypeResolver);
|
||||||
|
*
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Naturally a less contrived example would be slightly more complex. This
|
||||||
|
* can be used to plug in mime-type detection systems or to add new file types
|
||||||
|
* to TagLib.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT FileTypeResolver
|
||||||
|
{
|
||||||
|
TAGLIB_IGNORE_MISSING_DESTRUCTOR
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This method must be overridden to provide an additional file type
|
||||||
|
* resolver. If the resolver is able to determine the file type it should
|
||||||
|
* return a valid File object; if not it should return 0.
|
||||||
|
*
|
||||||
|
* \note The created file is then owned by the FileRef and should not be
|
||||||
|
* deleted. Deletion will happen automatically when the FileRef passes
|
||||||
|
* out of scope.
|
||||||
|
*/
|
||||||
|
virtual File *createFile(FileName fileName,
|
||||||
|
bool readAudioProperties = true,
|
||||||
|
AudioProperties::ReadStyle
|
||||||
|
audioPropertiesStyle = AudioProperties::Average) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a null FileRef.
|
||||||
|
*/
|
||||||
|
FileRef();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create a FileRef from \a fileName. If \a readAudioProperties is true then
|
||||||
|
* the audio properties will be read using \a audioPropertiesStyle. If
|
||||||
|
* \a readAudioProperties is false then \a audioPropertiesStyle will be
|
||||||
|
* ignored.
|
||||||
|
*
|
||||||
|
* Also see the note in the class documentation about why you may not want to
|
||||||
|
* use this method in your application.
|
||||||
|
*/
|
||||||
|
explicit FileRef(FileName fileName,
|
||||||
|
bool readAudioProperties = true,
|
||||||
|
AudioProperties::ReadStyle
|
||||||
|
audioPropertiesStyle = AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a FileRef from an opened \a IOStream. If \a readAudioProperties
|
||||||
|
* is true then the audio properties will be read using \a audioPropertiesStyle.
|
||||||
|
* If \a readAudioProperties is false then \a audioPropertiesStyle will be
|
||||||
|
* ignored.
|
||||||
|
*
|
||||||
|
* Also see the note in the class documentation about why you may not want to
|
||||||
|
* use this method in your application.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
explicit FileRef(IOStream* stream,
|
||||||
|
bool readAudioProperties = true,
|
||||||
|
AudioProperties::ReadStyle
|
||||||
|
audioPropertiesStyle = AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a FileRef using \a file. The FileRef now takes ownership of the
|
||||||
|
* pointer and will delete the File when it passes out of scope.
|
||||||
|
*/
|
||||||
|
explicit FileRef(File *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a copy of \a ref.
|
||||||
|
*/
|
||||||
|
FileRef(const FileRef &ref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this FileRef instance.
|
||||||
|
*/
|
||||||
|
virtual ~FileRef();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to represented file's tag.
|
||||||
|
*
|
||||||
|
* \warning This pointer will become invalid when this FileRef and all
|
||||||
|
* copies pass out of scope.
|
||||||
|
*
|
||||||
|
* \warning Do not cast it to any subclasses of Tag.
|
||||||
|
* Use tag returning methods of appropriate subclasses of File instead.
|
||||||
|
*
|
||||||
|
* \see File::tag()
|
||||||
|
*/
|
||||||
|
Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the audio properties for this FileRef. If no audio properties
|
||||||
|
* were read then this will returns a null pointer.
|
||||||
|
*/
|
||||||
|
AudioProperties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the file represented by this handler class.
|
||||||
|
*
|
||||||
|
* As a general rule this call should be avoided since if you need to work
|
||||||
|
* with file objects directly, you are probably better served instantiating
|
||||||
|
* the File subclasses (i.e. MPEG::File) manually and working with their APIs.
|
||||||
|
*
|
||||||
|
* This <i>handle</i> exists to provide a minimal, generic and value-based
|
||||||
|
* wrapper around a File. Accessing the file directly generally indicates
|
||||||
|
* a moving away from this simplicity (and into things beyond the scope of
|
||||||
|
* FileRef).
|
||||||
|
*
|
||||||
|
* \warning This pointer will become invalid when this FileRef and all
|
||||||
|
* copies pass out of scope.
|
||||||
|
*/
|
||||||
|
File *file() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Saves the file. Returns true on success.
|
||||||
|
*/
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Adds a FileTypeResolver to the list of those used by TagLib. Each
|
||||||
|
* additional FileTypeResolver is added to the front of a list of resolvers
|
||||||
|
* that are tried. If the FileTypeResolver returns zero the next resolver
|
||||||
|
* is tried.
|
||||||
|
*
|
||||||
|
* Returns a pointer to the added resolver (the same one that's passed in --
|
||||||
|
* this is mostly so that static initializers have something to use for
|
||||||
|
* assignment).
|
||||||
|
*
|
||||||
|
* \see FileTypeResolver
|
||||||
|
*/
|
||||||
|
static const FileTypeResolver *addFileTypeResolver(const FileTypeResolver *resolver);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* As is mentioned elsewhere in this class's documentation, the default file
|
||||||
|
* type resolution code provided by TagLib only works by comparing file
|
||||||
|
* extensions.
|
||||||
|
*
|
||||||
|
* This method returns the list of file extensions that are used by default.
|
||||||
|
*
|
||||||
|
* The extensions are all returned in lowercase, though the comparison used
|
||||||
|
* by TagLib for resolution is case-insensitive.
|
||||||
|
*
|
||||||
|
* \note This does not account for any additional file type resolvers that
|
||||||
|
* are plugged in. Also note that this is not intended to replace a proper
|
||||||
|
* mime-type resolution system, but is just here for reference.
|
||||||
|
*
|
||||||
|
* \see FileTypeResolver
|
||||||
|
*/
|
||||||
|
static StringList defaultFileExtensions();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file (and as such other pointers) are null.
|
||||||
|
*/
|
||||||
|
bool isNull() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Assign the file pointed to by \a ref to this FileRef.
|
||||||
|
*/
|
||||||
|
FileRef &operator=(const FileRef &ref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the FileRef by the content of \a ref.
|
||||||
|
*/
|
||||||
|
void swap(FileRef &ref);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this FileRef and \a ref point to the same File object.
|
||||||
|
*/
|
||||||
|
bool operator==(const FileRef &ref) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this FileRef and \a ref do not point to the same File
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
bool operator!=(const FileRef &ref) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A simple implementation of file type guessing. If \a readAudioProperties
|
||||||
|
* is true then the audio properties will be read using
|
||||||
|
* \a audioPropertiesStyle. If \a readAudioProperties is false then
|
||||||
|
* \a audioPropertiesStyle will be ignored.
|
||||||
|
*
|
||||||
|
* \note You generally shouldn't use this method, but instead the constructor
|
||||||
|
* directly.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
static File *create(FileName fileName,
|
||||||
|
bool readAudioProperties = true,
|
||||||
|
AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
||||||
|
void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
||||||
|
|
||||||
|
class FileRefPrivate;
|
||||||
|
FileRefPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace TagLib
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,343 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2003 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FLACFILE_H
|
||||||
|
#define TAGLIB_FLACFILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tag.h"
|
||||||
|
|
||||||
|
#include "flacpicture.h"
|
||||||
|
#include "flacproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
namespace ID3v2 { class FrameFactory; class Tag; }
|
||||||
|
namespace ID3v1 { class Tag; }
|
||||||
|
namespace Ogg { class XiphComment; }
|
||||||
|
|
||||||
|
//! An implementation of FLAC metadata
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is implementation of FLAC metadata for non-Ogg FLAC files. At some
|
||||||
|
* point when Ogg / FLAC is more common there will be a similar implementation
|
||||||
|
* under the Ogg hierarchy.
|
||||||
|
*
|
||||||
|
* This supports ID3v1, ID3v2 and Xiph style comments as well as reading stream
|
||||||
|
* properties from the file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with FLAC specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for FLAC files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to FLAC files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This set of flags is used for various operations and is suitable for
|
||||||
|
* being OR-ed together.
|
||||||
|
*/
|
||||||
|
enum TagTypes {
|
||||||
|
//! Empty set. Matches no tag types.
|
||||||
|
NoTags = 0x0000,
|
||||||
|
//! Matches Vorbis comments.
|
||||||
|
XiphComment = 0x0001,
|
||||||
|
//! Matches ID3v1 tags.
|
||||||
|
ID3v1 = 0x0002,
|
||||||
|
//! Matches ID3v2 tags.
|
||||||
|
ID3v2 = 0x0004,
|
||||||
|
//! Matches all tag types.
|
||||||
|
AllTags = 0xffff
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a FLAC file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*
|
||||||
|
* \deprecated This constructor will be dropped in favor of the one below
|
||||||
|
* in a future version.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an FLAC file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using
|
||||||
|
* \a frameFactory.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
// BIC: merge with the above constructor
|
||||||
|
File(FileName file, ID3v2::FrameFactory *frameFactory,
|
||||||
|
bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a FLAC file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using
|
||||||
|
* \a frameFactory.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
// BIC: merge with the above constructor
|
||||||
|
File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
||||||
|
bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Tag for this file. This will be a union of XiphComment,
|
||||||
|
* ID3v1 and ID3v2 tags.
|
||||||
|
*
|
||||||
|
* \see ID3v2Tag()
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
* \see XiphComment()
|
||||||
|
*/
|
||||||
|
virtual TagLib::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* If the file contains more than one tag (e.g. XiphComment and ID3v1),
|
||||||
|
* only the first one (in the order XiphComment, ID3v2, ID3v1) will be
|
||||||
|
* converted to the PropertyMap.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
void removeUnsupportedProperties(const StringList &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* This always creates a Xiph comment, if none exists. The return value
|
||||||
|
* relates to the Xiph comment only.
|
||||||
|
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed
|
||||||
|
* in the FLAC specification.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the FLAC::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file. This will primarily save the XiphComment, but
|
||||||
|
* will also keep any old ID3-tags up to date. If the file
|
||||||
|
* has no XiphComment, one will be constructed from the ID3-tags.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v2 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this returns a null pointer
|
||||||
|
* if there is no valid ID3v2 tag. If \a create is true it will create
|
||||||
|
* an ID3v2 tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v2Tag()
|
||||||
|
*/
|
||||||
|
ID3v2::Tag *ID3v2Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this returns a null pointer
|
||||||
|
* if there is no valid APE tag. If \a create is true it will create
|
||||||
|
* an APE tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v1Tag()
|
||||||
|
*/
|
||||||
|
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the XiphComment for the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this returns a null pointer
|
||||||
|
* if there is no valid XiphComment. If \a create is true it will create
|
||||||
|
* a XiphComment if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has a XiphComment. Use hasXiphComment() to check if the
|
||||||
|
* file on disk actually has a XiphComment.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the FLAC::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasXiphComment()
|
||||||
|
*/
|
||||||
|
Ogg::XiphComment *xiphComment(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the ID3v2::FrameFactory to something other than the default. This
|
||||||
|
* can be used to specify the way that ID3v2 frames will be interpreted
|
||||||
|
* when
|
||||||
|
*
|
||||||
|
* \see ID3v2FrameFactory
|
||||||
|
* \deprecated This value should be passed in via the constructor
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the block of data used by FLAC::Properties for parsing the
|
||||||
|
* stream properties.
|
||||||
|
*
|
||||||
|
* \deprecated Always returns an empty vector.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED ByteVector streamInfoData(); // BIC: remove
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the audio-stream, used by FLAC::Properties for
|
||||||
|
* calculating the bitrate.
|
||||||
|
*
|
||||||
|
* \deprecated Always returns zero.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED long streamLength(); // BIC: remove
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a list of pictures attached to the FLAC file.
|
||||||
|
*/
|
||||||
|
List<Picture *> pictureList();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes an attached picture. If \a del is true the picture's memory
|
||||||
|
* will be freed; if it is false, it must be deleted by the user.
|
||||||
|
*/
|
||||||
|
void removePicture(Picture *picture, bool del = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove all attached images.
|
||||||
|
*/
|
||||||
|
void removePictures();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Add a new picture to the file. The file takes ownership of the
|
||||||
|
* picture and will handle freeing its memory.
|
||||||
|
*
|
||||||
|
* \note The file will be saved only after calling save().
|
||||||
|
*/
|
||||||
|
void addPicture(Picture *picture);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will remove the tags that match the OR-ed together TagTypes from
|
||||||
|
* the file. By default it removes all tags.
|
||||||
|
*
|
||||||
|
* \warning This will also invalidate pointers to the tags as their memory
|
||||||
|
* will be freed.
|
||||||
|
*
|
||||||
|
* \note In order to make the removal permanent save() still needs to be
|
||||||
|
* called.
|
||||||
|
*
|
||||||
|
* \note This won't remove the Vorbis comment block completely. The
|
||||||
|
* vendor ID will be preserved.
|
||||||
|
*/
|
||||||
|
void strip(int tags = AllTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has a XiphComment.
|
||||||
|
*
|
||||||
|
* \see xiphComment()
|
||||||
|
*/
|
||||||
|
bool hasXiphComment() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v1Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v2Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v2Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as a FLAC
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
void scan();
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2010 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FLACMETADATABLOCK_H
|
||||||
|
#define TAGLIB_FLACMETADATABLOCK_H
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT MetadataBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MetadataBlock();
|
||||||
|
virtual ~MetadataBlock();
|
||||||
|
|
||||||
|
enum BlockType {
|
||||||
|
StreamInfo = 0,
|
||||||
|
Padding,
|
||||||
|
Application,
|
||||||
|
SeekTable,
|
||||||
|
VorbisComment,
|
||||||
|
CueSheet,
|
||||||
|
Picture
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the FLAC metadata block type.
|
||||||
|
*/
|
||||||
|
virtual int code() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the content of the block.
|
||||||
|
*/
|
||||||
|
virtual ByteVector render() const = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
MetadataBlock(const MetadataBlock &item);
|
||||||
|
MetadataBlock &operator=(const MetadataBlock &item);
|
||||||
|
|
||||||
|
class MetadataBlockPrivate;
|
||||||
|
MetadataBlockPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,208 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2010 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FLACPICTURE_H
|
||||||
|
#define TAGLIB_FLACPICTURE_H
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "flacmetadatablock.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Picture : public MetadataBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This describes the function or content of the picture.
|
||||||
|
*/
|
||||||
|
enum Type {
|
||||||
|
//! A type not enumerated below
|
||||||
|
Other = 0x00,
|
||||||
|
//! 32x32 PNG image that should be used as the file icon
|
||||||
|
FileIcon = 0x01,
|
||||||
|
//! File icon of a different size or format
|
||||||
|
OtherFileIcon = 0x02,
|
||||||
|
//! Front cover image of the album
|
||||||
|
FrontCover = 0x03,
|
||||||
|
//! Back cover image of the album
|
||||||
|
BackCover = 0x04,
|
||||||
|
//! Inside leaflet page of the album
|
||||||
|
LeafletPage = 0x05,
|
||||||
|
//! Image from the album itself
|
||||||
|
Media = 0x06,
|
||||||
|
//! Picture of the lead artist or soloist
|
||||||
|
LeadArtist = 0x07,
|
||||||
|
//! Picture of the artist or performer
|
||||||
|
Artist = 0x08,
|
||||||
|
//! Picture of the conductor
|
||||||
|
Conductor = 0x09,
|
||||||
|
//! Picture of the band or orchestra
|
||||||
|
Band = 0x0A,
|
||||||
|
//! Picture of the composer
|
||||||
|
Composer = 0x0B,
|
||||||
|
//! Picture of the lyricist or text writer
|
||||||
|
Lyricist = 0x0C,
|
||||||
|
//! Picture of the recording location or studio
|
||||||
|
RecordingLocation = 0x0D,
|
||||||
|
//! Picture of the artists during recording
|
||||||
|
DuringRecording = 0x0E,
|
||||||
|
//! Picture of the artists during performance
|
||||||
|
DuringPerformance = 0x0F,
|
||||||
|
//! Picture from a movie or video related to the track
|
||||||
|
MovieScreenCapture = 0x10,
|
||||||
|
//! Picture of a large, coloured fish
|
||||||
|
ColouredFish = 0x11,
|
||||||
|
//! Illustration related to the track
|
||||||
|
Illustration = 0x12,
|
||||||
|
//! Logo of the band or performer
|
||||||
|
BandLogo = 0x13,
|
||||||
|
//! Logo of the publisher (record company)
|
||||||
|
PublisherLogo = 0x14
|
||||||
|
};
|
||||||
|
|
||||||
|
Picture();
|
||||||
|
Picture(const ByteVector &data);
|
||||||
|
~Picture();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the type of the image.
|
||||||
|
*/
|
||||||
|
Type type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the type of the image.
|
||||||
|
*/
|
||||||
|
void setType(Type type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
*/
|
||||||
|
String mimeType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the mime type of the image. This should in most cases be
|
||||||
|
* "image/png" or "image/jpeg".
|
||||||
|
*/
|
||||||
|
void setMimeType(const String &m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a text description of the image.
|
||||||
|
*/
|
||||||
|
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets a textual description of the image to \a desc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setDescription(const String &desc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the width of the image.
|
||||||
|
*/
|
||||||
|
int width() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the width of the image.
|
||||||
|
*/
|
||||||
|
void setWidth(int w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the height of the image.
|
||||||
|
*/
|
||||||
|
int height() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the height of the image.
|
||||||
|
*/
|
||||||
|
void setHeight(int h);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the color depth (in bits-per-pixel) of the image.
|
||||||
|
*/
|
||||||
|
int colorDepth() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the color depth (in bits-per-pixel) of the image.
|
||||||
|
*/
|
||||||
|
void setColorDepth(int depth);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of colors used on the image..
|
||||||
|
*/
|
||||||
|
int numColors() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the number of colors used on the image (for indexed images).
|
||||||
|
*/
|
||||||
|
void setNumColors(int numColors);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the image data.
|
||||||
|
*/
|
||||||
|
ByteVector data() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the image data.
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the FLAC metadata block type.
|
||||||
|
*/
|
||||||
|
int code() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the content to the FLAC picture block format.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parse the picture data in the FLAC picture block format.
|
||||||
|
*/
|
||||||
|
bool parse(const ByteVector &rawData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Picture(const Picture &item);
|
||||||
|
Picture &operator=(const Picture &item);
|
||||||
|
|
||||||
|
class PicturePrivate;
|
||||||
|
PicturePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef List<Picture> PictureList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,148 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2003 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FLACPROPERTIES_H
|
||||||
|
#define TAGLIB_FLACPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for FLAC
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an FLAC stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of FLAC::Properties with the data read from the
|
||||||
|
* ByteVector \a data.
|
||||||
|
*/
|
||||||
|
// BIC: switch to const reference
|
||||||
|
Properties(ByteVector data, long streamLength, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an instance of FLAC::Properties with the data read from the
|
||||||
|
* FLAC::File \a file.
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
Properties(File *file, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this FLAC::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample as read from the FLAC
|
||||||
|
* identification header.
|
||||||
|
*/
|
||||||
|
int bitsPerSample() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample width as read from the FLAC identification
|
||||||
|
* header.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of bitsPerSample().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED int sampleWidth() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Return the number of sample frames.
|
||||||
|
*/
|
||||||
|
unsigned long long sampleFrames() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MD5 signature of the uncompressed audio stream as read
|
||||||
|
* from the stream info header.
|
||||||
|
*/
|
||||||
|
ByteVector signature() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(const ByteVector &data, long streamLength);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,179 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||||
|
email : wheeler@kde.org
|
||||||
|
|
||||||
|
copyright : (C) 2006 by Aaron VonderHaar
|
||||||
|
email : avh4@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_GENERALENCAPSULATEDOBJECT_H
|
||||||
|
#define TAGLIB_GENERALENCAPSULATEDOBJECT_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "id3v2header.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An ID3v2 general encapsulated object frame implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ID3v2 general encapsulated objects.
|
||||||
|
* Arbitrary binary data may be included in tags, stored in GEOB frames.
|
||||||
|
* There may be multiple GEOB frames in a single tag. Each GEOB it
|
||||||
|
* labelled with a content description (which may be blank), a required
|
||||||
|
* mime-type, and a file name (may be blank). The content description
|
||||||
|
* uniquely identifies the GEOB frame in the tag.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT GeneralEncapsulatedObjectFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty object frame. The description, file name and text
|
||||||
|
* encoding should be set manually.
|
||||||
|
*/
|
||||||
|
GeneralEncapsulatedObjectFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a GeneralEncapsulatedObjectFrame frame based on \a data.
|
||||||
|
*
|
||||||
|
* \warning This is \em not data for the encapsulated object, for that use
|
||||||
|
* setObject(). This constructor is used when reading the frame from the
|
||||||
|
* disk.
|
||||||
|
*/
|
||||||
|
explicit GeneralEncapsulatedObjectFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the GeneralEncapsulatedObjectFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~GeneralEncapsulatedObjectFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a string containing the description, file name and mime-type
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding used for the description and file name.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see description()
|
||||||
|
* \see fileName()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the text encoding used for the description and file name.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
* \see fileName()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the mime type of the object.
|
||||||
|
*/
|
||||||
|
String mimeType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the mime type of the object.
|
||||||
|
*/
|
||||||
|
void setMimeType(const String &type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the file name of the object.
|
||||||
|
*
|
||||||
|
* \see setFileName()
|
||||||
|
*/
|
||||||
|
String fileName() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the file name for the object.
|
||||||
|
*
|
||||||
|
* \see fileName()
|
||||||
|
*/
|
||||||
|
void setFileName(const String &name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the content description of the object.
|
||||||
|
*
|
||||||
|
* \see setDescription()
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see setTextEncoding()
|
||||||
|
*/
|
||||||
|
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the content description of the object to \a desc.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see setTextEncoding()
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setDescription(const String &desc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the object data as a ByteVector.
|
||||||
|
*
|
||||||
|
* \note ByteVector has a data() method that returns a const char * which
|
||||||
|
* should make it easy to export this data to external programs.
|
||||||
|
*
|
||||||
|
* \see setObject()
|
||||||
|
* \see mimeType()
|
||||||
|
*/
|
||||||
|
ByteVector object() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the object data to \a data. \a data should be of the type specified in
|
||||||
|
* this frame's mime-type specification.
|
||||||
|
*
|
||||||
|
* \see object()
|
||||||
|
* \see mimeType()
|
||||||
|
* \see setMimeType()
|
||||||
|
*/
|
||||||
|
void setObject(const ByteVector &object);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h);
|
||||||
|
GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame &);
|
||||||
|
GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame &);
|
||||||
|
|
||||||
|
class GeneralEncapsulatedObjectFramePrivate;
|
||||||
|
GeneralEncapsulatedObjectFramePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V1GENRE_H
|
||||||
|
#define TAGLIB_ID3V1GENRE_H
|
||||||
|
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
namespace ID3v1 {
|
||||||
|
|
||||||
|
typedef Map<String, int> GenreMap;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the list of canonical ID3v1 genre names in the order that they
|
||||||
|
* are listed in the standard.
|
||||||
|
*/
|
||||||
|
StringList TAGLIB_EXPORT genreList();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A "reverse mapping" that goes from the canonical ID3v1 genre name to the
|
||||||
|
* respective genre number. genreMap()["Rock"] ==
|
||||||
|
*/
|
||||||
|
GenreMap TAGLIB_EXPORT genreMap();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the name of the genre at \a index in the ID3v1 genre list. If
|
||||||
|
* \a index is out of range -- less than zero or greater than 191 -- a null
|
||||||
|
* string will be returned.
|
||||||
|
*/
|
||||||
|
String TAGLIB_EXPORT genre(int index);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the genre index for the (case sensitive) genre \a name. If the
|
||||||
|
* genre is not in the list 255 (which signifies an unknown genre in ID3v1)
|
||||||
|
* will be returned.
|
||||||
|
*/
|
||||||
|
int TAGLIB_EXPORT genreIndex(const String &name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,202 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V1TAG_H
|
||||||
|
#define TAGLIB_ID3V1TAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An ID3v1 implementation
|
||||||
|
|
||||||
|
namespace ID3v1 {
|
||||||
|
|
||||||
|
//! A abstraction for the string to data encoding in ID3v1 tags.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* ID3v1 should in theory always contain ISO-8859-1 (Latin1) data. In
|
||||||
|
* practice it does not. TagLib by default only supports ISO-8859-1 data
|
||||||
|
* in ID3v1 tags.
|
||||||
|
*
|
||||||
|
* However by subclassing this class and reimplementing parse() and render()
|
||||||
|
* and setting your reimplementation as the default with
|
||||||
|
* ID3v1::Tag::setStringHandler() you can define how you would like these
|
||||||
|
* transformations to be done.
|
||||||
|
*
|
||||||
|
* \warning It is advisable <b>not</b> to write non-ISO-8859-1 data to ID3v1
|
||||||
|
* tags. Please consider disabling the writing of ID3v1 tags in the case
|
||||||
|
* that the data is not ISO-8859-1.
|
||||||
|
*
|
||||||
|
* \see ID3v1::Tag::setStringHandler()
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT StringHandler
|
||||||
|
{
|
||||||
|
TAGLIB_IGNORE_MISSING_DESTRUCTOR
|
||||||
|
public:
|
||||||
|
// BIC: Add virtual destructor.
|
||||||
|
StringHandler();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Decode a string from \a data. The default implementation assumes that
|
||||||
|
* \a data is an ISO-8859-1 (Latin1) character array.
|
||||||
|
*/
|
||||||
|
virtual String parse(const ByteVector &data) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Encode a ByteVector with the data from \a s. The default implementation
|
||||||
|
* assumes that \a s is an ISO-8859-1 (Latin1) string. If the string is
|
||||||
|
* does not conform to ISO-8859-1, no value is written.
|
||||||
|
*
|
||||||
|
* \warning It is recommended that you <b>not</b> override this method, but
|
||||||
|
* instead do not write an ID3v1 tag in the case that the data is not
|
||||||
|
* ISO-8859-1.
|
||||||
|
*/
|
||||||
|
virtual ByteVector render(const String &s) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The main class in the ID3v1 implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of the ID3v1 format. ID3v1 is both the simplest
|
||||||
|
* and most common of tag formats but is rather limited. Because of its
|
||||||
|
* pervasiveness and the way that applications have been written around the
|
||||||
|
* fields that it provides, the generic TagLib::Tag API is a mirror of what is
|
||||||
|
* provided by ID3v1.
|
||||||
|
*
|
||||||
|
* ID3v1 tags should generally only contain Latin1 information. However because
|
||||||
|
* many applications do not follow this rule there is now support for overriding
|
||||||
|
* the ID3v1 string handling using the ID3v1::StringHandler class. Please see
|
||||||
|
* the documentation for that class for more information.
|
||||||
|
*
|
||||||
|
* \see StringHandler
|
||||||
|
*
|
||||||
|
* \note Most fields are truncated to a maximum of 28-30 bytes. The
|
||||||
|
* truncation happens automatically when the tag is rendered.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an ID3v1 tag with default values.
|
||||||
|
*/
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an ID3v1 tag and parse the data in \a file starting at
|
||||||
|
* \a tagOffset.
|
||||||
|
*/
|
||||||
|
Tag(File *file, long tagOffset);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Tag instance.
|
||||||
|
*/
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the in memory values to a ByteVector suitable for writing to
|
||||||
|
* the file.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the string "TAG" suitable for usage in locating the tag in a
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
static ByteVector fileIdentifier();
|
||||||
|
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual String title() const;
|
||||||
|
virtual String artist() const;
|
||||||
|
virtual String album() const;
|
||||||
|
virtual String comment() const;
|
||||||
|
virtual String genre() const;
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
virtual void setTitle(const String &s);
|
||||||
|
virtual void setArtist(const String &s);
|
||||||
|
virtual void setAlbum(const String &s);
|
||||||
|
virtual void setComment(const String &s);
|
||||||
|
virtual void setGenre(const String &s);
|
||||||
|
virtual void setYear(unsigned int i);
|
||||||
|
virtual void setTrack(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the genre in number.
|
||||||
|
*
|
||||||
|
* \note Normally 255 indicates that this tag contains no genre.
|
||||||
|
*/
|
||||||
|
unsigned int genreNumber() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the genre in number to \a i.
|
||||||
|
*
|
||||||
|
* \note Valid value is from 0 up to 255. Normally 255 indicates that
|
||||||
|
* this tag contains no genre.
|
||||||
|
*/
|
||||||
|
void setGenreNumber(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the string handler that decides how the ID3v1 data will be
|
||||||
|
* converted to and from binary data.
|
||||||
|
* If the parameter \a handler is null, the previous handler is
|
||||||
|
* released and default ISO-8859-1 handler is restored.
|
||||||
|
*
|
||||||
|
* \note The caller is responsible for deleting the previous handler
|
||||||
|
* as needed after it is released.
|
||||||
|
*
|
||||||
|
* \see StringHandler
|
||||||
|
*/
|
||||||
|
static void setStringHandler(const StringHandler *handler);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Reads from the file specified in the constructor.
|
||||||
|
*/
|
||||||
|
void read();
|
||||||
|
/*!
|
||||||
|
* Pareses the body of the tag in \a data.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef TAGLIB_ID3V2_H
|
||||||
|
#define TAGLIB_ID3V2_H
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
//! An ID3v2 implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is a relatively complete and flexible framework for working with ID3v2
|
||||||
|
* tags.
|
||||||
|
*
|
||||||
|
* \see ID3v2::Tag
|
||||||
|
*/
|
||||||
|
namespace ID3v2 {
|
||||||
|
/*!
|
||||||
|
* Used to specify which version of the ID3 standard to use when saving tags.
|
||||||
|
*/
|
||||||
|
enum Version {
|
||||||
|
v3 = 3, //<! ID3v2.3
|
||||||
|
v4 = 4 //<! ID3v2.4
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,93 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2EXTENDEDHEADER_H
|
||||||
|
#define TAGLIB_ID3V2EXTENDEDHEADER_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! ID3v2 extended header implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class implements ID3v2 extended headers. It attempts to follow,
|
||||||
|
* both semantically and programmatically, the structure specified in
|
||||||
|
* the ID3v2 standard. The API is based on the properties of ID3v2 extended
|
||||||
|
* headers specified there. If any of the terms used in this documentation
|
||||||
|
* are unclear please check the specification in the linked section.
|
||||||
|
* (Structure, <a href="id3v2-structure.html#3.2">3.2</a>)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT ExtendedHeader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty ID3v2 extended header.
|
||||||
|
*/
|
||||||
|
ExtendedHeader();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the extended header.
|
||||||
|
*/
|
||||||
|
virtual ~ExtendedHeader();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the extended header. This is variable for the
|
||||||
|
* extended header.
|
||||||
|
*/
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data that will be used as the extended header. Since the
|
||||||
|
* length is not known before the extended header has been parsed, this
|
||||||
|
* should just be a pointer to the first byte of the extended header. It
|
||||||
|
* will determine the length internally and make that available through
|
||||||
|
* size().
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Called by setData() to parse the extended header data. It makes this
|
||||||
|
* information available through the public API.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExtendedHeader(const ExtendedHeader &);
|
||||||
|
ExtendedHeader &operator=(const ExtendedHeader &);
|
||||||
|
|
||||||
|
class ExtendedHeaderPrivate;
|
||||||
|
ExtendedHeaderPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,82 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2FOOTER_H
|
||||||
|
#define TAGLIB_ID3V2FOOTER_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
class Header;
|
||||||
|
|
||||||
|
//! ID3v2 footer implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Per the ID3v2 specification, the tag's footer is just a copy of the
|
||||||
|
* information in the header. As such there is no API for reading the
|
||||||
|
* data from the header, it can just as easily be done from the header.
|
||||||
|
*
|
||||||
|
* In fact, at this point, TagLib does not even parse the footer since
|
||||||
|
* it is not useful internally. However, if the flag to include a footer
|
||||||
|
* has been set in the ID3v2::Tag, TagLib will render a footer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Footer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty ID3v2 footer.
|
||||||
|
*/
|
||||||
|
Footer();
|
||||||
|
/*!
|
||||||
|
* Destroys the footer.
|
||||||
|
*/
|
||||||
|
virtual ~Footer();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the footer. Presently this is always 10 bytes.
|
||||||
|
*/
|
||||||
|
static unsigned int size();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the footer based on the data in \a header.
|
||||||
|
*/
|
||||||
|
ByteVector render(const Header *header) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Footer(const Footer &);
|
||||||
|
Footer &operator=(const Footer &);
|
||||||
|
|
||||||
|
class FooterPrivate;
|
||||||
|
FooterPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,521 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2FRAME_H
|
||||||
|
#define TAGLIB_ID3V2FRAME_H
|
||||||
|
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class StringList;
|
||||||
|
class PropertyMap;
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
class FrameFactory;
|
||||||
|
|
||||||
|
//! ID3v2 frame implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class is the main ID3v2 frame implementation. In ID3v2, a tag is
|
||||||
|
* split between a collection of frames (which are in turn split into fields
|
||||||
|
* (Structure, <a href="id3v2-structure.html#4">4</a>)
|
||||||
|
* (<a href="id3v2-frames.html">Frames</a>). This class provides an API for
|
||||||
|
* gathering information about and modifying ID3v2 frames. Functionality
|
||||||
|
* specific to a given frame type is handed in one of the many subclasses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Frame
|
||||||
|
{
|
||||||
|
friend class Tag;
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a textual frame which corresponds to a single key in the PropertyMap
|
||||||
|
* interface. These are all (User)TextIdentificationFrames except TIPL and TMCL,
|
||||||
|
* all (User)URLLinkFrames, CommentsFrames, and UnsynchronizedLyricsFrame.
|
||||||
|
*/
|
||||||
|
static Frame *createTextualFrame(const String &key, const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Frame instance.
|
||||||
|
*/
|
||||||
|
virtual ~Frame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Frame ID (Structure, <a href="id3v2-structure.html#4">4</a>)
|
||||||
|
* (Frames, <a href="id3v2-frames.html#4">4</a>)
|
||||||
|
*/
|
||||||
|
ByteVector frameID() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame.
|
||||||
|
*/
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame header
|
||||||
|
*
|
||||||
|
* \deprecated This is only accurate for ID3v2.3 or ID3v2.4. Please use
|
||||||
|
* the call below which accepts an ID3v2 version number. In the next
|
||||||
|
* non-binary compatible release this will be made into a non-static
|
||||||
|
* member that checks the internal ID3v2 version.
|
||||||
|
*/
|
||||||
|
static unsigned int headerSize(); // BIC: make non-static
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame header for the given ID3v2 version.
|
||||||
|
*
|
||||||
|
* \deprecated Please see the explanation above.
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
static unsigned int headerSize(unsigned int version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data that will be used as the frame. Since the length is not
|
||||||
|
* known before the frame has been parsed, this should just be a pointer to
|
||||||
|
* the first byte of the frame. It will determine the length internally
|
||||||
|
* and make that available through size().
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the text of frame in the sanest way possible. This should only be
|
||||||
|
* reimplemented in frames where there is some logical mapping to text.
|
||||||
|
*
|
||||||
|
* \note If the frame type supports multiple text encodings, this will not
|
||||||
|
* change the text encoding of the frame; the string will be converted to
|
||||||
|
* that frame's encoding. Please use the specific APIs of the frame types
|
||||||
|
* to set the encoding if that is desired.
|
||||||
|
*/
|
||||||
|
virtual void setText(const String &text);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This returns the textual representation of the data in the frame.
|
||||||
|
* Subclasses must reimplement this method to provide a string
|
||||||
|
* representation of the frame's data.
|
||||||
|
*/
|
||||||
|
virtual String toString() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the frame back to its binary format in a ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text delimiter that is used between fields for the string
|
||||||
|
* type \a t.
|
||||||
|
*/
|
||||||
|
static ByteVector textDelimiter(String::Type t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The string with which an instrument name is prefixed to build a key in a PropertyMap;
|
||||||
|
* used to translate PropertyMaps to TMCL frames. In the current implementation, this
|
||||||
|
* is "PERFORMER:".
|
||||||
|
*/
|
||||||
|
static const String instrumentPrefix;
|
||||||
|
/*!
|
||||||
|
* The PropertyMap key prefix which triggers the use of a COMM frame instead of a TXXX
|
||||||
|
* frame for a non-standard key. In the current implementation, this is "COMMENT:".
|
||||||
|
*/
|
||||||
|
static const String commentPrefix;
|
||||||
|
/*!
|
||||||
|
* The PropertyMap key prefix which triggers the use of a USLT frame instead of a TXXX
|
||||||
|
* frame for a non-standard key. In the current implementation, this is "LYRICS:".
|
||||||
|
*/
|
||||||
|
static const String lyricsPrefix;
|
||||||
|
/*!
|
||||||
|
* The PropertyMap key prefix which triggers the use of a WXXX frame instead of a TXX
|
||||||
|
* frame for a non-standard key. In the current implementation, this is "URL:".
|
||||||
|
*/
|
||||||
|
static const String urlPrefix;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
class Header;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an ID3v2 frame using \a data to read the header information.
|
||||||
|
* All other processing of \a data should be handled in a subclass.
|
||||||
|
*
|
||||||
|
* \note This need not contain anything more than a frame ID, but
|
||||||
|
* \e must contain at least that.
|
||||||
|
*/
|
||||||
|
explicit Frame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This creates an Frame using the header \a h.
|
||||||
|
*
|
||||||
|
* The ownership of this header will be assigned to the frame and the
|
||||||
|
* header will be deleted when the frame is destroyed.
|
||||||
|
*/
|
||||||
|
Frame(Header *h);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the frame header.
|
||||||
|
*/
|
||||||
|
Header *header() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the header to \a h. If \a deleteCurrent is true, this will free
|
||||||
|
* the memory of the current header.
|
||||||
|
*
|
||||||
|
* The ownership of this header will be assigned to the frame and the
|
||||||
|
* header will be deleted when the frame is destroyed.
|
||||||
|
*/
|
||||||
|
void setHeader(Header *h, bool deleteCurrent = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Called by setData() to parse the frame data. It makes this information
|
||||||
|
* available through the public API.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Called by parse() to parse the field data. It makes this information
|
||||||
|
* available through the public API. This must be overridden by the
|
||||||
|
* subclasses.
|
||||||
|
*/
|
||||||
|
virtual void parseFields(const ByteVector &data) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the field data back to a binary format in a ByteVector. This
|
||||||
|
* must be overridden by subclasses.
|
||||||
|
*/
|
||||||
|
virtual ByteVector renderFields() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ByteVector containing the field data given the frame data.
|
||||||
|
* This correctly adjusts for the header size plus any additional frame
|
||||||
|
* data that's specified in the frame header flags.
|
||||||
|
*/
|
||||||
|
ByteVector fieldData(const ByteVector &frameData) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads a String of type \a encoding from the ByteVector \a data. If \a
|
||||||
|
* position is passed in it is used both as the starting point and is
|
||||||
|
* updated to return the position just after the string that has been read.
|
||||||
|
* This is useful for reading strings sequentially.
|
||||||
|
*/
|
||||||
|
String readStringField(const ByteVector &data, String::Type encoding,
|
||||||
|
int *position = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks a the list of string values to see if they can be used with the
|
||||||
|
* specified encoding and returns the recommended encoding.
|
||||||
|
*/
|
||||||
|
// BIC: remove and make non-static
|
||||||
|
static String::Type checkEncoding(const StringList &fields,
|
||||||
|
String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks a the list of string values to see if they can be used with the
|
||||||
|
* specified encoding and returns the recommended encoding. This method
|
||||||
|
* also checks the ID3v2 version and makes sure the encoding can be used
|
||||||
|
* in the specified version.
|
||||||
|
*/
|
||||||
|
// BIC: remove and make non-static
|
||||||
|
static String::Type checkEncoding(const StringList &fields,
|
||||||
|
String::Type encoding, unsigned int version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks a the list of string values to see if they can be used with the
|
||||||
|
* specified encoding and returns the recommended encoding. This method
|
||||||
|
* also checks the ID3v2 version and makes sure the encoding can be used
|
||||||
|
* in the version specified by the frame's header.
|
||||||
|
*/
|
||||||
|
String::Type checkTextEncoding(const StringList &fields,
|
||||||
|
String::Type encoding) const;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parses the contents of this frame as PropertyMap. If that fails, the returned
|
||||||
|
* PropertyMap will be empty, and its unsupportedData() will contain this frame's
|
||||||
|
* ID.
|
||||||
|
* BIC: Will be a virtual function in future releases.
|
||||||
|
*/
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an appropriate ID3 frame ID for the given free-form tag key. This method
|
||||||
|
* will return an empty ByteVector if no specialized translation is found.
|
||||||
|
*/
|
||||||
|
static ByteVector keyToFrameID(const String &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a free-form tag name for the given ID3 frame ID. Note that this does not work
|
||||||
|
* for general frame IDs such as TXXX or WXXX; in such a case an empty string is returned.
|
||||||
|
*/
|
||||||
|
static String frameIDToKey(const ByteVector &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an appropriate TXXX frame description for the given free-form tag key.
|
||||||
|
*/
|
||||||
|
static String keyToTXXX(const String &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a free-form tag name for the given ID3 frame description.
|
||||||
|
*/
|
||||||
|
static String txxxToKey(const String &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This helper function splits the PropertyMap \a original into three ProperytMaps
|
||||||
|
* \a singleFrameProperties, \a tiplProperties, and \a tmclProperties, such that:
|
||||||
|
* - \a singleFrameProperties contains only of keys which can be represented with
|
||||||
|
* exactly one ID3 frame per key. In the current implementation
|
||||||
|
* this is everything except for the fixed "involved people" keys and keys of the
|
||||||
|
* form "TextIdentificationFrame::instrumentPrefix" + "instrument", which are
|
||||||
|
* mapped to a TMCL frame.
|
||||||
|
* - \a tiplProperties will consist of those keys that are present in
|
||||||
|
* TextIdentificationFrame::involvedPeopleMap()
|
||||||
|
* - \a tmclProperties contains the "musician credits" keys which should be mapped
|
||||||
|
* to a TMCL frame
|
||||||
|
*/
|
||||||
|
static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
|
||||||
|
PropertyMap &tiplProperties, PropertyMap &tmclProperties);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Frame(const Frame &);
|
||||||
|
Frame &operator=(const Frame &);
|
||||||
|
|
||||||
|
class FramePrivate;
|
||||||
|
friend class FramePrivate;
|
||||||
|
FramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! ID3v2 frame header implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The ID3v2 Frame Header (Structure, <a href="id3v2-structure.html#4">4</a>)
|
||||||
|
*
|
||||||
|
* Every ID3v2::Frame has an associated header that gives some general
|
||||||
|
* properties of the frame and also makes it possible to identify the frame
|
||||||
|
* type.
|
||||||
|
*
|
||||||
|
* As such when reading an ID3v2 tag ID3v2::FrameFactory first creates the
|
||||||
|
* frame headers and then creates the appropriate Frame subclass based on
|
||||||
|
* the type and attaches the header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Frame::Header
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct a Frame Header based on \a data. \a data must at least
|
||||||
|
* contain a 4 byte frame ID, and optionally can contain flag data and the
|
||||||
|
* frame size. i.e. Just the frame id -- "TALB" -- is a valid value.
|
||||||
|
*
|
||||||
|
* \deprecated Please use the constructor below that accepts a version
|
||||||
|
* number.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Header(const ByteVector &data, bool synchSafeInts);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a Frame Header based on \a data. \a data must at least
|
||||||
|
* contain a 4 byte frame ID, and optionally can contain flag data and the
|
||||||
|
* frame size. i.e. Just the frame id -- "TALB" -- is a valid value.
|
||||||
|
*
|
||||||
|
* \a version should be the ID3v2 version of the tag.
|
||||||
|
*/
|
||||||
|
explicit Header(const ByteVector &data, unsigned int version = 4);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Header instance.
|
||||||
|
*/
|
||||||
|
virtual ~Header();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the Header.
|
||||||
|
*
|
||||||
|
* \deprecated Please use the version below that accepts an ID3v2 version
|
||||||
|
* number.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED void setData(const ByteVector &data, bool synchSafeInts);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the Header. \a version should indicate the ID3v2
|
||||||
|
* version number of the tag that this frame is contained in.
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data, unsigned int version = 4);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Frame ID (Structure, <a href="id3v2-structure.html#4">4</a>)
|
||||||
|
* (Frames, <a href="id3v2-frames.html#4">4</a>)
|
||||||
|
*/
|
||||||
|
ByteVector frameID() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the frame's ID to \a id. Only the first four bytes of \a id will
|
||||||
|
* be used.
|
||||||
|
*
|
||||||
|
* \warning This method should in general be avoided. It exists simply to
|
||||||
|
* provide a mechanism for transforming frames from a deprecated frame type
|
||||||
|
* to a newer one -- i.e. TYER to TDRC from ID3v2.3 to ID3v2.4.
|
||||||
|
*/
|
||||||
|
void setFrameID(const ByteVector &id);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame data portion, as set when setData() was
|
||||||
|
* called or set explicitly via setFrameSize().
|
||||||
|
*/
|
||||||
|
unsigned int frameSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the size of the frame data portion.
|
||||||
|
*/
|
||||||
|
void setFrameSize(unsigned int size);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the ID3v2 version of the header, as passed in from the
|
||||||
|
* construction of the header or set via setVersion().
|
||||||
|
*/
|
||||||
|
unsigned int version() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the ID3v2 version of the header, changing has impact on the
|
||||||
|
* correct parsing/rendering of frame data.
|
||||||
|
*/
|
||||||
|
void setVersion(unsigned int version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame header in bytes.
|
||||||
|
*
|
||||||
|
* \deprecated Please use the version of this method that accepts a
|
||||||
|
* version. This is only accurate for ID3v2.3 and ID3v2.4. This will be
|
||||||
|
* removed in the next binary incompatible release (2.0) and will be
|
||||||
|
* replaced with a non-static method that checks the frame version.
|
||||||
|
*/
|
||||||
|
// BIC: make non-static
|
||||||
|
static unsigned int size();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the frame header in bytes for the ID3v2 version
|
||||||
|
* that's given.
|
||||||
|
*
|
||||||
|
* \deprecated Please see the explanation in the version above.
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
static unsigned int size(unsigned int version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the flag for tag alter preservation is set.
|
||||||
|
*
|
||||||
|
* The semantics are a little backwards from what would seem natural
|
||||||
|
* (setting the preservation flag to throw away the frame), but this
|
||||||
|
* follows the ID3v2 standard.
|
||||||
|
*
|
||||||
|
* \see setTagAlterPreservation()
|
||||||
|
*/
|
||||||
|
bool tagAlterPreservation() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the flag for preservation of this frame if the tag is set. If
|
||||||
|
* this is set to true the frame will not be written when the tag is
|
||||||
|
* saved.
|
||||||
|
*
|
||||||
|
* The semantics are a little backwards from what would seem natural
|
||||||
|
* (setting the preservation flag to throw away the frame), but this
|
||||||
|
* follows the ID3v2 standard.
|
||||||
|
*
|
||||||
|
* \see tagAlterPreservation()
|
||||||
|
*/
|
||||||
|
void setTagAlterPreservation(bool discard);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the flag for file alter preservation is set.
|
||||||
|
*
|
||||||
|
* \note This flag is currently ignored internally in TagLib.
|
||||||
|
*/
|
||||||
|
bool fileAlterPreservation() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the frame is meant to be read only.
|
||||||
|
*
|
||||||
|
* \note This flag is currently ignored internally in TagLib.
|
||||||
|
*/
|
||||||
|
bool readOnly() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the flag for the grouping identity is set.
|
||||||
|
*
|
||||||
|
* \note This flag is currently ignored internally in TagLib.
|
||||||
|
*/
|
||||||
|
bool groupingIdentity() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if compression is enabled for this frame.
|
||||||
|
*
|
||||||
|
* \note This flag is currently ignored internally in TagLib.
|
||||||
|
*/
|
||||||
|
bool compression() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if encryption is enabled for this frame.
|
||||||
|
*
|
||||||
|
* \note This flag is currently ignored internally in TagLib.
|
||||||
|
*/
|
||||||
|
bool encryption() const;
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
bool unsycronisation() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if unsynchronisation is enabled for this frame.
|
||||||
|
*/
|
||||||
|
bool unsynchronisation() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the flag for a data length indicator is set.
|
||||||
|
*/
|
||||||
|
bool dataLengthIndicator() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the Header back to binary format in a ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED bool frameAlterPreservation() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Header(const Header &);
|
||||||
|
Header &operator=(const Header &);
|
||||||
|
|
||||||
|
class HeaderPrivate;
|
||||||
|
HeaderPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,169 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2FRAMEFACTORY_H
|
||||||
|
#define TAGLIB_ID3V2FRAMEFACTORY_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "id3v2header.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
class TextIdentificationFrame;
|
||||||
|
|
||||||
|
//! A factory for creating ID3v2 frames during parsing
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This factory abstracts away the frame creation process and instantiates
|
||||||
|
* the appropriate ID3v2::Frame subclasses based on the contents of the
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* Reimplementing this factory is the key to adding support for frame types
|
||||||
|
* not directly supported by TagLib to your application. To do so you would
|
||||||
|
* subclass this factory and reimplement createFrame(). Then by setting your
|
||||||
|
* factory to be the default factory in ID3v2::Tag constructor you can
|
||||||
|
* implement behavior that will allow for new ID3v2::Frame subclasses (also
|
||||||
|
* provided by you) to be used.
|
||||||
|
*
|
||||||
|
* This implements both <i>abstract factory</i> and <i>singleton</i> patterns
|
||||||
|
* of which more information is available on the web and in software design
|
||||||
|
* textbooks (Notably <i>Design Patters</i>).
|
||||||
|
*
|
||||||
|
* \note You do not need to use this factory to create new frames to add to
|
||||||
|
* an ID3v2::Tag. You can instantiate frame subclasses directly (with new)
|
||||||
|
* and add them to a tag using ID3v2::Tag::addFrame()
|
||||||
|
*
|
||||||
|
* \see ID3v2::Tag::addFrame()
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT FrameFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static FrameFactory *instance();
|
||||||
|
/*!
|
||||||
|
* Create a frame based on \a data. \a synchSafeInts should only be set
|
||||||
|
* false if we are parsing an old tag (v2.3 or older) that does not support
|
||||||
|
* synchsafe ints.
|
||||||
|
*
|
||||||
|
* \deprecated Please use the method below that accepts a ID3v2::Header
|
||||||
|
* instance in new code.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Frame *createFrame(const ByteVector &data, bool synchSafeInts) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create a frame based on \a data. \a version should indicate the ID3v2
|
||||||
|
* version of the tag. As ID3v2.4 is the most current version of the
|
||||||
|
* standard 4 is the default.
|
||||||
|
*
|
||||||
|
* \deprecated Please use the method below that accepts a ID3v2::Header
|
||||||
|
* instance in new code.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Frame *createFrame(const ByteVector &data, unsigned int version = 4) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
Frame *createFrame(const ByteVector &data, Header *tagHeader) const;
|
||||||
|
/*!
|
||||||
|
* Create a frame based on \a data. \a tagHeader should be a valid
|
||||||
|
* ID3v2::Header instance.
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
Frame *createFrame(const ByteVector &data, const Header *tagHeader) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* After a tag has been read, this tries to rebuild some of them
|
||||||
|
* information, most notably the recording date, from frames that
|
||||||
|
* have been deprecated and can't be upgraded directly.
|
||||||
|
*/
|
||||||
|
// BIC: Make virtual
|
||||||
|
void rebuildAggregateFrames(ID3v2::Tag *tag) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the default text encoding for text frames. If setTextEncoding()
|
||||||
|
* has not been explicitly called this will only be used for new text
|
||||||
|
* frames. However, if this value has been set explicitly all frames will be
|
||||||
|
* converted to this type (unless it's explicitly set differently for the
|
||||||
|
* individual frame) when being rendered.
|
||||||
|
*
|
||||||
|
* \see setDefaultTextEncoding()
|
||||||
|
*/
|
||||||
|
String::Type defaultTextEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the default text encoding for all text frames that are created to
|
||||||
|
* \a encoding. If no value is set the frames with either default to the
|
||||||
|
* encoding type that was parsed and new frames default to Latin1.
|
||||||
|
*
|
||||||
|
* Valid string types for ID3v2 tags are Latin1, UTF8, UTF16 and UTF16BE.
|
||||||
|
*
|
||||||
|
* \see defaultTextEncoding()
|
||||||
|
*/
|
||||||
|
void setDefaultTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Constructs a frame factory. Because this is a singleton this method is
|
||||||
|
* protected, but may be used for subclasses.
|
||||||
|
*/
|
||||||
|
FrameFactory();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the frame factory.
|
||||||
|
*/
|
||||||
|
virtual ~FrameFactory();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This method checks for compliance to the current ID3v2 standard (2.4)
|
||||||
|
* and does nothing in the common case. However if a frame is found that
|
||||||
|
* is not compatible with the current standard, this method either updates
|
||||||
|
* the frame or indicates that it should be discarded.
|
||||||
|
*
|
||||||
|
* This method with return true (with or without changes to the frame) if
|
||||||
|
* this frame should be kept or false if it should be discarded.
|
||||||
|
*
|
||||||
|
* See the id3v2.4.0-changes.txt document for further information.
|
||||||
|
*/
|
||||||
|
virtual bool updateFrame(Frame::Header *header) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FrameFactory(const FrameFactory &);
|
||||||
|
FrameFactory &operator=(const FrameFactory &);
|
||||||
|
|
||||||
|
static FrameFactory factory;
|
||||||
|
|
||||||
|
class FrameFactoryPrivate;
|
||||||
|
FrameFactoryPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,176 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2HEADER_H
|
||||||
|
#define TAGLIB_ID3V2HEADER_H
|
||||||
|
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "id3v2.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 headers
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class implements ID3v2 headers. It attempts to follow, both
|
||||||
|
* semantically and programmatically, the structure specified in
|
||||||
|
* the ID3v2 standard. The API is based on the properties of ID3v2 headers
|
||||||
|
* specified there. If any of the terms used in this documentation are
|
||||||
|
* unclear please check the specification in the linked section.
|
||||||
|
* (Structure, <a href="id3v2-structure.html#3.1">3.1</a>)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Header
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty ID3v2 header.
|
||||||
|
*/
|
||||||
|
Header();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an ID3v2 header based on \a data. parse() is called
|
||||||
|
* immediately.
|
||||||
|
*/
|
||||||
|
Header(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the header.
|
||||||
|
*/
|
||||||
|
virtual ~Header();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the major version number. (Note: This is the 4, not the 2 in
|
||||||
|
* ID3v2.4.0. The 2 is implied.)
|
||||||
|
*/
|
||||||
|
unsigned int majorVersion() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the the major version number to \a version. (Note: This is
|
||||||
|
* the 4, not the 2 in ID3v2.4.0. The 2 is implied.)
|
||||||
|
* \see majorVersion()
|
||||||
|
*
|
||||||
|
* \note This is used by the internal parser; this will not change the
|
||||||
|
* version which is written and in general should not be called by API
|
||||||
|
* users.
|
||||||
|
*/
|
||||||
|
void setMajorVersion(unsigned int version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the revision number. (Note: This is the 0, not the 4 in
|
||||||
|
* ID3v2.4.0. The 2 is implied.)
|
||||||
|
*/
|
||||||
|
unsigned int revisionNumber() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if unsynchronisation has been applied to all frames.
|
||||||
|
*/
|
||||||
|
bool unsynchronisation() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if an extended header is present in the tag.
|
||||||
|
*/
|
||||||
|
bool extendedHeader() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the experimental indicator flag is set.
|
||||||
|
*/
|
||||||
|
bool experimentalIndicator() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if a footer is present in the tag.
|
||||||
|
*/
|
||||||
|
bool footerPresent() const;
|
||||||
|
/*!
|
||||||
|
* Returns the tag size in bytes. This is the size of the frame content.
|
||||||
|
* The size of the \e entire tag will be this plus the header size (10
|
||||||
|
* bytes) and, if present, the footer size (potentially another 10 bytes).
|
||||||
|
*
|
||||||
|
* \note This is the value as read from the header to which TagLib attempts
|
||||||
|
* to provide an API to; it was not a design decision on the part of TagLib
|
||||||
|
* to not include the mentioned portions of the tag in the \e size.
|
||||||
|
*
|
||||||
|
* \see completeTagSize()
|
||||||
|
*/
|
||||||
|
unsigned int tagSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the tag size, including the header and, if present, the footer
|
||||||
|
* size.
|
||||||
|
*
|
||||||
|
* \see tagSize()
|
||||||
|
*/
|
||||||
|
unsigned int completeTagSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the tag size to \a s.
|
||||||
|
* \see tagSize()
|
||||||
|
*/
|
||||||
|
void setTagSize(unsigned int s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the header. Presently this is always 10 bytes.
|
||||||
|
*/
|
||||||
|
static unsigned int size();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the string used to identify and ID3v2 tag inside of a file.
|
||||||
|
* Presently this is always "ID3".
|
||||||
|
*/
|
||||||
|
static ByteVector fileIdentifier();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data that will be used as the header. 10 bytes, starting from
|
||||||
|
* the beginning of \a data are used.
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Renders the Header back to binary format.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Called by setData() to parse the header data. It makes this information
|
||||||
|
* available through the public API.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Header(const Header &);
|
||||||
|
Header &operator=(const Header &);
|
||||||
|
|
||||||
|
class HeaderPrivate;
|
||||||
|
HeaderPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,70 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2SYNCHDATA_H
|
||||||
|
#define TAGLIB_ID3V2SYNCHDATA_H
|
||||||
|
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! A few functions for ID3v2 synch safe integer conversion
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* In the ID3v2.4 standard most integer values are encoded as "synch safe"
|
||||||
|
* integers which are encoded in such a way that they will not give false
|
||||||
|
* MPEG syncs and confuse MPEG decoders. This namespace provides some
|
||||||
|
* methods for converting to and from these values to ByteVectors for
|
||||||
|
* things rendering and parsing ID3v2 data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace SynchData
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* This returns the unsigned integer value of \a data where \a data is a
|
||||||
|
* ByteVector that contains a \e synchsafe integer (Structure,
|
||||||
|
* <a href="id3v2-structure.html#6.2">6.2</a>). The default \a length of
|
||||||
|
* 4 is used if another value is not specified.
|
||||||
|
*/
|
||||||
|
TAGLIB_EXPORT unsigned int toUInt(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a 4 byte (32 bit) synchsafe integer based on \a value.
|
||||||
|
*/
|
||||||
|
TAGLIB_EXPORT ByteVector fromUInt(unsigned int value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Convert the data from unsynchronized data to its original format.
|
||||||
|
*/
|
||||||
|
TAGLIB_EXPORT ByteVector decode(const ByteVector &input);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,411 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ID3V2TAG_H
|
||||||
|
#define TAGLIB_ID3V2TAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
#include "id3v2.h"
|
||||||
|
#include "id3v2framefactory.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
class Header;
|
||||||
|
class ExtendedHeader;
|
||||||
|
class Footer;
|
||||||
|
|
||||||
|
typedef List<Frame *> FrameList;
|
||||||
|
typedef Map<ByteVector, FrameList> FrameListMap;
|
||||||
|
|
||||||
|
//! An abstraction for the ISO-8859-1 string to data encoding in ID3v2 tags.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* ID3v2 tag can store strings in ISO-8859-1 (Latin1), and TagLib only
|
||||||
|
* supports genuine ISO-8859-1 by default. However, in practice, non
|
||||||
|
* ISO-8859-1 encodings are often used instead of ISO-8859-1, such as
|
||||||
|
* Windows-1252 for western languages, Shift_JIS for Japanese and so on.
|
||||||
|
*
|
||||||
|
* Here is an option to read such tags by subclassing this class,
|
||||||
|
* reimplementing parse() and setting your reimplementation as the default
|
||||||
|
* with ID3v2::Tag::setStringHandler().
|
||||||
|
*
|
||||||
|
* \note Writing non-ISO-8859-1 tags is not implemented intentionally.
|
||||||
|
* Use UTF-16 or UTF-8 instead.
|
||||||
|
*
|
||||||
|
* \see ID3v2::Tag::setStringHandler()
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT Latin1StringHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Latin1StringHandler();
|
||||||
|
virtual ~Latin1StringHandler();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Decode a string from \a data. The default implementation assumes that
|
||||||
|
* \a data is an ISO-8859-1 (Latin1) character array.
|
||||||
|
*/
|
||||||
|
virtual String parse(const ByteVector &data) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The main class in the ID3v2 implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is the main class in the ID3v2 implementation. It serves two
|
||||||
|
* functions. This first, as is obvious from the public API, is to provide a
|
||||||
|
* container for the other ID3v2 related classes. In addition, through the
|
||||||
|
* read() and parse() protected methods, it provides the most basic level of
|
||||||
|
* parsing. In these methods the ID3v2 tag is extracted from the file and
|
||||||
|
* split into data components.
|
||||||
|
*
|
||||||
|
* ID3v2 tags have several parts, TagLib attempts to provide an interface
|
||||||
|
* for them all. header(), footer() and extendedHeader() correspond to those
|
||||||
|
* data structures in the ID3v2 standard and the APIs for the classes that
|
||||||
|
* they return attempt to reflect this.
|
||||||
|
*
|
||||||
|
* Also ID3v2 tags are built up from a list of frames, which are in turn
|
||||||
|
* have a header and a list of fields. TagLib provides two ways of accessing
|
||||||
|
* the list of frames that are in a given ID3v2 tag. The first is simply
|
||||||
|
* via the frameList() method. This is just a list of pointers to the frames.
|
||||||
|
* The second is a map from the frame type -- i.e. "COMM" for comments -- and
|
||||||
|
* a list of frames of that type. (In some cases ID3v2 allows for multiple
|
||||||
|
* frames of the same type, hence this being a map to a list rather than just
|
||||||
|
* a map to an individual frame.)
|
||||||
|
*
|
||||||
|
* More information on the structure of frames can be found in the ID3v2::Frame
|
||||||
|
* class.
|
||||||
|
*
|
||||||
|
* read() and parse() pass binary data to the other ID3v2 class structures,
|
||||||
|
* they do not handle parsing of flags or fields, for instance. Those are
|
||||||
|
* handled by similar functions within those classes.
|
||||||
|
*
|
||||||
|
* \note All pointers to data structures within the tag will become invalid
|
||||||
|
* when the tag is destroyed.
|
||||||
|
*
|
||||||
|
* \warning Dealing with the nasty details of ID3v2 is not for the faint of
|
||||||
|
* heart and should not be done without much meditation on the spec. It's
|
||||||
|
* rather long, but if you're planning on messing with this class and others
|
||||||
|
* that deal with the details of ID3v2 (rather than the nice, safe, abstract
|
||||||
|
* TagLib::Tag and friends), it's worth your time to familiarize yourself
|
||||||
|
* with said spec (which is distributed with the TagLib sources). TagLib
|
||||||
|
* tries to do most of the work, but with a little luck, you can still
|
||||||
|
* convince it to generate invalid ID3v2 tags. The APIs for ID3v2 assume a
|
||||||
|
* working knowledge of ID3v2 structure. You're been warned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \note You must create at least one frame for this tag to be valid.
|
||||||
|
*/
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an ID3v2 tag read from \a file starting at \a tagOffset.
|
||||||
|
* \a factory specifies which FrameFactory will be used for the
|
||||||
|
* construction of new frames.
|
||||||
|
*
|
||||||
|
* \note You should be able to ignore the \a factory parameter in almost
|
||||||
|
* all situations. You would want to specify your own FrameFactory
|
||||||
|
* subclass in the case that you are extending TagLib to support additional
|
||||||
|
* frame types, which would be incorporated into your factory.
|
||||||
|
*
|
||||||
|
* \see FrameFactory
|
||||||
|
*/
|
||||||
|
Tag(File *file, long tagOffset,
|
||||||
|
const FrameFactory *factory = FrameFactory::instance());
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Tag instance.
|
||||||
|
*/
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual String title() const;
|
||||||
|
virtual String artist() const;
|
||||||
|
virtual String album() const;
|
||||||
|
virtual String comment() const;
|
||||||
|
virtual String genre() const;
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
virtual void setTitle(const String &s);
|
||||||
|
virtual void setArtist(const String &s);
|
||||||
|
virtual void setAlbum(const String &s);
|
||||||
|
virtual void setComment(const String &s);
|
||||||
|
virtual void setGenre(const String &s);
|
||||||
|
virtual void setYear(unsigned int i);
|
||||||
|
virtual void setTrack(unsigned int i);
|
||||||
|
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the tag's header.
|
||||||
|
*/
|
||||||
|
Header *header() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the tag's extended header or null if there is no
|
||||||
|
* extended header.
|
||||||
|
*/
|
||||||
|
ExtendedHeader *extendedHeader() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the tag's footer or null if there is no footer.
|
||||||
|
*
|
||||||
|
* \deprecated I don't see any reason to keep this around since there's
|
||||||
|
* nothing useful to be retrieved from the footer, but well, again, I'm
|
||||||
|
* prone to change my mind, so this gets to stay around until near a
|
||||||
|
* release.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Footer *footer() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the frame list map. This is an FrameListMap of
|
||||||
|
* all of the frames in the tag.
|
||||||
|
*
|
||||||
|
* This is the most convenient structure for accessing the tag's frames.
|
||||||
|
* Many frame types allow multiple instances of the same frame type so this
|
||||||
|
* is a map of lists. In most cases however there will only be a single
|
||||||
|
* frame of a certain type.
|
||||||
|
*
|
||||||
|
* Let's say for instance that you wanted to access the frame for total
|
||||||
|
* beats per minute -- the TBPM frame.
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* TagLib::MPEG::File f("foo.mp3");
|
||||||
|
*
|
||||||
|
* // Check to make sure that it has an ID3v2 tag
|
||||||
|
*
|
||||||
|
* if(f.ID3v2Tag()) {
|
||||||
|
*
|
||||||
|
* // Get the list of frames for a specific frame type
|
||||||
|
*
|
||||||
|
* TagLib::ID3v2::FrameList l = f.ID3v2Tag()->frameListMap()["TBPM"];
|
||||||
|
*
|
||||||
|
* if(!l.isEmpty())
|
||||||
|
* std::cout << l.front()->toString() << std::endl;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addFrame() and removeFrame().
|
||||||
|
*
|
||||||
|
* \see frameList()
|
||||||
|
*/
|
||||||
|
const FrameListMap &frameListMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the frame list. This is an FrameList of all of
|
||||||
|
* the frames in the tag in the order that they were parsed.
|
||||||
|
*
|
||||||
|
* This can be useful if for example you want iterate over the tag's frames
|
||||||
|
* in the order that they occur in the tag.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addFrame() and removeFrame().
|
||||||
|
*/
|
||||||
|
const FrameList &frameList() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the frame list for frames with the id \a frameID or an empty
|
||||||
|
* list if there are no frames of that type. This is just a convenience
|
||||||
|
* and is equivalent to:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* frameListMap()[frameID];
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \see frameListMap()
|
||||||
|
*/
|
||||||
|
const FrameList &frameList(const ByteVector &frameID) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Add a frame to the tag. At this point the tag takes ownership of
|
||||||
|
* the frame and will handle freeing its memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by frameList()
|
||||||
|
*/
|
||||||
|
void addFrame(Frame *frame);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove a frame from the tag. If \a del is true the frame's memory
|
||||||
|
* will be freed; if it is false, it must be deleted by the user.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by frameList()
|
||||||
|
*/
|
||||||
|
void removeFrame(Frame *frame, bool del = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove all frames of type \a id from the tag and free their memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by frameList()
|
||||||
|
*/
|
||||||
|
void removeFrames(const ByteVector &id);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* This function does some work to translate the hard-specified ID3v2
|
||||||
|
* frame types into a free-form string-to-stringlist PropertyMap:
|
||||||
|
* - if ID3v2 frame ID is known by Frame::frameIDToKey(), the returned
|
||||||
|
* key is used
|
||||||
|
* - if the frame ID is "TXXX" (user text frame), the description() is
|
||||||
|
* used as key
|
||||||
|
* - if the frame ID is "WXXX" (user url frame),
|
||||||
|
* - if the description is empty or "URL", the key "URL" is used
|
||||||
|
* - otherwise, the key "URL:<description>" is used;
|
||||||
|
* - if the frame ID is "COMM" (comments frame),
|
||||||
|
* - if the description is empty or "COMMENT", the key "COMMENT"
|
||||||
|
* is used
|
||||||
|
* - otherwise, the key "COMMENT:<description>" is used;
|
||||||
|
* - if the frame ID is "USLT" (unsynchronized lyrics),
|
||||||
|
* - if the description is empty or "LYRICS", the key "LYRICS" is used
|
||||||
|
* - otherwise, the key "LYRICS:<description>" is used;
|
||||||
|
* - if the frame ID is "TIPL" (involved peoples list), and if all the
|
||||||
|
* roles defined in the frame are known in TextIdentificationFrame::involvedPeopleMap(),
|
||||||
|
* then "<role>=<name>" will be contained in the returned object for each
|
||||||
|
* - if the frame ID is "TMCL" (musician credit list), then
|
||||||
|
* "PERFORMER:<instrument>=<name>" will be contained in the returned
|
||||||
|
* PropertyMap for each defined musician
|
||||||
|
* In any other case, the unsupportedData() of the returned object will contain
|
||||||
|
* the frame's ID and, in case of a frame ID which is allowed to appear more than
|
||||||
|
* once, the description, separated by a "/".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported frames given by \a properties. The elements of
|
||||||
|
* \a properties must be taken from properties().unsupportedData(); they
|
||||||
|
* are of one of the following forms:
|
||||||
|
* - a four-character frame ID, if the ID3 specification allows only one
|
||||||
|
* frame with that ID (thus, the frame is uniquely determined)
|
||||||
|
* - frameID + "/" + description(), when the ID is one of "TXXX", "WXXX",
|
||||||
|
* "COMM", or "USLT",
|
||||||
|
* - "UNKNOWN/" + frameID, for frames that could not be parsed by TagLib.
|
||||||
|
* In that case, *all* unknown frames with the given ID will be removed.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* See the comments in properties().
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the tag back to binary data, suitable to be written to disk.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED ByteVector render(int version) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the tag back to binary data, suitable to be written to disk.
|
||||||
|
*
|
||||||
|
* The \a version parameter specifies whether ID3v2.4 (default) or ID3v2.3
|
||||||
|
* should be used.
|
||||||
|
*/
|
||||||
|
ByteVector render(Version version) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Gets the current string handler that decides how the "Latin-1" data
|
||||||
|
* will be converted to and from binary data.
|
||||||
|
*
|
||||||
|
* \see Latin1StringHandler
|
||||||
|
*/
|
||||||
|
static Latin1StringHandler const *latin1StringHandler();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the string handler that decides how the "Latin-1" data will be
|
||||||
|
* converted to and from binary data.
|
||||||
|
* If the parameter \a handler is null, the previous handler is
|
||||||
|
* released and default ISO-8859-1 handler is restored.
|
||||||
|
*
|
||||||
|
* \note The caller is responsible for deleting the previous handler
|
||||||
|
* as needed after it is released.
|
||||||
|
*
|
||||||
|
* \see Latin1StringHandler
|
||||||
|
*/
|
||||||
|
static void setLatin1StringHandler(const Latin1StringHandler *handler);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Reads data from the file specified in the constructor. It does basic
|
||||||
|
* parsing of the data in the largest chunks. It partitions the tag into
|
||||||
|
* the Header, the body of the tag (which contains the ExtendedHeader and
|
||||||
|
* frames) and Footer.
|
||||||
|
*/
|
||||||
|
void read();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is called by read to parse the body of the tag. It determines if an
|
||||||
|
* extended header exists and adds frames to the FrameListMap.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the value of the text frame with the Frame ID \a id to \a value.
|
||||||
|
* If the frame does not exist, it is created.
|
||||||
|
*/
|
||||||
|
void setTextFrame(const ByteVector &id, const String &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Downgrade frames from ID3v2.4 (used internally and by default) to ID3v2.3.
|
||||||
|
*/
|
||||||
|
void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,192 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2012 by Tsuda Kageyu
|
||||||
|
email : tsuda.kageyu@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_INFOTAG_H
|
||||||
|
#define TAGLIB_INFOTAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! A RIFF INFO tag implementation.
|
||||||
|
namespace RIFF {
|
||||||
|
namespace Info {
|
||||||
|
|
||||||
|
typedef Map<ByteVector, String> FieldListMap;
|
||||||
|
|
||||||
|
//! A abstraction for the string to data encoding in Info tags.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* RIFF INFO tag has no clear definitions about character encodings.
|
||||||
|
* In practice, local encoding of each system is largely used and UTF-8 is
|
||||||
|
* popular too.
|
||||||
|
*
|
||||||
|
* Here is an option to read and write tags in your preferred encoding
|
||||||
|
* by subclassing this class, reimplementing parse() and render() and setting
|
||||||
|
* your reimplementation as the default with Info::Tag::setStringHandler().
|
||||||
|
*
|
||||||
|
* \see ID3v1::Tag::setStringHandler()
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT StringHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StringHandler();
|
||||||
|
~StringHandler();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Decode a string from \a data. The default implementation assumes that
|
||||||
|
* \a data is an UTF-8 character array.
|
||||||
|
*/
|
||||||
|
virtual String parse(const ByteVector &data) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Encode a ByteVector with the data from \a s. The default implementation
|
||||||
|
* assumes that \a s is an UTF-8 string.
|
||||||
|
*/
|
||||||
|
virtual ByteVector render(const String &s) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The main class in the ID3v2 implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is the main class in the INFO tag implementation. RIFF INFO tag is a
|
||||||
|
* metadata format found in WAV audio and AVI video files. Though it is a part
|
||||||
|
* of Microsoft/IBM's RIFF specification, the author could not find the official
|
||||||
|
* documents about it. So, this implementation is referring to unofficial documents
|
||||||
|
* online and some applications' behaviors especially Windows Explorer.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty INFO tag.
|
||||||
|
*/
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an INFO tag read from \a data which is contents of "LIST" chunk.
|
||||||
|
*/
|
||||||
|
Tag(const ByteVector &data);
|
||||||
|
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
// Reimplementations
|
||||||
|
|
||||||
|
virtual String title() const;
|
||||||
|
virtual String artist() const;
|
||||||
|
virtual String album() const;
|
||||||
|
virtual String comment() const;
|
||||||
|
virtual String genre() const;
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
virtual void setTitle(const String &s);
|
||||||
|
virtual void setArtist(const String &s);
|
||||||
|
virtual void setAlbum(const String &s);
|
||||||
|
virtual void setComment(const String &s);
|
||||||
|
virtual void setGenre(const String &s);
|
||||||
|
virtual void setYear(unsigned int i);
|
||||||
|
virtual void setTrack(unsigned int i);
|
||||||
|
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a copy of the internal fields of the tag. The returned map directly
|
||||||
|
* reflects the contents of the "INFO" chunk.
|
||||||
|
*
|
||||||
|
* \note Modifying this map does not affect the tag's internal data.
|
||||||
|
* Use setFieldText() and removeField() instead.
|
||||||
|
*
|
||||||
|
* \see setFieldText()
|
||||||
|
* \see removeField()
|
||||||
|
*/
|
||||||
|
FieldListMap fieldListMap() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the value of the field with the ID \a id.
|
||||||
|
*/
|
||||||
|
String fieldText(const ByteVector &id) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the value of the field with the ID \a id to \a s.
|
||||||
|
* If the field does not exist, it is created.
|
||||||
|
* If \s is empty, the field is removed.
|
||||||
|
*
|
||||||
|
* \note fieldId must be four-byte long pure ASCII string. This function
|
||||||
|
* performs nothing if fieldId is invalid.
|
||||||
|
*/
|
||||||
|
void setFieldText(const ByteVector &id, const String &s);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes the field with the ID \a id.
|
||||||
|
*/
|
||||||
|
void removeField(const ByteVector &id);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the tag back to binary data, suitable to be written to disk.
|
||||||
|
*
|
||||||
|
* \note Returns empty ByteVector is the tag contains no fields.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the string handler that decides how the text data will be
|
||||||
|
* converted to and from binary data.
|
||||||
|
* If the parameter \a handler is null, the previous handler is
|
||||||
|
* released and default UTF-8 handler is restored.
|
||||||
|
*
|
||||||
|
* \note The caller is responsible for deleting the previous handler
|
||||||
|
* as needed after it is released.
|
||||||
|
*
|
||||||
|
* \see StringHandler
|
||||||
|
*/
|
||||||
|
static void setStringHandler(const StringHandler *handler);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Pareses the body of the tag in \a data.
|
||||||
|
*/
|
||||||
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,109 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ITFILE_H
|
||||||
|
#define TAGLIB_ITFILE_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "modfilebase.h"
|
||||||
|
#include "modtag.h"
|
||||||
|
#include "itproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace IT {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs a Impulse Tracker file from \a file.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a Impulse Tracker file from \a stream.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
Mod::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Forwards to Mod::Tag::properties().
|
||||||
|
* BIC: will be removed once File::toDict() is made virtual
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Forwards to Mod::Tag::setProperties().
|
||||||
|
* BIC: will be removed once File::setProperties() is made virtual
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the IT::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
IT::Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
* This is the same as calling save(AllTags);
|
||||||
|
*
|
||||||
|
* \note Saving Impulse Tracker tags is not supported.
|
||||||
|
*/
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,107 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_ITPROPERTIES_H
|
||||||
|
#define TAGLIB_ITPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
namespace IT {
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties {
|
||||||
|
friend class File;
|
||||||
|
public:
|
||||||
|
/*! Flag bits. */
|
||||||
|
enum {
|
||||||
|
Stereo = 1,
|
||||||
|
Vol0MixOptimizations = 2,
|
||||||
|
UseInstruments = 4,
|
||||||
|
LinearSlides = 8,
|
||||||
|
OldEffects = 16,
|
||||||
|
LinkEffects = 32,
|
||||||
|
UseMidiPitchController = 64,
|
||||||
|
RequestEmbeddedMidiConf = 128
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! Special bits. */
|
||||||
|
enum {
|
||||||
|
MessageAttached = 1,
|
||||||
|
MidiConfEmbedded = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
Properties(AudioProperties::ReadStyle propertiesStyle);
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
int length() const;
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
int bitrate() const;
|
||||||
|
int sampleRate() const;
|
||||||
|
int channels() const;
|
||||||
|
|
||||||
|
unsigned short lengthInPatterns() const;
|
||||||
|
bool stereo() const;
|
||||||
|
unsigned short instrumentCount() const;
|
||||||
|
unsigned short sampleCount() const;
|
||||||
|
unsigned short patternCount() const;
|
||||||
|
unsigned short version() const;
|
||||||
|
unsigned short compatibleVersion() const;
|
||||||
|
unsigned short flags() const;
|
||||||
|
unsigned short special() const;
|
||||||
|
unsigned char globalVolume() const;
|
||||||
|
unsigned char mixVolume() const;
|
||||||
|
unsigned char tempo() const;
|
||||||
|
unsigned char bpmSpeed() const;
|
||||||
|
unsigned char panningSeparation() const;
|
||||||
|
unsigned char pitchWheelDepth() const;
|
||||||
|
|
||||||
|
void setChannels(int channels);
|
||||||
|
void setLengthInPatterns(unsigned short lengthInPatterns);
|
||||||
|
void setInstrumentCount(unsigned short instrumentCount);
|
||||||
|
void setSampleCount (unsigned short sampleCount);
|
||||||
|
void setPatternCount(unsigned short patternCount);
|
||||||
|
void setVersion (unsigned short version);
|
||||||
|
void setCompatibleVersion(unsigned short compatibleVersion);
|
||||||
|
void setFlags (unsigned short flags);
|
||||||
|
void setSpecial (unsigned short special);
|
||||||
|
void setGlobalVolume(unsigned char globalVolume);
|
||||||
|
void setMixVolume (unsigned char mixVolume);
|
||||||
|
void setTempo (unsigned char tempo);
|
||||||
|
void setBpmSpeed (unsigned char bpmSpeed);
|
||||||
|
void setPanningSeparation(unsigned char panningSeparation);
|
||||||
|
void setPitchWheelDepth (unsigned char pitchWheelDepth);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties&);
|
||||||
|
Properties &operator=(const Properties&);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,114 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MODFILE_H
|
||||||
|
#define TAGLIB_MODFILE_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "modfilebase.h"
|
||||||
|
#include "modtag.h"
|
||||||
|
#include "modproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::Mod::FileBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs a Protracker file from \a file.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a Protracker file from \a stream.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
Mod::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* Forwards to Mod::Tag::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* Forwards to Mod::Tag::setProperties().
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
/*!
|
||||||
|
* Returns the Mod::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
Mod::Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
* This is the same as calling save(AllTags);
|
||||||
|
*
|
||||||
|
* \note Saving Protracker tags is not supported.
|
||||||
|
*/
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MODFILEBASE_H
|
||||||
|
#define TAGLIB_MODFILEBASE_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT FileBase : public TagLib::File
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
FileBase(FileName file);
|
||||||
|
FileBase(IOStream *stream);
|
||||||
|
|
||||||
|
void writeString(const String &s, unsigned long size, char padding = 0);
|
||||||
|
void writeByte(unsigned char byte);
|
||||||
|
void writeU16L(unsigned short number);
|
||||||
|
void writeU32L(unsigned long number);
|
||||||
|
void writeU16B(unsigned short number);
|
||||||
|
void writeU32B(unsigned long number);
|
||||||
|
|
||||||
|
bool readString(String &s, unsigned long size);
|
||||||
|
bool readByte(unsigned char &byte);
|
||||||
|
bool readU16L(unsigned short &number);
|
||||||
|
bool readU32L(unsigned long &number);
|
||||||
|
bool readU16B(unsigned short &number);
|
||||||
|
bool readU32B(unsigned long &number);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,71 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MODPROPERTIES_H
|
||||||
|
#define TAGLIB_MODPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Properties(AudioProperties::ReadStyle propertiesStyle);
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
int length() const;
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
int bitrate() const;
|
||||||
|
int sampleRate() const;
|
||||||
|
int channels() const;
|
||||||
|
|
||||||
|
unsigned int instrumentCount() const;
|
||||||
|
unsigned char lengthInPatterns() const;
|
||||||
|
|
||||||
|
void setChannels(int channels);
|
||||||
|
|
||||||
|
void setInstrumentCount(unsigned int sampleCount);
|
||||||
|
void setLengthInPatterns(unsigned char lengthInPatterns);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class File;
|
||||||
|
|
||||||
|
Properties(const Properties&);
|
||||||
|
Properties &operator=(const Properties&);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,194 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MODTAG_H
|
||||||
|
#define TAGLIB_MODTAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Tags for module files (Mod, S3M, IT, XM).
|
||||||
|
*
|
||||||
|
* Note that only the \a title is supported as such by most
|
||||||
|
* module file formats. Except for XM files the \a trackerName
|
||||||
|
* is derived from the file format or the flavour of the file
|
||||||
|
* format. For XM files it is stored in the file.
|
||||||
|
*
|
||||||
|
* The \a comment tag is not strictly supported by module files,
|
||||||
|
* but it is common practice to abuse instrument/sample/pattern
|
||||||
|
* names as multiline comments. TagLib does so as well.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Tag();
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track name; if no track name is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String title() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files. Therefore always returns String::null.
|
||||||
|
*/
|
||||||
|
virtual String artist() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files. Therefore always returns String::null.
|
||||||
|
*/
|
||||||
|
virtual String album() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track comment derived from the instrument/sample/pattern
|
||||||
|
* names; if no comment is present in the tag String::null will be
|
||||||
|
* returned.
|
||||||
|
*/
|
||||||
|
virtual String comment() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files. Therefore always returns String::null.
|
||||||
|
*/
|
||||||
|
virtual String genre() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files. Therefore always returns 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files. Therefore always returns 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the name of the tracker used to create/edit the module file.
|
||||||
|
* Only XM files store this tag to the file as such, for other formats
|
||||||
|
* (Mod, S3M, IT) this is derived from the file type or the flavour of
|
||||||
|
* the file type. Therefore only XM files might have an empty
|
||||||
|
* (String::null) tracker name.
|
||||||
|
*/
|
||||||
|
String trackerName() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the title to \a title. If \a title is String::null then this
|
||||||
|
* value will be cleared.
|
||||||
|
*
|
||||||
|
* The length limits per file type are (1 character = 1 byte):
|
||||||
|
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20
|
||||||
|
* characters.
|
||||||
|
*/
|
||||||
|
virtual void setTitle(const String &title);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files and therefore ignored.
|
||||||
|
*/
|
||||||
|
virtual void setArtist(const String &artist);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files and therefore ignored.
|
||||||
|
*/
|
||||||
|
virtual void setAlbum(const String &album);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the comment to \a comment. If \a comment is String::null then
|
||||||
|
* this value will be cleared.
|
||||||
|
*
|
||||||
|
* Note that module file formats don't actually support a comment tag.
|
||||||
|
* Instead the names of instruments/patterns/samples are abused as
|
||||||
|
* a multiline comment. Because of this the number of lines in a
|
||||||
|
* module file is fixed to the number of instruments/patterns/samples.
|
||||||
|
*
|
||||||
|
* Also note that the instrument/pattern/sample name length is limited
|
||||||
|
* an thus the line length in comments are limited. Too big comments
|
||||||
|
* will be truncated.
|
||||||
|
*
|
||||||
|
* The line length limits per file type are (1 character = 1 byte):
|
||||||
|
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22
|
||||||
|
* characters.
|
||||||
|
*/
|
||||||
|
virtual void setComment(const String &comment);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files and therefore ignored.
|
||||||
|
*/
|
||||||
|
virtual void setGenre(const String &genre);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files and therefore ignored.
|
||||||
|
*/
|
||||||
|
virtual void setYear(unsigned int year);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported by module files and therefore ignored.
|
||||||
|
*/
|
||||||
|
virtual void setTrack(unsigned int track);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tracker name to \a trackerName. If \a trackerName is
|
||||||
|
* String::null then this value will be cleared.
|
||||||
|
*
|
||||||
|
* Note that only XM files support this tag. Setting the
|
||||||
|
* tracker name for other module file formats will be ignored.
|
||||||
|
*
|
||||||
|
* The length of this tag is limited to 20 characters (1 character
|
||||||
|
* = 1 byte).
|
||||||
|
*/
|
||||||
|
void setTrackerName(const String &trackerName);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* Since the module tag is very limited, the exported map is as well.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* Because of the limitations of the module file tag, any tags besides
|
||||||
|
* COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be
|
||||||
|
* returned. Additionally, if the map contains tags with multiple values,
|
||||||
|
* all but the first will be contained in the returned map of unsupported
|
||||||
|
* properties.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,111 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2007,2011 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
// This file is not part of the public API!
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4ATOM_H
|
||||||
|
#define TAGLIB_MP4ATOM_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
class Atom;
|
||||||
|
typedef TagLib::List<Atom *> AtomList;
|
||||||
|
|
||||||
|
enum AtomDataType
|
||||||
|
{
|
||||||
|
TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed
|
||||||
|
TypeUTF8 = 1, // without any count or null terminator
|
||||||
|
TypeUTF16 = 2, // also known as UTF-16BE
|
||||||
|
TypeSJIS = 3, // deprecated unless it is needed for special Japanese characters
|
||||||
|
TypeHTML = 6, // the HTML file header specifies which HTML version
|
||||||
|
TypeXML = 7, // the XML header must identify the DTD or schemas
|
||||||
|
TypeUUID = 8, // also known as GUID; stored as 16 bytes in binary (valid as an ID)
|
||||||
|
TypeISRC = 9, // stored as UTF-8 text (valid as an ID)
|
||||||
|
TypeMI3P = 10, // stored as UTF-8 text (valid as an ID)
|
||||||
|
TypeGIF = 12, // (deprecated) a GIF image
|
||||||
|
TypeJPEG = 13, // a JPEG image
|
||||||
|
TypePNG = 14, // a PNG image
|
||||||
|
TypeURL = 15, // absolute, in UTF-8 characters
|
||||||
|
TypeDuration = 16, // in milliseconds, 32-bit integer
|
||||||
|
TypeDateTime = 17, // in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits
|
||||||
|
TypeGenred = 18, // a list of enumerated values
|
||||||
|
TypeInteger = 21, // a signed big-endian integer with length one of { 1,2,3,4,8 } bytes
|
||||||
|
TypeRIAAPA = 24, // RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit integer
|
||||||
|
TypeUPC = 25, // Universal Product Code, in text UTF-8 format (valid as an ID)
|
||||||
|
TypeBMP = 27, // Windows bitmap image
|
||||||
|
TypeUndefined = 255 // undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AtomData {
|
||||||
|
AtomData(AtomDataType type, ByteVector data) : type(type), locale(0), data(data) {}
|
||||||
|
AtomDataType type;
|
||||||
|
int locale;
|
||||||
|
ByteVector data;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TagLib::List<AtomData> AtomDataList;
|
||||||
|
|
||||||
|
class Atom
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Atom(File *file);
|
||||||
|
~Atom();
|
||||||
|
Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0);
|
||||||
|
bool path(AtomList &path, const char *name1, const char *name2 = 0, const char *name3 = 0);
|
||||||
|
AtomList findall(const char *name, bool recursive = false);
|
||||||
|
long offset;
|
||||||
|
long length;
|
||||||
|
TagLib::ByteVector name;
|
||||||
|
AtomList children;
|
||||||
|
private:
|
||||||
|
static const int numContainers = 11;
|
||||||
|
static const char *containers[11];
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Root-level atoms
|
||||||
|
class Atoms
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Atoms(File *file);
|
||||||
|
~Atoms();
|
||||||
|
Atom *find(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0);
|
||||||
|
AtomList path(const char *name1, const char *name2 = 0, const char *name3 = 0, const char *name4 = 0);
|
||||||
|
AtomList atoms;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,84 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2009 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4COVERART_H
|
||||||
|
#define TAGLIB_MP4COVERART_H
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "mp4atom.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT CoverArt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This describes the image type.
|
||||||
|
*/
|
||||||
|
enum Format {
|
||||||
|
JPEG = TypeJPEG,
|
||||||
|
PNG = TypePNG,
|
||||||
|
BMP = TypeBMP,
|
||||||
|
GIF = TypeGIF,
|
||||||
|
Unknown = TypeImplicit,
|
||||||
|
};
|
||||||
|
|
||||||
|
CoverArt(Format format, const ByteVector &data);
|
||||||
|
~CoverArt();
|
||||||
|
|
||||||
|
CoverArt(const CoverArt &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the contents of \a item into this CoverArt.
|
||||||
|
*/
|
||||||
|
CoverArt &operator=(const CoverArt &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the CoverArt by the content of \a item.
|
||||||
|
*/
|
||||||
|
void swap(CoverArt &item);
|
||||||
|
|
||||||
|
//! Format of the image
|
||||||
|
Format format() const;
|
||||||
|
|
||||||
|
//! The image data
|
||||||
|
ByteVector data() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class CoverArtPrivate;
|
||||||
|
CoverArtPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef List<CoverArt> CoverArtList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,143 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4FILE_H
|
||||||
|
#define TAGLIB_MP4FILE_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "mp4properties.h"
|
||||||
|
#include "mp4tag.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! An implementation of MP4 (AAC, ALAC, ...) metadata
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
class Atoms;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for MP4 files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to MP4 files.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an MP4 file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle audioPropertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MP4 file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle audioPropertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the MP4 tag of the file.
|
||||||
|
*
|
||||||
|
* MP4::Tag implements the tag interface, so this serves as the
|
||||||
|
* reimplementation of TagLib::File::tag().
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MP4::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*/
|
||||||
|
Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties. Forwards to the actual Tag's
|
||||||
|
* removeUnsupportedProperties() function.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MP4 audio properties for this file.
|
||||||
|
*/
|
||||||
|
Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an MP4 tag, or the
|
||||||
|
* file has a Metadata Item List (ilst) atom.
|
||||||
|
*/
|
||||||
|
bool hasMP4Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an ASF
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,93 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4ITEM_H
|
||||||
|
#define TAGLIB_MP4ITEM_H
|
||||||
|
|
||||||
|
#include "tstringlist.h"
|
||||||
|
#include "mp4coverart.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct IntPair {
|
||||||
|
int first, second;
|
||||||
|
};
|
||||||
|
|
||||||
|
Item();
|
||||||
|
Item(const Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the contents of \a item into this Item.
|
||||||
|
*/
|
||||||
|
Item &operator=(const Item &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the Item by the content of \a item.
|
||||||
|
*/
|
||||||
|
void swap(Item &item);
|
||||||
|
|
||||||
|
~Item();
|
||||||
|
|
||||||
|
Item(int value);
|
||||||
|
Item(unsigned char value);
|
||||||
|
Item(unsigned int value);
|
||||||
|
Item(long long value);
|
||||||
|
Item(bool value);
|
||||||
|
Item(int first, int second);
|
||||||
|
Item(const StringList &value);
|
||||||
|
Item(const ByteVectorList &value);
|
||||||
|
Item(const CoverArtList &value);
|
||||||
|
|
||||||
|
void setAtomDataType(AtomDataType type);
|
||||||
|
AtomDataType atomDataType() const;
|
||||||
|
|
||||||
|
int toInt() const;
|
||||||
|
unsigned char toByte() const;
|
||||||
|
unsigned int toUInt() const;
|
||||||
|
long long toLongLong() const;
|
||||||
|
bool toBool() const;
|
||||||
|
IntPair toIntPair() const;
|
||||||
|
StringList toStringList() const;
|
||||||
|
ByteVectorList toByteVectorList() const;
|
||||||
|
CoverArtList toCoverArtList() const;
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ItemPrivate;
|
||||||
|
ItemPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,120 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2007 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4PROPERTIES_H
|
||||||
|
#define TAGLIB_MP4PROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
class Atoms;
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of MP4 audio properties
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Codec {
|
||||||
|
Unknown = 0,
|
||||||
|
AAC,
|
||||||
|
ALAC
|
||||||
|
};
|
||||||
|
|
||||||
|
Properties(File *file, Atoms *atoms, ReadStyle style = Average);
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of bits per audio sample.
|
||||||
|
*/
|
||||||
|
virtual int bitsPerSample() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file is encrypted.
|
||||||
|
*/
|
||||||
|
bool isEncrypted() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the codec used in the file.
|
||||||
|
*/
|
||||||
|
Codec codec() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void read(File *file, Atoms *atoms);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,164 @@
|
||||||
|
/**************************************************************************
|
||||||
|
copyright : (C) 2007,2011 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MP4TAG_H
|
||||||
|
#define TAGLIB_MP4TAG_H
|
||||||
|
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tbytevectorlist.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "mp4atom.h"
|
||||||
|
#include "mp4item.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MP4 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED typedef TagLib::Map<String, Item> ItemListMap;
|
||||||
|
typedef TagLib::Map<String, Item> ItemMap;
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag: public TagLib::Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Tag();
|
||||||
|
Tag(TagLib::File *file, Atoms *atoms);
|
||||||
|
virtual ~Tag();
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
virtual String title() const;
|
||||||
|
virtual String artist() const;
|
||||||
|
virtual String album() const;
|
||||||
|
virtual String comment() const;
|
||||||
|
virtual String genre() const;
|
||||||
|
virtual unsigned int year() const;
|
||||||
|
virtual unsigned int track() const;
|
||||||
|
|
||||||
|
virtual void setTitle(const String &value);
|
||||||
|
virtual void setArtist(const String &value);
|
||||||
|
virtual void setAlbum(const String &value);
|
||||||
|
virtual void setComment(const String &value);
|
||||||
|
virtual void setGenre(const String &value);
|
||||||
|
virtual void setYear(unsigned int value);
|
||||||
|
virtual void setTrack(unsigned int value);
|
||||||
|
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated Use the item() and setItem() API instead
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED ItemMap &itemListMap();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a string-keyed map of the MP4::Items for this tag.
|
||||||
|
*/
|
||||||
|
const ItemMap &itemMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The item, if any, corresponding to \a key.
|
||||||
|
*/
|
||||||
|
Item item(const String &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the value of \a key to \a value, overwriting any previous value.
|
||||||
|
*/
|
||||||
|
void setItem(const String &key, const Item &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes the entry with \a key from the tag, or does nothing if it does
|
||||||
|
* not exist.
|
||||||
|
*/
|
||||||
|
void removeItem(const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return True if the tag contains an entry for \a key.
|
||||||
|
*/
|
||||||
|
bool contains(const String &key) const;
|
||||||
|
|
||||||
|
PropertyMap properties() const;
|
||||||
|
void removeUnsupportedProperties(const StringList& properties);
|
||||||
|
PropertyMap setProperties(const PropertyMap &properties);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Sets the value of \a key to \a value, overwriting any previous value.
|
||||||
|
* If \a value is empty, the item is removed.
|
||||||
|
*/
|
||||||
|
void setTextItem(const String &key, const String &value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AtomDataList parseData2(const Atom *atom, int expectedFlags = -1,
|
||||||
|
bool freeForm = false);
|
||||||
|
ByteVectorList parseData(const Atom *atom, int expectedFlags = -1,
|
||||||
|
bool freeForm = false);
|
||||||
|
void parseText(const Atom *atom, int expectedFlags = 1);
|
||||||
|
void parseFreeForm(const Atom *atom);
|
||||||
|
void parseInt(const Atom *atom);
|
||||||
|
void parseByte(const Atom *atom);
|
||||||
|
void parseUInt(const Atom *atom);
|
||||||
|
void parseLongLong(const Atom *atom);
|
||||||
|
void parseGnre(const Atom *atom);
|
||||||
|
void parseIntPair(const Atom *atom);
|
||||||
|
void parseBool(const Atom *atom);
|
||||||
|
void parseCovr(const Atom *atom);
|
||||||
|
|
||||||
|
ByteVector padIlst(const ByteVector &data, int length = -1) const;
|
||||||
|
ByteVector renderAtom(const ByteVector &name, const ByteVector &data) const;
|
||||||
|
ByteVector renderData(const ByteVector &name, int flags,
|
||||||
|
const ByteVectorList &data) const;
|
||||||
|
ByteVector renderText(const ByteVector &name, const Item &item,
|
||||||
|
int flags = TypeUTF8) const;
|
||||||
|
ByteVector renderFreeForm(const String &name, const Item &item) const;
|
||||||
|
ByteVector renderBool(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderInt(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderByte(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderUInt(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderLongLong(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderIntPair(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderIntPairNoTrailing(const ByteVector &name, const Item &item) const;
|
||||||
|
ByteVector renderCovr(const ByteVector &name, const Item &item) const;
|
||||||
|
|
||||||
|
void updateParents(const AtomList &path, long delta, int ignore = 0);
|
||||||
|
void updateOffsets(long delta, long offset);
|
||||||
|
|
||||||
|
void saveNew(ByteVector data);
|
||||||
|
void saveExisting(ByteVector data, const AtomList &path);
|
||||||
|
|
||||||
|
void addItem(const String &name, const Item &value);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,238 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MPCFILE_H
|
||||||
|
#define TAGLIB_MPCFILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tag.h"
|
||||||
|
|
||||||
|
#include "mpcproperties.h"
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
|
||||||
|
namespace ID3v1 { class Tag; }
|
||||||
|
namespace APE { class Tag; }
|
||||||
|
|
||||||
|
//! An implementation of MPC metadata
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is implementation of MPC metadata.
|
||||||
|
*
|
||||||
|
* This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream
|
||||||
|
* properties from the file. ID3v2 tags are invalid in MPC-files, but will be skipped
|
||||||
|
* and ignored.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace MPC {
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with MPC specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for MPC files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to MPC files.
|
||||||
|
* The only invalid tag combination supported is an ID3v1 tag after an APE tag.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This set of flags is used for various operations and is suitable for
|
||||||
|
* being OR-ed together.
|
||||||
|
*/
|
||||||
|
enum TagTypes {
|
||||||
|
//! Empty set. Matches no tag types.
|
||||||
|
NoTags = 0x0000,
|
||||||
|
//! Matches ID3v1 tags.
|
||||||
|
ID3v1 = 0x0001,
|
||||||
|
//! Matches ID3v2 tags.
|
||||||
|
ID3v2 = 0x0002,
|
||||||
|
//! Matches APE tags.
|
||||||
|
APE = 0x0004,
|
||||||
|
//! Matches all tag types.
|
||||||
|
AllTags = 0xffff
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MPC file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MPC file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
|
||||||
|
* or a combination of the two.
|
||||||
|
*/
|
||||||
|
virtual TagLib::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* If the file contains both an APE and an ID3v1 tag, only the APE
|
||||||
|
* tag will be converted to the PropertyMap.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* Affects only the APEv2 tag which will be created if necessary.
|
||||||
|
* If an ID3v1 tag exists, it will be updated as well.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MPC::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Saves the file.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this returns a null pointer
|
||||||
|
* if there is no valid APE tag. If \a create is true it will create
|
||||||
|
* an APE tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v1Tag()
|
||||||
|
*/
|
||||||
|
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the APE tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid APE tag. If \a create is true it will create
|
||||||
|
* an APE tag if one does not exist and returns a valid pointer. If
|
||||||
|
* there already be an ID3v1 tag, the new APE tag will be placed before it.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an APE tag. Use hasAPETag() to check if the file
|
||||||
|
* on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasAPETag()
|
||||||
|
*/
|
||||||
|
APE::Tag *APETag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will remove the tags that match the OR-ed together TagTypes from the
|
||||||
|
* file. By default it removes all tags.
|
||||||
|
*
|
||||||
|
* \warning This will also invalidate pointers to the tags
|
||||||
|
* as their memory will be freed.
|
||||||
|
*
|
||||||
|
* \note In order to make the removal permanent save() still needs to be called.
|
||||||
|
*/
|
||||||
|
void strip(int tags = AllTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
* \see strip
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED void remove(int tags = AllTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v1Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \see APETag()
|
||||||
|
*/
|
||||||
|
bool hasAPETag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an MPC
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,158 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MPCPROPERTIES_H
|
||||||
|
#define TAGLIB_MPCPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MPC {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
static const unsigned int HeaderSize = 8 * 7;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for MPC
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an MPC stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of MPC::Properties with the data read from the
|
||||||
|
* ByteVector \a data.
|
||||||
|
*
|
||||||
|
* This constructor is deprecated. It only works for MPC version up to 7.
|
||||||
|
*/
|
||||||
|
Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Create an instance of MPC::Properties with the data read directly
|
||||||
|
* from a MPC::File.
|
||||||
|
*/
|
||||||
|
Properties(File *file, long streamLength, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this MPC::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the version of the bitstream (SV4-SV8)
|
||||||
|
*/
|
||||||
|
int mpcVersion() const;
|
||||||
|
|
||||||
|
unsigned int totalFrames() const;
|
||||||
|
unsigned int sampleFrames() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track gain as an integer value,
|
||||||
|
* to convert to dB: trackGain in dB = 64.82 - (trackGain / 256)
|
||||||
|
*/
|
||||||
|
int trackGain() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track peak as an integer value,
|
||||||
|
* to convert to dB: trackPeak in dB = trackPeak / 256
|
||||||
|
* to convert to floating [-1..1]: trackPeak = 10^(trackPeak / 256 / 20)/32768
|
||||||
|
*/
|
||||||
|
int trackPeak() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the album gain as an integer value,
|
||||||
|
* to convert to dB: albumGain in dB = 64.82 - (albumGain / 256)
|
||||||
|
*/
|
||||||
|
int albumGain() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the album peak as an integer value,
|
||||||
|
* to convert to dB: albumPeak in dB = albumPeak / 256
|
||||||
|
* to convert to floating [-1..1]: albumPeak = 10^(albumPeak / 256 / 20)/32768
|
||||||
|
*/
|
||||||
|
int albumPeak() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void readSV7(const ByteVector &data, long streamLength);
|
||||||
|
void readSV8(File *file, long streamLength);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,387 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MPEGFILE_H
|
||||||
|
#define TAGLIB_MPEGFILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tag.h"
|
||||||
|
|
||||||
|
#include "mpegproperties.h"
|
||||||
|
|
||||||
|
#include "id3v2.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 { class Tag; class FrameFactory; }
|
||||||
|
namespace ID3v1 { class Tag; }
|
||||||
|
namespace APE { class Tag; }
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with MPEG (MP3) specific methods
|
||||||
|
|
||||||
|
namespace MPEG {
|
||||||
|
|
||||||
|
//! An MPEG file class with some useful methods specific to MPEG
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements the generic TagLib::File API and additionally provides
|
||||||
|
* access to properties that are distinct to MPEG files, notably access
|
||||||
|
* to the different ID3 tags.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* This set of flags is used for various operations and is suitable for
|
||||||
|
* being OR-ed together.
|
||||||
|
*/
|
||||||
|
enum TagTypes {
|
||||||
|
//! Empty set. Matches no tag types.
|
||||||
|
NoTags = 0x0000,
|
||||||
|
//! Matches ID3v1 tags.
|
||||||
|
ID3v1 = 0x0001,
|
||||||
|
//! Matches ID3v2 tags.
|
||||||
|
ID3v2 = 0x0002,
|
||||||
|
//! Matches APE tags.
|
||||||
|
APE = 0x0004,
|
||||||
|
//! Matches all tag types.
|
||||||
|
AllTags = 0xffff
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MPEG file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*
|
||||||
|
* \deprecated This constructor will be dropped in favor of the one below
|
||||||
|
* in a future version.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MPEG file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using
|
||||||
|
* \a frameFactory.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
// BIC: merge with the above constructor
|
||||||
|
File(FileName file, ID3v2::FrameFactory *frameFactory,
|
||||||
|
bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an MPEG file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using
|
||||||
|
* \a frameFactory.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
||||||
|
bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to a tag that is the union of the ID3v2 and ID3v1
|
||||||
|
* tags. The ID3v2 tag is given priority in reading the information -- if
|
||||||
|
* requested information exists in both the ID3v2 tag and the ID3v1 tag,
|
||||||
|
* the information from the ID3v2 tag will be returned.
|
||||||
|
*
|
||||||
|
* If you would like more granular control over the content of the tags,
|
||||||
|
* with the concession of generality, use the tag-type specific calls.
|
||||||
|
*
|
||||||
|
* \note As this tag is not implemented as an ID3v2 tag or an ID3v1 tag,
|
||||||
|
* but a union of the two this pointer may not be cast to the specific
|
||||||
|
* tag types.
|
||||||
|
*
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
* \see ID3v2Tag()
|
||||||
|
* \see APETag()
|
||||||
|
*/
|
||||||
|
virtual Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the reading part of the unified property interface.
|
||||||
|
* If the file contains more than one tag, only the
|
||||||
|
* first one (in the order ID3v2, APE, ID3v1) will be converted to the
|
||||||
|
* PropertyMap.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the writing part of the unified tag dictionary interface.
|
||||||
|
* In order to avoid problems with deprecated tag formats, this method
|
||||||
|
* always creates an ID3v2 tag if necessary.
|
||||||
|
* If an ID3v1 tag exists, it will be updated as well, within the
|
||||||
|
* limitations of that format.
|
||||||
|
* The returned PropertyMap refers to the ID3v2 tag only.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MPEG::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file. If at least one tag -- ID3v1 or ID3v2 -- exists this
|
||||||
|
* will duplicate its content into the other tag. This returns true
|
||||||
|
* if saving was successful.
|
||||||
|
*
|
||||||
|
* If neither exists or if both tags are empty, this will strip the tags
|
||||||
|
* from the file.
|
||||||
|
*
|
||||||
|
* This is the same as calling save(AllTags);
|
||||||
|
*
|
||||||
|
* If you would like more granular control over the content of the tags,
|
||||||
|
* with the concession of generality, use parameterized save call below.
|
||||||
|
*
|
||||||
|
* \see save(int tags)
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file. This will attempt to save all of the tag types that are
|
||||||
|
* specified by OR-ing together TagTypes values. The save() method above
|
||||||
|
* uses AllTags. This returns true if saving was successful.
|
||||||
|
*
|
||||||
|
* This strips all tags not included in the mask, but does not modify them
|
||||||
|
* in memory, so later calls to save() which make use of these tags will
|
||||||
|
* remain valid. This also strips empty tags.
|
||||||
|
*/
|
||||||
|
bool save(int tags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: combine with the above method
|
||||||
|
TAGLIB_DEPRECATED bool save(int tags, bool stripOthers);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: combine with the above method
|
||||||
|
TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: combine with the above method
|
||||||
|
TAGLIB_DEPRECATED bool save(int tags, bool stripOthers, int id3v2Version, bool duplicateTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file. This will attempt to save all of the tag types that are
|
||||||
|
* specified by OR-ing together TagTypes values.
|
||||||
|
*
|
||||||
|
* \a strip can be set to strip all tags except those in \a tags. Those
|
||||||
|
* tags will not be modified in memory, and thus remain valid.
|
||||||
|
*
|
||||||
|
* \a version specifies the ID3v2 version to be used for writing tags. By
|
||||||
|
* default, the latest standard, ID3v2.4 is used.
|
||||||
|
*
|
||||||
|
* If \a duplicate is set to DuplicateTags and at least one tag -- ID3v1
|
||||||
|
* or ID3v2 -- exists this will duplicate its content into the other tag.
|
||||||
|
*/
|
||||||
|
bool save(int tags, StripTags strip,
|
||||||
|
ID3v2::Version version = ID3v2::v4,
|
||||||
|
DuplicateTags duplicate = Duplicate);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v2 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid ID3v2 tag. If \a create is true it will create
|
||||||
|
* an ID3v2 tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v2Tag()
|
||||||
|
*/
|
||||||
|
ID3v2::Tag *ID3v2Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid ID3v1 tag. If \a create is true it will create
|
||||||
|
* an ID3v1 tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
||||||
|
* on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasID3v1Tag()
|
||||||
|
*/
|
||||||
|
ID3v1::Tag *ID3v1Tag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the APE tag of the file.
|
||||||
|
*
|
||||||
|
* If \a create is false (the default) this may return a null pointer
|
||||||
|
* if there is no valid APE tag. If \a create is true it will create
|
||||||
|
* an APE tag if one does not exist and returns a valid pointer.
|
||||||
|
*
|
||||||
|
* \note This may return a valid pointer regardless of whether or not the
|
||||||
|
* file on disk has an APE tag. Use hasAPETag() to check if the file
|
||||||
|
* on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasAPETag()
|
||||||
|
*/
|
||||||
|
APE::Tag *APETag(bool create = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will strip the tags that match the OR-ed together TagTypes from the
|
||||||
|
* file. By default it strips all tags. It returns true if the tags are
|
||||||
|
* successfully stripped.
|
||||||
|
*
|
||||||
|
* This is equivalent to strip(tags, true)
|
||||||
|
*
|
||||||
|
* \note This will also invalidate pointers to the ID3 and APE tags
|
||||||
|
* as their memory will be freed.
|
||||||
|
*
|
||||||
|
* \note This will update the file immediately.
|
||||||
|
*/
|
||||||
|
bool strip(int tags = AllTags);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will strip the tags that match the OR-ed together TagTypes from the
|
||||||
|
* file. By default it strips all tags. It returns true if the tags are
|
||||||
|
* successfully stripped.
|
||||||
|
*
|
||||||
|
* If \a freeMemory is true the ID3 and APE tags will be deleted and
|
||||||
|
* pointers to them will be invalidated.
|
||||||
|
*
|
||||||
|
* \note This will update the file immediately.
|
||||||
|
*/
|
||||||
|
// BIC: merge with the method above
|
||||||
|
bool strip(int tags, bool freeMemory);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the ID3v2::FrameFactory to something other than the default.
|
||||||
|
*
|
||||||
|
* \see ID3v2FrameFactory
|
||||||
|
* \deprecated This value should be passed in via the constructor
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the position in the file of the first MPEG frame.
|
||||||
|
*/
|
||||||
|
long firstFrameOffset();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the position in the file of the next MPEG frame,
|
||||||
|
* using the current position as start
|
||||||
|
*/
|
||||||
|
long nextFrameOffset(long position);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the position in the file of the previous MPEG frame,
|
||||||
|
* using the current position as start
|
||||||
|
*/
|
||||||
|
long previousFrameOffset(long position);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the position in the file of the last MPEG frame.
|
||||||
|
*/
|
||||||
|
long lastFrameOffset();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v1 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v1Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v1Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
||||||
|
*
|
||||||
|
* \see ID3v2Tag()
|
||||||
|
*/
|
||||||
|
bool hasID3v2Tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has an APE tag.
|
||||||
|
*
|
||||||
|
* \see APETag()
|
||||||
|
*/
|
||||||
|
bool hasAPETag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an MPEG
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
long findID3v2();
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,178 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MPEGHEADER_H
|
||||||
|
#define TAGLIB_MPEGHEADER_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class ByteVector;
|
||||||
|
class File;
|
||||||
|
|
||||||
|
namespace MPEG {
|
||||||
|
|
||||||
|
//! An implementation of MP3 frame headers
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of MPEG Layer III headers. The API follows more
|
||||||
|
* or less the binary format of these headers. I've used
|
||||||
|
* <a href="http://www.mp3-tech.org/programmer/frame_header.html">this</a>
|
||||||
|
* document as a reference.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Header
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Parses an MPEG header based on \a data.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Header(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parses an MPEG header based on \a file and \a offset.
|
||||||
|
*
|
||||||
|
* \note If \a checkLength is true, this requires the next MPEG frame to
|
||||||
|
* check if the frame length is parsed and calculated correctly. So it's
|
||||||
|
* suitable for seeking for the first valid frame.
|
||||||
|
*/
|
||||||
|
Header(File *file, long offset, bool checkLength = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Does a shallow copy of \a h.
|
||||||
|
*/
|
||||||
|
Header(const Header &h);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Header instance.
|
||||||
|
*/
|
||||||
|
virtual ~Header();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the frame is at least an appropriate size and has
|
||||||
|
* legal values.
|
||||||
|
*/
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The MPEG Version.
|
||||||
|
*/
|
||||||
|
enum Version {
|
||||||
|
//! MPEG Version 1
|
||||||
|
Version1 = 0,
|
||||||
|
//! MPEG Version 2
|
||||||
|
Version2 = 1,
|
||||||
|
//! MPEG Version 2.5
|
||||||
|
Version2_5 = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MPEG Version of the header.
|
||||||
|
*/
|
||||||
|
Version version() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the layer version. This will be between the values 1-3.
|
||||||
|
*/
|
||||||
|
int layer() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the MPEG protection bit is enabled.
|
||||||
|
*/
|
||||||
|
bool protectionEnabled() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the bitrate encoded in the header.
|
||||||
|
*/
|
||||||
|
int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the frame is padded.
|
||||||
|
*/
|
||||||
|
bool isPadded() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* There are a few combinations or one or two channel audio that are
|
||||||
|
* possible:
|
||||||
|
*/
|
||||||
|
enum ChannelMode {
|
||||||
|
//! Stereo
|
||||||
|
Stereo = 0,
|
||||||
|
//! Stereo
|
||||||
|
JointStereo = 1,
|
||||||
|
//! Dual Mono
|
||||||
|
DualChannel = 2,
|
||||||
|
//! Mono
|
||||||
|
SingleChannel = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the channel mode for this frame.
|
||||||
|
*/
|
||||||
|
ChannelMode channelMode() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the copyrighted bit is set.
|
||||||
|
*/
|
||||||
|
bool isCopyrighted() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the "original" bit is set.
|
||||||
|
*/
|
||||||
|
bool isOriginal() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the frame length in bytes.
|
||||||
|
*/
|
||||||
|
int frameLength() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of frames per sample.
|
||||||
|
*/
|
||||||
|
int samplesPerFrame() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Makes a shallow copy of the header.
|
||||||
|
*/
|
||||||
|
Header &operator=(const Header &h);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parse(File *file, long offset, bool checkLength);
|
||||||
|
|
||||||
|
class HeaderPrivate;
|
||||||
|
HeaderPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,152 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MPEGPROPERTIES_H
|
||||||
|
#define TAGLIB_MPEGPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
#include "mpegheader.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace MPEG {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
class XingHeader;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for MP3
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an MPEG Layer III stream found in the
|
||||||
|
* AudioProperties API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of MPEG::Properties with the data read from the
|
||||||
|
* MPEG::File \a file.
|
||||||
|
*/
|
||||||
|
Properties(File *file, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this MPEG Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the Xing/VBRI header if one exists or null if no
|
||||||
|
* Xing/VBRI header was found.
|
||||||
|
*/
|
||||||
|
const XingHeader *xingHeader() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the MPEG Version of the file.
|
||||||
|
*/
|
||||||
|
Header::Version version() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the layer version. This will be between the values 1-3.
|
||||||
|
*/
|
||||||
|
int layer() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the MPEG protection bit is enabled.
|
||||||
|
*/
|
||||||
|
bool protectionEnabled() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the channel mode for this frame.
|
||||||
|
*/
|
||||||
|
Header::ChannelMode channelMode() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the copyrighted bit is set.
|
||||||
|
*/
|
||||||
|
bool isCopyrighted() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the "original" bit is set.
|
||||||
|
*/
|
||||||
|
bool isOriginal() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(File *file);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,127 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "tbytevectorlist.h"
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OGGFILE_H
|
||||||
|
#define TAGLIB_OGGFILE_H
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A namespace for the classes used by Ogg-based metadata files
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
class PageHeader;
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with some helpers for Ogg based formats
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of Ogg file page and packet rendering and is of
|
||||||
|
* use to Ogg based formats. While the API is small this handles the
|
||||||
|
* non-trivial details of breaking up an Ogg stream into packets and makes
|
||||||
|
* these available (via subclassing) to the codec meta data implementations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the packet contents for the i-th packet (starting from zero)
|
||||||
|
* in the Ogg bitstream.
|
||||||
|
*
|
||||||
|
* \warning This requires reading at least the packet header for every page
|
||||||
|
* up to the requested page.
|
||||||
|
*/
|
||||||
|
ByteVector packet(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the packet with index \a i to the value \a p.
|
||||||
|
*/
|
||||||
|
void setPacket(unsigned int i, const ByteVector &p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the PageHeader for the first page in the stream or
|
||||||
|
* null if the page could not be found.
|
||||||
|
*/
|
||||||
|
const PageHeader *firstPageHeader();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the PageHeader for the last page in the stream or
|
||||||
|
* null if the page could not be found.
|
||||||
|
*/
|
||||||
|
const PageHeader *lastPageHeader();
|
||||||
|
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Constructs an Ogg file from \a file.
|
||||||
|
*
|
||||||
|
* \note This constructor is protected since Ogg::File shouldn't be
|
||||||
|
* instantiated directly but rather should be used through the codec
|
||||||
|
* specific subclasses.
|
||||||
|
*/
|
||||||
|
File(FileName file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an Ogg file from \a stream.
|
||||||
|
*
|
||||||
|
* \note This constructor is protected since Ogg::File shouldn't be
|
||||||
|
* instantiated directly but rather should be used through the codec
|
||||||
|
* specific subclasses.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads the pages from the beginning of the file until enough to compose
|
||||||
|
* the requested packet.
|
||||||
|
*/
|
||||||
|
bool readPages(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Writes the requested packet to the file.
|
||||||
|
*/
|
||||||
|
void writePacket(unsigned int i, const ByteVector &packet);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,170 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2004 by Allan Sandfeld Jensen
|
||||||
|
email : kde@carewolf.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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OGGFLACFILE_H
|
||||||
|
#define TAGLIB_OGGFLACFILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "oggfile.h"
|
||||||
|
#include "xiphcomment.h"
|
||||||
|
|
||||||
|
#include "flacproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
//! An implementation of Ogg FLAC metadata
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is implementation of FLAC metadata for Ogg FLAC files. For "pure"
|
||||||
|
* FLAC files look under the FLAC hierarchy.
|
||||||
|
*
|
||||||
|
* Unlike "pure" FLAC-files, Ogg FLAC only supports Xiph-comments,
|
||||||
|
* while the audio-properties are the same.
|
||||||
|
*/
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
|
using TagLib::FLAC::Properties;
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with Ogg/FLAC specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements and provides an interface for Ogg/FLAC files to the
|
||||||
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
|
* information specific to Ogg FLAC files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public Ogg::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an Ogg/FLAC file from \a file. If \a readProperties is true
|
||||||
|
* the file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an Ogg/FLAC file from \a stream. If \a readProperties is true
|
||||||
|
* the file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Tag for this file. This will always be a XiphComment.
|
||||||
|
*
|
||||||
|
* \note This always returns a valid pointer regardless of whether or not
|
||||||
|
* the file on disk has a XiphComment. Use hasXiphComment() to check if
|
||||||
|
* the file on disk actually has a XiphComment.
|
||||||
|
*
|
||||||
|
* \note The Tag <b>is still</b> owned by the FLAC::File and should not be
|
||||||
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
|
* destroyed.
|
||||||
|
*
|
||||||
|
* \see hasXiphComment()
|
||||||
|
*/
|
||||||
|
virtual XiphComment *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the FLAC::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* This forwards directly to XiphComment::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified tag dictionary interface -- import function.
|
||||||
|
* Like properties(), this is a forwarder to the file's XiphComment.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file. This will primarily save and update the XiphComment.
|
||||||
|
* Returns true if the save is successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the audio-stream, used by FLAC::Properties for
|
||||||
|
* calculating the bitrate.
|
||||||
|
*/
|
||||||
|
long streamLength();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the file on disk actually has a XiphComment.
|
||||||
|
*
|
||||||
|
* \see tag()
|
||||||
|
*/
|
||||||
|
bool hasXiphComment() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Check if the given \a stream can be opened as an Ogg FLAC file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
||||||
|
void scan();
|
||||||
|
ByteVector streamInfoData();
|
||||||
|
ByteVector xiphCommentData();
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
} // namespace FLAC
|
||||||
|
} // namespace Ogg
|
||||||
|
} // namespace TagLib
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,228 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OGGPAGE_H
|
||||||
|
#define TAGLIB_OGGPAGE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tbytevectorlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
class PageHeader;
|
||||||
|
|
||||||
|
//! An implementation of Ogg pages
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of the pages that make up an Ogg stream.
|
||||||
|
* This handles parsing pages and breaking them down into packets and handles
|
||||||
|
* the details of packets spanning multiple pages and pages that contain
|
||||||
|
* multiple packets.
|
||||||
|
*
|
||||||
|
* In most Xiph.org formats the comments are found in the first few packets,
|
||||||
|
* this however is a reasonably complete implementation of Ogg pages that
|
||||||
|
* could potentially be useful for non-meta data purposes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Page
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Read an Ogg page from the \a file at the position \a pageOffset.
|
||||||
|
*/
|
||||||
|
Page(File *file, long pageOffset);
|
||||||
|
|
||||||
|
virtual ~Page();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the page's position within the file (in bytes).
|
||||||
|
*/
|
||||||
|
long fileOffset() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the header for this page. This pointer will become
|
||||||
|
* invalid when the page is deleted.
|
||||||
|
*/
|
||||||
|
const PageHeader *header() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the index of the page within the Ogg stream. This helps make it
|
||||||
|
* possible to determine if pages have been lost.
|
||||||
|
*
|
||||||
|
* \see setPageSequenceNumber()
|
||||||
|
*/
|
||||||
|
int pageSequenceNumber() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the page's position in the stream to \a sequenceNumber.
|
||||||
|
*
|
||||||
|
* \see pageSequenceNumber()
|
||||||
|
*/
|
||||||
|
void setPageSequenceNumber(int sequenceNumber);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a copy of the page with \a sequenceNumber set as sequence number.
|
||||||
|
*
|
||||||
|
* \see header()
|
||||||
|
* \see PageHeader::setPageSequenceNumber()
|
||||||
|
*
|
||||||
|
* \deprecated Always returns null.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED Page *getCopyWithNewPageSequenceNumber(int sequenceNumber);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the index of the first packet wholly or partially contained in
|
||||||
|
* this page.
|
||||||
|
*
|
||||||
|
* \see setFirstPacketIndex()
|
||||||
|
*/
|
||||||
|
int firstPacketIndex() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the index of the first packet in the page.
|
||||||
|
*
|
||||||
|
* \see firstPacketIndex()
|
||||||
|
*/
|
||||||
|
void setFirstPacketIndex(int index);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* When checking to see if a page contains a given packet this set of flags
|
||||||
|
* represents the possible values for that packets status in the page.
|
||||||
|
*
|
||||||
|
* \see containsPacket()
|
||||||
|
*/
|
||||||
|
enum ContainsPacketFlags {
|
||||||
|
//! No part of the packet is contained in the page
|
||||||
|
DoesNotContainPacket = 0x0000,
|
||||||
|
//! The packet is wholly contained in the page
|
||||||
|
CompletePacket = 0x0001,
|
||||||
|
//! The page starts with the given packet
|
||||||
|
BeginsWithPacket = 0x0002,
|
||||||
|
//! The page ends with the given packet
|
||||||
|
EndsWithPacket = 0x0004
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks to see if the specified \a packet is contained in the current
|
||||||
|
* page.
|
||||||
|
*
|
||||||
|
* \see ContainsPacketFlags
|
||||||
|
*/
|
||||||
|
ContainsPacketFlags containsPacket(int index) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of packets (whole or partial) in this page.
|
||||||
|
*/
|
||||||
|
unsigned int packetCount() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a list of the packets in this page.
|
||||||
|
*
|
||||||
|
* \note Either or both the first and last packets may be only partial.
|
||||||
|
* \see PageHeader::firstPacketContinued()
|
||||||
|
*/
|
||||||
|
ByteVectorList packets() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the page in bytes.
|
||||||
|
*/
|
||||||
|
int size() const;
|
||||||
|
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Defines a strategy for pagination, or grouping pages into Ogg packets,
|
||||||
|
* for use with pagination methods.
|
||||||
|
*
|
||||||
|
* \note Yes, I'm aware that this is not a canonical "Strategy Pattern",
|
||||||
|
* the term was simply convenient.
|
||||||
|
*/
|
||||||
|
enum PaginationStrategy {
|
||||||
|
/*!
|
||||||
|
* Attempt to put the specified set of packets into a single Ogg packet.
|
||||||
|
* If the sum of the packet data is greater than will fit into a single
|
||||||
|
* Ogg page -- 65280 bytes -- this will fall back to repagination using
|
||||||
|
* the recommended page sizes.
|
||||||
|
*/
|
||||||
|
SinglePagePerGroup,
|
||||||
|
/*!
|
||||||
|
* Split the packet or group of packets into pages that conform to the
|
||||||
|
* sizes recommended in the Ogg standard.
|
||||||
|
*/
|
||||||
|
Repaginate
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Pack \a packets into Ogg pages using the \a strategy for pagination.
|
||||||
|
* The page number indicator inside of the rendered packets will start
|
||||||
|
* with \a firstPage and be incremented for each page rendered.
|
||||||
|
* \a containsLastPacket should be set to true if \a packets contains the
|
||||||
|
* last page in the stream and will set the appropriate flag in the last
|
||||||
|
* rendered Ogg page's header. \a streamSerialNumber should be set to
|
||||||
|
* the serial number for this stream.
|
||||||
|
*
|
||||||
|
* \note The "absolute granule position" is currently always zeroed using
|
||||||
|
* this method as this suffices for the comment headers.
|
||||||
|
*
|
||||||
|
* \warning The pages returned by this method must be deleted by the user.
|
||||||
|
* You can use List<T>::setAutoDelete(true) to set these pages to be
|
||||||
|
* automatically deleted when this list passes out of scope.
|
||||||
|
*
|
||||||
|
* \see PaginationStrategy
|
||||||
|
* \see List::setAutoDelete()
|
||||||
|
*/
|
||||||
|
static List<Page *> paginate(const ByteVectorList &packets,
|
||||||
|
PaginationStrategy strategy,
|
||||||
|
unsigned int streamSerialNumber,
|
||||||
|
int firstPage,
|
||||||
|
bool firstPacketContinued = false,
|
||||||
|
bool lastPacketCompleted = true,
|
||||||
|
bool containsLastPacket = false);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Creates an Ogg packet based on the data in \a packets. The page number
|
||||||
|
* for each page will be set to \a pageNumber.
|
||||||
|
*/
|
||||||
|
Page(const ByteVectorList &packets,
|
||||||
|
unsigned int streamSerialNumber,
|
||||||
|
int pageNumber,
|
||||||
|
bool firstPacketContinued = false,
|
||||||
|
bool lastPacketCompleted = true,
|
||||||
|
bool containsLastPacket = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Page(const Page &);
|
||||||
|
Page &operator=(const Page &);
|
||||||
|
|
||||||
|
class PagePrivate;
|
||||||
|
PagePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,232 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OGGPAGEHEADER_H
|
||||||
|
#define TAGLIB_OGGPAGEHEADER_H
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of the page headers associated with each Ogg::Page
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class implements Ogg page headers which contain the information
|
||||||
|
* about Ogg pages needed to break them into packets which can be passed on
|
||||||
|
* to the codecs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT PageHeader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Reads a PageHeader from \a file starting at \a pageOffset. The defaults
|
||||||
|
* create a page with no (and as such, invalid) data that must be set
|
||||||
|
* later.
|
||||||
|
*/
|
||||||
|
PageHeader(File *file = 0, long pageOffset = -1);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Deletes this instance of the PageHeader.
|
||||||
|
*/
|
||||||
|
virtual ~PageHeader();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the header parsed properly and is valid.
|
||||||
|
*/
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Ogg pages contain a list of packets (which are used by the contained
|
||||||
|
* codecs). The sizes of these pages is encoded in the page header. This
|
||||||
|
* returns a list of the packet sizes in bytes.
|
||||||
|
*
|
||||||
|
* \see setPacketSizes()
|
||||||
|
*/
|
||||||
|
List<int> packetSizes() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the sizes of the packets in this page to \a sizes. Internally this
|
||||||
|
* updates the lacing values in the header.
|
||||||
|
*
|
||||||
|
* \see packetSizes()
|
||||||
|
*/
|
||||||
|
void setPacketSizes(const List<int> &sizes);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Some packets can be <i>continued</i> across multiple pages. If the
|
||||||
|
* first packet in the current page is a continuation this will return
|
||||||
|
* true. If this is page starts with a new packet this will return false.
|
||||||
|
*
|
||||||
|
* \see lastPacketCompleted()
|
||||||
|
* \see setFirstPacketContinued()
|
||||||
|
*/
|
||||||
|
bool firstPacketContinued() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the internal flag indicating if the first packet in this page is
|
||||||
|
* continued to \a continued.
|
||||||
|
*
|
||||||
|
* \see firstPacketContinued()
|
||||||
|
*/
|
||||||
|
void setFirstPacketContinued(bool continued);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the last packet of this page is completely contained in
|
||||||
|
* this page.
|
||||||
|
*
|
||||||
|
* \see firstPacketContinued()
|
||||||
|
* \see setLastPacketCompleted()
|
||||||
|
*/
|
||||||
|
bool lastPacketCompleted() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the internal flag indicating if the last packet in this page is
|
||||||
|
* complete to \a completed.
|
||||||
|
*
|
||||||
|
* \see lastPacketCompleted()
|
||||||
|
*/
|
||||||
|
void setLastPacketCompleted(bool completed);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This returns true if this is the first page of the Ogg (logical) stream.
|
||||||
|
*
|
||||||
|
* \see setFirstPageOfStream()
|
||||||
|
*/
|
||||||
|
bool firstPageOfStream() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Marks this page as the first page of the Ogg stream.
|
||||||
|
*
|
||||||
|
* \see firstPageOfStream()
|
||||||
|
*/
|
||||||
|
void setFirstPageOfStream(bool first);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This returns true if this is the last page of the Ogg (logical) stream.
|
||||||
|
*
|
||||||
|
* \see setLastPageOfStream()
|
||||||
|
*/
|
||||||
|
bool lastPageOfStream() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Marks this page as the last page of the Ogg stream.
|
||||||
|
*
|
||||||
|
* \see lastPageOfStream()
|
||||||
|
*/
|
||||||
|
void setLastPageOfStream(bool last);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A special value of containing the position of the packet to be
|
||||||
|
* interpreted by the codec. In the case of Vorbis this contains the PCM
|
||||||
|
* value and is used to calculate the length of the stream.
|
||||||
|
*
|
||||||
|
* \see setAbsoluteGranularPosition()
|
||||||
|
*/
|
||||||
|
long long absoluteGranularPosition() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A special value of containing the position of the packet to be
|
||||||
|
* interpreted by the codec. It is only supported here so that it may be
|
||||||
|
* copied from one page to another.
|
||||||
|
*
|
||||||
|
* \see absoluteGranularPosition()
|
||||||
|
*/
|
||||||
|
void setAbsoluteGranularPosition(long long agp);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Every Ogg logical stream is given a random serial number which is common
|
||||||
|
* to every page in that logical stream. This returns the serial number of
|
||||||
|
* the stream associated with this packet.
|
||||||
|
*
|
||||||
|
* \see setStreamSerialNumber()
|
||||||
|
*/
|
||||||
|
unsigned int streamSerialNumber() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Every Ogg logical stream is given a random serial number which is common
|
||||||
|
* to every page in that logical stream. This sets this pages serial
|
||||||
|
* number. This method should be used when adding new pages to a logical
|
||||||
|
* stream.
|
||||||
|
*
|
||||||
|
* \see streamSerialNumber()
|
||||||
|
*/
|
||||||
|
void setStreamSerialNumber(unsigned int n);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the index of the page within the Ogg stream. This helps make it
|
||||||
|
* possible to determine if pages have been lost.
|
||||||
|
*
|
||||||
|
* \see setPageSequenceNumber()
|
||||||
|
*/
|
||||||
|
int pageSequenceNumber() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the page's position in the stream to \a sequenceNumber.
|
||||||
|
*
|
||||||
|
* \see pageSequenceNumber()
|
||||||
|
*/
|
||||||
|
void setPageSequenceNumber(int sequenceNumber);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the complete header size.
|
||||||
|
*/
|
||||||
|
int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the data portion of the page -- i.e. the size of the
|
||||||
|
* page less the header size.
|
||||||
|
*/
|
||||||
|
int dataSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Render the page header to binary data.
|
||||||
|
*
|
||||||
|
* \note The checksum -- bytes 22 - 25 -- will be left empty and must be
|
||||||
|
* filled in when rendering the entire page.
|
||||||
|
*/
|
||||||
|
ByteVector render() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PageHeader(const PageHeader &);
|
||||||
|
PageHeader &operator=(const PageHeader &);
|
||||||
|
|
||||||
|
void read(Ogg::File *file, long pageOffset);
|
||||||
|
ByteVector lacingValues() const;
|
||||||
|
|
||||||
|
class PageHeaderPrivate;
|
||||||
|
PageHeaderPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,138 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2012 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
|
||||||
|
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||||
|
email : wheeler@kde.org
|
||||||
|
(original Vorbis 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OPUSFILE_H
|
||||||
|
#define TAGLIB_OPUSFILE_H
|
||||||
|
|
||||||
|
#include "oggfile.h"
|
||||||
|
#include "xiphcomment.h"
|
||||||
|
|
||||||
|
#include "opusproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
//! A namespace containing classes for Opus metadata
|
||||||
|
|
||||||
|
namespace Opus {
|
||||||
|
|
||||||
|
//! An implementation of Ogg::File with Opus specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is the central class in the Ogg Opus metadata processing collection
|
||||||
|
* of classes. It's built upon Ogg::File which handles processing of the Ogg
|
||||||
|
* logical bitstream and breaking it down into pages which are handled by
|
||||||
|
* the codec implementations, in this case Opus specifically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public Ogg::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an Opus file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an Opus file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the XiphComment for this file. XiphComment implements the tag
|
||||||
|
* interface, so this serves as the reimplementation of
|
||||||
|
* TagLib::File::tag().
|
||||||
|
*/
|
||||||
|
virtual Ogg::XiphComment *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* This forwards directly to XiphComment::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified tag dictionary interface -- import function.
|
||||||
|
* Like properties(), this is a forwarder to the file's XiphComment.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Opus::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as an Opus
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,134 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2012 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
|
||||||
|
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||||
|
email : wheeler@kde.org
|
||||||
|
(original Vorbis 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OPUSPROPERTIES_H
|
||||||
|
#define TAGLIB_OPUSPROPERTIES_H
|
||||||
|
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
namespace Opus {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for Ogg Opus
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an Ogg Opus stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of Opus::Properties with the data read from the
|
||||||
|
* Opus::File \a file.
|
||||||
|
*/
|
||||||
|
Properties(File *file, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Opus::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*
|
||||||
|
* \note Always returns 48000, because Opus can decode any stream at a
|
||||||
|
* sample rate of 8, 12, 16, 24, or 48 kHz,
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The Opus codec supports decoding at multiple sample rates, there is no
|
||||||
|
* single sample rate of the encoded stream. This returns the sample rate
|
||||||
|
* of the original audio stream.
|
||||||
|
*/
|
||||||
|
int inputSampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Opus version, in the range 0...255.
|
||||||
|
*/
|
||||||
|
int opusVersion() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(File *file);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,151 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2012 by Rupert Daniel
|
||||||
|
email : rupert@cancelmonday.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_OWNERSHIPFRAME_H
|
||||||
|
#define TAGLIB_OWNERSHIPFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 "ownership"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements the ID3v2 ownership (OWNE frame). It consists of
|
||||||
|
* a price paid, a date purchased (YYYYMMDD) and the name of the seller.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT OwnershipFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct an empty ownership frame.
|
||||||
|
*/
|
||||||
|
explicit OwnershipFrame(String::Type encoding = String::Latin1);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a ownership based on the data in \a data.
|
||||||
|
*/
|
||||||
|
explicit OwnershipFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this OwnershipFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~OwnershipFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text of this popularimeter.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the date purchased.
|
||||||
|
*
|
||||||
|
* \see setDatePurchased()
|
||||||
|
*/
|
||||||
|
String datePurchased() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the date purchased.
|
||||||
|
*
|
||||||
|
* \see datePurchased()
|
||||||
|
*/
|
||||||
|
void setDatePurchased(const String &datePurchased);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the price paid.
|
||||||
|
*
|
||||||
|
* \see setPricePaid()
|
||||||
|
*/
|
||||||
|
String pricePaid() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the price paid.
|
||||||
|
*
|
||||||
|
* \see pricePaid()
|
||||||
|
*/
|
||||||
|
void setPricePaid(const String &pricePaid);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the seller.
|
||||||
|
*
|
||||||
|
* \see setSeller()
|
||||||
|
*/
|
||||||
|
String seller() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the seller.
|
||||||
|
*
|
||||||
|
* \see seller()
|
||||||
|
*/
|
||||||
|
void setSeller(const String &seller);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding that will be used in rendering this frame.
|
||||||
|
* This defaults to the type that was either specified in the constructor
|
||||||
|
* or read from the frame when parsed.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text encoding to be used when rendering this frame to
|
||||||
|
* \a encoding.
|
||||||
|
*
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
OwnershipFrame(const ByteVector &data, Header *h);
|
||||||
|
OwnershipFrame(const OwnershipFrame &);
|
||||||
|
OwnershipFrame &operator=(const OwnershipFrame &);
|
||||||
|
|
||||||
|
class OwnershipFramePrivate;
|
||||||
|
OwnershipFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,82 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2015 by Urs Fleisch
|
||||||
|
email : ufleisch@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_PODCASTFRAME_H
|
||||||
|
#define TAGLIB_PODCASTFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! ID3v2 podcast frame
|
||||||
|
/*!
|
||||||
|
* An implementation of ID3v2 podcast flag, a frame with four zero bytes.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT PodcastFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct a podcast frame.
|
||||||
|
*/
|
||||||
|
PodcastFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this PodcastFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~PodcastFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a null string.
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
PodcastFrame(const ByteVector &data, Header *h);
|
||||||
|
PodcastFrame(const PodcastFrame &);
|
||||||
|
PodcastFrame &operator=(const PodcastFrame &);
|
||||||
|
|
||||||
|
class PodcastFramePrivate;
|
||||||
|
PodcastFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,132 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2008 by Lukas Lalinsky
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_POPULARIMETERFRAME_H
|
||||||
|
#define TAGLIB_POPULARIMETERFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 "popularimeter"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements the ID3v2 popularimeter (POPM frame). It consists of
|
||||||
|
* an email, a rating and an optional counter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT PopularimeterFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct an empty popularimeter frame.
|
||||||
|
*/
|
||||||
|
explicit PopularimeterFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a popularimeter based on the data in \a data.
|
||||||
|
*/
|
||||||
|
explicit PopularimeterFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this PopularimeterFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~PopularimeterFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text of this popularimeter.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the email.
|
||||||
|
*
|
||||||
|
* \see setEmail()
|
||||||
|
*/
|
||||||
|
String email() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the email.
|
||||||
|
*
|
||||||
|
* \see email()
|
||||||
|
*/
|
||||||
|
void setEmail(const String &email);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the rating.
|
||||||
|
*
|
||||||
|
* \see setRating()
|
||||||
|
*/
|
||||||
|
int rating() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the rating.
|
||||||
|
*
|
||||||
|
* \see rating()
|
||||||
|
*/
|
||||||
|
void setRating(int rating);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the counter.
|
||||||
|
*
|
||||||
|
* \see setCounter()
|
||||||
|
*/
|
||||||
|
unsigned int counter() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the counter.
|
||||||
|
*
|
||||||
|
* \see counter()
|
||||||
|
*/
|
||||||
|
void setCounter(unsigned int counter);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
PopularimeterFrame(const ByteVector &data, Header *h);
|
||||||
|
PopularimeterFrame(const PopularimeterFrame &);
|
||||||
|
PopularimeterFrame &operator=(const PopularimeterFrame &);
|
||||||
|
|
||||||
|
class PopularimeterFramePrivate;
|
||||||
|
PopularimeterFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,111 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2008 by Serkan Kalyoncu
|
||||||
|
copyright : (C) 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_PRIVATEFRAME_H
|
||||||
|
#define TAGLIB_PRIVATEFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 privateframe
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT PrivateFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct an empty private frame.
|
||||||
|
*/
|
||||||
|
PrivateFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a private frame based on the data in \a data.
|
||||||
|
*
|
||||||
|
* \note This is the constructor used when parsing the frame from a file.
|
||||||
|
*/
|
||||||
|
explicit PrivateFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this private frame instance.
|
||||||
|
*/
|
||||||
|
virtual ~PrivateFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text of this private frame, currently just the owner.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The owner of the private frame.
|
||||||
|
* \note This should contain an email address or link to a website.
|
||||||
|
*/
|
||||||
|
String owner() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ByteVector data() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the owner of the frame to \a s.
|
||||||
|
* \note This should contain an email address or link to a website.
|
||||||
|
*/
|
||||||
|
void setOwner(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void setData(const ByteVector &v);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
PrivateFrame(const ByteVector &data, Header *h);
|
||||||
|
|
||||||
|
PrivateFrame(const PrivateFrame &);
|
||||||
|
PrivateFrame &operator=(const PrivateFrame &);
|
||||||
|
|
||||||
|
class PrivateFramePrivate;
|
||||||
|
PrivateFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,274 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_RELATIVEVOLUMEFRAME_H
|
||||||
|
#define TAGLIB_RELATIVEVOLUMEFRAME_H
|
||||||
|
|
||||||
|
#include "tlist.h"
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! An ID3v2 relative volume adjustment frame implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ID3v2 relative volume adjustment. The
|
||||||
|
* presence of this frame makes it possible to specify an increase in volume
|
||||||
|
* for an audio file or specific audio tracks in that file.
|
||||||
|
*
|
||||||
|
* Multiple relative volume adjustment frames may be present in the tag
|
||||||
|
* each with a unique identification and describing volume adjustment for
|
||||||
|
* different channel types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT RelativeVolumeFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This indicates the type of volume adjustment that should be applied.
|
||||||
|
*/
|
||||||
|
enum ChannelType {
|
||||||
|
//! A type not enumerated below
|
||||||
|
Other = 0x00,
|
||||||
|
//! The master volume for the track
|
||||||
|
MasterVolume = 0x01,
|
||||||
|
//! The front right audio channel
|
||||||
|
FrontRight = 0x02,
|
||||||
|
//! The front left audio channel
|
||||||
|
FrontLeft = 0x03,
|
||||||
|
//! The back right audio channel
|
||||||
|
BackRight = 0x04,
|
||||||
|
//! The back left audio channel
|
||||||
|
BackLeft = 0x05,
|
||||||
|
//! The front center audio channel
|
||||||
|
FrontCentre = 0x06,
|
||||||
|
//! The back center audio channel
|
||||||
|
BackCentre = 0x07,
|
||||||
|
//! The subwoofer audio channel
|
||||||
|
Subwoofer = 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Struct that stores the relevant values for ID3v2 peak volume
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The peak volume is described as a series of bits that is padded to fill
|
||||||
|
* a block of bytes. These two values should always be updated in tandem.
|
||||||
|
*/
|
||||||
|
struct PeakVolume
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Constructs an empty peak volume description.
|
||||||
|
*/
|
||||||
|
PeakVolume() : bitsRepresentingPeak(0) {}
|
||||||
|
/*!
|
||||||
|
* The number of bits (in the range of 0 to 255) used to describe the
|
||||||
|
* peak volume.
|
||||||
|
*/
|
||||||
|
unsigned char bitsRepresentingPeak;
|
||||||
|
/*!
|
||||||
|
* The array of bits (represented as a series of bytes) used to describe
|
||||||
|
* the peak volume.
|
||||||
|
*/
|
||||||
|
ByteVector peakVolume;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a RelativeVolumeFrame. The relevant data should be set
|
||||||
|
* manually.
|
||||||
|
*/
|
||||||
|
RelativeVolumeFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a RelativeVolumeFrame based on the contents of \a data.
|
||||||
|
*/
|
||||||
|
RelativeVolumeFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the RelativeVolumeFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~RelativeVolumeFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the frame's identification.
|
||||||
|
*
|
||||||
|
* \see identification()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a list of channels with information currently in the frame.
|
||||||
|
*/
|
||||||
|
List<ChannelType> channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated Always returns master volume.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED ChannelType channelType() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \deprecated This method no longer has any effect.
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED void setChannelType(ChannelType t);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There was a terrible API goof here, and while this can't be changed to
|
||||||
|
* the way it appears below for binary compatibility reasons, let's at
|
||||||
|
* least pretend that it looks clean.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef DOXYGEN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the relative volume adjustment "index". As indicated by the
|
||||||
|
* ID3v2 standard this is a 16-bit signed integer that reflects the
|
||||||
|
* decibels of adjustment when divided by 512.
|
||||||
|
*
|
||||||
|
* This defaults to returning the value for the master volume channel if
|
||||||
|
* available and returns 0 if the specified channel does not exist.
|
||||||
|
*
|
||||||
|
* \see setVolumeAdjustmentIndex()
|
||||||
|
* \see volumeAdjustment()
|
||||||
|
*/
|
||||||
|
short volumeAdjustmentIndex(ChannelType type = MasterVolume) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the volume adjustment to \a index. As indicated by the ID3v2
|
||||||
|
* standard this is a 16-bit signed integer that reflects the decibels of
|
||||||
|
* adjustment when divided by 512.
|
||||||
|
*
|
||||||
|
* By default this sets the value for the master volume.
|
||||||
|
*
|
||||||
|
* \see volumeAdjustmentIndex()
|
||||||
|
* \see setVolumeAdjustment()
|
||||||
|
*/
|
||||||
|
void setVolumeAdjustmentIndex(short index, ChannelType type = MasterVolume);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the relative volume adjustment in decibels.
|
||||||
|
*
|
||||||
|
* \note Because this is actually stored internally as an "index" to this
|
||||||
|
* value the value returned by this method may not be identical to the
|
||||||
|
* value set using setVolumeAdjustment().
|
||||||
|
*
|
||||||
|
* This defaults to returning the value for the master volume channel if
|
||||||
|
* available and returns 0 if the specified channel does not exist.
|
||||||
|
*
|
||||||
|
* \see setVolumeAdjustment()
|
||||||
|
* \see volumeAdjustmentIndex()
|
||||||
|
*/
|
||||||
|
float volumeAdjustment(ChannelType type = MasterVolume) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the relative volume adjustment in decibels to \a adjustment.
|
||||||
|
*
|
||||||
|
* By default this sets the value for the master volume.
|
||||||
|
*
|
||||||
|
* \note Because this is actually stored internally as an "index" to this
|
||||||
|
* value the value set by this method may not be identical to the one
|
||||||
|
* returned by volumeAdjustment().
|
||||||
|
*
|
||||||
|
* \see setVolumeAdjustment()
|
||||||
|
* \see volumeAdjustmentIndex()
|
||||||
|
*/
|
||||||
|
void setVolumeAdjustment(float adjustment, ChannelType type = MasterVolume);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the peak volume (represented as a length and a string of bits).
|
||||||
|
*
|
||||||
|
* This defaults to returning the value for the master volume channel if
|
||||||
|
* available and returns 0 if the specified channel does not exist.
|
||||||
|
*
|
||||||
|
* \see setPeakVolume()
|
||||||
|
*/
|
||||||
|
PeakVolume peakVolume(ChannelType type = MasterVolume) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the peak volume to \a peak.
|
||||||
|
*
|
||||||
|
* By default this sets the value for the master volume.
|
||||||
|
*
|
||||||
|
* \see peakVolume()
|
||||||
|
*/
|
||||||
|
void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// BIC: Combine each of the following pairs of functions (or maybe just
|
||||||
|
// rework this junk altogether).
|
||||||
|
|
||||||
|
short volumeAdjustmentIndex(ChannelType type) const;
|
||||||
|
short volumeAdjustmentIndex() const;
|
||||||
|
|
||||||
|
void setVolumeAdjustmentIndex(short index, ChannelType type);
|
||||||
|
void setVolumeAdjustmentIndex(short index);
|
||||||
|
|
||||||
|
float volumeAdjustment(ChannelType type) const;
|
||||||
|
float volumeAdjustment() const;
|
||||||
|
|
||||||
|
void setVolumeAdjustment(float adjustment, ChannelType type);
|
||||||
|
void setVolumeAdjustment(float adjustment);
|
||||||
|
|
||||||
|
PeakVolume peakVolume(ChannelType type) const;
|
||||||
|
PeakVolume peakVolume() const;
|
||||||
|
|
||||||
|
void setPeakVolume(const PeakVolume &peak, ChannelType type);
|
||||||
|
void setPeakVolume(const PeakVolume &peak);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the identification for this frame.
|
||||||
|
*/
|
||||||
|
String identification() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the identification of the frame to \a s. The string
|
||||||
|
* is used to identify the situation and/or device where this
|
||||||
|
* adjustment should apply.
|
||||||
|
*/
|
||||||
|
void setIdentification(const String &s);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RelativeVolumeFrame(const ByteVector &data, Header *h);
|
||||||
|
RelativeVolumeFrame(const RelativeVolumeFrame &);
|
||||||
|
RelativeVolumeFrame &operator=(const RelativeVolumeFrame &);
|
||||||
|
|
||||||
|
class RelativeVolumeFramePrivate;
|
||||||
|
RelativeVolumeFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,161 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_RIFFFILE_H
|
||||||
|
#define TAGLIB_RIFFFILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tfile.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! An implementation of TagLib::File with RIFF specific methods
|
||||||
|
|
||||||
|
namespace RIFF {
|
||||||
|
|
||||||
|
//! An RIFF file class with some useful methods specific to RIFF
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements the generic TagLib::File API and additionally provides
|
||||||
|
* access to properties that are distinct to RIFF files, notably access
|
||||||
|
* to the different ID3 tags.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public TagLib::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum Endianness { BigEndian, LittleEndian };
|
||||||
|
|
||||||
|
File(FileName file, Endianness endianness);
|
||||||
|
File(IOStream *stream, Endianness endianness);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The size of the main RIFF chunk.
|
||||||
|
*/
|
||||||
|
unsigned int riffSize() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The number of chunks in the file.
|
||||||
|
*/
|
||||||
|
unsigned int chunkCount() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The offset within the file for the selected chunk number.
|
||||||
|
*/
|
||||||
|
unsigned int chunkOffset(unsigned int i) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The size of the chunk data.
|
||||||
|
*/
|
||||||
|
unsigned int chunkDataSize(unsigned int i) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The size of the padding after the chunk (can be either 0 or 1).
|
||||||
|
*/
|
||||||
|
unsigned int chunkPadding(unsigned int i) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The name of the specified chunk, for instance, "COMM" or "ID3 "
|
||||||
|
*/
|
||||||
|
ByteVector chunkName(unsigned int i) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads the chunk data from the file and returns it.
|
||||||
|
*
|
||||||
|
* \note This \e will move the read pointer for the file.
|
||||||
|
*/
|
||||||
|
ByteVector chunkData(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the specified chunk to \a data.
|
||||||
|
*
|
||||||
|
* \warning This will update the file immediately.
|
||||||
|
*/
|
||||||
|
void setChunkData(unsigned int i, const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the chunk \a name to \a data. If a chunk with the
|
||||||
|
* given name already exists it will be overwritten, otherwise it will be
|
||||||
|
* created after the existing chunks.
|
||||||
|
*
|
||||||
|
* \warning This will update the file immediately.
|
||||||
|
*/
|
||||||
|
void setChunkData(const ByteVector &name, const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the chunk \a name to \a data. If a chunk with the
|
||||||
|
* given name already exists it will be overwritten, otherwise it will be
|
||||||
|
* created after the existing chunks.
|
||||||
|
*
|
||||||
|
* \note If \a alwaysCreate is true, a new chunk is created regardless of
|
||||||
|
* whether or not the chunk \a name exists. It should only be used for
|
||||||
|
* "LIST" chunks.
|
||||||
|
*
|
||||||
|
* \warning This will update the file immediately.
|
||||||
|
*/
|
||||||
|
void setChunkData(const ByteVector &name, const ByteVector &data, bool alwaysCreate);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes the specified chunk.
|
||||||
|
*
|
||||||
|
* \warning This will update the file immediately.
|
||||||
|
*/
|
||||||
|
void removeChunk(unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes the chunk \a name.
|
||||||
|
*
|
||||||
|
* \warning This will update the file immediately.
|
||||||
|
* \warning This removes all the chunks with the given name.
|
||||||
|
*/
|
||||||
|
void removeChunk(const ByteVector &name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read();
|
||||||
|
void writeChunk(const ByteVector &name, const ByteVector &data,
|
||||||
|
unsigned long offset, unsigned long replace = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Update the global RIFF size based on the current internal structure.
|
||||||
|
*/
|
||||||
|
void updateGlobalSize();
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,112 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_S3MFILE_H
|
||||||
|
#define TAGLIB_S3MFILE_H
|
||||||
|
|
||||||
|
#include "tfile.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "modfilebase.h"
|
||||||
|
#include "modtag.h"
|
||||||
|
#include "s3mproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace S3M {
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs a ScreamTracker III from \a file.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a ScreamTracker III file from \a stream.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, both \a readProperties and
|
||||||
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
|
* read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
AudioProperties::ReadStyle propertiesStyle =
|
||||||
|
AudioProperties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
Mod::Tag *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* Forwards to Mod::Tag::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- import function.
|
||||||
|
* Forwards to Mod::Tag::setProperties().
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the S3M::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
S3M::Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
* This is the same as calling save(AllTags);
|
||||||
|
*
|
||||||
|
* \note Saving ScreamTracker III tags is not supported.
|
||||||
|
*/
|
||||||
|
bool save();
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,94 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Mathias Panzenböck
|
||||||
|
email : grosser.meister.morti@gmx.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_S3MPROPERTIES_H
|
||||||
|
#define TAGLIB_S3MPROPERTIES_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
namespace S3M {
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties {
|
||||||
|
friend class File;
|
||||||
|
public:
|
||||||
|
/*! Flag bits. */
|
||||||
|
enum {
|
||||||
|
ST2Vibrato = 1,
|
||||||
|
ST2Tempo = 2,
|
||||||
|
AmigaSlides = 4,
|
||||||
|
Vol0MixOptimizations = 8,
|
||||||
|
AmigaLimits = 16,
|
||||||
|
EnableFilter = 32,
|
||||||
|
CustomData = 128
|
||||||
|
};
|
||||||
|
|
||||||
|
Properties(AudioProperties::ReadStyle propertiesStyle);
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
int length() const;
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
int bitrate() const;
|
||||||
|
int sampleRate() const;
|
||||||
|
int channels() const;
|
||||||
|
|
||||||
|
unsigned short lengthInPatterns() const;
|
||||||
|
bool stereo() const;
|
||||||
|
unsigned short sampleCount() const;
|
||||||
|
unsigned short patternCount() const;
|
||||||
|
unsigned short flags() const;
|
||||||
|
unsigned short trackerVersion() const;
|
||||||
|
unsigned short fileFormatVersion() const;
|
||||||
|
unsigned char globalVolume() const;
|
||||||
|
unsigned char masterVolume() const;
|
||||||
|
unsigned char tempo() const;
|
||||||
|
unsigned char bpmSpeed() const;
|
||||||
|
|
||||||
|
void setChannels(int channels);
|
||||||
|
|
||||||
|
void setLengthInPatterns (unsigned short lengthInPatterns);
|
||||||
|
void setStereo (bool stereo);
|
||||||
|
void setSampleCount (unsigned short sampleCount);
|
||||||
|
void setPatternCount (unsigned short patternCount);
|
||||||
|
void setFlags (unsigned short flags);
|
||||||
|
void setTrackerVersion (unsigned short trackerVersion);
|
||||||
|
void setFileFormatVersion(unsigned short fileFormatVersion);
|
||||||
|
void setGlobalVolume (unsigned char globalVolume);
|
||||||
|
void setMasterVolume (unsigned char masterVolume);
|
||||||
|
void setTempo (unsigned char tempo);
|
||||||
|
void setBpmSpeed (unsigned char bpmSpeed);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties&);
|
||||||
|
Properties &operator=(const Properties&);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,138 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2006 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
|
||||||
|
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||||
|
email : wheeler@kde.org
|
||||||
|
(original Vorbis 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_SPEEXFILE_H
|
||||||
|
#define TAGLIB_SPEEXFILE_H
|
||||||
|
|
||||||
|
#include "oggfile.h"
|
||||||
|
#include "xiphcomment.h"
|
||||||
|
|
||||||
|
#include "speexproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
//! A namespace containing classes for Speex metadata
|
||||||
|
|
||||||
|
namespace Speex {
|
||||||
|
|
||||||
|
//! An implementation of Ogg::File with Speex specific methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is the central class in the Ogg Speex metadata processing collection
|
||||||
|
* of classes. It's built upon Ogg::File which handles processing of the Ogg
|
||||||
|
* logical bitstream and breaking it down into pages which are handled by
|
||||||
|
* the codec implementations, in this case Speex specifically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File : public Ogg::File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs a Speex file from \a file. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(FileName file, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a Speex file from \a stream. If \a readProperties is true the
|
||||||
|
* file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream, bool readProperties = true,
|
||||||
|
Properties::ReadStyle propertiesStyle = Properties::Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the File.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the XiphComment for this file. XiphComment implements the tag
|
||||||
|
* interface, so this serves as the reimplementation of
|
||||||
|
* TagLib::File::tag().
|
||||||
|
*/
|
||||||
|
virtual Ogg::XiphComment *tag() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified property interface -- export function.
|
||||||
|
* This forwards directly to XiphComment::properties().
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Implements the unified tag dictionary interface -- import function.
|
||||||
|
* Like properties(), this is a forwarder to the file's XiphComment.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Speex::Properties for this file. If no audio properties
|
||||||
|
* were read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual Properties *audioProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file.
|
||||||
|
*
|
||||||
|
* This returns true if the save was successful.
|
||||||
|
*/
|
||||||
|
virtual bool save();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the given \a stream can be opened as a Speex
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This method is designed to do a quick check. The result may
|
||||||
|
* not necessarily be correct.
|
||||||
|
*/
|
||||||
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void read(bool readProperties);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,129 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2006 by Lukáš Lalinský
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
|
||||||
|
copyright : (C) 2002 - 2008 by Scott Wheeler
|
||||||
|
email : wheeler@kde.org
|
||||||
|
(original Vorbis 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_SPEEXPROPERTIES_H
|
||||||
|
#define TAGLIB_SPEEXPROPERTIES_H
|
||||||
|
|
||||||
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace Ogg {
|
||||||
|
|
||||||
|
namespace Speex {
|
||||||
|
|
||||||
|
class File;
|
||||||
|
|
||||||
|
//! An implementation of audio property reading for Ogg Speex
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This reads the data from an Ogg Speex stream found in the AudioProperties
|
||||||
|
* API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Properties : public AudioProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Create an instance of Speex::Properties with the data read from the
|
||||||
|
* Speex::File \a file.
|
||||||
|
*/
|
||||||
|
Properties(File *file, ReadStyle style = Average);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Speex::Properties instance.
|
||||||
|
*/
|
||||||
|
virtual ~Properties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \note This method is just an alias of lengthInSeconds().
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED virtual int length() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
|
* the nearest whole second.
|
||||||
|
*
|
||||||
|
* \see lengthInMilliseconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInSeconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in milliseconds.
|
||||||
|
*
|
||||||
|
* \see lengthInSeconds()
|
||||||
|
*/
|
||||||
|
// BIC: make virtual
|
||||||
|
int lengthInMilliseconds() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the average bit rate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
virtual int bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the nominal bit rate as read from the Speex header in kb/s.
|
||||||
|
*/
|
||||||
|
int bitrateNominal() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate in Hz.
|
||||||
|
*/
|
||||||
|
virtual int sampleRate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of audio channels.
|
||||||
|
*/
|
||||||
|
virtual int channels() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the Speex version, currently "0" (as specified by the spec).
|
||||||
|
*/
|
||||||
|
int speexVersion() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Properties(const Properties &);
|
||||||
|
Properties &operator=(const Properties &);
|
||||||
|
|
||||||
|
void read(File *file);
|
||||||
|
|
||||||
|
class PropertiesPrivate;
|
||||||
|
PropertiesPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,231 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2014 by Urs Fleisch
|
||||||
|
email : ufleisch@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_SYNCHRONIZEDLYRICSFRAME_H
|
||||||
|
#define TAGLIB_SYNCHRONIZEDLYRICSFRAME_H
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
//! ID3v2 synchronized lyrics frame
|
||||||
|
/*!
|
||||||
|
* An implementation of ID3v2 synchronized lyrics.
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT SynchronizedLyricsFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specifies the timestamp format used.
|
||||||
|
*/
|
||||||
|
enum TimestampFormat {
|
||||||
|
//! The timestamp is of unknown format.
|
||||||
|
Unknown = 0x00,
|
||||||
|
//! The timestamp represents the number of MPEG frames since
|
||||||
|
//! the beginning of the audio stream.
|
||||||
|
AbsoluteMpegFrames = 0x01,
|
||||||
|
//! The timestamp represents the number of milliseconds since
|
||||||
|
//! the beginning of the audio stream.
|
||||||
|
AbsoluteMilliseconds = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specifies the type of text contained.
|
||||||
|
*/
|
||||||
|
enum Type {
|
||||||
|
//! The text is some other type of text.
|
||||||
|
Other = 0x00,
|
||||||
|
//! The text contains lyrical data.
|
||||||
|
Lyrics = 0x01,
|
||||||
|
//! The text contains a transcription.
|
||||||
|
TextTranscription = 0x02,
|
||||||
|
//! The text lists the movements in the piece.
|
||||||
|
Movement = 0x03,
|
||||||
|
//! The text describes events that occur.
|
||||||
|
Events = 0x04,
|
||||||
|
//! The text contains chord changes that occur in the music.
|
||||||
|
Chord = 0x05,
|
||||||
|
//! The text contains trivia or "pop up" information about the media.
|
||||||
|
Trivia = 0x06,
|
||||||
|
//! The text contains URLs for relevant webpages.
|
||||||
|
WebpageUrls = 0x07,
|
||||||
|
//! The text contains URLs for relevant images.
|
||||||
|
ImageUrls = 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Single entry of time stamp and lyrics text.
|
||||||
|
*/
|
||||||
|
struct SynchedText {
|
||||||
|
SynchedText(unsigned int ms, String str) : time(ms), text(str) {}
|
||||||
|
unsigned int time;
|
||||||
|
String text;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* List of synchronized lyrics.
|
||||||
|
*/
|
||||||
|
typedef TagLib::List<SynchedText> SynchedTextList;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an empty synchronized lyrics frame that will use the text
|
||||||
|
* encoding \a encoding.
|
||||||
|
*/
|
||||||
|
explicit SynchronizedLyricsFrame(String::Type encoding = String::Latin1);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a synchronized lyrics frame based on the data in \a data.
|
||||||
|
*/
|
||||||
|
explicit SynchronizedLyricsFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this SynchronizedLyricsFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~SynchronizedLyricsFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the description of this synchronized lyrics frame.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding that will be used in rendering this frame.
|
||||||
|
* This defaults to the type that was either specified in the constructor
|
||||||
|
* or read from the frame when parsed.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the language encoding as a 3 byte encoding as specified by
|
||||||
|
* <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a>.
|
||||||
|
*
|
||||||
|
* \note Most taggers simply ignore this value.
|
||||||
|
*
|
||||||
|
* \see setLanguage()
|
||||||
|
*/
|
||||||
|
ByteVector language() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the timestamp format.
|
||||||
|
*/
|
||||||
|
TimestampFormat timestampFormat() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the type of text contained.
|
||||||
|
*/
|
||||||
|
Type type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the description of this synchronized lyrics frame.
|
||||||
|
*
|
||||||
|
* \note Most taggers simply ignore this value.
|
||||||
|
*
|
||||||
|
* \see setDescription()
|
||||||
|
*/
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text with the time stamps.
|
||||||
|
*/
|
||||||
|
SynchedTextList synchedText() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text encoding to be used when rendering this frame to
|
||||||
|
* \a encoding.
|
||||||
|
*
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the language using the 3 byte language code from
|
||||||
|
* <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a> to
|
||||||
|
* \a languageCode.
|
||||||
|
*
|
||||||
|
* \see language()
|
||||||
|
*/
|
||||||
|
void setLanguage(const ByteVector &languageCode);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the timestamp format.
|
||||||
|
*
|
||||||
|
* \see timestampFormat()
|
||||||
|
*/
|
||||||
|
void setTimestampFormat(TimestampFormat f);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set the type of text contained.
|
||||||
|
*
|
||||||
|
* \see type()
|
||||||
|
*/
|
||||||
|
void setType(Type t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the description of the synchronized lyrics frame to \a s.
|
||||||
|
*
|
||||||
|
* \see description()
|
||||||
|
*/
|
||||||
|
void setDescription(const String &s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text with the time stamps.
|
||||||
|
*
|
||||||
|
* \see text()
|
||||||
|
*/
|
||||||
|
void setSynchedText(const SynchedTextList &t);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
SynchronizedLyricsFrame(const ByteVector &data, Header *h);
|
||||||
|
SynchronizedLyricsFrame(const SynchronizedLyricsFrame &);
|
||||||
|
SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame &);
|
||||||
|
|
||||||
|
class SynchronizedLyricsFramePrivate;
|
||||||
|
SynchronizedLyricsFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,260 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2013 by Lukas Krejci
|
||||||
|
email : krejclu6@fel.cvut.cz
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_TABLEOFCONTENTSFRAME
|
||||||
|
#define TAGLIB_TABLEOFCONTENTSFRAME
|
||||||
|
|
||||||
|
#include "id3v2tag.h"
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
|
||||||
|
#include "tbytevectorlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of ID3v2 table of contents frames. Purpose
|
||||||
|
* of this frame is to allow a table of contents to be defined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! An implementation of ID3v2 table of contents frames
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT TableOfContentsFrame : public ID3v2::Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Creates a table of contents frame based on \a data. \a tagHeader is
|
||||||
|
* required as the internal frames are parsed based on the tag version.
|
||||||
|
*/
|
||||||
|
TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a table of contents frame with the element ID \a elementID,
|
||||||
|
* the child elements \a children and embedded frames, which become owned
|
||||||
|
* by this frame, in \a embeddedFrames.
|
||||||
|
*/
|
||||||
|
TableOfContentsFrame(const ByteVector &elementID,
|
||||||
|
const ByteVectorList &children = ByteVectorList(),
|
||||||
|
const FrameList &embeddedFrames = FrameList());
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys the frame.
|
||||||
|
*/
|
||||||
|
~TableOfContentsFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the elementID of the frame. Element ID
|
||||||
|
* is a null terminated string, however it's not human-readable.
|
||||||
|
*
|
||||||
|
* \see setElementID()
|
||||||
|
*/
|
||||||
|
ByteVector elementID() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true, if the frame is top-level (doesn't have
|
||||||
|
* any parent CTOC frame).
|
||||||
|
*
|
||||||
|
* \see setIsTopLevel()
|
||||||
|
*/
|
||||||
|
bool isTopLevel() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true, if the child elements list entries
|
||||||
|
* are ordered.
|
||||||
|
*
|
||||||
|
* \see setIsOrdered()
|
||||||
|
*/
|
||||||
|
bool isOrdered() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns count of child elements of the frame. It always
|
||||||
|
* corresponds to size of child elements list.
|
||||||
|
*
|
||||||
|
* \see childElements()
|
||||||
|
*/
|
||||||
|
unsigned int entryCount() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns list of child elements of the frame.
|
||||||
|
*
|
||||||
|
* \see setChildElements()
|
||||||
|
*/
|
||||||
|
ByteVectorList childElements() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the elementID of the frame to \a eID. If \a eID isn't
|
||||||
|
* null terminated, a null char is appended automatically.
|
||||||
|
*
|
||||||
|
* \see elementID()
|
||||||
|
*/
|
||||||
|
void setElementID(const ByteVector &eID);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets, if the frame is top-level (doesn't have
|
||||||
|
* any parent CTOC frame).
|
||||||
|
*
|
||||||
|
* \see isTopLevel()
|
||||||
|
*/
|
||||||
|
void setIsTopLevel(const bool &t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets, if the child elements list entries
|
||||||
|
* are ordered.
|
||||||
|
*
|
||||||
|
* \see isOrdered()
|
||||||
|
*/
|
||||||
|
void setIsOrdered(const bool &o);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets list of child elements of the frame to \a l.
|
||||||
|
*
|
||||||
|
* \see childElements()
|
||||||
|
*/
|
||||||
|
void setChildElements(const ByteVectorList &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Adds \a cE to list of child elements of the frame.
|
||||||
|
*
|
||||||
|
* \see childElements()
|
||||||
|
*/
|
||||||
|
void addChildElement(const ByteVector &cE);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes \a cE to list of child elements of the frame.
|
||||||
|
*
|
||||||
|
* \see childElements()
|
||||||
|
*/
|
||||||
|
void removeChildElement(const ByteVector &cE);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the frame list map. This is an FrameListMap of
|
||||||
|
* all of the frames embedded in the CTOC frame.
|
||||||
|
*
|
||||||
|
* This is the most convenient structure for accessing the CTOC frame's
|
||||||
|
* embedded frames. Many frame types allow multiple instances of the same
|
||||||
|
* frame type so this is a map of lists. In most cases however there will
|
||||||
|
* only be a single frame of a certain type.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addEmbeddedFrame() and removeEmbeddedFrame().
|
||||||
|
*
|
||||||
|
* \see embeddedFrameList()
|
||||||
|
*/
|
||||||
|
const FrameListMap &embeddedFrameListMap() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the embedded frame list. This is an FrameList
|
||||||
|
* of all of the frames embedded in the CTOC frame in the order that they
|
||||||
|
* were parsed.
|
||||||
|
*
|
||||||
|
* This can be useful if for example you want iterate over the CTOC frame's
|
||||||
|
* embedded frames in the order that they occur in the CTOC frame.
|
||||||
|
*
|
||||||
|
* \warning You should not modify this data structure directly, instead
|
||||||
|
* use addEmbeddedFrame() and removeEmbeddedFrame().
|
||||||
|
*/
|
||||||
|
const FrameList &embeddedFrameList() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the embedded frame list for frames with the id \a frameID
|
||||||
|
* or an empty list if there are no embedded frames of that type. This
|
||||||
|
* is just a convenience and is equivalent to:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* embeddedFrameListMap()[frameID];
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* \see embeddedFrameListMap()
|
||||||
|
*/
|
||||||
|
const FrameList &embeddedFrameList(const ByteVector &frameID) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Add an embedded frame to the CTOC frame. At this point the CTOC frame
|
||||||
|
* takes ownership of the embedded frame and will handle freeing its memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void addEmbeddedFrame(Frame *frame);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove an embedded frame from the CTOC frame. If \a del is true the frame's
|
||||||
|
* memory will be freed; if it is false, it must be deleted by the user.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void removeEmbeddedFrame(Frame *frame, bool del = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Remove all embedded frames of type \a id from the CTOC frame and free their
|
||||||
|
* memory.
|
||||||
|
*
|
||||||
|
* \note Using this method will invalidate any pointers on the list
|
||||||
|
* returned by embeddedFrameList()
|
||||||
|
*/
|
||||||
|
void removeEmbeddedFrames(const ByteVector &id);
|
||||||
|
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* CTOC frames each have a unique element ID. This searches for a CTOC
|
||||||
|
* frame with the element ID \a eID and returns a pointer to it. This
|
||||||
|
* can be used to link together parent and child CTOC frames.
|
||||||
|
*
|
||||||
|
* \see elementID()
|
||||||
|
*/
|
||||||
|
static TableOfContentsFrame *findByElementID(const Tag *tag, const ByteVector &eID);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* CTOC frames each contain a flag that indicates, if CTOC frame is top-level (there isn't
|
||||||
|
* any frame, which contains this frame in its child elements list). Only a single frame
|
||||||
|
* within tag can be top-level. This searches for a top-level CTOC frame.
|
||||||
|
*
|
||||||
|
* \see isTopLevel()
|
||||||
|
*/
|
||||||
|
static TableOfContentsFrame *findTopLevel(const Tag *tag);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h);
|
||||||
|
TableOfContentsFrame(const TableOfContentsFrame &);
|
||||||
|
TableOfContentsFrame &operator=(const TableOfContentsFrame &);
|
||||||
|
|
||||||
|
class TableOfContentsFramePrivate;
|
||||||
|
TableOfContentsFramePrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,201 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_TAG_H
|
||||||
|
#define TAGLIB_TAG_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A simple, generic interface to common audio meta data fields
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an attempt to abstract away the difference in the meta data formats
|
||||||
|
* of various audio codecs and tagging schemes. As such it is generally a
|
||||||
|
* subset of what is available in the specific formats but should be suitable
|
||||||
|
* for most applications. This is meant to compliment the generic APIs found
|
||||||
|
* in TagLib::AudioProperties, TagLib::File and TagLib::FileRef.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PropertyMap;
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT Tag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this Tag instance.
|
||||||
|
*/
|
||||||
|
virtual ~Tag();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exports the tags of the file as dictionary mapping (human readable) tag
|
||||||
|
* names (Strings) to StringLists of tag values.
|
||||||
|
* The default implementation in this class considers only the usual built-in
|
||||||
|
* tags (artist, album, ...) and only one value per key.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties, or a subset of them, from the tag.
|
||||||
|
* The parameter \a properties must contain only entries from
|
||||||
|
* properties().unsupportedData().
|
||||||
|
* BIC: Will become virtual in future releases. Currently the non-virtual
|
||||||
|
* standard implementation of TagLib::Tag does nothing, since there are
|
||||||
|
* no unsupported elements.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList& properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tags of this File to those specified in \a properties. This default
|
||||||
|
* implementation sets only the tags for which setter methods exist in this class
|
||||||
|
* (artist, album, ...), and only one value per key; the rest will be contained
|
||||||
|
* in the returned PropertyMap.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track name; if no track name is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String title() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the artist name; if no artist name is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String artist() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the album name; if no album name is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String album() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track comment; if no comment is present in the tag
|
||||||
|
* String::null will be returned.
|
||||||
|
*/
|
||||||
|
virtual String comment() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the genre name; if no genre is present in the tag String::null
|
||||||
|
* will be returned.
|
||||||
|
*/
|
||||||
|
virtual String genre() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the year; if there is no year set, this will return 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int year() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the track number; if there is no track number set, this will
|
||||||
|
* return 0.
|
||||||
|
*/
|
||||||
|
virtual unsigned int track() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the title to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared.
|
||||||
|
*/
|
||||||
|
virtual void setTitle(const String &s) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the artist to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared.
|
||||||
|
*/
|
||||||
|
virtual void setArtist(const String &s) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the album to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared.
|
||||||
|
*/
|
||||||
|
virtual void setAlbum(const String &s) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the comment to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared.
|
||||||
|
*/
|
||||||
|
virtual void setComment(const String &s) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the genre to \a s. If \a s is String::null then this value will be
|
||||||
|
* cleared. For tag formats that use a fixed set of genres, the appropriate
|
||||||
|
* value will be selected based on a string comparison. A list of available
|
||||||
|
* genres for those formats should be available in that type's
|
||||||
|
* implementation.
|
||||||
|
*/
|
||||||
|
virtual void setGenre(const String &s) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
|
||||||
|
*/
|
||||||
|
virtual void setYear(unsigned int i) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
|
||||||
|
*/
|
||||||
|
virtual void setTrack(unsigned int i) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the tag does not contain any data. This should be
|
||||||
|
* reimplemented in subclasses that provide more than the basic tagging
|
||||||
|
* abilities in this class.
|
||||||
|
*/
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies the generic data from one tag to another.
|
||||||
|
*
|
||||||
|
* \note This will no affect any of the lower level details of the tag. For
|
||||||
|
* instance if any of the tag type specific data (maybe a URL for a band) is
|
||||||
|
* set, this will not modify or copy that. This just copies using the API
|
||||||
|
* in this class.
|
||||||
|
*
|
||||||
|
* If \a overwrite is true then the values will be unconditionally copied.
|
||||||
|
* If false only empty values will be overwritten.
|
||||||
|
*/
|
||||||
|
static void duplicate(const Tag *source, Tag *target, bool overwrite = true);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Construct a Tag. This is protected since tags should only be instantiated
|
||||||
|
* through subclasses.
|
||||||
|
*/
|
||||||
|
Tag();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Tag(const Tag &);
|
||||||
|
Tag &operator=(const Tag &);
|
||||||
|
|
||||||
|
class TagPrivate;
|
||||||
|
TagPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,299 @@
|
||||||
|
/***************************************************************************
|
||||||
|
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
|
||||||
|
|
||||||
|
#if defined(TAGLIB_STATIC)
|
||||||
|
#define TAGLIB_C_EXPORT
|
||||||
|
#elif defined(_WIN32) || defined(_WIN64)
|
||||||
|
#ifdef MAKE_TAGLIB_C_LIB
|
||||||
|
#define TAGLIB_C_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define TAGLIB_C_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
||||||
|
#define TAGLIB_C_EXPORT __attribute__ ((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define TAGLIB_C_EXPORT
|
||||||
|
#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 corresponding 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_set_string_management_enabled(BOOL management);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Explicitly free a string returned from TagLib
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_free(void* pointer);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* File API
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TagLib_File_MPEG,
|
||||||
|
TagLib_File_OggVorbis,
|
||||||
|
TagLib_File_FLAC,
|
||||||
|
TagLib_File_MPC,
|
||||||
|
TagLib_File_OggFlac,
|
||||||
|
TagLib_File_WavPack,
|
||||||
|
TagLib_File_Speex,
|
||||||
|
TagLib_File_TrueAudio,
|
||||||
|
TagLib_File_MP4,
|
||||||
|
TagLib_File_ASF
|
||||||
|
} 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_C_EXPORT 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_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Frees and closes the file.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_file_free(TagLib_File *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is open and readable and valid information for
|
||||||
|
* the Tag and / or AudioProperties was found.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TAGLIB_C_EXPORT BOOL taglib_file_is_valid(const TagLib_File *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the tag associated with this file. This will be freed
|
||||||
|
* automatically when the file is freed.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT TagLib_Tag *taglib_file_tag(const TagLib_File *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the audio properties associated with this file. This
|
||||||
|
* will be freed automatically when the file is freed.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Saves the \a file to disk.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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().
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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().
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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().
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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().
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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().
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT char *taglib_tag_genre(const TagLib_Tag *tag);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the tag's year or 0 if year is not set.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT unsigned int taglib_tag_year(const TagLib_Tag *tag);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the tag's track number or 0 if track number is not set.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT unsigned int taglib_tag_track(const TagLib_Tag *tag);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tag's title.
|
||||||
|
*
|
||||||
|
* \note By default this string should be UTF8 encoded.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tag's year. 0 indicates that this field should be cleared.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Frees all of the strings that have been created by the tag.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT void taglib_tag_free_strings(void);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Audio Properties API
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file in seconds.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the bitrate of the file in kb/s.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the sample rate of the file in Hz.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of channels in the audio stream.
|
||||||
|
*/
|
||||||
|
TAGLIB_C_EXPORT 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TAGLIB_C_EXPORT void taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_Encoding encoding);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* DO_NOT_DOCUMENT */
|
||||||
|
#endif
|
|
@ -0,0 +1,179 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_H
|
||||||
|
#define TAGLIB_H
|
||||||
|
|
||||||
|
#include "taglib_config.h"
|
||||||
|
|
||||||
|
#define TAGLIB_MAJOR_VERSION 1
|
||||||
|
#define TAGLIB_MINOR_VERSION 12
|
||||||
|
#define TAGLIB_PATCH_VERSION 0
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) || defined(__clang__)
|
||||||
|
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")
|
||||||
|
#else
|
||||||
|
#define TAGLIB_IGNORE_MISSING_DESTRUCTOR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||||
|
#define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long long>(x)
|
||||||
|
#else
|
||||||
|
#define TAGLIB_CONSTRUCT_BITSET(x) static_cast<unsigned long>(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __cplusplus >= 201402
|
||||||
|
#define TAGLIB_DEPRECATED [[deprecated]]
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define TAGLIB_DEPRECATED __attribute__((deprecated))
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define TAGLIB_DEPRECATED __declspec(deprecated)
|
||||||
|
#else
|
||||||
|
#define TAGLIB_DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
//! A namespace for all TagLib related classes and functions
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This namespace contains everything in TagLib. For projects working with
|
||||||
|
* TagLib extensively it may be convenient to add a
|
||||||
|
* \code
|
||||||
|
* using namespace TagLib;
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
|
||||||
|
// These integer types are deprecated. Do not use them.
|
||||||
|
|
||||||
|
typedef wchar_t wchar; // Assumed to be sufficient to store a UTF-16 char.
|
||||||
|
typedef unsigned char uchar;
|
||||||
|
typedef unsigned short ushort;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
typedef unsigned long ulong;
|
||||||
|
typedef unsigned long long ulonglong;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3)
|
||||||
|
* so I'm providing something here that should be constant.
|
||||||
|
*/
|
||||||
|
typedef std::basic_string<wchar_t> wstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \mainpage TagLib
|
||||||
|
*
|
||||||
|
* \section intro Introduction
|
||||||
|
*
|
||||||
|
* TagLib is a library for reading and editing audio meta data, commonly know as \e tags.
|
||||||
|
*
|
||||||
|
* Features:
|
||||||
|
* - A clean, high level, C++ API to handling audio meta data.
|
||||||
|
* - Format specific APIs for advanced API users.
|
||||||
|
* - ID3v1, ID3v2, APE, FLAC, Xiph, iTunes-style MP4 and WMA tag formats.
|
||||||
|
* - MP3, MPC, FLAC, MP4, ASF, AIFF, WAV, TrueAudio, WavPack, Ogg FLAC, Ogg Vorbis, Speex and Opus file formats.
|
||||||
|
* - Basic audio file properties such as length, sample rate, etc.
|
||||||
|
* - Long term binary and source compatibility.
|
||||||
|
* - Extensible design, notably the ability to add other formats or extend current formats as a library user.
|
||||||
|
* - Full support for unicode and internationalized tags.
|
||||||
|
* - Dual <a href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL</a> and
|
||||||
|
* <a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</a> licenses.
|
||||||
|
* - No external toolkit dependencies.
|
||||||
|
*
|
||||||
|
* \section why Why TagLib?
|
||||||
|
*
|
||||||
|
* TagLib originally was written to provide an updated and improved ID3v2 implementation in C++ for use
|
||||||
|
* in a variety of Open Source projects. Since development began in 2002 and the 1.0 release in 2004
|
||||||
|
* it has expanded to cover a wide variety of tag and file formats and is used in a wide variety of
|
||||||
|
* Open Source and proprietary applications. It now supports a variety of UNIXes, including Apple's OS
|
||||||
|
* X, as well as Microsoft Windows.
|
||||||
|
*
|
||||||
|
* \section commercial Usage in Commercial Applications
|
||||||
|
*
|
||||||
|
* TagLib's licenses \e do allow usage within propriety (\e closed) applications, however TagLib is \e not
|
||||||
|
* public domain. Please note the requirements of the LGPL or MPL, and adhere to at least one of them.
|
||||||
|
* In simple terms, you must at a minimum note your usage of TagLib, note the licensing terms of TagLib and
|
||||||
|
* if you make changes to TagLib publish them. Please review the licenses above before using TagLib in your
|
||||||
|
* software. Note that you may choose either the MPL or the LGPL, you do not have to fulfill the
|
||||||
|
* requirements of both.
|
||||||
|
*
|
||||||
|
* \section installing Installing TagLib
|
||||||
|
*
|
||||||
|
* Please see the <a href="http://taglib.org/">TagLib website</a> for the latest
|
||||||
|
* downloads.
|
||||||
|
*
|
||||||
|
* TagLib can be built using the CMake build system. TagLib installs a taglib-config and pkg-config file to
|
||||||
|
* make it easier to integrate into various build systems. Note that TagLib's include install directory \e must
|
||||||
|
* be included in the header include path. Simply adding <taglib/tag.h> will \e not work.
|
||||||
|
*
|
||||||
|
* \section start Getting Started
|
||||||
|
*
|
||||||
|
* TagLib provides both simple, abstract APIs which make it possible to ignore the differences between tagging
|
||||||
|
* formats and format specific APIs which allow programmers to work with the features of specific tagging
|
||||||
|
* schemes. There is a similar abstraction mechanism for AudioProperties.
|
||||||
|
*
|
||||||
|
* The best place to start is with the <b>Class Hierarchy</b> linked at the top of the page. The File and
|
||||||
|
* AudioProperties classes and their subclasses are the core of TagLib. The FileRef class is also a convenient
|
||||||
|
* way for using a value-based handle.
|
||||||
|
*
|
||||||
|
* \note When working with FileRef please consider that it has only the most basic (extension-based) file
|
||||||
|
* type resolution. Please see its documentation on how to plug in more advanced file type resolution. (Such
|
||||||
|
* resolution may be part of later TagLib releases by default.)
|
||||||
|
*
|
||||||
|
* Here's a very simple example with TagLib:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
*
|
||||||
|
* TagLib::FileRef f("Latex Solar Beef.mp3");
|
||||||
|
* TagLib::String artist = f.tag()->artist(); // artist == "Frank Zappa"
|
||||||
|
*
|
||||||
|
* f.tag()->setAlbum("Fillmore East");
|
||||||
|
* f.save();
|
||||||
|
*
|
||||||
|
* TagLib::FileRef g("Free City Rhymes.ogg");
|
||||||
|
* TagLib::String album = g.tag()->album(); // album == "NYC Ghosts & Flowers"
|
||||||
|
*
|
||||||
|
* g.tag()->setTrack(1);
|
||||||
|
* g.save();
|
||||||
|
*
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* More examples can be found in the \e examples directory of the source distribution.
|
||||||
|
*
|
||||||
|
* \section Contact
|
||||||
|
*
|
||||||
|
* Questions about TagLib should be directed to the TagLib mailing list, not directly to the author.
|
||||||
|
*
|
||||||
|
* - <a href="http://taglib.org/">TagLib Homepage</a>
|
||||||
|
* - <a href="https://mail.kde.org/mailman/listinfo/taglib-devel">TagLib Mailing List (taglib-devel@kde.org)</a>
|
||||||
|
*
|
||||||
|
* \author <a href="https://github.com/taglib/taglib/blob/master/AUTHORS">TagLib authors</a>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* taglib_config.h. Generated by cmake from taglib_config.h.cmake */
|
||||||
|
|
||||||
|
#ifndef TAGLIB_TAGLIB_CONFIG_H
|
||||||
|
#define TAGLIB_TAGLIB_CONFIG_H
|
||||||
|
|
||||||
|
/* These values are no longer used. This file is present only for compatibility reasons. */
|
||||||
|
|
||||||
|
#define TAGLIB_WITH_ASF 1
|
||||||
|
#define TAGLIB_WITH_MP4 1
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,43 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_EXPORT_H
|
||||||
|
#define TAGLIB_EXPORT_H
|
||||||
|
|
||||||
|
#if defined(TAGLIB_STATIC)
|
||||||
|
#define TAGLIB_EXPORT
|
||||||
|
#elif (defined(_WIN32) || defined(_WIN64))
|
||||||
|
#ifdef MAKE_TAGLIB_LIB
|
||||||
|
#define TAGLIB_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define TAGLIB_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
||||||
|
#define TAGLIB_EXPORT __attribute__ ((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define TAGLIB_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,635 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_BYTEVECTOR_H
|
||||||
|
#define TAGLIB_BYTEVECTOR_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A byte vector
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class provides a byte vector with some methods that are useful for
|
||||||
|
* tagging purposes. Many of the search functions are tailored to what is
|
||||||
|
* useful for finding tag related patterns in a data array.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT ByteVector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
typedef std::vector<char>::iterator Iterator;
|
||||||
|
typedef std::vector<char>::const_iterator ConstIterator;
|
||||||
|
typedef std::vector<char>::reverse_iterator ReverseIterator;
|
||||||
|
typedef std::vector<char>::const_reverse_iterator ConstReverseIterator;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty byte vector.
|
||||||
|
*/
|
||||||
|
ByteVector();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a vector of size \a size with all values set to \a value by
|
||||||
|
* default.
|
||||||
|
*/
|
||||||
|
ByteVector(unsigned int size, char value = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a byte vector that is a copy of \a v.
|
||||||
|
*/
|
||||||
|
ByteVector(const ByteVector &v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a byte vector that is a copy of \a v.
|
||||||
|
*/
|
||||||
|
ByteVector(const ByteVector &v, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a byte vector that contains \a c.
|
||||||
|
*/
|
||||||
|
ByteVector(char c);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a byte vector that copies \a data for up to \a length bytes.
|
||||||
|
*/
|
||||||
|
ByteVector(const char *data, unsigned int length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a byte vector that copies \a data up to the first null
|
||||||
|
* byte. This is particularly useful for constructing byte arrays from
|
||||||
|
* string constants.
|
||||||
|
*
|
||||||
|
* \warning The behavior is undefined if \a data is not null terminated.
|
||||||
|
*/
|
||||||
|
ByteVector(const char *data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this ByteVector instance.
|
||||||
|
*/
|
||||||
|
virtual ~ByteVector();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the byte array using the first \a length bytes of \a data
|
||||||
|
*/
|
||||||
|
ByteVector &setData(const char *data, unsigned int length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the data for the byte array copies \a data up to the first null
|
||||||
|
* byte. The behavior is undefined if \a data is not null terminated.
|
||||||
|
*/
|
||||||
|
ByteVector &setData(const char *data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the internal data structure.
|
||||||
|
*
|
||||||
|
* \warning Care should be taken when modifying this data structure as it is
|
||||||
|
* easy to corrupt the ByteVector when doing so. Specifically, while the
|
||||||
|
* data may be changed, its length may not be.
|
||||||
|
*/
|
||||||
|
char *data();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to the internal data structure which may not be modified.
|
||||||
|
*/
|
||||||
|
const char *data() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a byte vector made up of the bytes starting at \a index and
|
||||||
|
* for \a length bytes. If \a length is not specified it will return the bytes
|
||||||
|
* from \a index to the end of the vector.
|
||||||
|
*/
|
||||||
|
ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This essentially performs the same as operator[](), but instead of causing
|
||||||
|
* a runtime error if the index is out of bounds, it will return a null byte.
|
||||||
|
*/
|
||||||
|
char at(unsigned int index) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Searches the ByteVector for \a pattern starting at \a offset and returns
|
||||||
|
* the offset. Returns -1 if the pattern was not found. If \a byteAlign is
|
||||||
|
* specified the pattern will only be matched if it starts on a byte divisible
|
||||||
|
* by \a byteAlign (starting from \a offset).
|
||||||
|
*/
|
||||||
|
int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Searches the char for \a c starting at \a offset and returns
|
||||||
|
* the offset. Returns \a -1 if the pattern was not found. If \a byteAlign is
|
||||||
|
* specified the pattern will only be matched if it starts on a byte divisible
|
||||||
|
* by \a byteAlign (starting from \a offset).
|
||||||
|
*/
|
||||||
|
int find(char c, unsigned int offset = 0, int byteAlign = 1) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Searches the ByteVector for \a pattern starting from either the end of the
|
||||||
|
* vector or \a offset and returns the offset. Returns -1 if the pattern was
|
||||||
|
* not found. If \a byteAlign is specified the pattern will only be matched
|
||||||
|
* if it starts on a byte divisible by \a byteAlign (starting from \a offset).
|
||||||
|
*/
|
||||||
|
int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks to see if the vector contains the \a pattern starting at position
|
||||||
|
* \a offset. Optionally, if you only want to search for part of the pattern
|
||||||
|
* you can specify an offset within the pattern to start from. Also, you can
|
||||||
|
* specify to only check for the first \a patternLength bytes of \a pattern with
|
||||||
|
* the \a patternLength argument.
|
||||||
|
*/
|
||||||
|
bool containsAt(const ByteVector &pattern, unsigned int offset,
|
||||||
|
unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the vector starts with \a pattern.
|
||||||
|
*/
|
||||||
|
bool startsWith(const ByteVector &pattern) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the vector ends with \a pattern.
|
||||||
|
*/
|
||||||
|
bool endsWith(const ByteVector &pattern) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Replaces \a oldByte with \a newByte and returns a reference to the
|
||||||
|
* ByteVector after the operation. This \e does modify the vector.
|
||||||
|
*/
|
||||||
|
ByteVector &replace(char oldByte, char newByte);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Replaces \a pattern with \a with and returns a reference to the ByteVector
|
||||||
|
* after the operation. This \e does modify the vector.
|
||||||
|
*/
|
||||||
|
ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Checks for a partial match of \a pattern at the end of the vector. It
|
||||||
|
* returns the offset of the partial match within the vector, or -1 if the
|
||||||
|
* pattern is not found. This method is particularly useful when searching for
|
||||||
|
* patterns that start in one vector and end in another. When combined with
|
||||||
|
* startsWith() it can be used to find a pattern that overlaps two buffers.
|
||||||
|
*
|
||||||
|
* \note This will not match the complete pattern at the end of the string; use
|
||||||
|
* endsWith() for that.
|
||||||
|
*/
|
||||||
|
int endsWithPartialMatch(const ByteVector &pattern) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends \a v to the end of the ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector &append(const ByteVector &v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends \a c to the end of the ByteVector.
|
||||||
|
*/
|
||||||
|
ByteVector &append(char c);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Clears the data.
|
||||||
|
*/
|
||||||
|
ByteVector &clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the size of the array.
|
||||||
|
*/
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Resize the vector to \a size. If the vector is currently less than
|
||||||
|
* \a size, pad the remaining spaces with \a padding. Returns a reference
|
||||||
|
* to the resized vector.
|
||||||
|
*/
|
||||||
|
ByteVector &resize(unsigned int size, char padding = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an Iterator that points to the front of the vector.
|
||||||
|
*/
|
||||||
|
Iterator begin();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ConstIterator that points to the front of the vector.
|
||||||
|
*/
|
||||||
|
ConstIterator begin() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an Iterator that points to the back of the vector.
|
||||||
|
*/
|
||||||
|
Iterator end();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ConstIterator that points to the back of the vector.
|
||||||
|
*/
|
||||||
|
ConstIterator end() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ReverseIterator that points to the front of the vector.
|
||||||
|
*/
|
||||||
|
ReverseIterator rbegin();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ConstReverseIterator that points to the front of the vector.
|
||||||
|
*/
|
||||||
|
ConstReverseIterator rbegin() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ReverseIterator that points to the back of the vector.
|
||||||
|
*/
|
||||||
|
ReverseIterator rend();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ConstReverseIterator that points to the back of the vector.
|
||||||
|
*/
|
||||||
|
ConstReverseIterator rend() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the vector is null.
|
||||||
|
*
|
||||||
|
* \note A vector may be empty without being null. So do not use this
|
||||||
|
* method to check if the vector is empty.
|
||||||
|
*
|
||||||
|
* \see isEmpty()
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
TAGLIB_DEPRECATED bool isNull() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the ByteVector is empty.
|
||||||
|
*
|
||||||
|
* \see size()
|
||||||
|
* \see isNull()
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a CRC checksum of the byte vector's data.
|
||||||
|
*
|
||||||
|
* \note This uses an uncommon variant of CRC32 specializes in Ogg.
|
||||||
|
*/
|
||||||
|
// BIC: Remove or make generic.
|
||||||
|
unsigned int checksum() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the first 4 bytes of the vector to an unsigned integer.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $00 $00 $01 == 0x00000001 == 1, if false, $01 00 00 00 ==
|
||||||
|
* 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromUInt()
|
||||||
|
*/
|
||||||
|
unsigned int toUInt(bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the 4 bytes at \a offset of the vector to an unsigned integer.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $00 $00 $01 == 0x00000001 == 1, if false, $01 00 00 00 ==
|
||||||
|
* 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromUInt()
|
||||||
|
*/
|
||||||
|
unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the \a length bytes at \a offset of the vector to an unsigned
|
||||||
|
* integer. If \a length is larger than 4, the excess is ignored.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $00 $00 $01 == 0x00000001 == 1, if false, $01 00 00 00 ==
|
||||||
|
* 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromUInt()
|
||||||
|
*/
|
||||||
|
unsigned int toUInt(unsigned int offset, unsigned int length,
|
||||||
|
bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the first 2 bytes of the vector to a (signed) short.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromShort()
|
||||||
|
*/
|
||||||
|
short toShort(bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the 2 bytes at \a offset of the vector to a (signed) short.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromShort()
|
||||||
|
*/
|
||||||
|
short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the first 2 bytes of the vector to a unsigned short.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromShort()
|
||||||
|
*/
|
||||||
|
unsigned short toUShort(bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the 2 bytes at \a offset of the vector to a unsigned short.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromShort()
|
||||||
|
*/
|
||||||
|
unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the first 8 bytes of the vector to a (signed) long long.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 00 00 00 00 00 00 01 == 0x0000000000000001 == 1,
|
||||||
|
* if false, $01 00 00 00 00 00 00 00 == 0x0100000000000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromUInt()
|
||||||
|
*/
|
||||||
|
long long toLongLong(bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Converts the 8 bytes at \a offset of the vector to a (signed) long long.
|
||||||
|
*
|
||||||
|
* If \a mostSignificantByteFirst is true this will operate left to right
|
||||||
|
* evaluating the integer. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 00 00 00 00 00 00 01 == 0x0000000000000001 == 1,
|
||||||
|
* if false, $01 00 00 00 00 00 00 00 == 0x0100000000000000 == 1.
|
||||||
|
*
|
||||||
|
* \see fromUInt()
|
||||||
|
*/
|
||||||
|
long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 4 bytes at \a offset of the vector to a float as an IEEE754
|
||||||
|
* 32-bit little-endian floating point number.
|
||||||
|
*/
|
||||||
|
float toFloat32LE(size_t offset) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 4 bytes at \a offset of the vector to a float as an IEEE754
|
||||||
|
* 32-bit big-endian floating point number.
|
||||||
|
*/
|
||||||
|
float toFloat32BE(size_t offset) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 8 bytes at \a offset of the vector to a double as an IEEE754
|
||||||
|
* 64-bit little-endian floating point number.
|
||||||
|
*/
|
||||||
|
double toFloat64LE(size_t offset) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 8 bytes at \a offset of the vector to a double as an IEEE754
|
||||||
|
* 64-bit big-endian floating point number.
|
||||||
|
*/
|
||||||
|
double toFloat64BE(size_t offset) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 10 bytes at \a offset of the vector to a long double as an
|
||||||
|
* IEEE754 80-bit little-endian floating point number.
|
||||||
|
*
|
||||||
|
* \note This may compromise the precision depends on the size of long double.
|
||||||
|
*/
|
||||||
|
long double toFloat80LE(size_t offset) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the 10 bytes at \a offset of the vector to a long double as an
|
||||||
|
* IEEE754 80-bit big-endian floating point number.
|
||||||
|
*
|
||||||
|
* \note This may compromise the precision depends on the size of long double.
|
||||||
|
*/
|
||||||
|
long double toFloat80BE(size_t offset) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 4 byte ByteVector based on \a value. If
|
||||||
|
* \a mostSignificantByteFirst is true, then this will operate left to right
|
||||||
|
* in building the ByteVector. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 00 00 01 == 0x00000001 == 1, if false, $01 00 00 00 ==
|
||||||
|
* 0x01000000 == 1.
|
||||||
|
*
|
||||||
|
* \see toUInt()
|
||||||
|
*/
|
||||||
|
static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 2 byte ByteVector based on \a value. If
|
||||||
|
* \a mostSignificantByteFirst is true, then this will operate left to right
|
||||||
|
* in building the ByteVector. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 01 == 0x0001 == 1, if false, $01 00 == 0x0100 == 1.
|
||||||
|
*
|
||||||
|
* \see toShort()
|
||||||
|
*/
|
||||||
|
static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 8 byte ByteVector based on \a value. If
|
||||||
|
* \a mostSignificantByteFirst is true, then this will operate left to right
|
||||||
|
* in building the ByteVector. For example if \a mostSignificantByteFirst is
|
||||||
|
* true then $00 00 00 01 == 0x0000000000000001 == 1, if false,
|
||||||
|
* $01 00 00 00 00 00 00 00 == 0x0100000000000000 == 1.
|
||||||
|
*
|
||||||
|
* \see toLongLong()
|
||||||
|
*/
|
||||||
|
static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 4 byte ByteVector based on \a value as an IEEE754 32-bit
|
||||||
|
* little-endian floating point number.
|
||||||
|
*
|
||||||
|
* \see fromFloat32BE()
|
||||||
|
*/
|
||||||
|
static ByteVector fromFloat32LE(float value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 4 byte ByteVector based on \a value as an IEEE754 32-bit
|
||||||
|
* big-endian floating point number.
|
||||||
|
*
|
||||||
|
* \see fromFloat32LE()
|
||||||
|
*/
|
||||||
|
static ByteVector fromFloat32BE(float value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 8 byte ByteVector based on \a value as an IEEE754 64-bit
|
||||||
|
* little-endian floating point number.
|
||||||
|
*
|
||||||
|
* \see fromFloat64BE()
|
||||||
|
*/
|
||||||
|
static ByteVector fromFloat64LE(double value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a 8 byte ByteVector based on \a value as an IEEE754 64-bit
|
||||||
|
* big-endian floating point number.
|
||||||
|
*
|
||||||
|
* \see fromFloat64LE()
|
||||||
|
*/
|
||||||
|
static ByteVector fromFloat64BE(double value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a ByteVector based on the CString \a s.
|
||||||
|
*/
|
||||||
|
static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a const reference to the byte at \a index.
|
||||||
|
*/
|
||||||
|
const char &operator[](int index) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the byte at \a index.
|
||||||
|
*/
|
||||||
|
char &operator[](int index);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector and \a v are equal.
|
||||||
|
*/
|
||||||
|
bool operator==(const ByteVector &v) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector and \a v are not equal.
|
||||||
|
*/
|
||||||
|
bool operator!=(const ByteVector &v) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector and the null terminated C string \a s
|
||||||
|
* contain the same data.
|
||||||
|
*/
|
||||||
|
bool operator==(const char *s) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector and the null terminated C string \a s
|
||||||
|
* do not contain the same data.
|
||||||
|
*/
|
||||||
|
bool operator!=(const char *s) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector is less than \a v. The value of the
|
||||||
|
* vectors is determined by evaluating the character from left to right, and
|
||||||
|
* in the event one vector is a superset of the other, the size is used.
|
||||||
|
*/
|
||||||
|
bool operator<(const ByteVector &v) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this ByteVector is greater than \a v.
|
||||||
|
*/
|
||||||
|
bool operator>(const ByteVector &v) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a vector that is \a v appended to this vector.
|
||||||
|
*/
|
||||||
|
ByteVector operator+(const ByteVector &v) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies ByteVector \a v.
|
||||||
|
*/
|
||||||
|
ByteVector &operator=(const ByteVector &v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies a byte \a c.
|
||||||
|
*/
|
||||||
|
ByteVector &operator=(char c);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Copies \a data up to the first null byte.
|
||||||
|
*
|
||||||
|
* \warning The behavior is undefined if \a data is not null terminated.
|
||||||
|
*/
|
||||||
|
ByteVector &operator=(const char *data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of the ByteVector by the content of \a v.
|
||||||
|
*/
|
||||||
|
void swap(ByteVector &v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A static, empty ByteVector which is convenient and fast (since returning
|
||||||
|
* an empty or "null" value does not require instantiating a new ByteVector).
|
||||||
|
*
|
||||||
|
* \warning Do not modify this variable. It will mess up the internal state
|
||||||
|
* of TagLib.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
// BIC: remove
|
||||||
|
TAGLIB_DEPRECATED static ByteVector null;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a hex-encoded copy of the byte vector.
|
||||||
|
*/
|
||||||
|
ByteVector toHex() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a base64 encoded copy of the byte vector
|
||||||
|
*/
|
||||||
|
ByteVector toBase64() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Decodes the base64 encoded byte vector.
|
||||||
|
*/
|
||||||
|
static ByteVector fromBase64(const ByteVector &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*
|
||||||
|
* If this ByteVector is being shared via implicit sharing, do a deep copy
|
||||||
|
* of the data and separate from the shared members. This should be called
|
||||||
|
* by all non-const subclass members.
|
||||||
|
*/
|
||||||
|
void detach();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ByteVectorPrivate;
|
||||||
|
ByteVectorPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \relates TagLib::ByteVector
|
||||||
|
* Streams the ByteVector \a v to the output stream \a s.
|
||||||
|
*/
|
||||||
|
TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,91 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_BYTEVECTORLIST_H
|
||||||
|
#define TAGLIB_BYTEVECTORLIST_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A list of ByteVectors
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A List specialization with some handy features useful for ByteVectors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT ByteVectorList : public List<ByteVector>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct an empty ByteVectorList.
|
||||||
|
*/
|
||||||
|
ByteVectorList();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this ByteVectorList instance.
|
||||||
|
*/
|
||||||
|
virtual ~ByteVectorList();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a shallow, implicitly shared, copy of \a l. Because this is
|
||||||
|
* implicitly shared, this method is lightweight and suitable for
|
||||||
|
* pass-by-value usage.
|
||||||
|
*/
|
||||||
|
ByteVectorList(const ByteVectorList &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Convert the ByteVectorList to a ByteVector separated by \a separator. By
|
||||||
|
* default a space is used.
|
||||||
|
*/
|
||||||
|
ByteVector toByteVector(const ByteVector &separator = " ") const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Splits the ByteVector \a v into several strings at \a pattern. This will
|
||||||
|
* not include the pattern in the returned ByteVectors.
|
||||||
|
*/
|
||||||
|
static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
|
||||||
|
int byteAlign = 1);
|
||||||
|
/*!
|
||||||
|
* Splits the ByteVector \a v into several strings at \a pattern. This will
|
||||||
|
* not include the pattern in the returned ByteVectors. \a max is the
|
||||||
|
* maximum number of entries that will be separated. If \a max for instance
|
||||||
|
* is 2 then a maximum of 1 match will be found and the vector will be split
|
||||||
|
* on that match.
|
||||||
|
*/
|
||||||
|
// BIC: merge with the function above
|
||||||
|
static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
|
||||||
|
int byteAlign, int max);
|
||||||
|
private:
|
||||||
|
class ByteVectorListPrivate;
|
||||||
|
ByteVectorListPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,145 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Lukas Lalinsky
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_BYTEVECTORSTREAM_H
|
||||||
|
#define TAGLIB_BYTEVECTORSTREAM_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tiostream.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
class Tag;
|
||||||
|
class AudioProperties;
|
||||||
|
|
||||||
|
//! In-memory Stream class using ByteVector for its storage.
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT ByteVectorStream : public IOStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct a File object and opens the \a file. \a file should be a
|
||||||
|
* be a C-string in the local file system encoding.
|
||||||
|
*/
|
||||||
|
ByteVectorStream(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this ByteVectorStream instance.
|
||||||
|
*/
|
||||||
|
virtual ~ByteVectorStream();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the file name in the local file system encoding.
|
||||||
|
*/
|
||||||
|
FileName name() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads a block of size \a length at the current get pointer.
|
||||||
|
*/
|
||||||
|
ByteVector readBlock(unsigned long length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempts to write the block \a data at the current get pointer. If the
|
||||||
|
* file is currently only opened read only -- i.e. readOnly() returns true --
|
||||||
|
* this attempts to reopen the file in read/write mode.
|
||||||
|
*
|
||||||
|
* \note This should be used instead of using the streaming output operator
|
||||||
|
* for a ByteVector. And even this function is significantly slower than
|
||||||
|
* doing output with a char[].
|
||||||
|
*/
|
||||||
|
void writeBlock(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Insert \a data at position \a start in the file overwriting \a replace
|
||||||
|
* bytes of the original content.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it requires rewriting all of the file
|
||||||
|
* after the insertion point.
|
||||||
|
*/
|
||||||
|
void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes a block of the file starting a \a start and continuing for
|
||||||
|
* \a length bytes.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it involves rewriting all of the file
|
||||||
|
* after the removed portion.
|
||||||
|
*/
|
||||||
|
void removeBlock(unsigned long start = 0, unsigned long length = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is read only (or if the file can not be opened).
|
||||||
|
*/
|
||||||
|
bool readOnly() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Since the file can currently only be opened as an argument to the
|
||||||
|
* constructor (sort-of by design), this returns if that open succeeded.
|
||||||
|
*/
|
||||||
|
bool isOpen() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Move the I/O pointer to \a offset in the file from position \a p. This
|
||||||
|
* defaults to seeking from the beginning of the file.
|
||||||
|
*
|
||||||
|
* \see Position
|
||||||
|
*/
|
||||||
|
void seek(long offset, Position p = Beginning);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reset the end-of-file and error flags on the file.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current offset within the file.
|
||||||
|
*/
|
||||||
|
long tell() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file.
|
||||||
|
*/
|
||||||
|
long length();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Truncates the file to a \a length.
|
||||||
|
*/
|
||||||
|
void truncate(long length);
|
||||||
|
|
||||||
|
ByteVector *data();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ByteVectorStreamPrivate;
|
||||||
|
ByteVectorStreamPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,74 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2013 by Tsuda Kageyu
|
||||||
|
email : tsuda.kageyu@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_DEBUGLISTENER_H
|
||||||
|
#define TAGLIB_DEBUGLISTENER_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
|
||||||
|
namespace TagLib
|
||||||
|
{
|
||||||
|
//! An abstraction for the listener to the debug messages.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class enables you to handle the debug messages in your preferred
|
||||||
|
* way by subclassing this class, reimplementing printMessage() and setting
|
||||||
|
* your reimplementation as the default with setDebugListener().
|
||||||
|
*
|
||||||
|
* \see setDebugListener()
|
||||||
|
*/
|
||||||
|
class TAGLIB_EXPORT DebugListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DebugListener();
|
||||||
|
virtual ~DebugListener();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* When overridden in a derived class, redirects \a msg to your preferred
|
||||||
|
* channel such as stderr, Windows debugger or so forth.
|
||||||
|
*/
|
||||||
|
virtual void printMessage(const String &msg) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Noncopyable
|
||||||
|
DebugListener(const DebugListener &);
|
||||||
|
DebugListener &operator=(const DebugListener &);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the listener that decides how the debug messages are redirected.
|
||||||
|
* If the parameter \a listener is null, the previous listener is released
|
||||||
|
* and default stderr listener is restored.
|
||||||
|
*
|
||||||
|
* \note The caller is responsible for deleting the previous listener
|
||||||
|
* as needed after it is released.
|
||||||
|
*
|
||||||
|
* \see DebugListener
|
||||||
|
*/
|
||||||
|
TAGLIB_EXPORT void setDebugListener(DebugListener *listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,313 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_TEXTIDENTIFICATIONFRAME_H
|
||||||
|
#define TAGLIB_TEXTIDENTIFICATIONFRAME_H
|
||||||
|
|
||||||
|
#include "tstringlist.h"
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
#include "id3v2frame.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
namespace ID3v2 {
|
||||||
|
|
||||||
|
class Tag;
|
||||||
|
typedef Map<String, String> KeyConversionMap;
|
||||||
|
|
||||||
|
//! An ID3v2 text identification frame implementation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is an implementation of the most common type of ID3v2 frame -- text
|
||||||
|
* identification frames. There are a number of variations on this. Those
|
||||||
|
* enumerated in the ID3v2.4 standard are:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li><b>TALB</b> Album/Movie/Show title</li>
|
||||||
|
* <li><b>TBPM</b> BPM (beats per minute)</li>
|
||||||
|
* <li><b>TCOM</b> Composer</li>
|
||||||
|
* <li><b>TCON</b> Content type</li>
|
||||||
|
* <li><b>TCOP</b> Copyright message</li>
|
||||||
|
* <li><b>TDEN</b> Encoding time</li>
|
||||||
|
* <li><b>TDLY</b> Playlist delay</li>
|
||||||
|
* <li><b>TDOR</b> Original release time</li>
|
||||||
|
* <li><b>TDRC</b> Recording time</li>
|
||||||
|
* <li><b>TDRL</b> Release time</li>
|
||||||
|
* <li><b>TDTG</b> Tagging time</li>
|
||||||
|
* <li><b>TENC</b> Encoded by</li>
|
||||||
|
* <li><b>TEXT</b> Lyricist/Text writer</li>
|
||||||
|
* <li><b>TFLT</b> File type</li>
|
||||||
|
* <li><b>TIPL</b> Involved people list</li>
|
||||||
|
* <li><b>TIT1</b> Content group description</li>
|
||||||
|
* <li><b>TIT2</b> Title/songname/content description</li>
|
||||||
|
* <li><b>TIT3</b> Subtitle/Description refinement</li>
|
||||||
|
* <li><b>TKEY</b> Initial key</li>
|
||||||
|
* <li><b>TLAN</b> Language(s)</li>
|
||||||
|
* <li><b>TLEN</b> Length</li>
|
||||||
|
* <li><b>TMCL</b> Musician credits list</li>
|
||||||
|
* <li><b>TMED</b> Media type</li>
|
||||||
|
* <li><b>TMOO</b> Mood</li>
|
||||||
|
* <li><b>TOAL</b> Original album/movie/show title</li>
|
||||||
|
* <li><b>TOFN</b> Original filename</li>
|
||||||
|
* <li><b>TOLY</b> Original lyricist(s)/text writer(s)</li>
|
||||||
|
* <li><b>TOPE</b> Original artist(s)/performer(s)</li>
|
||||||
|
* <li><b>TOWN</b> File owner/licensee</li>
|
||||||
|
* <li><b>TPE1</b> Lead performer(s)/Soloist(s)</li>
|
||||||
|
* <li><b>TPE2</b> Band/orchestra/accompaniment</li>
|
||||||
|
* <li><b>TPE3</b> Conductor/performer refinement</li>
|
||||||
|
* <li><b>TPE4</b> Interpreted, remixed, or otherwise modified by</li>
|
||||||
|
* <li><b>TPOS</b> Part of a set</li>
|
||||||
|
* <li><b>TPRO</b> Produced notice</li>
|
||||||
|
* <li><b>TPUB</b> Publisher</li>
|
||||||
|
* <li><b>TRCK</b> Track number/Position in set</li>
|
||||||
|
* <li><b>TRSN</b> Internet radio station name</li>
|
||||||
|
* <li><b>TRSO</b> Internet radio station owner</li>
|
||||||
|
* <li><b>TSOA</b> Album sort order</li>
|
||||||
|
* <li><b>TSOP</b> Performer sort order</li>
|
||||||
|
* <li><b>TSOT</b> Title sort order</li>
|
||||||
|
* <li><b>TSRC</b> ISRC (international standard recording code)</li>
|
||||||
|
* <li><b>TSSE</b> Software/Hardware and settings used for encoding</li>
|
||||||
|
* <li><b>TSST</b> Set subtitle</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* The ID3v2 Frames document gives a description of each of these formats
|
||||||
|
* and the expected order of strings in each. ID3v2::Header::frameID() can
|
||||||
|
* be used to determine the frame type.
|
||||||
|
*
|
||||||
|
* \note If non-Latin1 compatible strings are used with this class, even if
|
||||||
|
* the text encoding is set to Latin1, the frame will be written using UTF8
|
||||||
|
* (with the encoding flag appropriately set in the output).
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT TextIdentificationFrame : public Frame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct an empty frame of type \a type. Uses \a encoding as the
|
||||||
|
* default text encoding.
|
||||||
|
*
|
||||||
|
* \note In this case you must specify the text encoding as it
|
||||||
|
* resolves the ambiguity between constructors.
|
||||||
|
*
|
||||||
|
* \note Please see the note in the class description regarding Latin1.
|
||||||
|
*/
|
||||||
|
TextIdentificationFrame(const ByteVector &type, String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is a dual purpose constructor. \a data can either be binary data
|
||||||
|
* that should be parsed or (at a minimum) the frame ID.
|
||||||
|
*/
|
||||||
|
explicit TextIdentificationFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is a special factory method to create a TIPL (involved people list)
|
||||||
|
* frame from the given \a properties. Will parse key=[list of values] data
|
||||||
|
* into the TIPL format as specified in the ID3 standard.
|
||||||
|
*/
|
||||||
|
static TextIdentificationFrame *createTIPLFrame(const PropertyMap &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is a special factory method to create a TMCL (musician credits list)
|
||||||
|
* frame from the given \a properties. Will parse key=[list of values] data
|
||||||
|
* into the TMCL format as specified in the ID3 standard, where key should be
|
||||||
|
* of the form instrumentPrefix:instrument.
|
||||||
|
*/
|
||||||
|
static TextIdentificationFrame *createTMCLFrame(const PropertyMap &properties);
|
||||||
|
/*!
|
||||||
|
* Destroys this TextIdentificationFrame instance.
|
||||||
|
*/
|
||||||
|
virtual ~TextIdentificationFrame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Text identification frames are a list of string fields.
|
||||||
|
*
|
||||||
|
* This function will accept either a StringList or a String (using the
|
||||||
|
* StringList constructor that accepts a single String).
|
||||||
|
*
|
||||||
|
* \note This will not change the text encoding of the frame even if the
|
||||||
|
* strings passed in are not of the same encoding. Please use
|
||||||
|
* setEncoding(s.type()) if you wish to change the encoding of the frame.
|
||||||
|
*/
|
||||||
|
void setText(const StringList &l);
|
||||||
|
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void setText(const String &s);
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the text encoding that will be used in rendering this frame.
|
||||||
|
* This defaults to the type that was either specified in the constructor
|
||||||
|
* or read from the frame when parsed.
|
||||||
|
*
|
||||||
|
* \note Please see the note in the class description regarding Latin1.
|
||||||
|
*
|
||||||
|
* \see setTextEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
String::Type textEncoding() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the text encoding to be used when rendering this frame to
|
||||||
|
* \a encoding.
|
||||||
|
*
|
||||||
|
* \note Please see the note in the class description regarding Latin1.
|
||||||
|
*
|
||||||
|
* \see textEncoding()
|
||||||
|
* \see render()
|
||||||
|
*/
|
||||||
|
void setTextEncoding(String::Type encoding);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a list of the strings in this frame.
|
||||||
|
*/
|
||||||
|
StringList fieldList() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a KeyConversionMap mapping a role as it would be used in a PropertyMap
|
||||||
|
* to the corresponding key used in a TIPL ID3 frame to describe that role.
|
||||||
|
*/
|
||||||
|
static const KeyConversionMap &involvedPeopleMap();
|
||||||
|
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Reimplementations.
|
||||||
|
|
||||||
|
virtual void parseFields(const ByteVector &data);
|
||||||
|
virtual ByteVector renderFields() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The constructor used by the FrameFactory.
|
||||||
|
*/
|
||||||
|
TextIdentificationFrame(const ByteVector &data, Header *h);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TextIdentificationFrame(const TextIdentificationFrame &);
|
||||||
|
TextIdentificationFrame &operator=(const TextIdentificationFrame &);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Parses the special structure of a TIPL frame
|
||||||
|
* Only the whitelisted roles "ARRANGER", "ENGINEER", "PRODUCER",
|
||||||
|
* "DJMIXER" (ID3: "DJ-MIX") and "MIXER" (ID3: "MIX") are allowed.
|
||||||
|
*/
|
||||||
|
PropertyMap makeTIPLProperties() const;
|
||||||
|
/*!
|
||||||
|
* Parses the special structure of a TMCL frame.
|
||||||
|
*/
|
||||||
|
PropertyMap makeTMCLProperties() const;
|
||||||
|
class TextIdentificationFramePrivate;
|
||||||
|
TextIdentificationFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is a specialization of text identification frames that allows for
|
||||||
|
* user defined entries. Each entry has a description in addition to the
|
||||||
|
* normal list of fields that a text identification frame has.
|
||||||
|
*
|
||||||
|
* This description identifies the frame and must be unique.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! An ID3v2 custom text identification frame implementation
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT UserTextIdentificationFrame : public TextIdentificationFrame
|
||||||
|
{
|
||||||
|
friend class FrameFactory;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Constructs an empty user defined text identification frame. For this to be
|
||||||
|
* a useful frame both a description and text must be set.
|
||||||
|
*/
|
||||||
|
explicit UserTextIdentificationFrame(String::Type encoding = String::Latin1);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a frame based on \a data.
|
||||||
|
*/
|
||||||
|
explicit UserTextIdentificationFrame(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a user defined text identification frame with the given \a description
|
||||||
|
* and \a values.
|
||||||
|
*/
|
||||||
|
UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding = String::UTF8);
|
||||||
|
|
||||||
|
virtual String toString() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the description for this frame.
|
||||||
|
*/
|
||||||
|
String description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the description of the frame to \a s. \a s must be unique. You can
|
||||||
|
* check for the presence of another user defined text frame of the same type
|
||||||
|
* using find() and testing for null.
|
||||||
|
*/
|
||||||
|
void setDescription(const String &s);
|
||||||
|
|
||||||
|
StringList fieldList() const;
|
||||||
|
void setText(const String &text);
|
||||||
|
void setText(const StringList &fields);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A UserTextIdentificationFrame is parsed into a PropertyMap as follows:
|
||||||
|
* - the key is the frame's description, uppercased
|
||||||
|
* - if the description contains '::', only the substring after that
|
||||||
|
* separator is considered as key (compatibility with exfalso)
|
||||||
|
* - if the above rules don't yield a valid key (e.g. containing non-ASCII
|
||||||
|
* characters), the returned map will contain an entry "TXXX/<description>"
|
||||||
|
* in its unsupportedData() list.
|
||||||
|
* - The values will be copies of the fieldList().
|
||||||
|
* - If the description() appears as value in fieldList(), it will be omitted
|
||||||
|
* in the value list, in order to be compatible with TagLib which copies
|
||||||
|
* the description() into the fieldList().
|
||||||
|
*/
|
||||||
|
PropertyMap asProperties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Searches for the user defined text frame with the description \a description
|
||||||
|
* in \a tag. This returns null if no matching frames were found.
|
||||||
|
*/
|
||||||
|
static UserTextIdentificationFrame *find(Tag *tag, const String &description);
|
||||||
|
|
||||||
|
private:
|
||||||
|
UserTextIdentificationFrame(const ByteVector &data, Header *h);
|
||||||
|
UserTextIdentificationFrame(const TextIdentificationFrame &);
|
||||||
|
UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &);
|
||||||
|
|
||||||
|
void checkFields();
|
||||||
|
|
||||||
|
class UserTextIdentificationFramePrivate;
|
||||||
|
UserTextIdentificationFramePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,323 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FILE_H
|
||||||
|
#define TAGLIB_FILE_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "tag.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tiostream.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
class Tag;
|
||||||
|
class AudioProperties;
|
||||||
|
class PropertyMap;
|
||||||
|
|
||||||
|
//! A file class with some useful methods for tag manipulation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class is a basic file class with some methods that are particularly
|
||||||
|
* useful for tag editors. It has methods to take advantage of
|
||||||
|
* ByteVector and a binary search method for finding patterns in a file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Position in the file used for seeking.
|
||||||
|
*/
|
||||||
|
enum Position {
|
||||||
|
//! Seek from the beginning of the file.
|
||||||
|
Beginning,
|
||||||
|
//! Seek from the current position in the file.
|
||||||
|
Current,
|
||||||
|
//! Seek from the end of the file.
|
||||||
|
End
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Specify which tags to strip either explicitly, or on save.
|
||||||
|
*/
|
||||||
|
enum StripTags {
|
||||||
|
StripNone, //<! Don't strip any tags
|
||||||
|
StripOthers //<! Strip all tags not explicitly referenced in method call
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Used to specify if when saving files, if values between different tag
|
||||||
|
* types should be synchronized.
|
||||||
|
*/
|
||||||
|
enum DuplicateTags {
|
||||||
|
Duplicate, //<! Synchronize values between different tag types
|
||||||
|
DoNotDuplicate //<! Do not synchronize values between different tag types
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this File instance.
|
||||||
|
*/
|
||||||
|
virtual ~File();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the file name in the local file system encoding.
|
||||||
|
*/
|
||||||
|
FileName name() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to this file's tag. This should be reimplemented in
|
||||||
|
* the concrete subclasses.
|
||||||
|
*/
|
||||||
|
virtual Tag *tag() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exports the tags of the file as dictionary mapping (human readable) tag
|
||||||
|
* names (uppercase Strings) to StringLists of tag values. Calls the according
|
||||||
|
* specialization in the File subclasses.
|
||||||
|
* For each metadata object of the file that could not be parsed into the PropertyMap
|
||||||
|
* format, the returned map's unsupportedData() list will contain one entry identifying
|
||||||
|
* that object (e.g. the frame type for ID3v2 tags). Use removeUnsupportedProperties()
|
||||||
|
* to remove (a subset of) them.
|
||||||
|
* For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2
|
||||||
|
* tag) only the most "modern" one will be exported (ID3v2 in this case).
|
||||||
|
* BIC: Will be made virtual in future releases.
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties, or a subset of them, from the file's metadata.
|
||||||
|
* The parameter \a properties must contain only entries from
|
||||||
|
* properties().unsupportedData().
|
||||||
|
* BIC: Will be mad virtual in future releases.
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList& properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tags of this File to those specified in \a properties. Calls the
|
||||||
|
* according specialization method in the subclasses of File to do the translation
|
||||||
|
* into the format-specific details.
|
||||||
|
* If some value(s) could not be written imported to the specific metadata format,
|
||||||
|
* the returned PropertyMap will contain those value(s). Otherwise it will be empty,
|
||||||
|
* indicating that no problems occurred.
|
||||||
|
* With file types that support several tag formats (for instance, MP3 files can have
|
||||||
|
* ID3v1, ID3v2, and APEv2 tags), this function will create the most appropriate one
|
||||||
|
* (ID3v2 for MP3 files). Older formats will be updated as well, if they exist, but won't
|
||||||
|
* be taken into account for the return value of this function.
|
||||||
|
* See the documentation of the subclass implementations for detailed descriptions.
|
||||||
|
* BIC: will become pure virtual in the future
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a pointer to this file's audio properties. This should be
|
||||||
|
* reimplemented in the concrete subclasses. If no audio properties were
|
||||||
|
* read then this will return a null pointer.
|
||||||
|
*/
|
||||||
|
virtual AudioProperties *audioProperties() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Save the file and its associated tags. This should be reimplemented in
|
||||||
|
* the concrete subclasses. Returns true if the save succeeds.
|
||||||
|
*
|
||||||
|
* \warning On UNIX multiple processes are able to write to the same file at
|
||||||
|
* the same time. This can result in serious file corruption. If you are
|
||||||
|
* developing a program that makes use of TagLib from multiple processes you
|
||||||
|
* must insure that you are only doing writes to a particular file from one
|
||||||
|
* of them.
|
||||||
|
*/
|
||||||
|
virtual bool save() = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads a block of size \a length at the current get pointer.
|
||||||
|
*/
|
||||||
|
ByteVector readBlock(unsigned long length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempts to write the block \a data at the current get pointer. If the
|
||||||
|
* file is currently only opened read only -- i.e. readOnly() returns true --
|
||||||
|
* this attempts to reopen the file in read/write mode.
|
||||||
|
*
|
||||||
|
* \note This should be used instead of using the streaming output operator
|
||||||
|
* for a ByteVector. And even this function is significantly slower than
|
||||||
|
* doing output with a char[].
|
||||||
|
*/
|
||||||
|
void writeBlock(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the offset in the file that \a pattern occurs at or -1 if it can
|
||||||
|
* not be found. If \a before is set, the search will only continue until the
|
||||||
|
* pattern \a before is found. This is useful for tagging purposes to search
|
||||||
|
* for a tag before the sync frame.
|
||||||
|
*
|
||||||
|
* Searching starts at \a fromOffset, which defaults to the beginning of the
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* \note This has the practical limitation that \a pattern can not be longer
|
||||||
|
* than the buffer size used by readBlock(). Currently this is 1024 bytes.
|
||||||
|
*/
|
||||||
|
long find(const ByteVector &pattern,
|
||||||
|
long fromOffset = 0,
|
||||||
|
const ByteVector &before = ByteVector());
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the offset in the file that \a pattern occurs at or -1 if it can
|
||||||
|
* not be found. If \a before is set, the search will only continue until the
|
||||||
|
* pattern \a before is found. This is useful for tagging purposes to search
|
||||||
|
* for a tag before the sync frame.
|
||||||
|
*
|
||||||
|
* Searching starts at \a fromOffset and proceeds from the that point to the
|
||||||
|
* beginning of the file and defaults to the end of the file.
|
||||||
|
*
|
||||||
|
* \note This has the practical limitation that \a pattern can not be longer
|
||||||
|
* than the buffer size used by readBlock(). Currently this is 1024 bytes.
|
||||||
|
*/
|
||||||
|
long rfind(const ByteVector &pattern,
|
||||||
|
long fromOffset = 0,
|
||||||
|
const ByteVector &before = ByteVector());
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Insert \a data at position \a start in the file overwriting \a replace
|
||||||
|
* bytes of the original content.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it requires rewriting all of the file
|
||||||
|
* after the insertion point.
|
||||||
|
*/
|
||||||
|
void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes a block of the file starting a \a start and continuing for
|
||||||
|
* \a length bytes.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it involves rewriting all of the file
|
||||||
|
* after the removed portion.
|
||||||
|
*/
|
||||||
|
void removeBlock(unsigned long start = 0, unsigned long length = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is read only (or if the file can not be opened).
|
||||||
|
*/
|
||||||
|
bool readOnly() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Since the file can currently only be opened as an argument to the
|
||||||
|
* constructor (sort-of by design), this returns if that open succeeded.
|
||||||
|
*/
|
||||||
|
bool isOpen() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is open and readable.
|
||||||
|
*/
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Move the I/O pointer to \a offset in the file from position \a p. This
|
||||||
|
* defaults to seeking from the beginning of the file.
|
||||||
|
*
|
||||||
|
* \see Position
|
||||||
|
*/
|
||||||
|
void seek(long offset, Position p = Beginning);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reset the end-of-file and error flags on the file.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current offset within the file.
|
||||||
|
*/
|
||||||
|
long tell() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file.
|
||||||
|
*/
|
||||||
|
long length();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if \a file can be opened for reading. If the file does not
|
||||||
|
* exist, this will return false.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED static bool isReadable(const char *file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if \a file can be opened for writing.
|
||||||
|
*
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
|
TAGLIB_DEPRECATED static bool isWritable(const char *name);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Construct a File object and opens the \a file. \a file should be a
|
||||||
|
* be a C-string in the local file system encoding.
|
||||||
|
*
|
||||||
|
* \note Constructor is protected since this class should only be
|
||||||
|
* instantiated through subclasses.
|
||||||
|
*/
|
||||||
|
File(FileName file);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a File object and use the \a stream instance.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
|
* responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note Constructor is protected since this class should only be
|
||||||
|
* instantiated through subclasses.
|
||||||
|
*/
|
||||||
|
File(IOStream *stream);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Marks the file as valid or invalid.
|
||||||
|
*
|
||||||
|
* \see isValid()
|
||||||
|
*/
|
||||||
|
void setValid(bool valid);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Truncates the file to a \a length.
|
||||||
|
*/
|
||||||
|
void truncate(long length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the buffer size that is used for internal buffering.
|
||||||
|
*/
|
||||||
|
static unsigned int bufferSize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
File(const File &);
|
||||||
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
class FilePrivate;
|
||||||
|
FilePrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,159 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_FILESTREAM_H
|
||||||
|
#define TAGLIB_FILESTREAM_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
#include "tiostream.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
class String;
|
||||||
|
class Tag;
|
||||||
|
class AudioProperties;
|
||||||
|
|
||||||
|
//! A file class with some useful methods for tag manipulation
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This class is a basic file class with some methods that are particularly
|
||||||
|
* useful for tag editors. It has methods to take advantage of
|
||||||
|
* ByteVector and a binary search method for finding patterns in a file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT FileStream : public IOStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Construct a File object and opens the \a file. \a file should be a
|
||||||
|
* be a C-string in the local file system encoding.
|
||||||
|
*/
|
||||||
|
FileStream(FileName file, bool openReadOnly = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Construct a File object and opens the \a file using file descriptor.
|
||||||
|
*/
|
||||||
|
FileStream(int fileDescriptor, bool openReadOnly = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this FileStream instance.
|
||||||
|
*/
|
||||||
|
virtual ~FileStream();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the file name in the local file system encoding.
|
||||||
|
*/
|
||||||
|
FileName name() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads a block of size \a length at the current get pointer.
|
||||||
|
*/
|
||||||
|
ByteVector readBlock(unsigned long length);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempts to write the block \a data at the current get pointer. If the
|
||||||
|
* file is currently only opened read only -- i.e. readOnly() returns true --
|
||||||
|
* this attempts to reopen the file in read/write mode.
|
||||||
|
*
|
||||||
|
* \note This should be used instead of using the streaming output operator
|
||||||
|
* for a ByteVector. And even this function is significantly slower than
|
||||||
|
* doing output with a char[].
|
||||||
|
*/
|
||||||
|
void writeBlock(const ByteVector &data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Insert \a data at position \a start in the file overwriting \a replace
|
||||||
|
* bytes of the original content.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it requires rewriting all of the file
|
||||||
|
* after the insertion point.
|
||||||
|
*/
|
||||||
|
void insert(const ByteVector &data, unsigned long start = 0, unsigned long replace = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes a block of the file starting a \a start and continuing for
|
||||||
|
* \a length bytes.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it involves rewriting all of the file
|
||||||
|
* after the removed portion.
|
||||||
|
*/
|
||||||
|
void removeBlock(unsigned long start = 0, unsigned long length = 0);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is read only (or if the file can not be opened).
|
||||||
|
*/
|
||||||
|
bool readOnly() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Since the file can currently only be opened as an argument to the
|
||||||
|
* constructor (sort-of by design), this returns if that open succeeded.
|
||||||
|
*/
|
||||||
|
bool isOpen() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Move the I/O pointer to \a offset in the file from position \a p. This
|
||||||
|
* defaults to seeking from the beginning of the file.
|
||||||
|
*
|
||||||
|
* \see Position
|
||||||
|
*/
|
||||||
|
void seek(long offset, Position p = Beginning);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reset the end-of-file and error flags on the file.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current offset within the file.
|
||||||
|
*/
|
||||||
|
long tell() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the file.
|
||||||
|
*/
|
||||||
|
long length();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Truncates the file to a \a length.
|
||||||
|
*/
|
||||||
|
void truncate(long length);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the buffer size that is used for internal buffering.
|
||||||
|
*/
|
||||||
|
static unsigned int bufferSize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class FileStreamPrivate;
|
||||||
|
FileStreamPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,170 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2011 by Lukas Lalinsky
|
||||||
|
email : lalinsky@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_IOSTREAM_H
|
||||||
|
#define TAGLIB_IOSTREAM_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
#include "tbytevector.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
class TAGLIB_EXPORT FileName
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileName(const wchar_t *name);
|
||||||
|
FileName(const char *name);
|
||||||
|
|
||||||
|
FileName(const FileName &name);
|
||||||
|
|
||||||
|
operator const wchar_t *() const;
|
||||||
|
operator const char *() const;
|
||||||
|
|
||||||
|
const std::wstring &wstr() const;
|
||||||
|
const std::string &str() const;
|
||||||
|
|
||||||
|
String toString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string m_name;
|
||||||
|
const std::wstring m_wname;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
typedef const char *FileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! An abstract class that provides operations on a sequence of bytes
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT IOStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* Position in the file used for seeking.
|
||||||
|
*/
|
||||||
|
enum Position {
|
||||||
|
//! Seek from the beginning of the file.
|
||||||
|
Beginning,
|
||||||
|
//! Seek from the current position in the file.
|
||||||
|
Current,
|
||||||
|
//! Seek from the end of the file.
|
||||||
|
End
|
||||||
|
};
|
||||||
|
|
||||||
|
IOStream();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this IOStream instance.
|
||||||
|
*/
|
||||||
|
virtual ~IOStream();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the stream name in the local file system encoding.
|
||||||
|
*/
|
||||||
|
virtual FileName name() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reads a block of size \a length at the current get pointer.
|
||||||
|
*/
|
||||||
|
virtual ByteVector readBlock(unsigned long length) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Attempts to write the block \a data at the current get pointer. If the
|
||||||
|
* file is currently only opened read only -- i.e. readOnly() returns true --
|
||||||
|
* this attempts to reopen the file in read/write mode.
|
||||||
|
*
|
||||||
|
* \note This should be used instead of using the streaming output operator
|
||||||
|
* for a ByteVector. And even this function is significantly slower than
|
||||||
|
* doing output with a char[].
|
||||||
|
*/
|
||||||
|
virtual void writeBlock(const ByteVector &data) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Insert \a data at position \a start in the file overwriting \a replace
|
||||||
|
* bytes of the original content.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it requires rewriting all of the file
|
||||||
|
* after the insertion point.
|
||||||
|
*/
|
||||||
|
virtual void insert(const ByteVector &data,
|
||||||
|
unsigned long start = 0, unsigned long replace = 0) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes a block of the file starting a \a start and continuing for
|
||||||
|
* \a length bytes.
|
||||||
|
*
|
||||||
|
* \note This method is slow since it involves rewriting all of the file
|
||||||
|
* after the removed portion.
|
||||||
|
*/
|
||||||
|
virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is read only (or if the file can not be opened).
|
||||||
|
*/
|
||||||
|
virtual bool readOnly() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Since the file can currently only be opened as an argument to the
|
||||||
|
* constructor (sort-of by design), this returns if that open succeeded.
|
||||||
|
*/
|
||||||
|
virtual bool isOpen() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Move the I/O pointer to \a offset in the stream from position \a p. This
|
||||||
|
* defaults to seeking from the beginning of the stream.
|
||||||
|
*
|
||||||
|
* \see Position
|
||||||
|
*/
|
||||||
|
virtual void seek(long offset, Position p = Beginning) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Reset the end-of-stream and error flags on the stream.
|
||||||
|
*/
|
||||||
|
virtual void clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current offset within the stream.
|
||||||
|
*/
|
||||||
|
virtual long tell() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the length of the stream.
|
||||||
|
*/
|
||||||
|
virtual long length() = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Truncates the stream to a \a length.
|
||||||
|
*/
|
||||||
|
virtual void truncate(long length) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IOStream(const IOStream &);
|
||||||
|
IOStream &operator=(const IOStream &);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,270 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_LIST_H
|
||||||
|
#define TAGLIB_LIST_H
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A generic, implicitly shared list.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This is basic generic list that's somewhere between a std::list and a
|
||||||
|
* QValueList. This class is implicitly shared. For example:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
*
|
||||||
|
* TagLib::List<int> l = someOtherIntList;
|
||||||
|
*
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* The above example is very cheap. This also makes lists suitable for the
|
||||||
|
* return types of functions. The above example will just copy a pointer rather
|
||||||
|
* than copying the data in the list. When your \e shared list's data changes,
|
||||||
|
* only \e then will the data be copied.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class T> class List
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
typedef typename std::list<T>::iterator Iterator;
|
||||||
|
typedef typename std::list<T>::const_iterator ConstIterator;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty list.
|
||||||
|
*/
|
||||||
|
List();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a shallow, implicitly shared, copy of \a l. Because this is
|
||||||
|
* implicitly shared, this method is lightweight and suitable for
|
||||||
|
* pass-by-value usage.
|
||||||
|
*/
|
||||||
|
List(const List<T> &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this List instance. If auto deletion is enabled and this list
|
||||||
|
* contains a pointer type all of the members are also deleted.
|
||||||
|
*/
|
||||||
|
virtual ~List();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the beginning of the list. See
|
||||||
|
* std::list::const_iterator for the semantics.
|
||||||
|
*/
|
||||||
|
Iterator begin();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style constant iterator to the beginning of the list. See
|
||||||
|
* std::list::iterator for the semantics.
|
||||||
|
*/
|
||||||
|
ConstIterator begin() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the end of the list. See
|
||||||
|
* std::list::iterator for the semantics.
|
||||||
|
*/
|
||||||
|
Iterator end();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style constant iterator to the end of the list. See
|
||||||
|
* std::list::const_iterator for the semantics.
|
||||||
|
*/
|
||||||
|
ConstIterator end() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Inserts a copy of \a value before \a it.
|
||||||
|
*/
|
||||||
|
Iterator insert(Iterator it, const T &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Inserts the \a value into the list. This assumes that the list is
|
||||||
|
* currently sorted. If \a unique is true then the value will not
|
||||||
|
* be inserted if it is already in the list.
|
||||||
|
*/
|
||||||
|
List<T> &sortedInsert(const T &value, bool unique = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends \a item to the end of the list and returns a reference to the
|
||||||
|
* list.
|
||||||
|
*/
|
||||||
|
List<T> &append(const T &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Appends all of the values in \a l to the end of the list and returns a
|
||||||
|
* reference to the list.
|
||||||
|
*/
|
||||||
|
List<T> &append(const List<T> &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Prepends \a item to the beginning list and returns a reference to the
|
||||||
|
* list.
|
||||||
|
*/
|
||||||
|
List<T> &prepend(const T &item);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Prepends all of the items in \a l to the beginning list and returns a
|
||||||
|
* reference to the list.
|
||||||
|
*/
|
||||||
|
List<T> &prepend(const List<T> &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Clears the list. If auto deletion is enabled and this list contains a
|
||||||
|
* pointer type the members are also deleted.
|
||||||
|
*
|
||||||
|
* \see setAutoDelete()
|
||||||
|
*/
|
||||||
|
List<T> &clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the number of elements in the list.
|
||||||
|
*
|
||||||
|
* \see isEmpty()
|
||||||
|
*/
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns whether or not the list is empty.
|
||||||
|
*
|
||||||
|
* \see size()
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a value.
|
||||||
|
*/
|
||||||
|
Iterator find(const T &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a value.
|
||||||
|
*/
|
||||||
|
ConstIterator find(const T &value) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the list contains \a value.
|
||||||
|
*/
|
||||||
|
bool contains(const T &value) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Erase the item at \a it from the list.
|
||||||
|
*/
|
||||||
|
Iterator erase(Iterator it);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the first item in the list.
|
||||||
|
*/
|
||||||
|
const T &front() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the first item in the list.
|
||||||
|
*/
|
||||||
|
T &front();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the last item in the list.
|
||||||
|
*/
|
||||||
|
const T &back() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the last item in the list.
|
||||||
|
*/
|
||||||
|
T &back();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Auto delete the members of the list when the last reference to the list
|
||||||
|
* passes out of scope. This will have no effect on lists which do not
|
||||||
|
* contain a pointer type.
|
||||||
|
*
|
||||||
|
* \note This relies on partial template instantiation -- most modern C++
|
||||||
|
* compilers should now support this.
|
||||||
|
*/
|
||||||
|
void setAutoDelete(bool autoDelete);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to item \a i in the list.
|
||||||
|
*
|
||||||
|
* \warning This method is slow. Use iterators to loop through the list.
|
||||||
|
*/
|
||||||
|
T &operator[](unsigned int i);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a const reference to item \a i in the list.
|
||||||
|
*
|
||||||
|
* \warning This method is slow. Use iterators to loop through the list.
|
||||||
|
*/
|
||||||
|
const T &operator[](unsigned int i) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a shallow, implicitly shared, copy of \a l. Because this is
|
||||||
|
* implicitly shared, this method is lightweight and suitable for
|
||||||
|
* pass-by-value usage.
|
||||||
|
*/
|
||||||
|
List<T> &operator=(const List<T> &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of this list by the content of \a l.
|
||||||
|
*/
|
||||||
|
void swap(List<T> &l);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Compares this list with \a l and returns true if all of the elements are
|
||||||
|
* the same.
|
||||||
|
*/
|
||||||
|
bool operator==(const List<T> &l) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Compares this list with \a l and returns true if the lists differ.
|
||||||
|
*/
|
||||||
|
bool operator!=(const List<T> &l) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*
|
||||||
|
* If this List is being shared via implicit sharing, do a deep copy of the
|
||||||
|
* data and separate from the shared members. This should be called by all
|
||||||
|
* non-const subclass members.
|
||||||
|
*/
|
||||||
|
void detach();
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
template <class TP> class ListPrivate;
|
||||||
|
ListPrivate<T> *d;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since GCC doesn't support the "export" keyword, we have to include the
|
||||||
|
// implementation.
|
||||||
|
|
||||||
|
#include "tlist.tcc"
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,323 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include "trefcounter.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// public members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// The functionality of List<T>::setAutoDelete() is implemented here partial
|
||||||
|
// template specialization. This is implemented in such a way that calling
|
||||||
|
// setAutoDelete() on non-pointer types will simply have no effect.
|
||||||
|
|
||||||
|
// A base for the generic and specialized private class types. New
|
||||||
|
// non-templatized members should be added here.
|
||||||
|
|
||||||
|
// BIC change to RefCounter
|
||||||
|
class ListPrivateBase : public RefCounterOld
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListPrivateBase() : autoDelete(false) {}
|
||||||
|
bool autoDelete;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A generic implementation
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
template <class TP> class List<T>::ListPrivate : public ListPrivateBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListPrivate() : ListPrivateBase() {}
|
||||||
|
ListPrivate(const std::list<TP> &l) : ListPrivateBase(), list(l) {}
|
||||||
|
void clear() {
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
std::list<TP> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A partial specialization for all pointer types that implements the
|
||||||
|
// setAutoDelete() functionality.
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
template <class TP> class List<T>::ListPrivate<TP *> : public ListPrivateBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListPrivate() : ListPrivateBase() {}
|
||||||
|
ListPrivate(const std::list<TP *> &l) : ListPrivateBase(), list(l) {}
|
||||||
|
~ListPrivate() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
void clear() {
|
||||||
|
if(autoDelete) {
|
||||||
|
typename std::list<TP *>::const_iterator it = list.begin();
|
||||||
|
for(; it != list.end(); ++it)
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
std::list<TP *> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// public members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T>::List() :
|
||||||
|
d(new ListPrivate<T>())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T>::List(const List<T> &l) : d(l.d)
|
||||||
|
{
|
||||||
|
d->ref();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T>::~List()
|
||||||
|
{
|
||||||
|
if(d->deref())
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::Iterator List<T>::begin()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->list.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::ConstIterator List<T>::begin() const
|
||||||
|
{
|
||||||
|
return d->list.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::Iterator List<T>::end()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->list.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::ConstIterator List<T>::end() const
|
||||||
|
{
|
||||||
|
return d->list.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::Iterator List<T>::insert(Iterator it, const T &item)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->list.insert(it, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::sortedInsert(const T &value, bool unique)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
Iterator it = begin();
|
||||||
|
while(it != end() && *it < value)
|
||||||
|
++it;
|
||||||
|
if(unique && it != end() && *it == value)
|
||||||
|
return *this;
|
||||||
|
insert(it, value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::append(const T &item)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->list.push_back(item);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::append(const List<T> &l)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->list.insert(d->list.end(), l.begin(), l.end());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::prepend(const T &item)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->list.push_front(item);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::prepend(const List<T> &l)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->list.insert(d->list.begin(), l.begin(), l.end());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::clear()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->clear();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
unsigned int List<T>::size() const
|
||||||
|
{
|
||||||
|
return static_cast<unsigned int>(d->list.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool List<T>::isEmpty() const
|
||||||
|
{
|
||||||
|
return d->list.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::Iterator List<T>::find(const T &value)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return std::find(d->list.begin(), d->list.end(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::ConstIterator List<T>::find(const T &value) const
|
||||||
|
{
|
||||||
|
return std::find(d->list.begin(), d->list.end(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool List<T>::contains(const T &value) const
|
||||||
|
{
|
||||||
|
return std::find(d->list.begin(), d->list.end(), value) != d->list.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
typename List<T>::Iterator List<T>::erase(Iterator it)
|
||||||
|
{
|
||||||
|
return d->list.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T &List<T>::front() const
|
||||||
|
{
|
||||||
|
return d->list.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T &List<T>::front()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->list.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T &List<T>::back() const
|
||||||
|
{
|
||||||
|
return d->list.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void List<T>::setAutoDelete(bool autoDelete)
|
||||||
|
{
|
||||||
|
d->autoDelete = autoDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T &List<T>::back()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->list.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T &List<T>::operator[](unsigned int i)
|
||||||
|
{
|
||||||
|
Iterator it = d->list.begin();
|
||||||
|
std::advance(it, i);
|
||||||
|
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T &List<T>::operator[](unsigned int i) const
|
||||||
|
{
|
||||||
|
ConstIterator it = d->list.begin();
|
||||||
|
std::advance(it, i);
|
||||||
|
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
List<T> &List<T>::operator=(const List<T> &l)
|
||||||
|
{
|
||||||
|
List<T>(l).swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void List<T>::swap(List<T> &l)
|
||||||
|
{
|
||||||
|
using std::swap;
|
||||||
|
|
||||||
|
swap(d, l.d);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool List<T>::operator==(const List<T> &l) const
|
||||||
|
{
|
||||||
|
return d->list == l.d->list;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool List<T>::operator!=(const List<T> &l) const
|
||||||
|
{
|
||||||
|
return d->list != l.d->list;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// protected members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void List<T>::detach()
|
||||||
|
{
|
||||||
|
if(d->count() > 1) {
|
||||||
|
d->deref();
|
||||||
|
d = new ListPrivate<T>(d->list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TagLib
|
|
@ -0,0 +1,204 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_MAP_H
|
||||||
|
#define TAGLIB_MAP_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "taglib.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
//! A generic, implicitly shared map.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This implements a standard map container that associates a key with a value
|
||||||
|
* and has fast key-based lookups. This map is also implicitly shared making
|
||||||
|
* it suitable for pass-by-value usage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class Key, class T> class Map
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
|
||||||
|
// Some STL implementations get snippy over the use of the
|
||||||
|
// class keyword to distinguish different templates; Sun Studio
|
||||||
|
// in particular finds multiple specializations in certain rare
|
||||||
|
// cases and complains about that. GCC doesn't seem to mind,
|
||||||
|
// and uses the typedefs further below without the class keyword.
|
||||||
|
// Not all the specializations of Map can use the class keyword
|
||||||
|
// (when T is not actually a class type), so don't apply this
|
||||||
|
// generally.
|
||||||
|
typedef typename std::map<class Key, class T>::iterator Iterator;
|
||||||
|
typedef typename std::map<class Key, class T>::const_iterator ConstIterator;
|
||||||
|
#else
|
||||||
|
typedef typename std::map<Key, T>::iterator Iterator;
|
||||||
|
typedef typename std::map<Key, T>::const_iterator ConstIterator;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs an empty Map.
|
||||||
|
*/
|
||||||
|
Map();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a shallow, implicitly shared, copy of \a m. Because this is
|
||||||
|
* implicitly shared, this method is lightweight and suitable for
|
||||||
|
* pass-by-value usage.
|
||||||
|
*/
|
||||||
|
Map(const Map<Key, T> &m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destroys this instance of the Map.
|
||||||
|
*/
|
||||||
|
virtual ~Map();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the beginning of the map. See
|
||||||
|
* std::map::iterator for the semantics.
|
||||||
|
*/
|
||||||
|
Iterator begin();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the beginning of the map. See
|
||||||
|
* std::map::const_iterator for the semantics.
|
||||||
|
*/
|
||||||
|
ConstIterator begin() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the end of the map. See
|
||||||
|
* std::map::iterator for the semantics.
|
||||||
|
*/
|
||||||
|
Iterator end();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns an STL style iterator to the end of the map. See
|
||||||
|
* std::map::const_iterator for the semantics.
|
||||||
|
*/
|
||||||
|
ConstIterator end() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Inserts \a value under \a key in the map. If a value for \a key already
|
||||||
|
* exists it will be overwritten.
|
||||||
|
*/
|
||||||
|
Map<Key, T> &insert(const Key &key, const T &value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes all of the elements from elements from the map. This however
|
||||||
|
* will not delete pointers if the mapped type is a pointer type.
|
||||||
|
*/
|
||||||
|
Map<Key, T> &clear();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The number of elements in the map.
|
||||||
|
*
|
||||||
|
* \see isEmpty()
|
||||||
|
*/
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the map is empty.
|
||||||
|
*
|
||||||
|
* \see size()
|
||||||
|
*/
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a key.
|
||||||
|
*/
|
||||||
|
Iterator find(const Key &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a key.
|
||||||
|
*/
|
||||||
|
ConstIterator find(const Key &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the map contains an instance of \a key.
|
||||||
|
*/
|
||||||
|
bool contains(const Key &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Erase the item at \a it from the list.
|
||||||
|
*/
|
||||||
|
Map<Key, T> &erase(Iterator it);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Erase the item with \a key from the list.
|
||||||
|
*/
|
||||||
|
Map<Key, T> &erase(const Key &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the value associated with \a key.
|
||||||
|
*
|
||||||
|
* \note This has undefined behavior if the key is not present in the map.
|
||||||
|
*/
|
||||||
|
const T &operator[](const Key &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the value associated with \a key.
|
||||||
|
*
|
||||||
|
* \note This has undefined behavior if the key is not present in the map.
|
||||||
|
*/
|
||||||
|
T &operator[](const Key &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Make a shallow, implicitly shared, copy of \a m. Because this is
|
||||||
|
* implicitly shared, this method is lightweight and suitable for
|
||||||
|
* pass-by-value usage.
|
||||||
|
*/
|
||||||
|
Map<Key, T> &operator=(const Map<Key, T> &m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Exchanges the content of this map by the content of \a m.
|
||||||
|
*/
|
||||||
|
void swap(Map<Key, T> &m);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*
|
||||||
|
* If this List is being shared via implicit sharing, do a deep copy of the
|
||||||
|
* data and separate from the shared members. This should be called by all
|
||||||
|
* non-const subclass members.
|
||||||
|
*/
|
||||||
|
void detach();
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifndef DO_NOT_DOCUMENT
|
||||||
|
template <class KeyP, class TP> class MapPrivate;
|
||||||
|
MapPrivate<Key, T> *d;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since GCC doesn't support the "export" keyword, we have to include the
|
||||||
|
// implementation.
|
||||||
|
|
||||||
|
#include "tmap.tcc"
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,199 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2002 - 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||||
|
* 02110-1301 USA *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "trefcounter.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// public members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// BIC change to RefCounter
|
||||||
|
template <class Key, class T>
|
||||||
|
template <class KeyP, class TP>
|
||||||
|
class Map<Key, T>::MapPrivate : public RefCounterOld
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MapPrivate() : RefCounterOld() {}
|
||||||
|
#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
|
||||||
|
MapPrivate(const std::map<class KeyP, class TP>& m) : RefCounterOld(), map(m) {}
|
||||||
|
std::map<class KeyP, class TP> map;
|
||||||
|
#else
|
||||||
|
MapPrivate(const std::map<KeyP, TP>& m) : RefCounterOld(), map(m) {}
|
||||||
|
std::map<KeyP, TP> map;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T>::Map() :
|
||||||
|
d(new MapPrivate<Key, T>())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T>::Map(const Map<Key, T> &m) : d(m.d)
|
||||||
|
{
|
||||||
|
d->ref();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T>::~Map()
|
||||||
|
{
|
||||||
|
if(d->deref())
|
||||||
|
delete(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key, T>::Iterator Map<Key, T>::begin()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->map.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key, T>::ConstIterator Map<Key, T>::begin() const
|
||||||
|
{
|
||||||
|
return d->map.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key, T>::Iterator Map<Key, T>::end()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->map.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key, T>::ConstIterator Map<Key, T>::end() const
|
||||||
|
{
|
||||||
|
return d->map.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T> &Map<Key, T>::insert(const Key &key, const T &value)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->map[key] = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T> &Map<Key, T>::clear()
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->map.clear();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
bool Map<Key, T>::isEmpty() const
|
||||||
|
{
|
||||||
|
return d->map.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key, T>::Iterator Map<Key, T>::find(const Key &key)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->map.find(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
typename Map<Key,T>::ConstIterator Map<Key, T>::find(const Key &key) const
|
||||||
|
{
|
||||||
|
return d->map.find(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
bool Map<Key, T>::contains(const Key &key) const
|
||||||
|
{
|
||||||
|
return d->map.find(key) != d->map.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T> &Map<Key,T>::erase(Iterator it)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->map.erase(it);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T> &Map<Key,T>::erase(const Key &key)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
d->map.erase(key);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
unsigned int Map<Key, T>::size() const
|
||||||
|
{
|
||||||
|
return static_cast<unsigned int>(d->map.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
const T &Map<Key, T>::operator[](const Key &key) const
|
||||||
|
{
|
||||||
|
return d->map[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
T &Map<Key, T>::operator[](const Key &key)
|
||||||
|
{
|
||||||
|
detach();
|
||||||
|
return d->map[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
Map<Key, T> &Map<Key, T>::operator=(const Map<Key, T> &m)
|
||||||
|
{
|
||||||
|
Map<Key, T>(m).swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
void Map<Key, T>::swap(Map<Key, T> &m)
|
||||||
|
{
|
||||||
|
using std::swap;
|
||||||
|
|
||||||
|
swap(d, m.d);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// protected members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class Key, class T>
|
||||||
|
void Map<Key, T>::detach()
|
||||||
|
{
|
||||||
|
if(d->count() > 1) {
|
||||||
|
d->deref();
|
||||||
|
d = new MapPrivate<Key, T>(d->map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TagLib
|
|
@ -0,0 +1,242 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2012 by Michael Helmling
|
||||||
|
email : helmling@mathematik.uni-kl.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_PROPERTYMAP_H_
|
||||||
|
#define TAGLIB_PROPERTYMAP_H_
|
||||||
|
|
||||||
|
#include "tmap.h"
|
||||||
|
#include "tstringlist.h"
|
||||||
|
|
||||||
|
namespace TagLib {
|
||||||
|
|
||||||
|
typedef Map<String,StringList> SimplePropertyMap;
|
||||||
|
|
||||||
|
//! A map for format-independent <key,valuelist> tag representations.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This map implements a generic representation of textual audio metadata
|
||||||
|
* ("tags") realized as pairs of a case-insensitive key
|
||||||
|
* and a nonempty list of corresponding values, each value being an arbitrary
|
||||||
|
* unicode String.
|
||||||
|
*
|
||||||
|
* Note that most metadata formats pose additional conditions on the tag keys. The
|
||||||
|
* most popular ones (Vorbis, APE, ID3v2) should support all ASCII only words of
|
||||||
|
* length between 2 and 16.
|
||||||
|
*
|
||||||
|
* This class can contain any tags, but here is a list of "well-known" tags that
|
||||||
|
* you might want to use:
|
||||||
|
*
|
||||||
|
* Basic tags:
|
||||||
|
*
|
||||||
|
* - TITLE
|
||||||
|
* - ALBUM
|
||||||
|
* - ARTIST
|
||||||
|
* - ALBUMARTIST
|
||||||
|
* - SUBTITLE
|
||||||
|
* - TRACKNUMBER
|
||||||
|
* - DISCNUMBER
|
||||||
|
* - DATE
|
||||||
|
* - ORIGINALDATE
|
||||||
|
* - GENRE
|
||||||
|
* - COMMENT
|
||||||
|
*
|
||||||
|
* Sort names:
|
||||||
|
*
|
||||||
|
* - TITLESORT
|
||||||
|
* - ALBUMSORT
|
||||||
|
* - ARTISTSORT
|
||||||
|
* - ALBUMARTISTSORT
|
||||||
|
* - COMPOSERSORT
|
||||||
|
*
|
||||||
|
* Credits:
|
||||||
|
*
|
||||||
|
* - COMPOSER
|
||||||
|
* - LYRICIST
|
||||||
|
* - CONDUCTOR
|
||||||
|
* - REMIXER
|
||||||
|
* - PERFORMER:\<XXXX>
|
||||||
|
*
|
||||||
|
* Other tags:
|
||||||
|
*
|
||||||
|
* - ISRC
|
||||||
|
* - ASIN
|
||||||
|
* - BPM
|
||||||
|
* - COPYRIGHT
|
||||||
|
* - ENCODEDBY
|
||||||
|
* - MOOD
|
||||||
|
* - COMMENT
|
||||||
|
* - MEDIA
|
||||||
|
* - LABEL
|
||||||
|
* - CATALOGNUMBER
|
||||||
|
* - BARCODE
|
||||||
|
* - RELEASECOUNTRY
|
||||||
|
* - RELEASESTATUS
|
||||||
|
* - RELEASETYPE
|
||||||
|
*
|
||||||
|
* MusicBrainz identifiers:
|
||||||
|
*
|
||||||
|
* - MUSICBRAINZ_TRACKID
|
||||||
|
* - MUSICBRAINZ_ALBUMID
|
||||||
|
* - MUSICBRAINZ_RELEASEGROUPID
|
||||||
|
* - MUSICBRAINZ_RELEASETRACKID
|
||||||
|
* - MUSICBRAINZ_WORKID
|
||||||
|
* - MUSICBRAINZ_ARTISTID
|
||||||
|
* - MUSICBRAINZ_ALBUMARTISTID
|
||||||
|
* - ACOUSTID_ID
|
||||||
|
* - ACOUSTID_FINGERPRINT
|
||||||
|
* - MUSICIP_PUID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT PropertyMap: public SimplePropertyMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef SimplePropertyMap::Iterator Iterator;
|
||||||
|
typedef SimplePropertyMap::ConstIterator ConstIterator;
|
||||||
|
|
||||||
|
PropertyMap();
|
||||||
|
|
||||||
|
PropertyMap(const PropertyMap &m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Creates a PropertyMap initialized from a SimplePropertyMap. Copies all
|
||||||
|
* entries from \a m that have valid keys.
|
||||||
|
* Invalid keys will be appended to the unsupportedData() list.
|
||||||
|
*/
|
||||||
|
PropertyMap(const SimplePropertyMap &m);
|
||||||
|
|
||||||
|
virtual ~PropertyMap();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Inserts \a values under \a key in the map. If \a key already exists,
|
||||||
|
* then \a values will be appended to the existing StringList.
|
||||||
|
* The returned value indicates success, i.e. whether \a key is a
|
||||||
|
* valid key.
|
||||||
|
*/
|
||||||
|
bool insert(const String &key, const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Replaces any existing values for \a key with the given \a values,
|
||||||
|
* and simply insert them if \a key did not exist before.
|
||||||
|
* The returned value indicates success, i.e. whether \a key is a
|
||||||
|
* valid key.
|
||||||
|
*/
|
||||||
|
bool replace(const String &key, const StringList &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a key.
|
||||||
|
*/
|
||||||
|
Iterator find(const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Find the first occurrence of \a key.
|
||||||
|
*/
|
||||||
|
ConstIterator find(const String &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the map contains values for \a key.
|
||||||
|
*/
|
||||||
|
bool contains(const String &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if this map contains all keys of \a other
|
||||||
|
* and the values coincide for that keys. Does not take
|
||||||
|
* the unsupportedData list into account.
|
||||||
|
*/
|
||||||
|
bool contains(const PropertyMap &other) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Erase the \a key and its values from the map.
|
||||||
|
*/
|
||||||
|
PropertyMap &erase(const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Erases from this map all keys that appear in \a other.
|
||||||
|
*/
|
||||||
|
PropertyMap &erase(const PropertyMap &other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Merge the contents of \a other into this PropertyMap.
|
||||||
|
* If a key is contained in both maps, the values of the second
|
||||||
|
* are appended to that of the first.
|
||||||
|
* The unsupportedData() lists are concatenated as well.
|
||||||
|
*/
|
||||||
|
PropertyMap &merge(const PropertyMap &other);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the value associated with \a key.
|
||||||
|
*
|
||||||
|
* \note: If \a key is not contained in the map, an empty
|
||||||
|
* StringList is returned without error.
|
||||||
|
*/
|
||||||
|
const StringList &operator[](const String &key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a reference to the value associated with \a key.
|
||||||
|
*
|
||||||
|
* \note: If \a key is not contained in the map, an empty
|
||||||
|
* StringList is returned. You can also directly add entries
|
||||||
|
* by using this function as an lvalue.
|
||||||
|
*/
|
||||||
|
StringList &operator[](const String &key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if and only if \a other has the same contents as this map.
|
||||||
|
*/
|
||||||
|
bool operator==(const PropertyMap &other) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns false if and only \a other has the same contents as this map.
|
||||||
|
*/
|
||||||
|
bool operator!=(const PropertyMap &other) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* If a PropertyMap is read from a File object using File::properties(),
|
||||||
|
* the StringList returned from this function will represent metadata
|
||||||
|
* that could not be parsed into the PropertyMap representation. This could
|
||||||
|
* be e.g. binary data, unknown ID3 frames, etc.
|
||||||
|
* You can remove items from the returned list, which tells TagLib to remove
|
||||||
|
* those unsupported elements if you call File::setProperties() with the
|
||||||
|
* same PropertyMap as argument.
|
||||||
|
*/
|
||||||
|
StringList &unsupportedData();
|
||||||
|
const StringList &unsupportedData() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes all entries which have an empty value list.
|
||||||
|
*/
|
||||||
|
void removeEmpty();
|
||||||
|
|
||||||
|
String toString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
StringList unsupported;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* TAGLIB_PROPERTYMAP_H_ */
|
|
@ -0,0 +1,114 @@
|
||||||
|
/***************************************************************************
|
||||||
|
copyright : (C) 2013 by Tsuda Kageyu
|
||||||
|
email : tsuda.kageyu@gmail.com
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* 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 *
|
||||||
|
* *
|
||||||
|
* Alternatively, this file is available under the Mozilla Public *
|
||||||
|
* License Version 1.1. You may obtain a copy of the License at *
|
||||||
|
* http://www.mozilla.org/MPL/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TAGLIB_REFCOUNTER_H
|
||||||
|
#define TAGLIB_REFCOUNTER_H
|
||||||
|
|
||||||
|
#include "taglib_export.h"
|
||||||
|
#include "taglib.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# define OSATOMIC_DEPRECATED 0
|
||||||
|
# include <libkern/OSAtomic.h>
|
||||||
|
# define TAGLIB_ATOMIC_MAC
|
||||||
|
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
|
# ifndef NOMINMAX
|
||||||
|
# define NOMINMAX
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# define TAGLIB_ATOMIC_WIN
|
||||||
|
#elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \
|
||||||
|
&& (defined(__i386__) || defined(__i486__) || defined(__i586__) || \
|
||||||
|
defined(__i686__) || defined(__x86_64) || defined(__ia64)) \
|
||||||
|
&& !defined(__INTEL_COMPILER)
|
||||||
|
# define TAGLIB_ATOMIC_GCC
|
||||||
|
#elif defined(__ia64) && defined(__INTEL_COMPILER)
|
||||||
|
# include <ia64intrin.h>
|
||||||
|
# define TAGLIB_ATOMIC_GCC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
|
||||||
|
/*!
|
||||||
|
* \internal
|
||||||
|
* This is just used as a base class for shared classes in TagLib.
|
||||||
|
*
|
||||||
|
* \warning This <b>is not</b> part of the TagLib public API!
|
||||||
|
*/
|
||||||
|
namespace TagLib
|
||||||
|
{
|
||||||
|
|
||||||
|
class TAGLIB_EXPORT RefCounter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RefCounter();
|
||||||
|
virtual ~RefCounter();
|
||||||
|
|
||||||
|
void ref();
|
||||||
|
bool deref();
|
||||||
|
int count() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class RefCounterPrivate;
|
||||||
|
RefCounterPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
// BIC this old class is needed by tlist.tcc and tmap.tcc
|
||||||
|
class RefCounterOld
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RefCounterOld() : refCount(1) {}
|
||||||
|
|
||||||
|
#ifdef TAGLIB_ATOMIC_MAC
|
||||||
|
void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); }
|
||||||
|
bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); }
|
||||||
|
int32_t count() { return refCount; }
|
||||||
|
private:
|
||||||
|
volatile int32_t refCount;
|
||||||
|
#elif defined(TAGLIB_ATOMIC_WIN)
|
||||||
|
void ref() { InterlockedIncrement(&refCount); }
|
||||||
|
bool deref() { return ! InterlockedDecrement(&refCount); }
|
||||||
|
long count() { return refCount; }
|
||||||
|
private:
|
||||||
|
volatile long refCount;
|
||||||
|
#elif defined(TAGLIB_ATOMIC_GCC)
|
||||||
|
void ref() { __sync_add_and_fetch(&refCount, 1); }
|
||||||
|
bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); }
|
||||||
|
int count() { return refCount; }
|
||||||
|
private:
|
||||||
|
volatile int refCount;
|
||||||
|
#else
|
||||||
|
void ref() { refCount++; }
|
||||||
|
bool deref() { return ! --refCount; }
|
||||||
|
int count() { return refCount; }
|
||||||
|
private:
|
||||||
|
unsigned int refCount;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DO_NOT_DOCUMENT
|
||||||
|
#endif
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue