Skip to content

Commit

Permalink
Config audio duration and keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
sepfy committed Jan 19, 2025
1 parent 734b80c commit d7d480c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@
#define CONFIG_TLS_READ_TIMEOUT 3000
#endif

#define AUDIO_LATENCY 20 // ms
#define KEEPALIVE_CONNCHECK 10000
#ifndef CONFIG_KEEPALIVE_TIMEOUT
#define CONFIG_KEEPALIVE_TIMEOUT 10000
#endif

#ifndef CONFIG_AUDIO_DURATION
#define CONFIG_AUDIO_DURATION 20
#endif

#define CONFIG_IPV6 0
// empty will use first active interface
#define CONFIG_IFACE_PREFIX ""
Expand Down
2 changes: 1 addition & 1 deletion src/peer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ int peer_connection_loop(PeerConnection* pc) {
}
}

if (KEEPALIVE_CONNCHECK > 0 && (ports_get_epoch_time() - pc->agent.binding_request_time) > KEEPALIVE_CONNCHECK) {
if (CONFIG_KEEPALIVE_TIMEOUT > 0 && (ports_get_epoch_time() - pc->agent.binding_request_time) > CONFIG_KEEPALIVE_TIMEOUT) {
LOGI("binding request timeout");
STATE_CHANGED(pc, PEER_CONNECTION_CLOSED);
}
Expand Down
6 changes: 3 additions & 3 deletions src/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,19 @@ void rtp_encoder_init(RtpEncoder* rtp_encoder, MediaCodec codec, RtpOnPacket on_
case CODEC_PCMA:
rtp_encoder->type = PT_PCMA;
rtp_encoder->ssrc = SSRC_PCMA;
rtp_encoder->timestamp_increment = AUDIO_LATENCY * 8000 / 1000;
rtp_encoder->timestamp_increment = CONFIG_AUDIO_DURATION * 8000 / 1000;
rtp_encoder->encode_func = rtp_encoder_encode_generic;
break;
case CODEC_PCMU:
rtp_encoder->type = PT_PCMU;
rtp_encoder->ssrc = SSRC_PCMU;
rtp_encoder->timestamp_increment = AUDIO_LATENCY * 8000 / 1000;
rtp_encoder->timestamp_increment = CONFIG_AUDIO_DURATION * 8000 / 1000;
rtp_encoder->encode_func = rtp_encoder_encode_generic;
break;
case CODEC_OPUS:
rtp_encoder->type = PT_OPUS;
rtp_encoder->ssrc = SSRC_OPUS;
rtp_encoder->timestamp_increment = AUDIO_LATENCY * 48000 / 1000;
rtp_encoder->timestamp_increment = CONFIG_AUDIO_DURATION * 48000 / 1000;
rtp_encoder->encode_func = rtp_encoder_encode_generic;
break;
default:
Expand Down

0 comments on commit d7d480c

Please sign in to comment.