@pictor-sdk/video-android 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -0
  3. package/android/CMakeLists.txt +30 -0
  4. package/android/build.gradle +119 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/cpp/pictor_overlaystage.cpp +372 -0
  7. package/android/src/main/cpp/pictor_publish.cpp +87 -0
  8. package/android/src/main/cpp/pictor_videosurface.cpp +735 -0
  9. package/android/src/main/java/dev/pictor/video/AacPriming.kt +261 -0
  10. package/android/src/main/java/dev/pictor/video/AudioMixer.kt +1112 -0
  11. package/android/src/main/java/dev/pictor/video/AudioProbe.kt +162 -0
  12. package/android/src/main/java/dev/pictor/video/CadenceShaderProgram.kt +337 -0
  13. package/android/src/main/java/dev/pictor/video/CodecLedger.kt +126 -0
  14. package/android/src/main/java/dev/pictor/video/CompositionSpike.kt +978 -0
  15. package/android/src/main/java/dev/pictor/video/Diagnostics.kt +54 -0
  16. package/android/src/main/java/dev/pictor/video/EncoderGate.kt +476 -0
  17. package/android/src/main/java/dev/pictor/video/ExportGate.kt +1974 -0
  18. package/android/src/main/java/dev/pictor/video/ExportHeartbeat.kt +72 -0
  19. package/android/src/main/java/dev/pictor/video/ExportProgress.kt +103 -0
  20. package/android/src/main/java/dev/pictor/video/FrameClock.kt +591 -0
  21. package/android/src/main/java/dev/pictor/video/FramePending.kt +181 -0
  22. package/android/src/main/java/dev/pictor/video/GateAudio.kt +456 -0
  23. package/android/src/main/java/dev/pictor/video/GateDestination.kt +445 -0
  24. package/android/src/main/java/dev/pictor/video/GateFrames.kt +662 -0
  25. package/android/src/main/java/dev/pictor/video/GateMux.kt +185 -0
  26. package/android/src/main/java/dev/pictor/video/ManagedSources.kt +333 -0
  27. package/android/src/main/java/dev/pictor/video/Media3Player.kt +934 -0
  28. package/android/src/main/java/dev/pictor/video/MediaStoreSave.kt +419 -0
  29. package/android/src/main/java/dev/pictor/video/OverlayResources.kt +169 -0
  30. package/android/src/main/java/dev/pictor/video/PictorVideoModule.kt +1612 -0
  31. package/android/src/main/java/dev/pictor/video/PictorVideoPackage.kt +26 -0
  32. package/android/src/main/java/dev/pictor/video/PlaybackAnchor.kt +161 -0
  33. package/android/src/main/java/dev/pictor/video/PreviewAudioPlayer.kt +291 -0
  34. package/android/src/main/java/dev/pictor/video/PreviewConfig.kt +96 -0
  35. package/android/src/main/java/dev/pictor/video/PreviewMix.kt +396 -0
  36. package/android/src/main/java/dev/pictor/video/PreviewSync.kt +374 -0
  37. package/android/src/main/java/dev/pictor/video/PreviewTrace.kt +478 -0
  38. package/android/src/main/java/dev/pictor/video/PrimingTrim.kt +337 -0
  39. package/android/src/main/java/dev/pictor/video/RepeatingEncoderFactory.kt +97 -0
  40. package/android/src/main/java/dev/pictor/video/SceneProgram.kt +169 -0
  41. package/android/src/main/java/dev/pictor/video/SceneProgramNative.kt +299 -0
  42. package/android/src/main/java/dev/pictor/video/SkiaPassThroughEffect.kt +695 -0
  43. package/android/src/main/java/dev/pictor/video/SurfaceAttachment.kt +110 -0
  44. package/android/src/main/java/dev/pictor/video/ThumbnailDecoder.kt +171 -0
  45. package/android/src/main/java/dev/pictor/video/VideoSurface.kt +394 -0
  46. package/app.plugin.js +43 -0
  47. package/dist/index.d.mts +3622 -0
  48. package/dist/index.d.ts +3622 -0
  49. package/dist/index.js +3737 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/index.mjs +3625 -0
  52. package/dist/index.mjs.map +1 -0
  53. package/package.json +82 -0
  54. package/plugin/gradleProperties.d.ts +19 -0
  55. package/plugin/gradleProperties.js +64 -0
  56. package/react-native.config.js +13 -0
  57. package/src/NativePictorVideo.ts +574 -0
  58. package/src/audioProbe.ts +72 -0
  59. package/src/compositionSpike.ts +305 -0
  60. package/src/convergence.ts +112 -0
  61. package/src/encoderGate.ts +66 -0
  62. package/src/exportDestination.ts +149 -0
  63. package/src/exportJob.ts +232 -0
  64. package/src/exportProgress.ts +391 -0
  65. package/src/exportProgressPump.ts +190 -0
  66. package/src/exporter.ts +655 -0
  67. package/src/index.ts +276 -0
  68. package/src/managedSources.ts +252 -0
  69. package/src/media3.ts +412 -0
  70. package/src/mediaStore.ts +177 -0
  71. package/src/memoryGuard.ts +118 -0
  72. package/src/mixSources.ts +82 -0
  73. package/src/overlayStaging.ts +216 -0
  74. package/src/playbackLifecycle.ts +137 -0
  75. package/src/player.ts +39 -0
  76. package/src/playlistSession.ts +125 -0
  77. package/src/previewAudioDiagnostics.ts +67 -0
  78. package/src/previewAudioSession.ts +168 -0
  79. package/src/previewCadence.ts +950 -0
  80. package/src/previewMix.ts +212 -0
  81. package/src/previewTrace.ts +348 -0
  82. package/src/spikeExcursions.ts +405 -0
  83. package/src/submissionScoring.ts +680 -0
  84. package/src/surfaceOwner.ts +264 -0
  85. package/src/surfaceRecovery.ts +121 -0
  86. package/src/syncTrace.ts +189 -0
  87. package/src/thumbnailProvider.ts +163 -0
  88. package/src/tracePhases.ts +217 -0
  89. package/src/useCompositionPlayback.ts +327 -0
  90. package/src/useMedia3Playback.ts +492 -0
  91. package/src/usePreviewAudio.ts +305 -0
  92. package/src/useVideoSurface.ts +282 -0
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@pictor-sdk/video-android",
3
+ "version": "0.1.0",
4
+ "description": "Optional Android video playback and export adapter for Pictor. Requires Android API 29+.",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "android",
12
+ "src",
13
+ "!android/build",
14
+ "!android/.cxx",
15
+ "app.plugin.js",
16
+ "plugin",
17
+ "LICENSE",
18
+ "README.md",
19
+ "!src/**/*.test.*",
20
+ "!src/**/__tests__/**",
21
+ "!dist/**/*.test.*",
22
+ "react-native.config.js",
23
+ "!android/src/test",
24
+ "!android/.gradle"
25
+ ],
26
+ "peerDependencies": {
27
+ "react-native": ">=0.76.0",
28
+ "@shopify/react-native-skia": ">=2.0.0",
29
+ "react": ">=18.0.0",
30
+ "@expo/config-plugins": ">=54.0.0",
31
+ "react-native-reanimated": ">=3.16.0",
32
+ "@pictor-sdk/video-core": "^0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "react-native": "^0.81.0",
36
+ "tsup": "^8.0.0",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^2.0.0",
39
+ "react": "^19.1.0",
40
+ "@types/react": "^19.0.0",
41
+ "@expo/config-plugins": "^54.0.5",
42
+ "react-native-reanimated": "^4.1.0",
43
+ "@pictor-sdk/video-core": "0.1.0"
44
+ },
45
+ "codegenConfig": {
46
+ "name": "PictorVideoSpec",
47
+ "type": "modules",
48
+ "jsSrcsDir": "src",
49
+ "android": {
50
+ "javaPackageName": "dev.pictor.video"
51
+ }
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "@shopify/react-native-skia": {
55
+ "optional": true
56
+ },
57
+ "@expo/config-plugins": {
58
+ "optional": true
59
+ },
60
+ "react-native-reanimated": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org/"
67
+ },
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://github.com/zahidhasanaunto/pictor.git",
71
+ "directory": "packages/video-android"
72
+ },
73
+ "homepage": "https://github.com/zahidhasanaunto/pictor#readme",
74
+ "bugs": {
75
+ "url": "https://github.com/zahidhasanaunto/pictor/issues"
76
+ },
77
+ "scripts": {
78
+ "build": "tsup",
79
+ "test": "vitest run",
80
+ "typecheck": "tsc --noEmit"
81
+ }
82
+ }
@@ -0,0 +1,19 @@
1
+ /** One line of a Gradle properties file, as `withGradleProperties` models it. */
2
+ export interface GradleProperty {
3
+ type: string
4
+ key?: string
5
+ value?: string
6
+ }
7
+
8
+ /** The oldest Android this adapter is known to run on. */
9
+ export declare const MIN_SDK_VERSION: number
10
+ export declare const MIN_SDK_KEY: string
11
+
12
+ /** The effective minimum SDK, or null when absent or unparseable. */
13
+ export declare function readMinSdkVersion(properties: GradleProperty[]): number | null
14
+
15
+ /** Ensure the minimum SDK is at least `required`. Raises, never lowers. */
16
+ export declare function withMinSdkVersion(
17
+ properties: GradleProperty[],
18
+ required?: number,
19
+ ): GradleProperty[]
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The arithmetic of the config plugin, with nothing Expo-shaped in it.
3
+ *
4
+ * `app.plugin.js` runs only inside a prebuild, where `expo/config-plugins`
5
+ * resolves. This file runs anywhere, which is what lets the rule that matters —
6
+ * *a clean prebuild cannot drop the adapter's minimum SDK* — be a test rather
7
+ * than something someone remembers to check after regenerating the project.
8
+ *
9
+ * The shape it operates on is the one `withGradleProperties` hands over: a flat
10
+ * list of `{ type: 'property' | 'comment' | 'empty', key?, value? }`.
11
+ */
12
+
13
+ /**
14
+ * The oldest Android the adapter is known to run on.
15
+ *
16
+ * Conservative, and deliberately so: the surviving code path needs 24, and 29 is
17
+ * held only because nothing older than the one device here has actually run it.
18
+ * Installing this adapter raises a host's `minSdkVersion`; not installing it
19
+ * leaves image-only consumers exactly where they were.
20
+ */
21
+ const MIN_SDK_VERSION = 29
22
+
23
+ const MIN_SDK_KEY = 'android.minSdkVersion'
24
+
25
+ /**
26
+ * Ensure `android.minSdkVersion` is at least `required`.
27
+ *
28
+ * **Raises, never lowers.** A host that already targets 31 has its own reason
29
+ * for it, and an adapter that quietly reset it to 29 would widen that host's
30
+ * support matrix without asking — the sort of change that is discovered in a
31
+ * crash report from a device nobody meant to support.
32
+ *
33
+ * A value that cannot be parsed is treated as absent and replaced, because the
34
+ * alternative is comparing against `NaN` and silently leaving it alone.
35
+ *
36
+ * @param {Array<{type: string, key?: string, value?: string}>} properties
37
+ * @param {number} required
38
+ * @returns {Array<{type: string, key?: string, value?: string}>} a new list
39
+ */
40
+ function withMinSdkVersion(properties, required = MIN_SDK_VERSION) {
41
+ const existing = properties.find(
42
+ (entry) => entry.type === 'property' && entry.key === MIN_SDK_KEY,
43
+ )
44
+
45
+ if (existing) {
46
+ const current = Number.parseInt(String(existing.value), 10)
47
+ if (Number.isFinite(current) && current >= required) return properties
48
+ return properties.map((entry) =>
49
+ entry === existing ? { ...entry, value: String(required) } : entry,
50
+ )
51
+ }
52
+
53
+ return [...properties, { type: 'property', key: MIN_SDK_KEY, value: String(required) }]
54
+ }
55
+
56
+ /** Read the effective value, or null when it is absent or unparseable. */
57
+ function readMinSdkVersion(properties) {
58
+ const entry = properties.find((p) => p.type === 'property' && p.key === MIN_SDK_KEY)
59
+ if (!entry) return null
60
+ const value = Number.parseInt(String(entry.value), 10)
61
+ return Number.isFinite(value) ? value : null
62
+ }
63
+
64
+ module.exports = { MIN_SDK_KEY, MIN_SDK_VERSION, readMinSdkVersion, withMinSdkVersion }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Android only, deliberately. iOS is deferred until the Android architecture is
3
+ * measured and reviewed, and declaring an absent iOS target would make
4
+ * autolinking fail on a Mac rather than simply skip.
5
+ */
6
+ module.exports = {
7
+ dependency: {
8
+ platforms: {
9
+ android: { sourceDir: './android' },
10
+ ios: null,
11
+ },
12
+ },
13
+ }