use of org.thoughtcrime.securesms.mms.MediaStream in project Signal-Android by WhisperSystems.
the class SendJob method scaleAttachments.
protected List<Attachment> scaleAttachments(@NonNull MasterSecret masterSecret, @NonNull MediaConstraints constraints, @NonNull List<Attachment> attachments) throws UndeliverableMessageException {
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
List<Attachment> results = new LinkedList<>();
for (Attachment attachment : attachments) {
try {
if (constraints.isSatisfied(context, masterSecret, attachment)) {
results.add(attachment);
} else if (constraints.canResize(attachment)) {
MediaStream resized = constraints.getResizedMedia(context, masterSecret, attachment);
results.add(attachmentDatabase.updateAttachmentData(masterSecret, attachment, resized));
} else {
throw new UndeliverableMessageException("Size constraints could not be met!");
}
} catch (IOException | MmsException e) {
throw new UndeliverableMessageException(e);
}
}
return results;
}
Aggregations