commit e8905b1ce2a58ef91234a7bed0b197d2e65b9dc7
Author: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Fri Aug 4 16:54:47 2017 +0500
Added some patches to fix build under other architectures.
libtgvoip-build-fixes.patch | 150 ++++++++++++++++++++++++++++++++++++++++++--
libtgvoip.spec | 5 +-
2 files changed, 150 insertions(+), 5 deletions(-)
---
diff --git a/libtgvoip-build-fixes.patch b/libtgvoip-build-fixes.patch
index cbd631f..7ae4a62 100644
--- a/libtgvoip-build-fixes.patch
+++ b/libtgvoip-build-fixes.patch
@@ -1,14 +1,17 @@
-From b53352e8801e65c6a2e7ef1573d6f2bf0696c7cd Mon Sep 17 00:00:00 2001
+From a396724480f232267f2b100d35193204e0df3953 Mon Sep 17 00:00:00 2001
From: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Thu, 6 Jul 2017 17:27:01 +0200
Subject: [PATCH] Fixed build of libtgvoip under Fedora as shared library.
---
- libtgvoip.gyp | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
+ libtgvoip.gyp | 17 +++++++++-----
+ webrtc_dsp/webrtc/common_audio/wav_file.cc | 20 ++++++++++++----
+ webrtc_dsp/webrtc/common_audio/wav_header.cc | 34 +++++++++++++++++++++++++++-
+ webrtc_dsp/webrtc/typedefs.h | 12 +++++++++-
+ 4 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/libtgvoip.gyp b/libtgvoip.gyp
-index 527708d..c5d2cd5 100644
+index 527708d..f5db56a 100644
--- a/libtgvoip.gyp
+++ b/libtgvoip.gyp
@@ -4,7 +4,8 @@
@@ -35,6 +38,145 @@ index 527708d..c5d2cd5 100644
],
'direct_dependent_settings': {
'include_dirs': [
+@@ -381,9 +382,6 @@
+ 'defines': [
+ 'WEBRTC_POSIX',
+ ],
+- 'cflags_cc': [
+- '-msse2',
+- ],
+ 'direct_dependent_settings': {
+ 'libraries': [
+
+@@ -391,6 +389,13 @@
+ },
+ },
+ ],
++ [
++ '"<!(uname -p)" == "i686"', {
++ 'cflags_cc': [
++ '-msse2',
++ ],
++ }
++ ],
+ ],
+ },
+ ],
+diff --git a/webrtc_dsp/webrtc/common_audio/wav_file.cc
b/webrtc_dsp/webrtc/common_audio/wav_file.cc
+index 2b9098a..4f99da7 100644
+--- a/webrtc_dsp/webrtc/common_audio/wav_file.cc
++++ b/webrtc_dsp/webrtc/common_audio/wav_file.cc
+@@ -77,9 +77,6 @@ size_t WavReader::num_samples() const {
+ }
+
+ size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
+-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to big-endian when reading from WAV file"
+-#endif
+ // There could be metadata after the audio; ensure we don't read it.
+ num_samples = std::min(num_samples, num_samples_remaining_);
+ const size_t read =
+@@ -88,6 +85,12 @@ size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
+ RTC_CHECK(read == num_samples || feof(file_handle_));
+ RTC_CHECK_LE(read, num_samples_remaining_);
+ num_samples_remaining_ -= read;
++#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
++ //convert to big-endian
++ for(size_t idx = 0; idx < num_samples; idx++) {
++ samples[idx] = (samples[idx]<<8) | (samples[idx]>>8);
++ }
++#endif
+ return read;
+ }
+
+@@ -144,10 +147,17 @@ size_t WavWriter::num_samples() const {
+
+ void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
+ #ifndef WEBRTC_ARCH_LITTLE_ENDIAN
+-#error "Need to convert samples to little-endian when writing to WAV file"
+-#endif
++ int16_t * le_samples = new int16_t[num_samples];
++ for(size_t idx = 0; idx < num_samples; idx++) {
++ le_samples[idx] = (samples[idx]<<8) | (samples[idx]>>8);
++ }
++ const size_t written =
++ fwrite(le_samples, sizeof(*le_samples), num_samples, file_handle_);
++ delete []le_samples;
++#else
+ const size_t written =
+ fwrite(samples, sizeof(*samples), num_samples, file_handle_);
++#endif
+ RTC_CHECK_EQ(num_samples, written);
+ num_samples_ += written;
+ RTC_CHECK(num_samples_ >= written); // detect size_t overflow
+diff --git a/webrtc_dsp/webrtc/common_audio/wav_header.cc
b/webrtc_dsp/webrtc/common_audio/wav_header.cc
+index 402ea17..b11ee58 100644
+--- a/webrtc_dsp/webrtc/common_audio/wav_header.cc
++++ b/webrtc_dsp/webrtc/common_audio/wav_header.cc
+@@ -127,7 +127,39 @@ static inline std::string ReadFourCC(uint32_t x) {
+ return std::string(reinterpret_cast<char*>(&x), 4);
+ }
+ #else
+-#error "Write be-to-le conversion functions"
++static inline void WriteLE16(uint16_t* f, uint16_t x) {
++ *f = ((x << 8) & 0xff00) | ( ( x >> 8) & 0x00ff);
++}
++
++static inline void WriteLE32(uint32_t* f, uint32_t x) {
++ *f = ( (x & 0x000000ff) << 24 )
++ | ((x & 0x0000ff00) << 8)
++ | ((x & 0x00ff0000) >> 8)
++ | ((x & 0xff000000) >> 24 );
++}
++
++static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
++ *f = (static_cast<uint32_t>(a) << 24 )
++ | (static_cast<uint32_t>(b) << 16)
++ | (static_cast<uint32_t>(c) << 8)
++ | (static_cast<uint32_t>(d) );
++}
++
++static inline uint16_t ReadLE16(uint16_t x) {
++ return (( x & 0x00ff) << 8 )| ((x & 0xff00)>>8);
++}
++
++static inline uint32_t ReadLE32(uint32_t x) {
++ return ( (x & 0x000000ff) << 24 )
++ | ( (x & 0x0000ff00) << 8 )
++ | ( (x & 0x00ff0000) >> 8)
++ | ( (x & 0xff000000) >> 24 );
++}
++
++static inline std::string ReadFourCC(uint32_t x) {
++ x = ReadLE32(x);
++ return std::string(reinterpret_cast<char*>(&x), 4);
++}
+ #endif
+
+ static inline uint32_t RiffChunkSize(size_t bytes_in_payload) {
+diff --git a/webrtc_dsp/webrtc/typedefs.h b/webrtc_dsp/webrtc/typedefs.h
+index c960d95..69740b0 100644
+--- a/webrtc_dsp/webrtc/typedefs.h
++++ b/webrtc_dsp/webrtc/typedefs.h
+@@ -48,7 +48,17 @@
+ #define WEBRTC_ARCH_32_BITS
+ #define WEBRTC_ARCH_LITTLE_ENDIAN
+ #else
+-#error Please add support for your architecture in typedefs.h
++#define WEBRTC_ARCH_LITTLE_ENDIAN
++#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
++#define WEBRTC_ARCH_BIG_ENDIAN
++#else
++#error __BYTE_ORDER__ is not defined
++#endif
++#if defined(__LP64__)
++#define WEBRTC_ARCH_64_BITS
++#else
++#define WEBRTC_ARCH_32_BITS
++#endif
+ #endif
+
+ #if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN))
--
2.13.3
diff --git a/libtgvoip.spec b/libtgvoip.spec
index ed38009..175bda8 100644
--- a/libtgvoip.spec
+++ b/libtgvoip.spec
@@ -5,7 +5,7 @@
Summary: VoIP library for Telegram clients
Name: libtgvoip
Version: 1.0
-Release: 2.%{date}git%{shortcommit0}%{?dist}
+Release: 3.%{date}git%{shortcommit0}%{?dist}
# Libtgvoip shared library - Public Domain.
# Bundled webrtc library - BSD with patented echo cancellation algorithms.
@@ -76,6 +76,9 @@ find audio -maxdepth 1 -type f -name "*.h" -exec install -m
0644 -p '{}' %{build
%{_libdir}/%{name}.so
%changelog
+* Fri Aug 04 2017 Vitaly Zaitsev <vitaly(a)easycoding.org> -
1.0-3.20170801gitbfd5cfe
+- Fixed build other another architectures.
+
* Wed Aug 02 2017 Vitaly Zaitsev <vitaly(a)easycoding.org> -
1.0-2.20170801gitbfd5cfe
- Updated to latest snapshot. Small SPEC fixes. Added virtual provides.