2016-12-11 13:37:27 -08:00
|
|
|
package org.thoughtcrime.securesms.video;
|
|
|
|
|
|
|
|
import android.media.MediaDataSource;
|
2019-07-25 15:29:31 -04:00
|
|
|
|
2019-06-05 15:47:14 -04:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2019-07-25 15:29:31 -04:00
|
|
|
import androidx.annotation.RequiresApi;
|
2016-12-11 13:37:27 -08:00
|
|
|
|
2018-01-24 19:17:44 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.AttachmentSecret;
|
2016-12-11 13:37:27 -08:00
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
2019-07-25 15:29:31 -04:00
|
|
|
@RequiresApi(23)
|
|
|
|
public final class EncryptedMediaDataSource {
|
2016-12-11 13:37:27 -08:00
|
|
|
|
2019-07-25 15:29:31 -04:00
|
|
|
public static MediaDataSource createFor(@NonNull AttachmentSecret attachmentSecret, @NonNull File mediaFile, @Nullable byte[] random, long length) {
|
|
|
|
if (random == null) {
|
|
|
|
return new ClassicEncryptedMediaDataSource(attachmentSecret, mediaFile, length);
|
|
|
|
} else {
|
|
|
|
return new ModernEncryptedMediaDataSource(attachmentSecret, mediaFile, random, length);
|
2016-12-11 13:37:27 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|