Skip to content

Commit 3e5d2ba

Browse files
committed
Update to 7.9.0 (2384)
1 parent 7a60f94 commit 3e5d2ba

File tree

170 files changed

+4686
-1379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+4686
-1379
lines changed

TMessagesProj/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ android {
299299
}
300300
}
301301

302-
defaultConfig.versionCode = 2376
302+
defaultConfig.versionCode = 2384
303303

304304
applicationVariants.all { variant ->
305305
variant.outputs.all { output ->
@@ -318,7 +318,7 @@ android {
318318
defaultConfig {
319319
minSdkVersion 16
320320
targetSdkVersion 29
321-
versionName "7.8.2"
321+
versionName "7.9.0"
322322

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

TMessagesProj/jni/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ target_compile_definitions(sqlite PUBLIC
399399
#voip
400400
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)
401401

402-
set(NATIVE_LIB "tmessages.39")
402+
set(NATIVE_LIB "tmessages.40")
403403

404404
#tmessages
405405
add_library(${NATIVE_LIB} SHARED

TMessagesProj/jni/TgNetWrapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ void setUserId(JNIEnv *env, jclass c, jint instanceNum, int32_t id) {
194194
ConnectionsManager::getInstance(instanceNum).setUserId(id);
195195
}
196196

197-
void switchBackend(JNIEnv *env, jclass c, jint instanceNum) {
198-
ConnectionsManager::getInstance(instanceNum).switchBackend();
197+
void switchBackend(JNIEnv *env, jclass c, jint instanceNum, jboolean restart) {
198+
ConnectionsManager::getInstance(instanceNum).switchBackend(restart);
199199
}
200200

201201
void pauseNetwork(JNIEnv *env, jclass c, jint instanceNum) {
@@ -448,7 +448,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = {
448448
{"native_setLangCode", "(ILjava/lang/String;)V", (void *) setLangCode},
449449
{"native_setRegId", "(ILjava/lang/String;)V", (void *) setRegId},
450450
{"native_setSystemLangCode", "(ILjava/lang/String;)V", (void *) setSystemLangCode},
451-
{"native_switchBackend", "(I)V", (void *) switchBackend},
451+
{"native_switchBackend", "(IZ)V", (void *) switchBackend},
452452
{"native_pauseNetwork", "(I)V", (void *) pauseNetwork},
453453
{"native_resumeNetwork", "(IZ)V", (void *) resumeNetwork},
454454
{"native_updateDcSettings", "(I)V", (void *) updateDcSettings},

TMessagesProj/jni/tgnet/ConnectionsManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,14 +1885,16 @@ void ConnectionsManager::setUserId(int32_t userId) {
18851885
});
18861886
}
18871887

1888-
void ConnectionsManager::switchBackend() {
1889-
scheduleTask([&] {
1888+
void ConnectionsManager::switchBackend(bool restart) {
1889+
scheduleTask([&, restart] {
18901890
currentDatacenterId = 1;
18911891
testBackend = !testBackend;
18921892
datacenters.clear();
18931893
initDatacenters();
18941894
saveConfig();
1895-
exit(1);
1895+
if (restart) {
1896+
exit(1);
1897+
}
18961898
});
18971899
}
18981900

TMessagesProj/jni/tgnet/ConnectionsManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ConnectionsManager {
5858
void setDelegate(ConnectiosManagerDelegate *connectiosManagerDelegate);
5959
ConnectionState getConnectionState();
6060
void setUserId(int32_t userId);
61-
void switchBackend();
61+
void switchBackend(bool restart);
6262
void resumeNetwork(bool partial);
6363
void pauseNetwork();
6464
void setNetworkAvailable(bool value, int32_t type, bool slow);

TMessagesProj/jni/voip/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,7 @@ add_library(voipandroid STATIC
22182218
voip/webrtc/modules/audio_device/android/audio_manager.cc
22192219
voip/webrtc/modules/audio_device/android/audio_record_jni.cc
22202220
voip/webrtc/modules/audio_device/android/audio_screen_record_jni.cc
2221+
voip/webrtc/modules/audio_device/android/audio_merged_screen_record_jni.cc
22212222
voip/webrtc/modules/audio_device/android/audio_track_jni.cc
22222223
voip/webrtc/modules/audio_device/android/build_info.cc
22232224
voip/webrtc/modules/audio_device/android/opensles_common.cc

TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ struct InstanceHolder {
169169
std::unique_ptr<Instance> nativeInstance;
170170
std::unique_ptr<GroupInstanceCustomImpl> groupNativeInstance;
171171
std::shared_ptr<tgcalls::VideoCaptureInterface> _videoCapture;
172+
std::shared_ptr<tgcalls::VideoCaptureInterface> _screenVideoCapture;
172173
std::shared_ptr<PlatformContext> _platformContext;
173174
std::map<std::string, SetVideoSink> remoteGroupSinks;
175+
bool useScreencast = false;
174176
};
175177

176178
jlong getInstanceHolderId(JNIEnv *env, jobject obj) {
@@ -846,9 +848,9 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_createVi
846848
initWebRTC(env);
847849
std::unique_ptr<VideoCaptureInterface> capture;
848850
if (type == 0 || type == 1) {
849-
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", std::make_shared<AndroidContext>(env, nullptr, false));
851+
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", false, std::make_shared<AndroidContext>(env, nullptr, false));
850852
} else {
851-
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", std::make_shared<AndroidContext>(env, nullptr, true));
853+
capture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", true, std::make_shared<AndroidContext>(env, nullptr, true));
852854
}
853855
capture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
854856
capture->setState(VideoState::Active);
@@ -866,6 +868,15 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_activateV
866868
capturer->setState(VideoState::Active);
867869
}
868870

871+
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_clearVideoCapturer(JNIEnv *env, jobject obj) {
872+
InstanceHolder *instance = getInstanceHolder(env, obj);
873+
if (instance->nativeInstance) {
874+
instance->nativeInstance->setVideoCapture(nullptr);
875+
} else if (instance->groupNativeInstance) {
876+
instance->groupNativeInstance->setVideoSource(nullptr);
877+
}
878+
}
879+
869880
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_destroyVideoCapturer(JNIEnv *env, jclass clazz, jlong videoCapturer) {
870881
auto capturer = reinterpret_cast<VideoCaptureInterface *>(videoCapturer);
871882
delete capturer;
@@ -899,24 +910,35 @@ JNIEXPORT jboolean JNICALL Java_org_telegram_messenger_voip_NativeInstance_hasVi
899910

900911
JNIEXPORT void Java_org_telegram_messenger_voip_NativeInstance_setVideoState(JNIEnv *env, jobject obj, jint state) {
901912
InstanceHolder *instance = getInstanceHolder(env, obj);
902-
if (instance->_videoCapture == nullptr) {
913+
std::shared_ptr<tgcalls::VideoCaptureInterface> capturer = instance->useScreencast ? instance->_screenVideoCapture : instance->_videoCapture;
914+
if (capturer == nullptr) {
903915
return;
904916
}
905-
instance->_videoCapture->setState(static_cast<VideoState>(state));
917+
capturer->setState(static_cast<VideoState>(state));
906918
}
907919

908-
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink, jboolean front) {
920+
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink, jint type) {
909921
InstanceHolder *instance = getInstanceHolder(env, obj);
910-
if (instance->_videoCapture) {
911-
return;
922+
std::shared_ptr<tgcalls::VideoCaptureInterface> capturer;
923+
if (type == 0 || type == 1) {
924+
if (instance->_videoCapture == nullptr) {
925+
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), type == 1 ? "front" : "back", false, instance->_platformContext);
926+
}
927+
capturer = instance->_videoCapture;
928+
instance->useScreencast = false;
929+
} else {
930+
if (instance->_screenVideoCapture == nullptr) {
931+
instance->_screenVideoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), "screen", true, instance->_platformContext);
932+
}
933+
capturer = instance->_screenVideoCapture;
934+
instance->useScreencast = true;
912935
}
913-
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(StaticThreads::getThreads(), front ? "front" : "back", instance->_platformContext);
914-
instance->_videoCapture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
915-
instance->_videoCapture->setState(VideoState::Active);
936+
capturer->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
937+
capturer->setState(VideoState::Active);
916938
if (instance->nativeInstance) {
917-
instance->nativeInstance->setVideoCapture(instance->_videoCapture);
939+
instance->nativeInstance->setVideoCapture(capturer);
918940
} else if (instance->groupNativeInstance) {
919-
instance->groupNativeInstance->setVideoCapture(instance->_videoCapture);
941+
instance->groupNativeInstance->setVideoCapture(capturer);
920942
}
921943
}
922944

@@ -931,6 +953,7 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutg
931953
instance->_videoCapture->setState(VideoState::Active);
932954
if (instance->nativeInstance) {
933955
instance->nativeInstance->setVideoCapture(instance->_videoCapture);
956+
instance->useScreencast = false;
934957
} else if (instance->groupNativeInstance) {
935958
instance->groupNativeInstance->setVideoCapture(instance->_videoCapture);
936959
}

TMessagesProj/jni/voip/tgcalls/AudioDeviceHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool SkipDefaultDevice(const char *name) {
2222
} // namespace
2323

2424
void SetAudioInputDeviceById(webrtc::AudioDeviceModule *adm, const std::string &id) {
25-
const auto recording = adm->Recording();
25+
const auto recording = adm->Recording() || adm->RecordingIsInitialized();
2626
if (recording) {
2727
adm->StopRecording();
2828
}

TMessagesProj/jni/voip/tgcalls/FakeVideoTrackSource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <functional>
4+
#include <memory>
45

56
namespace webrtc {
67
class VideoTrackSourceInterface;

TMessagesProj/jni/voip/tgcalls/Instance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ class Instance {
191191
virtual void setInputVolume(float level) = 0;
192192
virtual void setOutputVolume(float level) = 0;
193193
virtual void setAudioOutputDuckingEnabled(bool enabled) = 0;
194+
virtual void addExternalAudioSamples(std::vector<uint8_t> &&samples) {
195+
}
194196

195197
virtual void setIsLowBatteryLevel(bool isLowBatteryLevel) = 0;
196198

0 commit comments

Comments
 (0)