Skip to content

Commit

Permalink
Update to 7.9.0 (2384)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Jul 30, 2021
1 parent 7a60f94 commit 3e5d2ba
Show file tree
Hide file tree
Showing 170 changed files with 4,686 additions and 1,379 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ android {
}
}

defaultConfig.versionCode = 2376
defaultConfig.versionCode = 2384

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand All @@ -318,7 +318,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionName "7.8.2"
versionName "7.9.0"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ target_compile_definitions(sqlite PUBLIC
#voip
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)

set(NATIVE_LIB "tmessages.39")
set(NATIVE_LIB "tmessages.40")

#tmessages
add_library(${NATIVE_LIB} SHARED
Expand Down
6 changes: 3 additions & 3 deletions TMessagesProj/jni/TgNetWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ void setUserId(JNIEnv *env, jclass c, jint instanceNum, int32_t id) {
ConnectionsManager::getInstance(instanceNum).setUserId(id);
}

void switchBackend(JNIEnv *env, jclass c, jint instanceNum) {
ConnectionsManager::getInstance(instanceNum).switchBackend();
void switchBackend(JNIEnv *env, jclass c, jint instanceNum, jboolean restart) {
ConnectionsManager::getInstance(instanceNum).switchBackend(restart);
}

void pauseNetwork(JNIEnv *env, jclass c, jint instanceNum) {
Expand Down Expand Up @@ -448,7 +448,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = {
{"native_setLangCode", "(ILjava/lang/String;)V", (void *) setLangCode},
{"native_setRegId", "(ILjava/lang/String;)V", (void *) setRegId},
{"native_setSystemLangCode", "(ILjava/lang/String;)V", (void *) setSystemLangCode},
{"native_switchBackend", "(I)V", (void *) switchBackend},
{"native_switchBackend", "(IZ)V", (void *) switchBackend},
{"native_pauseNetwork", "(I)V", (void *) pauseNetwork},
{"native_resumeNetwork", "(IZ)V", (void *) resumeNetwork},
{"native_updateDcSettings", "(I)V", (void *) updateDcSettings},
Expand Down
8 changes: 5 additions & 3 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1885,14 +1885,16 @@ void ConnectionsManager::setUserId(int32_t userId) {
});
}

void ConnectionsManager::switchBackend() {
scheduleTask([&] {
void ConnectionsManager::switchBackend(bool restart) {
scheduleTask([&, restart] {
currentDatacenterId = 1;
testBackend = !testBackend;
datacenters.clear();
initDatacenters();
saveConfig();
exit(1);
if (restart) {
exit(1);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/tgnet/ConnectionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ConnectionsManager {
void setDelegate(ConnectiosManagerDelegate *connectiosManagerDelegate);
ConnectionState getConnectionState();
void setUserId(int32_t userId);
void switchBackend();
void switchBackend(bool restart);
void resumeNetwork(bool partial);
void pauseNetwork();
void setNetworkAvailable(bool value, int32_t type, bool slow);
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/voip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2218,6 +2218,7 @@ add_library(voipandroid STATIC
voip/webrtc/modules/audio_device/android/audio_manager.cc
voip/webrtc/modules/audio_device/android/audio_record_jni.cc
voip/webrtc/modules/audio_device/android/audio_screen_record_jni.cc
voip/webrtc/modules/audio_device/android/audio_merged_screen_record_jni.cc
voip/webrtc/modules/audio_device/android/audio_track_jni.cc
voip/webrtc/modules/audio_device/android/build_info.cc
voip/webrtc/modules/audio_device/android/opensles_common.cc
Expand Down
47 changes: 35 additions & 12 deletions TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ struct InstanceHolder {
std::unique_ptr<Instance> nativeInstance;
std::unique_ptr<GroupInstanceCustomImpl> groupNativeInstance;
std::shared_ptr<tgcalls::VideoCaptureInterface> _videoCapture;
std::shared_ptr<tgcalls::VideoCaptureInterface> _screenVideoCapture;
std::shared_ptr<PlatformContext> _platformContext;
std::map<std::string, SetVideoSink> remoteGroupSinks;
bool useScreencast = false;
};

jlong getInstanceHolderId(JNIEnv *env, jobject obj) {
Expand Down Expand Up @@ -846,9 +848,9 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_createVi
initWebRTC(env);
std::unique_ptr<VideoCaptureInterface> capture;
if (type == 0 || type == 1) {
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", std::make_shared<AndroidContext>(env, nullptr, false));
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", false, std::make_shared<AndroidContext>(env, nullptr, false));
} else {
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", std::make_shared<AndroidContext>(env, nullptr, true));
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", true, std::make_shared<AndroidContext>(env, nullptr, true));
}
capture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
capture->setState(VideoState::Active);
Expand All @@ -866,6 +868,15 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_activateV
capturer->setState(VideoState::Active);
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_clearVideoCapturer(JNIEnv *env, jobject obj) {
InstanceHolder *instance = getInstanceHolder(env, obj);
if (instance->nativeInstance) {
instance->nativeInstance->setVideoCapture(nullptr);
} else if (instance->groupNativeInstance) {
instance->groupNativeInstance->setVideoSource(nullptr);
}
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_destroyVideoCapturer(JNIEnv *env, jclass clazz, jlong videoCapturer) {
auto capturer = reinterpret_cast<VideoCaptureInterface *>(videoCapturer);
delete capturer;
Expand Down Expand Up @@ -899,24 +910,35 @@ JNIEXPORT jboolean JNICALL Java_org_telegram_messenger_voip_NativeInstance_hasVi

JNIEXPORT void Java_org_telegram_messenger_voip_NativeInstance_setVideoState(JNIEnv *env, jobject obj, jint state) {
InstanceHolder *instance = getInstanceHolder(env, obj);
if (instance->_videoCapture == nullptr) {
std::shared_ptr<tgcalls::VideoCaptureInterface> capturer = instance->useScreencast ? instance->_screenVideoCapture : instance->_videoCapture;
if (capturer == nullptr) {
return;
}
instance->_videoCapture->setState(static_cast<VideoState>(state));
capturer->setState(static_cast<VideoState>(state));
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink, jboolean front) {
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink, jint type) {
InstanceHolder *instance = getInstanceHolder(env, obj);
if (instance->_videoCapture) {
return;
std::shared_ptr<tgcalls::VideoCaptureInterface> capturer;
if (type == 0 || type == 1) {
if (instance->_videoCapture == nullptr) {
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", false, instance->_platformContext);
}
capturer = instance->_videoCapture;
instance->useScreencast = false;
} else {
if (instance->_screenVideoCapture == nullptr) {
instance->_screenVideoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", true, instance->_platformContext);
}
capturer = instance->_screenVideoCapture;
instance->useScreencast = true;
}
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), front ? "front" : "back", instance->_platformContext);
instance->_videoCapture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
instance->_videoCapture->setState(VideoState::Active);
capturer->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
capturer->setState(VideoState::Active);
if (instance->nativeInstance) {
instance->nativeInstance->setVideoCapture(instance->_videoCapture);
instance->nativeInstance->setVideoCapture(capturer);
} else if (instance->groupNativeInstance) {
instance->groupNativeInstance->setVideoCapture(instance->_videoCapture);
instance->groupNativeInstance->setVideoCapture(capturer);
}
}

Expand All @@ -931,6 +953,7 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutg
instance->_videoCapture->setState(VideoState::Active);
if (instance->nativeInstance) {
instance->nativeInstance->setVideoCapture(instance->_videoCapture);
instance->useScreencast = false;
} else if (instance->groupNativeInstance) {
instance->groupNativeInstance->setVideoCapture(instance->_videoCapture);
}
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/voip/tgcalls/AudioDeviceHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bool SkipDefaultDevice(const char *name) {
} // namespace

void SetAudioInputDeviceById(webrtc::AudioDeviceModule *adm, const std::string &id) {
const auto recording = adm->Recording();
const auto recording = adm->Recording() || adm->RecordingIsInitialized();
if (recording) {
adm->StopRecording();
}
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/voip/tgcalls/FakeVideoTrackSource.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <functional>
#include <memory>

namespace webrtc {
class VideoTrackSourceInterface;
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/jni/voip/tgcalls/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class Instance {
virtual void setInputVolume(float level) = 0;
virtual void setOutputVolume(float level) = 0;
virtual void setAudioOutputDuckingEnabled(bool enabled) = 0;
virtual void addExternalAudioSamples(std::vector<uint8_t> &&samples) {
}

virtual void setIsLowBatteryLevel(bool isLowBatteryLevel) = 0;

Expand Down
6 changes: 6 additions & 0 deletions TMessagesProj/jni/voip/tgcalls/InstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ void InstanceImpl::setAudioOutputDuckingEnabled(bool enabled) {
// TODO: not implemented
}

void InstanceImpl::addExternalAudioSamples(std::vector<uint8_t> &&samples) {
_manager->perform(RTC_FROM_HERE, [samples = std::move(samples)](Manager *manager) mutable {
manager->addExternalAudioSamples(std::move(samples));
});
}

void InstanceImpl::setIsLowBatteryLevel(bool isLowBatteryLevel) {
_manager->perform(RTC_FROM_HERE, [isLowBatteryLevel](Manager *manager) {
manager->setIsLowBatteryLevel(isLowBatteryLevel);
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/voip/tgcalls/InstanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class InstanceImpl final : public Instance {
void setInputVolume(float level) override;
void setOutputVolume(float level) override;
void setAudioOutputDuckingEnabled(bool enabled) override;
void addExternalAudioSamples(std::vector<uint8_t> &&samples) override;
void setIsLowBatteryLevel(bool isLowBatteryLevel) override;
std::string getLastError() override;
std::string getDebugInfo() override;
Expand Down
6 changes: 6 additions & 0 deletions TMessagesProj/jni/voip/tgcalls/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,10 @@ void Manager::setOutputVolume(float level) {
});
}

void Manager::addExternalAudioSamples(std::vector<uint8_t> &&samples) {
_mediaManager->perform(RTC_FROM_HERE, [samples = std::move(samples)](MediaManager *mediaManager) mutable {
mediaManager->addExternalAudioSamples(std::move(samples));
});
}

} // namespace tgcalls
2 changes: 2 additions & 0 deletions TMessagesProj/jni/voip/tgcalls/Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Manager final : public std::enable_shared_from_this<Manager> {
void setInputVolume(float level);
void setOutputVolume(float level);

void addExternalAudioSamples(std::vector<uint8_t> &&samples);

private:
void sendSignalingAsync(int delayMs, int cause);
void receiveMessage(DecryptedMessage &&message);
Expand Down
Loading

0 comments on commit 3e5d2ba

Please sign in to comment.