Warning, file /multimedia/audiocd-kio/plugins/wav/encoderwav.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002   Copyright (C) 2000 Rik Hemsley (rikkus) <rik@kde.org>
0003   Copyright (C) 2000, 2001, 2002 Michael Matz <matz@kde.org>
0004   Copyright (C) 2001 Carsten Duvenhorst <duvenhorst@m2.uni-hannover.de>
0005   Copyright (C) 2001 Adrian Schroeter <adrian@suse.de>
0006   Copyright (C) 2003 Richard Lärkäng <richard@goteborg.utfors.se>
0007   Copyright (C) 2003 Scott Wheeler <wheeler@kde.org>
0008   Copyright (C) 2004, 2005 Benjamin Meyer <ben at meyerhome dot net>
0009 
0010   This program is free software; you can redistribute it and/or modify
0011   it under the terms of the GNU General Public License as published by
0012   the Free Software Foundation; either version 2 of the License, or
0013   (at your option) any later version.
0014 
0015   This program is distributed in the hope that it will be useful,
0016   but WITHOUT ANY WARRANTY; without even the implied warranty of
0017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0018   GNU General Public License for more details.
0019 
0020   You should have received a copy of the GNU General Public License
0021   along with this program; if not, write to the Free Software
0022   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
0023   USA.
0024 */
0025 
0026 #include "encoderwav.h"
0027 #include <QList>
0028 
0029 extern "C" {
0030 AUDIOCDPLUGINS_EXPORT void create_audiocd_encoders(KIO::WorkerBase *worker, QList<AudioCDEncoder *> &encoders)
0031 {
0032     encoders.append(new EncoderWav(worker));
0033     encoders.append(new EncoderCda(worker));
0034 }
0035 }
0036 
0037 unsigned long EncoderWav::size(long time_secs) const {
0038   return (EncoderCda::size(time_secs) + 44);
0039 }
0040 
0041 const char *EncoderWav::mimeType() const
0042 {
0043     return "audio/x-wav";
0044 }
0045 
0046 long EncoderWav::readInit(long byteCount)
0047 {
0048     static unsigned char riffHeader[] = {
0049         0x52, 0x49, 0x46, 0x46, // 0  "AIFF"
0050         0x00, 0x00, 0x00, 0x00, // 4  wavSize
0051         0x57, 0x41, 0x56, 0x45, // 8  "WAVE"
0052         0x66, 0x6d, 0x74, 0x20, // 12 "fmt "
0053         0x10, 0x00, 0x00, 0x00, // 16
0054         0x01, 0x00, 0x02, 0x00, // 20
0055         0x44, 0xac, 0x00, 0x00, // 24
0056         0x10, 0xb1, 0x02, 0x00, // 28
0057         0x04, 0x00, 0x10, 0x00, // 32
0058         0x64, 0x61, 0x74, 0x61, // 36 "data"
0059         0x00, 0x00, 0x00, 0x00 // 40 byteCount
0060     };
0061 
0062     qint32 wavSize(byteCount + 44 - 8);
0063 
0064     riffHeader[4] = (wavSize >> 0) & 0xff;
0065     riffHeader[5] = (wavSize >> 8) & 0xff;
0066     riffHeader[6] = (wavSize >> 16) & 0xff;
0067     riffHeader[7] = (wavSize >> 24) & 0xff;
0068 
0069     riffHeader[40] = (byteCount >> 0) & 0xff;
0070     riffHeader[41] = (byteCount >> 8) & 0xff;
0071     riffHeader[42] = (byteCount >> 16) & 0xff;
0072     riffHeader[43] = (byteCount >> 24) & 0xff;
0073 
0074     QByteArray output;
0075     output = QByteArray::fromRawData((char *)riffHeader, 44);
0076     ioWorker->data(output);
0077     output.clear();
0078     return 44;
0079 }