KVIrc  4.9.2
DeveloperAPIs
MpMp3.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // File : MpMp3.h
4 // Creation date : Fri Mar 25 20:01:25 2005 GMT by Szymon Stefanek
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2005-2010 Szymon Stefanek (pragma at kvirc dot net)
8 //
9 // This file is based on the mp3tech.h. It is released under the original
10 // license and the original copyright notice follows.
11 //
12 // mp3tech.hCO
13 //
14 // Copyright (C) 2000 Cedric Tefft <cedric@earthling.net>
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program; if not, write to the Free Software Foundation
28 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 //
30 // This file is based in part on:
31 //
32 // * MP3Info 0.5 by Ricardo Cerqueira <rmc@rccn.net>
33 // * MP3Stat 0.9 by Ed Sweetman <safemode@voicenet.com> and
34 // Johannes Overmann <overmann@iname.com>
35 //
36 // There has been also a remarkable work by Cristopher Tieckle (Crissi)
37 //
38 //=============================================================================
39 
40 // MIN_CONSEC_GOOD_FRAMES defines how many consecutive valid MP3 frames
41 // we need to see before we decide we are looking at a real MP3 file
42 #define MIN_CONSEC_GOOD_FRAMES 4
43 #define FRAME_HEADER_SIZE 4
44 #define MIN_FRAME_SIZE 21
45 #define NUM_SAMPLES 4
46 #define TEXT_FIELD_LEN 30
47 #define INT_FIELD_LEN 4
48 
49 #include "kvi_settings.h"
50 
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <QString>
54 
55 #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)
56 #include <unistd.h>
57 #include <sys/stat.h>
58 #include <ctype.h>
59 #include <string.h>
60 #endif
61 
63 {
67 };
68 
69 typedef struct
70 {
71  unsigned int sync;
72  unsigned int version;
73  unsigned int layer;
74  unsigned int crc;
75  unsigned int bitrate;
76  unsigned int freq;
77  unsigned int padding;
78  unsigned int extension;
79  unsigned int mode;
80  unsigned int mode_extension;
81  unsigned int copyright;
82  unsigned int original;
83  unsigned int emphasis;
84 } mp3header;
85 
86 typedef struct
87 {
88  char title[31];
89  char artist[31];
90  char album[31];
91  char year[5];
92  char comment[31];
93  unsigned char track[1];
94  unsigned char genre[1];
95 } id3tag;
96 
97 typedef struct
98 {
99  QString filename;
100  FILE * file;
101  unsigned int datasize;
106  int vbr;
107  float vbr_average;
108  int seconds;
109  int frames;
111 } mp3info;
112 
113 // mode field:
114 // 00 - Stereo
115 // 01 - Joint stereo (Stereo)
116 // 10 - Dual channel (2 mono channels)
117 // 11 - Single channel (Mono)
118 
119 bool scan_mp3_file(QString & szFileName, mp3info * i);
120 
122 
125 const char * header_emphasis(mp3header * h);
126 const char * header_mode(mp3header * h);
127 int header_layer(mp3header * h);
128 int header_bitrate(mp3header * h);
129 double header_version(mp3header * h);
130 int header_crc(mp3header * h);
131 int get_header(FILE * file, mp3header * header);
132 int frame_length(mp3header * header);
133 int sameConstant(mp3header * h1, mp3header * h2);
134 int get_mp3_info(mp3info * mp3);
135 int get_id3(mp3info * mp3);
136 char * pad(char * string, int length);
137 char * unpad(char * string);
138 int get_first_header(mp3info * mp3, long startpos);
139 //void tagedit_curs(char *filename, int filenum, int fileoutof, id3tag *tag);
140 const char * get_typegenre(int idx);
unsigned int bitrate
Definition: MpMp3.h:75
FILE * file
Definition: MpMp3.h:100
int id3_isvalid
Definition: MpMp3.h:104
int frame_length(mp3header *header)
Definition: MpMp3.cpp:319
int frames
Definition: MpMp3.h:109
const char * get_typegenre(int idx)
Definition: MpMp3.cpp:121
Definition: MpMp3.h:86
Definition: MpMp3.h:64
double header_version(mp3header *h)
unsigned int mode
Definition: MpMp3.h:79
int header_frequency(mp3header *h)
Definition: MpMp3.cpp:337
unsigned int original
Definition: MpMp3.h:82
Definition: MpMp3.h:69
char * unpad(char *string)
Definition: MpMp3.cpp:439
float vbr_average
Definition: MpMp3.h:107
unsigned int freq
Definition: MpMp3.h:76
int header_isvalid
Definition: MpMp3.h:102
#define i
Definition: detector.cpp:73
int seconds
Definition: MpMp3.h:108
int header_crc(mp3header *h)
Definition: MpMp3.cpp:357
#define h
Definition: detector.cpp:72
void resetmp3infoStruct(mp3info *i)
Definition: MpMp3.cpp:179
unsigned int layer
Definition: MpMp3.h:73
int get_id3(mp3info *mp3)
Definition: MpMp3.cpp:373
Definition: MpMp3.h:65
int get_mp3_info(mp3info *mp3)
Definition: MpMp3.cpp:194
unsigned int sync
Definition: MpMp3.h:71
int get_header(FILE *file, mp3header *header)
Definition: MpMp3.cpp:284
mp3header header
Definition: MpMp3.h:103
int header_bitrate(mp3header *h)
Definition: MpMp3.cpp:329
id3tag id3
Definition: MpMp3.h:105
int badframes
Definition: MpMp3.h:110
int header_layer(mp3header *h)
Definition: MpMp3.cpp:324
const char * header_mode(mp3header *h)
Definition: MpMp3.cpp:347
unsigned int mode_extension
Definition: MpMp3.h:80
char * pad(char *string, int length)
Definition: MpMp3.cpp:423
unsigned int extension
Definition: MpMp3.h:78
unsigned int padding
Definition: MpMp3.h:77
unsigned int copyright
Definition: MpMp3.h:81
unsigned int datasize
Definition: MpMp3.h:101
int get_first_header(mp3info *mp3, long startpos)
Definition: MpMp3.cpp:235
const char * header_emphasis(mp3header *h)
Definition: MpMp3.cpp:342
Definition: MpMp3.h:66
bool scan_mp3_file(QString &szFileName, mp3info *i)
Definition: MpMp3.cpp:447
This file contains compile time settings.
int header_channels(mp3header *h)
Definition: MpMp3.cpp:352
int vbr
Definition: MpMp3.h:106
unsigned int crc
Definition: MpMp3.h:74
QString filename
Definition: MpMp3.h:99
unsigned int emphasis
Definition: MpMp3.h:83
VBR_REPORT
Definition: MpMp3.h:62
int sameConstant(mp3header *h1, mp3header *h2)
Definition: MpMp3.cpp:362
unsigned int version
Definition: MpMp3.h:72
Definition: MpMp3.h:97