Skip to content

Commit

Permalink
Merge remote-tracking branch 'telegram/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoInverter authored and NekoInverter committed Jun 5, 2020
2 parents 55204d8 + dceccae commit 89ccde3
Show file tree
Hide file tree
Showing 487 changed files with 23,029 additions and 9,362 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV ANDROID_SDK_URL https://dl.google.com/android/repository/sdk-tools-linux-385
ENV ANDROID_API_LEVEL android-29
ENV ANDROID_BUILD_TOOLS_VERSION 29.0.3
ENV ANDROID_HOME /usr/local/android-sdk-linux
ENV ANDROID_NDK_VERSION 20.0.5594570
ENV ANDROID_NDK_VERSION 21.1.6352462
ENV ANDROID_VERSION 29
ENV ANDROID_NDK_HOME ${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
Expand Down
22 changes: 6 additions & 16 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ dependencies {

compileOnly 'org.checkerframework:checker-qual:2.5.2'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
implementation 'com.google.firebase:firebase-messaging:20.1.7'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation 'com.google.android.gms:play-services-vision:16.2.0'
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
Expand Down Expand Up @@ -112,6 +112,7 @@ android {
signingConfig signingConfigs.debug
applicationIdSuffix ".beta"
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
packagingOptions {
Expand All @@ -134,12 +135,6 @@ android {
}
}*/

debugMultidex {
initWith debug
minifyEnabled false
multiDexEnabled true
}

HA {
debuggable false
jniDebuggable false
Expand Down Expand Up @@ -169,11 +164,6 @@ android {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}*/

sourceSets.debugMultidex {
manifest.srcFile 'config/debug/AndroidManifest.xml'
java.srcDirs = ['src/multidex/java']
}

sourceSets.HA {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
Expand Down Expand Up @@ -296,7 +286,7 @@ android {
}
}

defaultConfig.versionCode = 10 * 1955
defaultConfig.versionCode = 10 * 1984

def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
Expand Down Expand Up @@ -394,13 +384,13 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionName "6.1.1.3"
versionName "6.2.0"

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

externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8"
arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8", "LOCAL_ARM_NEON:=false"
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ endif
LOCAL_SRC_FILES += \
./jni.c \
./audio.c \
./image.c \
./image.cpp \
./video.c \
./intro/IntroRenderer.c \
./utilities.cpp \
Expand Down
43 changes: 39 additions & 4 deletions TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ static const std::string av_make_error_str(int errnum) {
jclass jclass_AnimatedFileDrawableStream;
jmethodID jclass_AnimatedFileDrawableStream_read;
jmethodID jclass_AnimatedFileDrawableStream_cancel;
jmethodID jclass_AnimatedFileDrawableStream_isFinishedLoadingFile;
jmethodID jclass_AnimatedFileDrawableStream_getFinishedFilePath;

typedef struct VideoInfo {

Expand Down Expand Up @@ -189,6 +191,20 @@ void requestFd(VideoInfo *info) {
attached = false;
}
jniEnv->CallIntMethod(info->stream, jclass_AnimatedFileDrawableStream_read, (jint) 0, (jint) 1);
jboolean loaded = jniEnv->CallBooleanMethod(info->stream, jclass_AnimatedFileDrawableStream_isFinishedLoadingFile);
if (loaded) {
delete[] info->src;
jstring src = (jstring) jniEnv->CallObjectMethod(info->stream, jclass_AnimatedFileDrawableStream_getFinishedFilePath);
char const *srcString = jniEnv->GetStringUTFChars(src, 0);
size_t len = strlen(srcString);
info->src = new char[len + 1];
memcpy(info->src, srcString, len);
info->src[len] = '\0';
if (srcString != 0) {
jniEnv->ReleaseStringUTFChars(src, srcString);
}
}

if (attached) {
javaVm->DetachCurrentThread();
}
Expand Down Expand Up @@ -579,7 +595,7 @@ void Java_org_telegram_ui_Components_AnimatedFileDrawable_seekToMs(JNIEnv *env,
}
}

jint Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *env, jclass clazz, jlong ptr, jobject bitmap, jintArray data, jint stride, jboolean preview) {
jint Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *env, jclass clazz, jlong ptr, jobject bitmap, jintArray data, jint stride, jboolean preview, jfloat start_time, jfloat end_time) {
if (ptr == NULL || bitmap == nullptr) {
return 0;
}
Expand All @@ -592,9 +608,16 @@ jint Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *
while (!info->stopped && triesCount != 0) {
if (info->pkt.size == 0) {
ret = av_read_frame(info->fmt_ctx, &info->pkt);
//LOGD("got packet with size %d", info->pkt.size);
if (ret >= 0) {
info->orig_pkt = info->pkt;
double pts = info->pkt.pts * av_q2d(info->video_stream->time_base);
if (end_time > 0 && info->pkt.stream_index == info->video_stream_idx && pts > end_time) {
av_packet_unref(&info->pkt);
info->pkt.data = NULL;
info->pkt.size = 0;
} else {
info->orig_pkt = info->pkt;
}

}
}

Expand Down Expand Up @@ -624,7 +647,11 @@ jint Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *
}
if (!preview && got_frame == 0) {
if (info->has_decoded_frames) {
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, 0, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
int64_t start_from = 0;
if (start_time > 0) {
start_from = (int64_t)(start_time / av_q2d(info->video_stream->time_base));
}
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, start_from, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
LOGE("can't seek to begin of file %s, %s", info->src, av_err2str(ret));
return 0;
} else {
Expand Down Expand Up @@ -710,6 +737,14 @@ jint videoOnJNILoad(JavaVM *vm, JNIEnv *env) {
if (jclass_AnimatedFileDrawableStream_cancel == 0) {
return JNI_FALSE;
}
jclass_AnimatedFileDrawableStream_isFinishedLoadingFile = env->GetMethodID(jclass_AnimatedFileDrawableStream, "isFinishedLoadingFile", "()Z");
if (jclass_AnimatedFileDrawableStream_isFinishedLoadingFile == 0) {
return JNI_FALSE;
}
jclass_AnimatedFileDrawableStream_getFinishedFilePath = env->GetMethodID(jclass_AnimatedFileDrawableStream, "getFinishedFilePath", "()Ljava/lang/String;");
if (jclass_AnimatedFileDrawableStream_getFinishedFilePath == 0) {
return JNI_FALSE;
}

return JNI_TRUE;
}
Expand Down
Loading

0 comments on commit 89ccde3

Please sign in to comment.