mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Refactor Mp4FaststartPostProcessor.
This commit is contained in:
committed by
Greyson Parrelli
parent
8e7383be05
commit
7bb1c58452
@@ -42,10 +42,8 @@ import org.thoughtcrime.securesms.video.InMemoryTranscoder;
|
||||
import org.thoughtcrime.securesms.video.StreamingTranscoder;
|
||||
import org.thoughtcrime.securesms.video.TranscoderCancelationSignal;
|
||||
import org.thoughtcrime.securesms.video.TranscoderOptions;
|
||||
import org.thoughtcrime.securesms.video.exceptions.VideoPostProcessingException;
|
||||
import org.thoughtcrime.securesms.video.exceptions.VideoSourceException;
|
||||
import org.thoughtcrime.securesms.video.postprocessing.Mp4FaststartPostProcessor;
|
||||
import org.thoughtcrime.securesms.video.exceptions.VideoSourceException;
|
||||
import org.thoughtcrime.securesms.video.videoconverter.EncodingException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -263,7 +261,7 @@ public final class AttachmentCompressionJob extends BaseJob {
|
||||
Log.i(TAG, "Compressing with streaming muxer");
|
||||
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
||||
|
||||
File file = SignalDatabase.attachments().newFile(context);
|
||||
File file = AttachmentTable.newFile(context);
|
||||
file.deleteOnExit();
|
||||
|
||||
boolean faststart = false;
|
||||
@@ -291,9 +289,10 @@ public final class AttachmentCompressionJob extends BaseJob {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, file.length());
|
||||
});
|
||||
|
||||
try (MediaStream mediaStream = new MediaStream(postProcessor.process(), MimeTypes.VIDEO_MP4, 0, 0, true)) {
|
||||
final long plaintextLength = ModernEncryptingPartOutputStream.getPlaintextLength(file.length());
|
||||
try (MediaStream mediaStream = new MediaStream(postProcessor.process(plaintextLength), MimeTypes.VIDEO_MP4, 0, 0, true)) {
|
||||
attachmentDatabase.updateAttachmentData(attachment, mediaStream, true);
|
||||
faststart = true;
|
||||
}
|
||||
|
||||
@@ -179,9 +179,9 @@ public final class InMemoryTranscoder implements Closeable {
|
||||
Log.w(TAG, "IOException thrown while creating FileInputStream.", e);
|
||||
throw new VideoPostProcessingException("Exception while opening InputStream!", e);
|
||||
}
|
||||
}, memoryFile.size());
|
||||
});
|
||||
|
||||
return new MediaStream(postProcessor.process(), MimeTypes.VIDEO_MP4, 0, 0, true);
|
||||
return new MediaStream(postProcessor.process(outSize), MimeTypes.VIDEO_MP4, 0, 0, true);
|
||||
} catch (VideoPostProcessingException e) {
|
||||
Log.w(TAG, "Exception thrown during post processing.", e);
|
||||
final Throwable cause = e.getCause();
|
||||
|
||||
Reference in New Issue
Block a user