π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Split
Manav Rathi88719025944a
diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.tsindex 7d67a37e44..2c408c3c66 100644--- a/web/packages/gallery/services/ffmpeg/index.ts+++ b/web/packages/gallery/services/ffmpeg/index.ts@@ -7,9 +7,9 @@ import {type UploadItem,} from "ente-gallery/services/upload";import {+ initiateConvertToMP4,readVideoStream,videoStreamDone,- writeVideoStream,} from "ente-gallery/utils/native-stream";import {parseMetadataDate,@@ -266,8 +266,7 @@ export const convertToMP4 = async (blob: Blob): Promise<Blob | Uint8Array> => {};const convertToMP4Native = async (electron: Electron, blob: Blob) => {- const res = await writeVideoStream(electron, "convert-to-mp4", blob);- const token = await res.text();+ const token = await initiateConvertToMP4(electron, blob);const mp4Blob = await readVideoStream(electron, token).then((res) =>res.blob(),);diff --git a/web/packages/gallery/utils/native-stream.ts b/web/packages/gallery/utils/native-stream.tsindex 9f15ce6b35..b0438b125b 100644--- a/web/packages/gallery/utils/native-stream.ts+++ b/web/packages/gallery/utils/native-stream.ts@@ -118,6 +118,31 @@ export const writeStream = async ();};+/**+ * Initate a conversion to MP4, streaming the video contents to the node side.+ *+ * This is a variant of {@link writeStream} tailored for the conversion to MP4.+ *+ * @param _ An {@link Electron} instance, witness to the fact that we're running+ * in the context of the desktop app. It is otherwise not used.+ *+ * @param video A {@link Blob} containing the video to convert.+ *+ * @returns return a token that can then be passed to {@link readVideoStream} to+ * retrieve the converted MP4 file. This three step sequence (write/read/done)+ * can then be ended by using {@link videoStreamDone}).+ */+export const initiateConvertToMP4 = async (+ _: Electron,+ video: Blob,+): Promise<string> => {+ const url = "stream://video?op=convert-to-mp4";+ const res = await fetch(url, { method: "POST", body: video });+ if (!res.ok)+ throw new Error(`Failed to write stream to ${url}: HTTP ${res.status}`);+ return res.text();+};+/*** One of the predefined operations to perform when invoking* {@link writeVideoStream} or {@link readVideoStream}.