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
@@ -155,8 +155,10 @@ impl RendererMessage {
})
}
fn from_decode_unit(decode_unit: _DECODE_UNIT) -> Result<Vec<Self>> {
let mut buffers = Vec::new();
fn from_decode_unit(decode_unit: _DECODE_UNIT) -> Result<Self> {
//fn from_decode_unit(decode_unit: _DECODE_UNIT) -> Result<Vec<Self>> {
let mut buffer = Vec::new();
//let mut buffers = Vec::new();
if decode_unit.bufferList.is_null() {
return Err(anyhow!("DecodeUnit bufferList is null"));
@@ -165,32 +167,35 @@ impl RendererMessage {
let mut index = 0;
loop {
let mut b = Buffer::try_from(next)?;
buffer.append(&mut b.data);
//buffers.push(msg);
index = index + 1;
if next.next.is_null() {
break;
}
let buffer = Buffer::try_from(next)?;
let msg = RendererMessage::DecodeUnit {
frame_number: <u64>::try_from(decode_unit.frameNumber)?,
frame_type: FrameType::try_from(decode_unit.frameType)?,
host_processing_latency: decode_unit.frameHostProcessingLatency,
receieve_time_ms: decode_unit.receiveTimeMs,
enqueue_time_ms: decode_unit.enqueueTimeMs,
presentation_time: decode_unit.presentationTimeMs as u64,
full_length: <usize>::try_from(decode_unit.fullLength)?,
buffer,
index,
hdr_active: decode_unit.hdrActive,
colorspace: decode_unit.colorspace,
};
buffers.push(msg);
index = index + 1;
next = unsafe { *next.next };
}
Ok(buffers)
Ok(RendererMessage::DecodeUnit {
frame_number: <u64>::try_from(decode_unit.frameNumber)?,
frame_type: FrameType::try_from(decode_unit.frameType)?,
host_processing_latency: decode_unit.frameHostProcessingLatency,
receieve_time_ms: decode_unit.receiveTimeMs,
enqueue_time_ms: decode_unit.enqueueTimeMs,
presentation_time: decode_unit.presentationTimeMs as u64,
full_length: <usize>::try_from(decode_unit.fullLength)?,
buffer: Buffer {
data: buffer,
buffer_type: BufferType::PICDATA,
},
index,
hdr_active: decode_unit.hdrActive,
colorspace: decode_unit.colorspace,
})
}
}
@@ -258,7 +263,7 @@ extern "C" fn submit_decode_unit_cb(decode_unit: PDECODE_UNIT) -> std::os::raw::
}
let decode_unit = unsafe { *decode_unit };
let messages = match RendererMessage::from_decode_unit(decode_unit) {
let message = match RendererMessage::from_decode_unit(decode_unit) {
Ok(m) => m,
Err(e) => {
error!("Cannot construct RendererMessage: {e}");
@@ -266,13 +271,14 @@ extern "C" fn submit_decode_unit_cb(decode_unit: PDECODE_UNIT) -> std::os::raw::
}
};
for msg in messages {
let ret = send_message(msg);
if ret != 0 {
return ret;
}
}
0
send_message(message)
//for msg in messages {
// let ret = send_message(msg);
// if ret != 0 {
// return ret;
// }
//}
//0
}
pub fn decoder_callbacks() -> Result<(DECODER_RENDERER_CALLBACKS, mpsc::Receiver<RendererMessage>)>