This commit is contained in:
John Preston 2015-05-26 11:19:52 +03:00
commit 6b60b51775
5 changed files with 47 additions and 12 deletions

View File

@ -27,3 +27,6 @@ Replace '\-lopusfile' '\/usr\/local\/lib\/libopusfile\.a'
Replace '\-lopus' '\/usr\/local\/lib\/libopus\.a'
Replace '\-lopenal' '\/usr\/local\/lib\/libopenal\.a'
Replace '\-logg' '\/usr\/local\/lib\/libogg\.a'
Replace '\-lfaad' '\/usr\/local\/lib\/libfaad\.a'
Replace '\-lmpg123' '\/usr\/lib\/x86_64\-linux\-gnu\/libmpg123\.a'
Replace '\-lmp4ff' '\/usr\/local\/lib\/libmp4ff\.a'

View File

@ -24,9 +24,18 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include <ogg/ogg.h>
#include <mpg123.h>
#include <mpeghead.h>
#define _test_HDR_SYNC 0xffe00000
#define _test_HDR_LAYER 0x00060000
#define _test_HDR_LAYER_VAL(h) (((h)&_test_HDR_LAYER) >> 17)
#define _test_HDR_BITRATE 0x0000f000
#define _test_HDR_BITRATE_VAL(h) (((h)&_test_HDR_BITRATE) >> 12)
#define _test_HDR_SAMPLERATE 0x00000c00
#define _test_HDR_SAMPLERATE_VAL(h) (((h)&_test_HDR_SAMPLERATE) >> 10)
#include <neaacdec.h>
#define HAVE_STDINT_H
#include <mp4ff.h>
extern "C" {
@ -567,7 +576,9 @@ public:
OpusFileCallbacks cb = { &OggOpusLoader::_read_data, &OggOpusLoader::_seek_data, &OggOpusLoader::_tell_data, 0 };
if (data.isEmpty()) {
cb = { &OggOpusLoader::_read_file, &OggOpusLoader::_seek_file, &OggOpusLoader::_tell_file, 0 };
cb.read = &OggOpusLoader::_read_file;
cb.seek = &OggOpusLoader::_seek_file;
cb.tell = &OggOpusLoader::_tell_file;
}
int ret = 0;
@ -892,10 +903,15 @@ trackId(-1), sampleId(0), samplesCount(0) {
}
if (data.isEmpty()) {
mp4cb = { &FAADMp4Loader::_read_file, 0, &FAADMp4Loader::_seek_file, 0, static_cast<void*>(this) };
mp4cb.read = &FAADMp4Loader::_read_file;
mp4cb.seek = &FAADMp4Loader::_seek_file;
} else {
mp4cb = { &FAADMp4Loader::_read_data, 0, &FAADMp4Loader::_seek_data, 0, static_cast<void*>(this) };
mp4cb.read = &FAADMp4Loader::_read_data;
mp4cb.seek = &FAADMp4Loader::_seek_data;
}
mp4cb.write = 0;
mp4cb.truncate = 0;
mp4cb.user_data = static_cast<void*>(this);
hDecoder = NeAACDecOpen();
@ -999,7 +1015,7 @@ trackId(-1), sampleId(0), samplesCount(0) {
}
uint32 delay = 0;
if (initial && (sample_count < framesize * frameInfo.channels) && (frameInfo.samples > sample_count)) {
if (initial && (sample_count < framesize * uint32(frameInfo.channels)) && (frameInfo.samples > sample_count)) {
delay = frameInfo.samples - sample_count;
}
@ -1039,7 +1055,8 @@ private:
mp4ff_callback_t mp4cb;
bool initial, useAacLength;
int32 framesize, timescale;
uint32 framesize;
int32 timescale;
int32 trackId, sampleId, samplesCount;
int32 getAACTrack() {
@ -1435,17 +1452,19 @@ void VoiceMessagesLoaders::onLoad(AudioData *audio) {
if (!f.open(QIODevice::ReadOnly)) {
LOG(("Audio Error: could not open file '%1'").arg(m.fname));
m.state = VoiceMessageStoppedAtStart;
return emit error(audio);
emit error(audio);
return;
}
header = f.read(8);
}
if (header.size() < 8) {
LOG(("Audio Error: could not read header from file '%1', data size %2").arg(m.fname).arg(m.data.isEmpty() ? QFileInfo(m.fname).size() : m.data.size()));
m.state = VoiceMessageStoppedAtStart;
return emit error(audio);
emit error(audio);
return;
}
uint32 mpegHead = (uint32(uchar(header.at(0))) << 24) | (uint32(uchar(header.at(1))) << 16) | (uint32(uchar(header.at(2))) << 8) | uint32(uchar(header.at(3)));
bool validMpegHead = ((mpegHead & HDR_SYNC) == HDR_SYNC) && !!(HDR_LAYER_VAL(mpegHead)) && (HDR_BITRATE_VAL(mpegHead) != 0x0F) && (HDR_SAMPLERATE_VAL(mpegHead) != 0x03);
bool validMpegHead = ((mpegHead & _test_HDR_SYNC) == _test_HDR_SYNC) && !!(_test_HDR_LAYER_VAL(mpegHead)) && (_test_HDR_BITRATE_VAL(mpegHead) != 0x0F) && (_test_HDR_SAMPLERATE_VAL(mpegHead) != 0x03);
if (true) {
j = _loaders.insert(audio, new FFMpegLoader(m.fname, m.data));
@ -1464,7 +1483,8 @@ void VoiceMessagesLoaders::onLoad(AudioData *audio) {
} else {
LOG(("Audio Error: could not guess file format from header, header %1 file '%2', data size %3").arg(mb(header.constData(), header.size()).str()).arg(m.fname).arg(m.data.isEmpty() ? QFileInfo(m.fname).size() : m.data.size()));
m.state = VoiceMessageStoppedAtStart;
return emit error(audio);
emit error(audio);
return;
}
l = j.value();

View File

@ -36,7 +36,7 @@ enum VoiceMessageState {
};
class VoiceMessagesFader;
class VoiceMessagesLoader;
class VoiceMessagesLoaders;
class VoiceMessages : public QObject {
Q_OBJECT

View File

@ -300,7 +300,7 @@ INCLUDEPATH += "/usr/include/atk-1.0"
INCLUDEPATH += "/usr/include/dee-1.0"
INCLUDEPATH += "/usr/include/libdbusmenu-glib-0.4"
LIBS += -lcrypto -lssl -lz -ldl -llzma -lexif -lopus -lopusfile -logg -lopenal
LIBS += -lcrypto -lssl -lz -ldl -llzma -lexif -lopus -lopusfile -logg -lopenal -lfaad -lmp4ff -lmpg123
LIBS += ./../../../Libraries/QtStatic/qtbase/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.a
RESOURCES += \

View File

@ -1768,7 +1768,10 @@
./../../Libraries/opus/include,
./../../Libraries/opusfile/include,
"./../../Libraries/openal-soft/include",
"./../../Libraries/mpg123-1.22.1/src/libmpg123",
"./../../Libraries/libexif-0.6.20",
"./../../Libraries/faad2-2.7/include",
"./../../Libraries/faad2-2.7/common/mp4ff",
"/usr/local/Qt-5.4.0/include",
"/usr/local/Qt-5.4.0/include/QtMultimedia",
"/usr/local/Qt-5.4.0/include/QtWidgets",
@ -1857,6 +1860,9 @@
/usr/local/lib/libogg.a,
/usr/local/lib/liblzma.a,
/usr/local/lib/libexif.a,
/usr/local/lib/libmpg123.a,
/usr/local/lib/libfaad.a,
/usr/local/lib/libmp4ff.a,
"../../Libraries/openssl-xcode/libcrypto.a",
);
PRODUCT_NAME = Telegram;
@ -1910,7 +1916,10 @@
./../../Libraries/opus/include,
./../../Libraries/opusfile/include,
"./../../Libraries/openal-soft/include",
"./../../Libraries/mpg123-1.22.1/src/libmpg123",
"./../../Libraries/libexif-0.6.20",
"./../../Libraries/faad2-2.7/include",
"./../../Libraries/faad2-2.7/common/mp4ff",
"/usr/local/Qt-5.4.0/include",
"/usr/local/Qt-5.4.0/include/QtMultimedia",
"/usr/local/Qt-5.4.0/include/QtWidgets",
@ -1998,6 +2007,9 @@
/usr/local/lib/libogg.a,
/usr/local/lib/liblzma.a,
/usr/local/lib/libexif.a,
/usr/local/lib/libmpg123.a,
/usr/local/lib/libfaad.a,
/usr/local/lib/libmp4ff.a,
"../../Libraries/openssl-xcode/libcrypto.a",
);
PRODUCT_NAME = Telegram;