Video Sending Redesign

This commit is contained in:
Nicholas Tinsley
2024-03-01 13:15:08 -05:00
committed by Alex Hart
parent 276e253fdf
commit c53abe0941
65 changed files with 1830 additions and 1621 deletions

View File

@@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.MemoryFileDescriptor;
import org.thoughtcrime.securesms.video.TranscodingPreset;
import java.io.IOException;
import java.io.InputStream;
@@ -40,6 +41,10 @@ public abstract class MediaConstraints {
public abstract int getImageMaxHeight(Context context);
public abstract int getImageMaxSize(Context context);
public TranscodingPreset getVideoTranscodingSettings() {
return TranscodingPreset.LEVEL_1;
}
public boolean isHighQuality() {
return false;
}

View File

@@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.LocaleFeatureFlags;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.video.TranscodingPreset;
import java.util.Arrays;
@@ -90,6 +91,11 @@ public class PushMediaConstraints extends MediaConstraints {
return currentConfig.qualitySetting;
}
@Override
public TranscodingPreset getVideoTranscodingSettings() {
return currentConfig.videoPreset;
}
private static @NonNull MediaConfig getCurrentConfig(@NonNull Context context, @Nullable SentMediaQuality sentMediaQuality) {
if (Util.isLowMemory(context)) {
return MediaConfig.LEVEL_1_LOW_MEMORY;
@@ -102,29 +108,32 @@ public class PushMediaConstraints extends MediaConstraints {
}
public enum MediaConfig {
LEVEL_1_LOW_MEMORY(true, 1, MB, new int[] { 768, 512 }, 70),
LEVEL_1_LOW_MEMORY(true, 1, MB, new int[] { 768, 512 }, 70, TranscodingPreset.LEVEL_1),
LEVEL_1(false, 1, MB, new int[] { 1600, 1024, 768, 512 }, 70),
LEVEL_2(false, 2, (int) (1.5 * MB), new int[] { 2048, 1600, 1024, 768, 512 }, 75),
LEVEL_3(false, 3, (int) (3 * MB), new int[] { 4096, 3072, 2048, 1600, 1024, 768, 512 }, 75);
LEVEL_1(false, 1, MB, new int[] { 1600, 1024, 768, 512 }, 70, TranscodingPreset.LEVEL_1),
LEVEL_2(false, 2, (int) (1.5 * MB), new int[] { 2048, 1600, 1024, 768, 512 }, 75, TranscodingPreset.LEVEL_2),
LEVEL_3(false, 3, (int) (3 * MB), new int[] { 4096, 3072, 2048, 1600, 1024, 768, 512 }, 75, TranscodingPreset.LEVEL_3);
private final boolean isLowMemory;
private final int level;
private final int maxImageFileSize;
private final int[] imageSizeTargets;
private final int qualitySetting;
private final boolean isLowMemory;
private final int level;
private final int maxImageFileSize;
private final int[] imageSizeTargets;
private final int qualitySetting;
private final TranscodingPreset videoPreset;
MediaConfig(boolean isLowMemory,
int level,
int maxImageFileSize,
@NonNull int[] imageSizeTargets,
@IntRange(from = 0, to = 100) int qualitySetting)
@IntRange(from = 0, to = 100) int qualitySetting,
TranscodingPreset videoPreset)
{
this.isLowMemory = isLowMemory;
this.level = level;
this.maxImageFileSize = maxImageFileSize;
this.imageSizeTargets = imageSizeTargets;
this.qualitySetting = qualitySetting;
this.videoPreset = videoPreset;
}
public int getMaxImageFileSize() {
@@ -135,10 +144,14 @@ public class PushMediaConstraints extends MediaConstraints {
return imageSizeTargets;
}
public int getQualitySetting() {
public int getImageQualitySetting() {
return qualitySetting;
}
public TranscodingPreset getVideoPreset() {
return videoPreset;
}
public static @Nullable MediaConfig forLevel(int level) {
boolean isLowMemory = Util.isLowMemory(ApplicationDependencies.getApplication());