Minor FEC/Flushing Fixes

This commit is contained in:
Florian Märkl 2019-07-29 22:16:02 +02:00
commit 92f10afd20
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 8 additions and 5 deletions

View file

@ -60,7 +60,7 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
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;
}

View file

@ -243,11 +243,13 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
if(frame_processor->units_source_expected == 0)
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)
{
ChiakiErrorCode err = chiaki_frame_processor_fec(frame_processor);
if(err != CHIAKI_ERR_SUCCESS)
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
@ -273,5 +275,5 @@ CHIAKI_EXPORT ChiakiFrameProcessorFlushResult chiaki_frame_processor_flush(Chiak
*frame = buf;
*frame_size = buf_size;
return CHIAKI_FRAME_PROCESSOR_FLUSH_RESULT_SUCCESS;
return result;
}

View file

@ -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)
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
{
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
}
@ -128,7 +129,7 @@ static ChiakiErrorCode chiaki_video_receiver_flush_frame(ChiakiVideoReceiver *vi
size_t 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?
CHIAKI_LOGW(video_receiver->log, "Failed to complete frame %d", (int)video_receiver->frame_index_cur);