mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Fix -Wsign-compare warnings in VoMP code
This commit is contained in:
parent
b7528412df
commit
dea46d0d8b
2
serval.h
2
serval.h
@ -569,7 +569,7 @@ struct vomp_call_state;
|
|||||||
void set_codec_flag(int codec, unsigned char *flags);
|
void set_codec_flag(int codec, unsigned char *flags);
|
||||||
int is_codec_set(int codec, unsigned char *flags);
|
int is_codec_set(int codec, unsigned char *flags);
|
||||||
|
|
||||||
struct vomp_call_state *vomp_find_call_by_session(int session_token);
|
struct vomp_call_state *vomp_find_call_by_session(unsigned int session_token);
|
||||||
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
||||||
int vomp_parse_dtmf_digit(char c);
|
int vomp_parse_dtmf_digit(char c);
|
||||||
int vomp_dial(struct subscriber *local, struct subscriber *remote, const char *local_did, const char *remote_did);
|
int vomp_dial(struct subscriber *local, struct subscriber *remote, const char *local_did, const char *remote_did);
|
||||||
|
38
vomp.c
38
vomp.c
@ -172,7 +172,7 @@ struct vomp_call_state {
|
|||||||
time_ms_t create_time;
|
time_ms_t create_time;
|
||||||
time_ms_t last_activity;
|
time_ms_t last_activity;
|
||||||
time_ms_t audio_clock;
|
time_ms_t audio_clock;
|
||||||
int remote_audio_clock;
|
unsigned remote_audio_clock;
|
||||||
|
|
||||||
// last local & remote status we sent to all interested parties
|
// last local & remote status we sent to all interested parties
|
||||||
int last_sent_status;
|
int last_sent_status;
|
||||||
@ -330,7 +330,7 @@ int is_codec_set(int codec, unsigned char *flags){
|
|||||||
return flags[codec >> 3] & (1<<(codec & 7));
|
return flags[codec >> 3] & (1<<(codec & 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vomp_call_state *vomp_find_call_by_session(int session_token)
|
struct vomp_call_state *vomp_find_call_by_session(unsigned int session_token)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for(i=0;i<vomp_call_count;i++)
|
for(i=0;i<vomp_call_count;i++)
|
||||||
@ -341,10 +341,10 @@ struct vomp_call_state *vomp_find_call_by_session(int session_token)
|
|||||||
|
|
||||||
static int vomp_generate_session_id()
|
static int vomp_generate_session_id()
|
||||||
{
|
{
|
||||||
int session_id=0;
|
unsigned int session_id=0;
|
||||||
while (!session_id)
|
while (!session_id)
|
||||||
{
|
{
|
||||||
if (urandombytes((unsigned char *)&session_id,sizeof(int)))
|
if (urandombytes((unsigned char *)&session_id, sizeof session_id))
|
||||||
return WHY("Insufficient entropy");
|
return WHY("Insufficient entropy");
|
||||||
session_id&=VOMP_SESSION_MASK;
|
session_id&=VOMP_SESSION_MASK;
|
||||||
if (config.debug.vomp) DEBUGF("session=0x%08x",session_id);
|
if (config.debug.vomp) DEBUGF("session=0x%08x",session_id);
|
||||||
@ -697,35 +697,33 @@ static int vomp_update(struct vomp_call_state *call)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int to_absolute_value(int short_value, int reference_value){
|
static uint32_t to_absolute_value(uint16_t short_value, unsigned int reference_value)
|
||||||
short_value = (reference_value & 0xFFFF0000) | short_value;
|
{
|
||||||
|
uint32_t abs_value = (reference_value & 0xFFFF0000) | short_value;
|
||||||
if (short_value + 0x8000 < reference_value)
|
if (abs_value + 0x8000 < reference_value)
|
||||||
short_value+=0x10000;
|
abs_value += 0x10000;
|
||||||
|
if (abs_value > reference_value + 0x8000)
|
||||||
if (short_value > reference_value + 0x8000)
|
abs_value -= 0x10000;
|
||||||
short_value-=0x10000;
|
return abs_value;
|
||||||
|
|
||||||
return short_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vomp_process_audio(struct vomp_call_state *call, overlay_mdp_frame *mdp, time_ms_t now)
|
static int vomp_process_audio(struct vomp_call_state *call, overlay_mdp_frame *mdp, time_ms_t now)
|
||||||
{
|
{
|
||||||
int ofs=6;
|
size_t ofs=6;
|
||||||
|
|
||||||
if(ofs>=mdp->in.payload_length)
|
if(ofs>=mdp->in.payload_length)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int codec=mdp->in.payload[ofs++];
|
int codec=mdp->in.payload[ofs++];
|
||||||
|
|
||||||
int time = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
uint16_t time = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||||
ofs+=2;
|
ofs+=2;
|
||||||
int sequence = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
uint16_t sequence = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||||
ofs+=2;
|
ofs+=2;
|
||||||
|
|
||||||
// rebuild absolute time value from short relative time.
|
// rebuild absolute time value from short relative time.
|
||||||
int decoded_time = to_absolute_value(time, call->remote_audio_clock);
|
uint32_t decoded_time = to_absolute_value(time, call->remote_audio_clock);
|
||||||
int decoded_sequence = to_absolute_value(sequence, call->remote.sequence);
|
uint32_t decoded_sequence = to_absolute_value(sequence, call->remote.sequence);
|
||||||
|
|
||||||
if (call->remote_audio_clock < decoded_time &&
|
if (call->remote_audio_clock < decoded_time &&
|
||||||
call->remote.sequence < decoded_sequence){
|
call->remote.sequence < decoded_sequence){
|
||||||
@ -733,7 +731,7 @@ static int vomp_process_audio(struct vomp_call_state *call, overlay_mdp_frame *m
|
|||||||
call->remote.sequence = decoded_sequence;
|
call->remote.sequence = decoded_sequence;
|
||||||
}else if (call->remote_audio_clock < decoded_time ||
|
}else if (call->remote_audio_clock < decoded_time ||
|
||||||
call->remote.sequence < decoded_sequence){
|
call->remote.sequence < decoded_sequence){
|
||||||
WARNF("Mismatch while decoding sequence and time offset (%d, %d) + (%d, %d) = (%d, %d)",
|
WARNF("Mismatch while decoding sequence and time offset (%u, %u) + (%u, %u) = (%u, %u)",
|
||||||
time, sequence,
|
time, sequence,
|
||||||
call->remote_audio_clock, call->remote.sequence,
|
call->remote_audio_clock, call->remote.sequence,
|
||||||
decoded_time, decoded_sequence);
|
decoded_time, decoded_sequence);
|
||||||
|
Loading…
Reference in New Issue
Block a user