frontend: video streaming now works!!

- changed the backend to append the buffers together and dispatch them
  as such (this is what moonlight-embedded does)
- fixed the frontend trying to playback an empty buffer because types
  are hard (this is why I should have used protobuf...)
This commit is contained in:
2025-07-21 02:06:55 -06:00
parent 7a2b0fd4d6
commit a11a12828c
2 changed files with 49 additions and 33 deletions
+14 -4
View File
@@ -39,10 +39,16 @@ type SetupPacket = {
Setup: Setup
}
type DecodeBuffer = {
buffer_bype: string,
data: Array<number>,
}
type DecodeUnit = {
frame_number: number,
frame_type: string,
buffer: Array<number>,
buffer: DecodeBuffer,
receieve_time_ms: number,
}
type DecodeUnitPacket = {
@@ -209,7 +215,8 @@ export async function connectToStream(url: string, cert_hash: Array<number>) {
let config: VideoDecoderConfig | undefined = undefined;
if (packet.Setup.video_format == "H264") {
config = {
codec: 'avc1.42E01E', // H.264 codec
//codec: 'avc1.42E01E', // H.264 codec
codec: 'avc1.4D002A', // H.264 codec
codedWidth: packet.Setup.width,
codedHeight: packet.Setup.height,
};
@@ -220,6 +227,8 @@ export async function connectToStream(url: string, cert_hash: Array<number>) {
const codecSupport = await VideoDecoder.isConfigSupported(config);
if (codecSupport.supported) {
videoDecoder.configure(config);
} else {
throw new Error(`Could not configure decoder`);
}
} else if (Object.hasOwn(packets[i], "DecodeUnit")) {
@@ -231,10 +240,11 @@ export async function connectToStream(url: string, cert_hash: Array<number>) {
frame_type = "key";
}
const chunk = new EncodedVideoChunk({
timestamp: 0,
timestamp: packet.DecodeUnit.receieve_time_ms,
type: frame_type,
data: new Uint8Array(packet.DecodeUnit.buffer),
data: new Uint8Array(packet.DecodeUnit.buffer.data),
});
console.log(chunk);
videoDecoder.decode(chunk);