feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,198 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cutdex/features/timeline/timeline_external_drop_target.dart';
|
||||
import 'package:cutdex/features/timeline/timeline_drop_preparation.dart';
|
||||
import 'package:cutdex/workspace/preview_target.dart';
|
||||
import 'package:cutdex/workspace/project_state.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:cutdex/workspace/timeline_session.dart';
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:cutdex_sdk/runtime.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../support/preview_fixture.dart';
|
||||
|
||||
class _Projects extends Projects {
|
||||
_Projects(this.session);
|
||||
final EditorTimelineSession session;
|
||||
|
||||
@override
|
||||
Future<ProjectState> build() async => ProjectState(
|
||||
activeProject: const RecentProject(
|
||||
id: 'project',
|
||||
name: 'Project',
|
||||
path: '/project',
|
||||
),
|
||||
timeline: session.document,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<T> withAssetMedia<T>(
|
||||
String? projectId,
|
||||
AssetDocument asset,
|
||||
Future<T> Function(MediaReference) action,
|
||||
) => action(MediaReference(id: asset.id, uri: Uri.parse(asset.location)));
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
testWidgets('releasing an MPG drag commits its precise source duration', (
|
||||
tester,
|
||||
) async {
|
||||
// Actual native probe duration of VENU662C.mpg (100 ns source clock).
|
||||
const numerator = 64737467444;
|
||||
const denominator = 10000000;
|
||||
const ticks = 9135751405697;
|
||||
const channel = MethodChannel('drop-duration-test');
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.windows;
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
const MethodChannel('cutdex_native/file_drop/timeline'),
|
||||
(_) async => null,
|
||||
);
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, (
|
||||
call,
|
||||
) async {
|
||||
final request = jsonDecode((call.arguments as Map)['request'] as String);
|
||||
expect(request['method'], 'probe');
|
||||
return jsonEncode({
|
||||
'value': {
|
||||
'duration': {'numerator': '$numerator', 'denominator': denominator},
|
||||
'videoTrackCount': 1,
|
||||
'audioTrackCount': 0,
|
||||
'videoTrackIds': [0],
|
||||
'audioTrackIds': <int>[],
|
||||
'isProtected': false,
|
||||
'audioTracks': <Object?>[],
|
||||
},
|
||||
});
|
||||
});
|
||||
final fixture = await tester.runAsync(
|
||||
() => createPreviewFixture(Uri.file('/VENU662C.mpg')),
|
||||
);
|
||||
final session = fixture!.timeline;
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
projectsProvider.overrideWith(() => _Projects(session)),
|
||||
runtimeConnectionProvider.overrideWithValue(
|
||||
CutdexRuntime(channel: channel),
|
||||
),
|
||||
],
|
||||
);
|
||||
final incoming = ValueNotifier<TimelineIncomingAsset?>(null);
|
||||
addTearDown(() async {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
incoming.dispose();
|
||||
container.dispose();
|
||||
await fixture.workspace.close();
|
||||
await fixture.directory.delete(recursive: true);
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
channel,
|
||||
null,
|
||||
);
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
const MethodChannel('cutdex_native/file_drop/timeline'),
|
||||
null,
|
||||
);
|
||||
});
|
||||
await container.read(projectsProvider.future);
|
||||
final sequence = SequenceId('empty');
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: TimelineExternalDropTarget(
|
||||
projectId: 'project',
|
||||
session: session,
|
||||
sequenceId: sequence,
|
||||
incoming: incoming,
|
||||
child: const SizedBox(width: 600, height: 300),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final finder = find.byType(TimelineExternalDropTarget);
|
||||
incoming.value = (
|
||||
asset: AssetDocument(
|
||||
id: 'media',
|
||||
name: 'VENU662C.mpg',
|
||||
storage: AssetStorage.external,
|
||||
location: Uri.file('/VENU662C.mpg').toString(),
|
||||
),
|
||||
globalPosition: tester.getCenter(finder),
|
||||
);
|
||||
await tester.runAsync(
|
||||
() => container
|
||||
.read(
|
||||
timelineDropPreparationProvider(
|
||||
'project',
|
||||
session,
|
||||
sequence,
|
||||
).notifier,
|
||||
)
|
||||
.waitForPreparation(),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final drop = tester.state<TimelineExternalDropTargetState>(finder);
|
||||
final preparation = container
|
||||
.read(timelineDropPreparationProvider('project', session, sequence))
|
||||
.preparation;
|
||||
expect(
|
||||
drop.preparedMedia,
|
||||
isNotNull,
|
||||
reason: '${preparation.error}\n${preparation.stackTrace}',
|
||||
);
|
||||
expect(
|
||||
session.persistence.timeline(sequence).exportDto().elements,
|
||||
isEmpty,
|
||||
);
|
||||
|
||||
// This is the same release entry point as the media-library drag target.
|
||||
await drop.drop();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byType(SnackBar),
|
||||
findsNothing,
|
||||
reason: find
|
||||
.descendant(of: find.byType(SnackBar), matching: find.byType(Text))
|
||||
.evaluate()
|
||||
.map((element) => (element.widget as Text).data)
|
||||
.join('\n'),
|
||||
);
|
||||
final element = session.persistence
|
||||
.timeline(sequence)
|
||||
.exportDto()
|
||||
.elements
|
||||
.singleWhere((element) => element.payloadRef != null);
|
||||
final clock = session.persistence.timeline(sequence).clock;
|
||||
expect(clock.toTicks(element.duration), ticks);
|
||||
expect(element.sourceRange.start, RationalTime.zero);
|
||||
expect(element.sourceRange.duration, element.duration);
|
||||
expect(element.mediaRange!.duration, element.duration);
|
||||
final remainder =
|
||||
BigInt.from(numerator) * BigInt.from(TimelineClock.ticksPerSecond) -
|
||||
BigInt.from(ticks) * BigInt.from(denominator);
|
||||
expect(remainder >= BigInt.zero, isTrue);
|
||||
expect(remainder < BigInt.from(denominator), isTrue);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.runAsync(session.close);
|
||||
final stored = await tester.runAsync(
|
||||
() => fixture.workspace.project!.loadTimeline(session.document.id),
|
||||
);
|
||||
final restored = stored!.sequences
|
||||
.singleWhere((item) => item.id == sequence)
|
||||
.elements
|
||||
.singleWhere((item) => item.payloadRef != null);
|
||||
expect(clock.toTicks(restored.duration), ticks);
|
||||
expect(restored.sourceRange.duration, element.sourceRange.duration);
|
||||
expect(restored.mediaRange!.duration, element.mediaRange!.duration);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user