From 53c536d76d4dbd7d0c181dbb48b5a7245b068ab7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 24 May 2015 21:39:07 +0300 Subject: [PATCH 1/2] libmpg123, libfaad and libmp4ff added to os x build --- Telegram/SourceFiles/audio.cpp | 5 +++-- Telegram/SourceFiles/audio.h | 2 +- Telegram/Telegram.xcodeproj/project.pbxproj | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/audio.cpp b/Telegram/SourceFiles/audio.cpp index f48f015579..21025b9738 100644 --- a/Telegram/SourceFiles/audio.cpp +++ b/Telegram/SourceFiles/audio.cpp @@ -987,7 +987,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; } @@ -1027,7 +1027,8 @@ private: mp4ff_callback_t mp4cb; bool initial, useAacLength; - int32 framesize, timescale; + uint32 framesize; + int32 timescale; int32 trackId, sampleId, samplesCount; int32 getAACTrack() { diff --git a/Telegram/SourceFiles/audio.h b/Telegram/SourceFiles/audio.h index a77c310c57..70aa791e09 100644 --- a/Telegram/SourceFiles/audio.h +++ b/Telegram/SourceFiles/audio.h @@ -36,7 +36,7 @@ enum VoiceMessageState { }; class VoiceMessagesFader; -class VoiceMessagesLoader; +class VoiceMessagesLoaders; class VoiceMessages : public QObject { Q_OBJECT diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 8de202f74f..45b29e6dc5 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -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; From c5dd99b1f1820907fac58b15af12d1a937211a1a Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 24 May 2015 21:58:42 +0300 Subject: [PATCH 2/2] added libmpg123 and libfaad to linux version --- Telegram/FixMake.sh | 3 +++ Telegram/SourceFiles/audio.cpp | 35 ++++++++++++++++++++++++++-------- Telegram/Telegram.pro | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Telegram/FixMake.sh b/Telegram/FixMake.sh index e54dd57c51..24387e6f99 100755 --- a/Telegram/FixMake.sh +++ b/Telegram/FixMake.sh @@ -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' diff --git a/Telegram/SourceFiles/audio.cpp b/Telegram/SourceFiles/audio.cpp index 21025b9738..a5b34a1e61 100644 --- a/Telegram/SourceFiles/audio.cpp +++ b/Telegram/SourceFiles/audio.cpp @@ -24,9 +24,18 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org #include #include -#include + +#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 + +#define HAVE_STDINT_H #include namespace { @@ -555,7 +564,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; @@ -880,10 +891,15 @@ trackId(-1), sampleId(0), samplesCount(0) { } if (data.isEmpty()) { - mp4cb = { &FAADMp4Loader::_read_file, 0, &FAADMp4Loader::_seek_file, 0, static_cast(this) }; + mp4cb.read = &FAADMp4Loader::_read_file; + mp4cb.seek = &FAADMp4Loader::_seek_file; } else { - mp4cb = { &FAADMp4Loader::_read_data, 0, &FAADMp4Loader::_seek_data, 0, static_cast(this) }; + mp4cb.read = &FAADMp4Loader::_read_data; + mp4cb.seek = &FAADMp4Loader::_seek_data; } + mp4cb.write = 0; + mp4cb.truncate = 0; + mp4cb.user_data = static_cast(this); hDecoder = NeAACDecOpen(); @@ -1142,17 +1158,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 (header.at(0) == 'O' && header.at(1) == 'g' && header.at(2) == 'g' && header.at(3) == 'S') { j = _loaders.insert(audio, new OggOpusLoader(m.fname, m.data)); @@ -1169,7 +1187,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(); diff --git a/Telegram/Telegram.pro b/Telegram/Telegram.pro index b95ee14bf0..256ead3ebe 100644 --- a/Telegram/Telegram.pro +++ b/Telegram/Telegram.pro @@ -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 += \