add h264 tests (client and server), hide options that won't work for mac + linux and give warning for mac under certain circumstances (fuck ass file viewing).
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
|
||||
import {
|
||||
decodeMessage,
|
||||
encodeMessage,
|
||||
type Frame,
|
||||
type Hello,
|
||||
type Ping,
|
||||
} from "./protocol";
|
||||
@@ -37,4 +38,27 @@ describe("protocol encode/decode", () => {
|
||||
expect(decoded.type).toBe("ping");
|
||||
expect(decoded.ts).toBe(123);
|
||||
});
|
||||
|
||||
test("round trips h264 frame metadata", () => {
|
||||
const frame: Frame = {
|
||||
type: "frame",
|
||||
header: {
|
||||
monitor: 1,
|
||||
fps: 24,
|
||||
format: "h264",
|
||||
hvnc: true,
|
||||
},
|
||||
data: new Uint8Array([0, 0, 0, 1, 0x67, 0x42, 0xe0, 0x1e]),
|
||||
};
|
||||
|
||||
const encoded = encodeMessage(frame);
|
||||
const decoded = decodeMessage(encoded) as Frame;
|
||||
|
||||
expect(decoded.type).toBe("frame");
|
||||
expect(decoded.header.format).toBe("h264");
|
||||
expect(decoded.header.hvnc).toBe(true);
|
||||
expect(decoded.header.monitor).toBe(1);
|
||||
expect(decoded.header.fps).toBe(24);
|
||||
expect(Array.from(decoded.data)).toEqual(Array.from(frame.data));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user