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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
Copyright (C) 2004, 2005 Benjamin Meyer <ben at meyerhome dot net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef AUDIOCD_ENCODER_H
#define AUDIOCD_ENCODER_H
#include <sys/types.h>
#include <kio/slavebase.h>
#include <cdinfo.h>
class KConfigSkeleton;
using namespace KCDDB;
class AudioCDEncoder {
public:
/**
* Constructor.
* @param slave parent that this classes can use to call data() with
* when finished encoding bits.
*/
explicit AudioCDEncoder(KIO::SlaveBase *slave) : ioslave(slave) {};
/**
* Deconstructor.
*/
virtual ~AudioCDEncoder(){};
/**
* Initiallizes the decoder, loading libraries, etc. Encoders
* that don't return true will will deleted and not used.
* @returns false if unable to initialize the encoder.
*/
virtual bool init() = 0;
/**
* The encoder should read in its config data here.
*/
virtual void loadSettings() = 0;
/**
* Helper function to determine the end size of a
* encoded file.
* @param time_secs the lengh of the audio track in seconds.
* @returns the size of a file if it is time_secs in length.
*/
virtual unsigned long size(long time_secs) const = 0;
/**
* @returns the generic user string type/name of this encoder
* Examples: "MP3", "Ogg Vorbis", "Wav", "FID Level 2", etc
*/
virtual QString type() const = 0;
/**
* @returns the mime type for the files this encoder produces.
* Example: "audio/x-wav"
*/
virtual const char * mimeType() const = 0;
/**
* @returns the file type for the files this encoder produces.
* Used in naming of the file for example foo.mp3
* Examples: "mp3", "ogg", "wav"
*/
virtual const char * fileType() const = 0;
/**
* Before the read functions are called this is
* called to allow the encoders to store the cddb
* information if they want to so it can be inserted
* where neccessary (start, middle, end, or combos etc).
*/
virtual void fillSongInfo( KCDDB::CDInfo info, int track, const QString &comment ) = 0;
/**
* Perform any initial file creation necessary for a new song (that
* has just been sent via fillSongInfo())
* @param size - the total binary size of the end file (via size()).
* @return size of the data that was created by this function.
*/
virtual long readInit(long size) = 0;
/**
* Passes a little bit of cd data to be encoded
* This function is most likly called many many times.
* @param buf pointer to the audio that has been read in so far
* @param frames the number of frames of audio that are in buf
* @return size of the data that was created by this function, -1 on error.
*/
virtual long read(int16_t * buf, int frames) = 0;
/**
* Perform any final file creation/padding that is necessary
* @return size of the data that was created by this function.
*/
virtual long readCleanup() = 0;
/**
* Returns a configure widget for the encoder
*/
virtual QWidget* getConfigureWidget(KConfigSkeleton** manager) const
{ Q_UNUSED(manager); return NULL; };
/**
* Returns the last error message; called when e.g. read() returns -1.
*/
virtual QString lastErrorMessage() const { return QString::null; }
/**
* Helper function to load all of the AudioCD Encoders from libraries.
* Uses KStandardDirs to find where libraries could be, opens all of the ones
* that we might own audiocd_encoder_* and then uses the symbol
* create_audiocd_encoders to obtain the encoders from that library.
* @param slave ioslave needed if the plugin is going to be used to encode something.
* @param encoders container for new encoders.
*/
static void findAllPlugins(KIO::SlaveBase *slave, QPtrList<AudioCDEncoder> &encoders);
protected:
/**
* Pointer to the ioslave that is running this encoder.
* Used (only?) for the data() function to pass back encoded data.
*/
KIO::SlaveBase *ioslave;
};
#endif // AUDIOCD_ENCODER_H
|