diff --git a/lib/include/chiaki/frameprocessor.h b/lib/include/chiaki/frameprocessor.h index 0a49969..957a187 100644 --- a/lib/include/chiaki/frameprocessor.h +++ b/lib/include/chiaki/frameprocessor.h @@ -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; } diff --git a/lib/src/frameprocessor.c b/lib/src/frameprocessor.c index ea393c5..f2c83a7 100644 --- a/lib/src/frameprocessor.c +++ b/lib/src/frameprocessor.c @@ -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; } diff --git a/lib/src/videoreceiver.c b/lib/src/videoreceiver.c index fc9a171..f3f829e 100644 --- a/lib/src/videoreceiver.c +++ b/lib/src/videoreceiver.c @@ -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);