Skip to content

Commit

Permalink
Update to 7.1.1 (2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Oct 1, 2020
1 parent 2eeca37 commit 4992f23
Show file tree
Hide file tree
Showing 85 changed files with 1,063 additions and 7,014 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ android {
}
}

defaultConfig.versionCode = 2092
defaultConfig.versionCode = 2094

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down Expand Up @@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionName "7.1.0"
versionName "7.1.1"

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

Expand Down
24 changes: 15 additions & 9 deletions TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <rtc_base/ssl_adapter.h>
#include <modules/utility/include/jvm_android.h>
#include <sdk/android/native_api/base/init.h>
#include <voip/webrtc/media/base/media_constants.h>
#include <tgnet/FileLog.h>

#include "pc/video_track.h"
#include "legacy/InstanceImplLegacy.h"
Expand Down Expand Up @@ -266,10 +268,13 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeNati
.enableAEC = configObject.getBooleanField("enableAec") == JNI_TRUE,
.enableNS = configObject.getBooleanField("enableNs") == JNI_TRUE,
.enableAGC = configObject.getBooleanField("enableAgc") == JNI_TRUE,
.enableStunMarking = configObject.getBooleanField("enableSm") == JNI_TRUE,
.enableVolumeControl = true,
.logPath = tgvoip::jni::JavaStringToStdString(env, configObject.getStringField("logPath")),
.maxApiLayer = configObject.getIntField("maxApiLayer"),
.preferredAspectRatio = aspectRatio
.enableHighBitrateVideo = true,
.statsLogPath = tgvoip::jni::JavaStringToStdString(env, configObject.getStringField("statsLogPath")),
.preferredVideoCodecs = {cricket::kVp9CodecName}
},
.encryptionKey = EncryptionKey(
std::move(encryptionKeyValue),
Expand Down Expand Up @@ -346,6 +351,7 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeNati
holder->_platformContext = platformContext;
holder->nativeInstance->setIncomingVideoOutput(webrtc::JavaToNativeVideoSink(env, remoteSink));
holder->nativeInstance->setNetworkType(parseNetworkType(networkType));
holder->nativeInstance->setRequestedVideoAspect(aspectRatio);
return reinterpret_cast<jlong>(holder);
}

Expand Down Expand Up @@ -410,9 +416,9 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_stopNativ
});
}

