mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Minor FEC/Flushing Fixes
This commit is contained in:
parent
ac87d622c8
commit
92f10afd20
3 changed files with 8 additions and 5 deletions
|
@ -60,7 +60,7 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
|
||||||
|
|
||||||
static inline bool chiaki_frame_processor_flush_possible(ChiakiFrameProcessor *frame_processor)
|
static inline bool chiaki_frame_processor_flush_possible(ChiakiFrameProcessor *frame_processor)
|
||||||
{
|
{
|
||||||
return frame_processor->units_source_received //+ frame_processor->units_fec_received
|
return frame_processor->units_source_received + frame_processor->units_fec_received
|
||||||
>= frame_processor->units_source_expected;
|
>= frame_processor->units_source_expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,11 +243,13 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
|
||||||
if(frame_processor->units_source_expected == 0)
|
if(frame_processor->units_source_expected == 0)
|
||||||
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FAILED;
|
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FAILED;
|
||||||
|
|
||||||
|
ChiakiFrameProcessorFlushResult result = CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_SUCCESS;
|
||||||
if(frame_processor->units_source_received < frame_processor->units_source_expected)
|
if(frame_processor->units_source_received < frame_processor->units_source_expected)
|
||||||
{
|
{
|
||||||
ChiakiErrorCode err = chiaki_frame_processor_fec(frame_processor);
|
ChiakiErrorCode err = chiaki_frame_processor_fec(frame_processor);
|
||||||
if(err != CHIAKI_ERR_SUCCESS)
|
if(err != CHIAKI_ERR_SUCCESS)
|
||||||
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FAILED;
|
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FAILED;
|
||||||
|
result = CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FEC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buf = malloc(frame_processor->frame_buf_size); // TODO: this should come from outside instead of mallocing all the time
|
uint8_t *buf = malloc(frame_processor->frame_buf_size); // TODO: this should come from outside instead of mallocing all the time
|
||||||
|
@ -273,5 +275,5 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
|
||||||
|
|
||||||
*frame = buf;
|
*frame = buf;
|
||||||
*frame_size = buf_size;
|
*frame_size = buf_size;
|
||||||
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_SUCCESS;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,11 @@ CHIAKI_EXPORT void chiaki_video_receiver_av_packet(ChiakiVideoReceiver *video_re
|
||||||
if(video_receiver->frame_index_cur >= 0 && video_receiver->frame_index_prev != video_receiver->frame_index_cur)
|
if(video_receiver->frame_index_cur >= 0 && video_receiver->frame_index_prev != video_receiver->frame_index_cur)
|
||||||
chiaki_video_receiver_flush_frame(video_receiver);
|
chiaki_video_receiver_flush_frame(video_receiver);
|
||||||
|
|
||||||
if(chiaki_seq_num_16_gt(frame_index, (ChiakiSeqNum16)video_receiver->frame_index_prev + 1)
|
ChiakiSeqNum16 next_frame_expected = (ChiakiSeqNum16)video_receiver->frame_index_prev + 1;
|
||||||
|
if(chiaki_seq_num_16_gt(frame_index, next_frame_expected)
|
||||||
&& !(frame_index == 1 && video_receiver->frame_index_cur < 0)) // ok for frame 1
|
&& !(frame_index == 1 && video_receiver->frame_index_cur < 0)) // ok for frame 1
|
||||||
{
|
{
|
||||||
CHIAKI_LOGW(video_receiver->log, "Detected missing or corrupt frame(s) from %d to %d", (int)video_receiver->frame_index_cur, (int)frame_index);
|
CHIAKI_LOGW(video_receiver->log, "Detected missing or corrupt frame(s) from %d to %d", next_frame_expected, (int)frame_index);
|
||||||
// TODO: report
|
// TODO: report
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ static ChiakiErrorCode chiaki_video_receiver_flush_frame(ChiakiVideoReceiver *vi
|
||||||
size_t frame_size;
|
size_t frame_size;
|
||||||
ChiakiFrameProcessorFlushResult flush_result = chiaki_frame_processor_flush(&video_receiver->frame_processor, &frame, &frame_size);
|
ChiakiFrameProcessorFlushResult flush_result = chiaki_frame_processor_flush(&video_receiver->frame_processor, &frame, &frame_size);
|
||||||
|
|
||||||
if(flush_result != CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_SUCCESS)
|
if(flush_result == CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_FAILED)
|
||||||
{
|
{
|
||||||
// TODO: fake frame?
|
// TODO: fake frame?
|
||||||
CHIAKI_LOGW(video_receiver->log, "Failed to complete frame %d", (int)video_receiver->frame_index_cur);
|
CHIAKI_LOGW(video_receiver->log, "Failed to complete frame %d", (int)video_receiver->frame_index_cur);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue