From a798d110f9d3a6abbf3ee7f6606e5cbec7947cee Mon Sep 17 00:00:00 2001 From: igorshevach Date: Wed, 18 Sep 2024 21:12:39 +0300 Subject: [PATCH] - fix logs - fix acks in testing --- transcoder/ackHandler/ackHandlerInternal.cpp | 8 ++++---- transcoder/receiver_server.c | 9 +++++++-- .../transcode/transcode_session_output.c | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/transcoder/ackHandler/ackHandlerInternal.cpp b/transcoder/ackHandler/ackHandlerInternal.cpp index d979b10d..9722d656 100644 --- a/transcoder/ackHandler/ackHandlerInternal.cpp +++ b/transcoder/ackHandler/ackHandlerInternal.cpp @@ -7,7 +7,7 @@ try { am.addIn(*desc); } catch(const std::exception &e) { - LOGGER(LoggingCategory,AV_LOG_ERROR," %s audio map. ack_map_add_input %d %lld failed due to %s", + LOGGER(LoggingCategory,AV_LOG_ERROR," %s map. ack_map_add_input %lld %lld failed due to %s", am.m_name.c_str(),desc->id, desc->pts,e.what()); } } @@ -20,7 +20,7 @@ try { am.addFiltered(*desc); } catch(const std::exception &e) { - LOGGER(LoggingCategory,AV_LOG_ERROR," %s audio map. ack_map_add_filtered %d %lld failed due to %s", + LOGGER(LoggingCategory,AV_LOG_ERROR," %s map. ack_map_add_filtered %lld %lld failed due to %s", am.m_name.c_str(),desc->id, desc->pts,e.what()); } } @@ -33,7 +33,7 @@ try { am.addOut(*desc); } catch(const std::exception &e) { - LOGGER(LoggingCategory,AV_LOG_ERROR," %s audio map. ack_map_add_output %d %lld failed due to %s", + LOGGER(LoggingCategory,AV_LOG_ERROR," %s map. ack_map_add_output %lld %lld failed due to %s", am.m_name.c_str(),desc->id, desc->pts,e.what()); } } @@ -48,7 +48,7 @@ am.map(ack,*ao); return; } catch(const std::exception &e) { - LOGGER(LoggingCategory,AV_LOG_ERROR," %s audio map. ack_map_ack %lld failed due to %s", + LOGGER(LoggingCategory,AV_LOG_ERROR," %s map. ack_map_ack %lld failed due to %s", am.m_name.c_str(),ack, e.what()); } } diff --git a/transcoder/receiver_server.c b/transcoder/receiver_server.c index d24f6c72..bc37e0f7 100644 --- a/transcoder/receiver_server.c +++ b/transcoder/receiver_server.c @@ -119,9 +119,14 @@ int clientLoop(receiver_server_t *server,receiver_server_session_t *session,tran if(!autoAckMode) { transcode_session_get_ack_frame_id(transcode_session,¤t_position); // TODO: we cheat here, received_frame_id may have not been persisted yet - // so we should make sure all of the frames are consumed ny upstream + // so we should ensure all of the frames up to received_frame_id + // inclusively, are consumed by upstream current_position.frame_id = current_position.transcoded_frame_id = received_frame_id; - LOGGER(CATEGORY_RECEIVER,AV_LOG_INFO,"[%s] sending ack for packet # : %lld",session->stream_name,current_position.frame_id); + LOGGER(CATEGORY_RECEIVER,AV_LOG_INFO,"[%s] sending ack for frame position: %lld, %lld, %lld", + session->stream_name, + current_position.frame_id, + current_position.transcoded_frame_id, + current_position.offset); _S(KMP_send_ack(&session->kmpClient,¤t_position)); } break; diff --git a/transcoder/transcode/transcode_session_output.c b/transcoder/transcode/transcode_session_output.c index 5066cdf4..df73953a 100644 --- a/transcoder/transcode/transcode_session_output.c +++ b/transcoder/transcode/transcode_session_output.c @@ -130,14 +130,16 @@ int transcode_session_output_send_output_packet(transcode_session_output_t *pOut } av_write_frame(pOutput->oc, NULL); - ack_desc_t desc = {0}; - if( (ret = get_packet_frame_id(cpPacket,&desc.id)) >= 0) { - if(pOutput->acker.ctx){ - pOutput->acker.map(&pOutput->acker,desc.id,&desc); - } - pOutput->lastMappedAck = desc.id; - pOutput->lastAck=desc.id; - pOutput->lastOffset=desc.offset; + if(cpPacket->flags & AV_PKT_FLAG_KEY) { + ack_desc_t desc = {0}; + if( (ret = get_packet_frame_id(cpPacket,&desc.id)) >= 0) { + if(pOutput->acker.ctx){ + pOutput->acker.map(&pOutput->acker,desc.id,&desc); + } + pOutput->lastMappedAck = desc.id; + pOutput->lastAck=desc.id; + pOutput->lastOffset=desc.offset; + } } av_packet_free(&cpPacket);