JNIEXPORT long JNICALL Java_org_telegram_messenger_voip_NativeInstance_createVideoCapturer(JNIEnv *env, jclass clazz, jobject localSink) {
JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_createVideoCapturer(JNIEnv *env, jclass clazz, jobject localSink, jboolean front) {
initWebRTC(env);
std::unique_ptr<VideoCaptureInterface> capture = tgcalls::VideoCaptureInterface::Create(std::make_shared<AndroidContext>(env));
std::unique_ptr<VideoCaptureInterface> capture = tgcalls::VideoCaptureInterface::Create(front ? "front" : "back", std::make_shared<AndroidContext>(env));
capture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
capture->setState(VideoState::Active);
return reinterpret_cast<intptr_t>(capture.release());
Expand All @@ -423,22 +429,22 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_destroyVi
delete capturer;
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_switchCameraCapturer(JNIEnv *env, jclass clazz, jlong videoCapturer) {
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_switchCameraCapturer(JNIEnv *env, jclass clazz, jlong videoCapturer, jboolean front) {
VideoCaptureInterface *capturer = reinterpret_cast<VideoCaptureInterface *>(videoCapturer);
capturer->switchCamera();
capturer->switchToDevice(front ? "front" : "back");
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setVideoStateCapturer(JNIEnv *env, jclass clazz, jlong videoCapturer, jint videoState) {
VideoCaptureInterface *capturer = reinterpret_cast<VideoCaptureInterface *>(videoCapturer);
capturer->setState(static_cast<VideoState>(videoState));
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_switchCamera(JNIEnv *env, jobject obj) {
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_switchCamera(JNIEnv *env, jobject obj, jboolean front) {
InstanceHolder *instance = getInstanceHolder(env, obj);
if (instance->_videoCapture == nullptr) {
return;
}
instance->_videoCapture->switchCamera();
instance->_videoCapture->switchToDevice(front ? "front" : "back");
}

JNIEXPORT void Java_org_telegram_messenger_voip_NativeInstance_setVideoState(JNIEnv *env, jobject obj, jint state) {
Expand All @@ -449,12 +455,12 @@ JNIEXPORT void Java_org_telegram_messenger_voip_NativeInstance_setVideoState(JNI
instance->_videoCapture->setState(static_cast<VideoState>(state));
}

JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink) {
JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_setupOutgoingVideo(JNIEnv *env, jobject obj, jobject localSink, jboolean front) {
InstanceHolder *instance = getInstanceHolder(env, obj);
if (instance->_videoCapture) {
return;
}
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(instance->_platformContext);
instance->_videoCapture = tgcalls::VideoCaptureInterface::Create(front ? "front" : "back", instance->_platformContext);
instance->_videoCapture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
instance->_videoCapture->setState(VideoState::Active);
instance->nativeInstance->setVideoCapture(instance->_videoCapture);
Expand Down
33 changes: 25 additions & 8 deletions TMessagesProj/jni/voip/tgcalls/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <memory>
#include <map>

#include "Stats.h"

namespace rtc {
template <typename VideoFrameT>
class VideoSinkInterface;
Expand All @@ -21,6 +23,12 @@ namespace tgcalls {
class VideoCaptureInterface;
class PlatformContext;

#ifndef _WIN32
using FilePath = std::string;
#else
using FilePath = std::wstring;
#endif

struct Proxy {
std::string host;
uint16_t port = 0;
Expand Down Expand Up @@ -91,18 +99,16 @@ struct Config {
double receiveTimeout = 0.;
DataSaving dataSaving = DataSaving::Never;
bool enableP2P = false;
bool allowTCP = false;
bool enableStunMarking = false;
bool enableAEC = false;
bool enableNS = false;
bool enableAGC = false;
bool enableCallUpgrade = false;
bool enableVolumeControl = false;
#ifndef _WIN32
std::string logPath;
#else
std::wstring logPath;
#endif
FilePath logPath;
FilePath statsLogPath;
int maxApiLayer = 0;
float preferredAspectRatio;
bool enableHighBitrateVideo = false;
std::vector<std::string> preferredVideoCodecs;
ProtocolVersion protocolVersion = ProtocolVersion::V0;
Expand Down Expand Up @@ -148,9 +154,17 @@ struct FinalState {
PersistentState persistentState;
std::string debugLog;
TrafficStats trafficStats;
CallStats callStats;
bool isRatingSuggested = false;
};

struct MediaDevicesConfig {
std::string audioInputId;
std::string audioOutputId;
float inputVolume = 1.f;
float outputVolume = 1.f;
};

class Instance {
protected:
Instance() = default;
Expand All @@ -163,14 +177,15 @@ class Instance {
virtual void setAudioOutputGainControlEnabled(bool enabled) = 0;
virtual void setEchoCancellationStrength(int strength) = 0;

virtual bool supportsVideo() = 0;
virtual void setIncomingVideoOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) = 0;

virtual void setAudioInputDevice(std::string id) = 0;
virtual void setAudioOutputDevice(std::string id) = 0;
virtual void setInputVolume(float level) = 0;
virtual void setOutputVolume(float level) = 0;
virtual void setAudioOutputDuckingEnabled(bool enabled) = 0;

virtual void setIsLowBatteryLevel(bool isLowBatteryLevel) = 0;

virtual std::string getLastError() = 0;
Expand All @@ -181,6 +196,7 @@ class Instance {

virtual void receiveSignalingData(const std::vector<uint8_t> &data) = 0;
virtual void setVideoCapture(std::shared_ptr<VideoCaptureInterface> videoCapture) = 0;
virtual void setRequestedVideoAspect(float aspect) = 0;

virtual void stop(std::function<void(FinalState)> completion) = 0;

Expand All @@ -197,14 +213,15 @@ struct Descriptor {
std::vector<RtcServer> rtcServers;
NetworkType initialNetworkType = NetworkType();
EncryptionKey encryptionKey;
MediaDevicesConfig mediaDevicesConfig;
std::shared_ptr<VideoCaptureInterface> videoCapture;
std::function<void(State)> stateUpdated;
std::function<void(int)> signalBarsUpdated;
std::function<void(bool)> remoteBatteryLevelIsLowUpdated;
std::function<void(AudioState, VideoState)> remoteMediaStateUpdated;
std::function<void(float)> remotePrefferedAspectRatioUpdated;
std::function<void(const std::vector<uint8_t> &)> signalingDataEmitted;
std::shared_ptr<PlatformContext> platformContext;
std::shared_ptr<PlatformContext> platformContext;
};

class Meta {
Expand Down
48 changes: 20 additions & 28 deletions TMessagesProj/jni/voip/tgcalls/InstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ void InstanceImpl::setVideoCapture(std::shared_ptr<VideoCaptureInterface> videoC
});
}

void InstanceImpl::setRequestedVideoAspect(float aspect) {
_manager->perform(RTC_FROM_HERE, [aspect](Manager *manager) {
manager->setRequestedVideoAspect(aspect);
});
}

void InstanceImpl::setNetworkType(NetworkType networkType) {
bool isLowCostNetwork = false;
switch (networkType) {
Expand Down Expand Up @@ -93,19 +99,27 @@ void InstanceImpl::setEchoCancellationStrength(int strength) {
}

void InstanceImpl::setAudioInputDevice(std::string id) {
// TODO: not implemented
_manager->perform(RTC_FROM_HERE, [id](Manager *manager) {
manager->setAudioInputDevice(id);
});
}

void InstanceImpl::setAudioOutputDevice(std::string id) {
// TODO: not implemented
_manager->perform(RTC_FROM_HERE, [id](Manager *manager) {
manager->setAudioOutputDevice(id);
});
}

void InstanceImpl::setInputVolume(float level) {
// TODO: not implemented
_manager->perform(RTC_FROM_HERE, [level](Manager *manager) {
manager->setInputVolume(level);
});
}

void InstanceImpl::setOutputVolume(float level) {
// TODO: not implemented
_manager->perform(RTC_FROM_HERE, [level](Manager *manager) {
manager->setOutputVolume(level);
});
}

void InstanceImpl::setAudioOutputDuckingEnabled(bool enabled) {
Expand Down Expand Up @@ -142,40 +156,18 @@ void InstanceImpl::stop(std::function<void(FinalState)> completion) {
std::string debugLog = _logSink->result();

_manager->perform(RTC_FROM_HERE, [completion, debugLog = std::move(debugLog)](Manager *manager) {
manager->getNetworkStats([completion, debugLog = std::move(debugLog)](TrafficStats stats) {
manager->getNetworkStats([completion, debugLog = std::move(debugLog)](TrafficStats stats, CallStats callStats) {
FinalState finalState;
finalState.debugLog = debugLog;
finalState.isRatingSuggested = false;
finalState.trafficStats = stats;
finalState.callStats = callStats;

completion(finalState);
});
});
}

/*void InstanceImpl::controllerStateCallback(Controller::State state) {
if (onStateUpdated_) {
const auto mappedState = [&] {
switch (state) {
case Controller::State::WaitInit:
return State::WaitInit;
case Controller::State::WaitInitAck:
return State::WaitInitAck;
case Controller::State::Established:
return State::Estabilished;
case Controller::State::Failed:
return State::Failed;
case Controller::State::Reconnecting:
return State::Reconnecting;
default:
return State::Estabilished;
}
}();
onStateUpdated_(mappedState);
}
}*/

int InstanceImpl::GetConnectionMaxLayer() {
return 92; // TODO: retrieve from LayerBase
}
Expand Down
5 changes: 4 additions & 1 deletion TMessagesProj/jni/voip/tgcalls/InstanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class InstanceImpl final : public Instance {

void receiveSignalingData(const std::vector<uint8_t> &data) override;
void setVideoCapture(std::shared_ptr<VideoCaptureInterface> videoCapture) override;
void setRequestedVideoAspect(float aspect) override;
void setNetworkType(NetworkType networkType) override;
void setMuteMicrophone(bool muteMicrophone) override;
bool supportsVideo() override {
return true;
}
void setIncomingVideoOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) override;
void setAudioOutputGainControlEnabled(bool enabled) override;
void setEchoCancellationStrength(int strength) override;
Expand All @@ -38,7 +42,6 @@ class InstanceImpl final : public Instance {
TrafficStats getTrafficStats() override;
PersistentState getPersistentState() override;
void stop(std::function<void(FinalState)> completion) override;
//void controllerStateCallback(Controller::State state);

private:
std::unique_ptr<ThreadLocalObject<Manager>> _manager;
Expand Down
Loading

0 comments on commit 4992f23

Please sign in to comment.