serve-sim 0.1.23 → 0.1.24

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.
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ HERE="$(cd "$(dirname "$0")" && pwd)"
5
+ OUT_DIR="${1:-$HERE/../../dist/simcam}"
6
+ mkdir -p "$OUT_DIR"
7
+
8
+ SDK="$(xcrun --sdk iphonesimulator --show-sdk-path)"
9
+ DYLIB="$OUT_DIR/libSimCameraInjector.dylib"
10
+
11
+ # Build a fat dylib (arm64 + x86_64) for the iphonesimulator SDK.
12
+ xcrun --sdk iphonesimulator clang \
13
+ -arch arm64 -arch x86_64 \
14
+ -mios-simulator-version-min=15.0 \
15
+ -isysroot "$SDK" \
16
+ -dynamiclib \
17
+ -fobjc-arc \
18
+ -fmodules \
19
+ -fobjc-weak \
20
+ -framework Foundation \
21
+ -framework UIKit \
22
+ -framework AVFoundation \
23
+ -framework CoreImage \
24
+ -framework CoreMedia \
25
+ -framework CoreVideo \
26
+ -framework CoreGraphics \
27
+ -framework QuartzCore \
28
+ -install_name "@rpath/libSimCameraInjector.dylib" \
29
+ -o "$DYLIB" \
30
+ "$HERE/SimCameraInjector.m"
31
+
32
+ echo "Built: $DYLIB"
33
+ file "$DYLIB"
@@ -0,0 +1,55 @@
1
+ // Shared memory wire format for serve-sim's simulator camera feed.
2
+ //
3
+ // One process (the host helper, running on macOS) captures webcam frames and
4
+ // writes them into a POSIX shared-memory region. The injected dylib inside
5
+ // the simulator app maps the same region and dispatches the latest frame to
6
+ // AVFoundation delegates / preview layers.
7
+ //
8
+ // Format: BGRA, top-down, no padding except whatever bytesPerRow says.
9
+ //
10
+ // Synchronization is intentionally lock-free and lossy: the writer bumps
11
+ // `frameSeq` last after writing pixels; the reader samples `frameSeq` before
12
+ // and after copying and discards the read if they disagree. A single dropped
13
+ // frame is fine for a 30 fps camera.
14
+
15
+ #ifndef SIM_CAM_SHARED_H
16
+ #define SIM_CAM_SHARED_H
17
+
18
+ #include <stdint.h>
19
+
20
+ #define SIMCAM_SHM_MAGIC 0x53434D31u // 'SCM1'
21
+ #define SIMCAM_PIXEL_BGRA 0u
22
+ #define SIMCAM_DEFAULT_WIDTH 1280u
23
+ #define SIMCAM_DEFAULT_HEIGHT 720u
24
+
25
+ // Mirror mode codes for SimCamShmHeader.mirrorMode.
26
+ // "Unset" lets the dylib fall back to its env-var configuration (back-compat
27
+ // with hosts that don't write the byte).
28
+ #define SIMCAM_MIRROR_UNSET 0xFF
29
+ #define SIMCAM_MIRROR_AUTO 0
30
+ #define SIMCAM_MIRROR_ON 1
31
+ #define SIMCAM_MIRROR_OFF 2
32
+
33
+ // Header is 64 bytes — keeps pixel data 16-byte aligned.
34
+ typedef struct __attribute__((packed)) {
35
+ uint32_t magic; // SIMCAM_SHM_MAGIC
36
+ uint32_t version; // bumps on layout change
37
+ uint32_t width;
38
+ uint32_t height;
39
+ uint32_t pixelFormat; // SIMCAM_PIXEL_BGRA
40
+ uint32_t bytesPerRow;
41
+ uint64_t pixelByteSize;
42
+ uint64_t frameSeq; // written LAST; readers check tearing via re-read
43
+ uint64_t timestampNs; // mach_absolute_time-based, host monotonic
44
+ uint8_t mirrorMode; // SIMCAM_MIRROR_*; UNSET = ignore (use env)
45
+ uint8_t reserved[15];
46
+ } SimCamShmHeader;
47
+
48
+ _Static_assert(sizeof(SimCamShmHeader) == 64, "SimCamShmHeader must be 64 bytes");
49
+
50
+ // Total shm size for given dimensions: header + width*height*4
51
+ static inline uint64_t SimCamShmSizeFor(uint32_t w, uint32_t h) {
52
+ return (uint64_t)sizeof(SimCamShmHeader) + (uint64_t)w * (uint64_t)h * 4ull;
53
+ }
54
+
55
+ #endif
package/bin/serve-sim-bin CHANGED
Binary file