mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
[mob][perf] Avoid XMP extraction on main thread
This commit is contained in:
parent
c20b3cf585
commit
da7a0a60bf
@ -2,7 +2,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import "package:motion_photos/src/xmp_extractor.dart";
|
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:photo_manager/photo_manager.dart';
|
import 'package:photo_manager/photo_manager.dart';
|
||||||
import 'package:photos/core/configuration.dart';
|
import 'package:photos/core/configuration.dart';
|
||||||
@ -185,8 +184,7 @@ class EnteFile {
|
|||||||
|
|
||||||
if (mediaUploadData.isPanorama != true) {
|
if (mediaUploadData.isPanorama != true) {
|
||||||
try {
|
try {
|
||||||
final xmpData = XMPExtractor()
|
final xmpData = await getXmp(mediaUploadData.sourceFile!);
|
||||||
.extract(mediaUploadData.sourceFile!.readAsBytesSync());
|
|
||||||
mediaUploadData.isPanorama = checkPanoramaFromXMP(xmpData);
|
mediaUploadData.isPanorama = checkPanoramaFromXMP(xmpData);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
|
@ -160,8 +160,11 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(EnteFile file) async {
|
|||||||
int? motionPhotoStartingIndex;
|
int? motionPhotoStartingIndex;
|
||||||
if (Platform.isAndroid && asset.type == AssetType.image) {
|
if (Platform.isAndroid && asset.type == AssetType.image) {
|
||||||
try {
|
try {
|
||||||
motionPhotoStartingIndex =
|
motionPhotoStartingIndex = await Computer.shared().compute(
|
||||||
(await MotionPhotos(sourceFile.path).getMotionVideoIndex())?.start;
|
motionVideoIndex,
|
||||||
|
param: {'path': sourceFile.path},
|
||||||
|
taskName: 'motionPhotoIndex',
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.severe('error while detecthing motion photo start index', e);
|
_logger.severe('error while detecthing motion photo start index', e);
|
||||||
}
|
}
|
||||||
@ -177,6 +180,11 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(EnteFile file) async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int?> motionVideoIndex(Map<String, dynamic> args) async {
|
||||||
|
final String path = args['path'];
|
||||||
|
return (await MotionPhotos(path).getMotionVideoIndex())?.start;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _computeZip(Map<String, dynamic> args) async {
|
Future<void> _computeZip(Map<String, dynamic> args) async {
|
||||||
final String zipPath = args['zipPath'];
|
final String zipPath = args['zipPath'];
|
||||||
final String imagePath = args['imagePath'];
|
final String imagePath = args['imagePath'];
|
||||||
|
@ -18,8 +18,7 @@ Future<bool> checkIfPanorama(EnteFile enteFile) async {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final result = XMPExtractor().extract(file.readAsBytesSync());
|
final result = XMPExtractor().extract(file.readAsBytesSync());
|
||||||
if (result["GPano:ProjectionType"] == "cylindrical" ||
|
if (checkPanoramaFromXMP(result)) {
|
||||||
result["GPano:ProjectionType"] == "equirectangular") {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@ -30,7 +29,7 @@ Future<bool> checkIfPanorama(EnteFile enteFile) async {
|
|||||||
return element?.printable == "6";
|
return element?.printable == "6";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool? checkPanoramaFromXMP(Map<String, dynamic> xmpData) {
|
bool checkPanoramaFromXMP(Map<String, dynamic> xmpData) {
|
||||||
if (xmpData["GPano:ProjectionType"] == "cylindrical" ||
|
if (xmpData["GPano:ProjectionType"] == "cylindrical" ||
|
||||||
xmpData["GPano:ProjectionType"] == "equirectangular") {
|
xmpData["GPano:ProjectionType"] == "equirectangular") {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user