mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 10:46:51 -07:00
Implement Heartbeat
This commit is contained in:
parent
cb226eb3a8
commit
f128dd6426
3 changed files with 36 additions and 4 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#define SESSION_CTRL_PORT 9295
|
||||
|
@ -116,6 +117,35 @@ static void *ctrl_thread_func(void *user)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static ChiakiErrorCode ctrl_message_send(ChiakiCtrl *ctrl, CtrlMessageType type, const uint8_t *payload, size_t payload_size)
|
||||
{
|
||||
assert(payload_size == 0 || payload);
|
||||
|
||||
uint8_t header[8];
|
||||
*((uint32_t *)header) = htonl((uint32_t)payload_size);
|
||||
*((uint16_t *)(header + 4)) = htons(type);
|
||||
*((uint16_t *)(header + 6)) = 0;
|
||||
|
||||
ssize_t sent = send(ctrl->sock, header, sizeof(header), 0);
|
||||
if(sent < 0)
|
||||
{
|
||||
CHIAKI_LOGE(&ctrl->session->log, "Failed to send Ctrl Message Header\n");
|
||||
return CHIAKI_ERR_NETWORK;
|
||||
}
|
||||
|
||||
if(payload)
|
||||
{
|
||||
sent = send(ctrl->sock, payload, payload_size, 0);
|
||||
if(sent < 0)
|
||||
{
|
||||
CHIAKI_LOGE(&ctrl->session->log, "Failed to send Ctrl Message Payload\n");
|
||||
return CHIAKI_ERR_NETWORK;
|
||||
}
|
||||
}
|
||||
|
||||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void ctrl_message_received_session_id(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size);
|
||||
static void ctrl_message_received_heartbeat_req(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size);
|
||||
|
@ -199,7 +229,9 @@ static void ctrl_message_received_heartbeat_req(ChiakiCtrl *ctrl, uint8_t *paylo
|
|||
if(payload_size != 0)
|
||||
CHIAKI_LOGW(&ctrl->session->log, "Received Heartbeat request with non-empty payload\n");
|
||||
|
||||
// TODO: send CTRL_MESSAGE_TYPE_HEARTBEAT_REP
|
||||
CHIAKI_LOGD(&ctrl->session->log, "Received Heartbeat\n");
|
||||
|
||||
ctrl_message_send(ctrl, CTRL_MESSAGE_TYPE_HEARTBEAT_REP, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@ static void nagare_takion_av(uint8_t *buf, size_t buf_size, uint8_t base_type, u
|
|||
}
|
||||
else if(base_type == 2 && buf[0] != 0xf4)
|
||||
{
|
||||
CHIAKI_LOGD(nagare->log, "av frame 2, which is not audio\n");
|
||||
//CHIAKI_LOGD(nagare->log, "av frame 2, which is not audio\n");
|
||||
}
|
||||
|
||||
//CHIAKI_LOGD(nagare->log, "Nagare AV %lu\n", buf_size);
|
||||
|
|
|
@ -661,8 +661,8 @@ static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uin
|
|||
uint32_t key_pos = ntohl(*((uint32_t *)(buf + 0xd)));
|
||||
uint8_t unknown_1 = buf[0x11];
|
||||
|
||||
CHIAKI_LOGD(takion->log, "packet index %u, frame index %u\n", packet_index, frame_index);
|
||||
chiaki_log_hexdump(takion->log, CHIAKI_LOG_DEBUG, buf, buf_size);
|
||||
//CHIAKI_LOGD(takion->log, "packet index %u, frame index %u\n", packet_index, frame_index);
|
||||
//chiaki_log_hexdump(takion->log, CHIAKI_LOG_DEBUG, buf, buf_size);
|
||||
|
||||
uint8_t *data = buf + AV_HEADER_SIZE;
|
||||
size_t data_size = buf_size - AV_HEADER_SIZE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue