mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Add Corrupt Frame Reporting
This commit is contained in:
parent
92f10afd20
commit
785ff38db4
5 changed files with 28 additions and 4 deletions
|
@ -81,6 +81,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_run(ChiakiStreamConnectio
|
|||
*/
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_stop(ChiakiStreamConnection *stream_connection);
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode stream_connection_send_corrupt_frame(ChiakiStreamConnection *stream_connection, ChiakiSeqNum16 start, ChiakiSeqNum16 end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -194,7 +194,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send(ChiakiTakion *takion, uint8_t *
|
|||
/**
|
||||
* Thread-safe while Takion is running.
|
||||
*/
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_message_data(ChiakiTakion *takion, uint8_t flags, uint16_t channel, uint8_t *buf, size_t buf_size);
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_message_data(ChiakiTakion *takion, uint8_t chunk_flags, uint16_t channel, uint8_t *buf, size_t buf_size);
|
||||
|
||||
/**
|
||||
* Thread-safe while Takion is running.
|
||||
|
|
|
@ -754,3 +754,25 @@ static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *
|
|||
|
||||
return chiaki_takion_send_message_data(&stream_connection->takion, 1, 1, buf, stream.bytes_written);
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode stream_connection_send_corrupt_frame(ChiakiStreamConnection *stream_connection, ChiakiSeqNum16 start, ChiakiSeqNum16 end)
|
||||
{
|
||||
tkproto_TakionMessage msg = { 0 };
|
||||
msg.type = tkproto_TakionMessage_PayloadType_CORRUPTFRAME;
|
||||
msg.has_corrupt_payload = true;
|
||||
msg.corrupt_payload.start = start;
|
||||
msg.corrupt_payload.end = end;
|
||||
|
||||
uint8_t buf[0x10];
|
||||
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(buf, sizeof(buf));
|
||||
bool pbr = pb_encode(&stream, tkproto_TakionMessage_fields, &msg);
|
||||
if(!pbr)
|
||||
{
|
||||
CHIAKI_LOGE(stream_connection->log, "StreamConnection heartbeat protobuf encoding failed");
|
||||
return CHIAKI_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
CHIAKI_LOGD(stream_connection->log, "StreamConnection reporting corrupt frame(s) from %u to %u\n", (unsigned int)start, (unsigned int)end);
|
||||
return chiaki_takion_send_message_data(&stream_connection->takion, 1, 2, buf, stream.bytes_written);
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send(ChiakiTakion *takion, uint8_t *
|
|||
return chiaki_takion_send_raw(takion, buf, buf_size);
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_message_data(ChiakiTakion *takion, uint8_t flags, uint16_t channel, uint8_t *buf, size_t buf_size)
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_message_data(ChiakiTakion *takion, uint8_t chunk_flags, uint16_t channel, uint8_t *buf, size_t buf_size)
|
||||
{
|
||||
// TODO: can we make this more memory-efficient?
|
||||
// TODO: split packet if necessary?
|
||||
|
@ -357,7 +357,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_message_data(ChiakiTakion *taki
|
|||
return CHIAKI_ERR_MEMORY;
|
||||
packet_buf[0] = TAKION_PACKET_TYPE_CONTROL;
|
||||
|
||||
takion_write_message_header(packet_buf + 1, takion->tag_remote, key_pos, TAKION_CHUNK_TYPE_DATA, flags, 9 + buf_size);
|
||||
takion_write_message_header(packet_buf + 1, takion->tag_remote, key_pos, TAKION_CHUNK_TYPE_DATA, chunk_flags, 9 + buf_size);
|
||||
|
||||
uint8_t *msg_payload = packet_buf + 1 + TAKION_MESSAGE_HEADER_SIZE;
|
||||
ChiakiSeqNum32 seq_num = takion->seq_num_local++;
|
||||
|
|
|
@ -105,7 +105,7 @@ CHIAKI_EXPORT void chiaki_video_receiver_av_packet(ChiakiVideoReceiver *video_re
|
|||
&& !(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", next_frame_expected, (int)frame_index);
|
||||
// TODO: report
|
||||
stream_connection_send_corrupt_frame(&video_receiver->session->stream_connection, next_frame_expected, frame_index - 1);
|
||||
}
|
||||
|
||||
video_receiver->frame_index_cur = frame_index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue