Closed jasonz1987 closed 5 months ago
For one way communication, perhaps you can use media direction setting in call setting. There may still some RTP packets sent at the beginning for NAT hole puching and then the rate is reduced significantly to maintain NAT.
FYI, your first method relies on codec's VAD & DTX capability (try to search "VAD" in docs). For the second method, normally some (silent) packets will still be sent at some interval, e.g: every 5 seconds, for keep the NAT binding open.
If I use the first method, the account configuration has enabled VAD configuration. this is my code:
acfg.getMediaConfig().setStreamKaEnabled(true);
acfg.getNatConfig().setUdpKaIntervalSec(3);
but silent packets will still be sent at every 5 seconds, so, how i control the interval ?
For codec's VAD/DTX, please check macro PJMEDIA_CODEC_MAX_SILENCE_PERIOD to be set in config_site.h
.
@nanangizz Tks very much, but there still hava a strange issue, Although I set up silent operation, and most of the time it will send silent frames, but sometimes it does not work properly. I am not sure what caused VAD to not send normally. The attachment is that I made several calls. After that, abnormal packet capture occurred. I don’t know if this is related to the device or the software? rtp11.pcap.zip
from the image ,the first time send client frame at No 9198,but threre is not any mark frame after 5 seconds
You can try to debug into or add log information in pjmedia/src/pjmedia/g711.c
(search for the text PJMEDIA_CODEC_MAX_SILENCE_PERIOD
).
this is my logs, the logs seemed that vad is work normally, but it still have not send any null frame ?
if (priv->vad_enabled) {
pj_bool_t is_silence;
pj_int32_t silence_period;
silence_period = pj_timestamp_diff32(&priv->last_tx,
&input->timestamp);
is_silence = pjmedia_silence_det_detect(priv->vad,
(const pj_int16_t*) input->buf,
(input->size >> 1), NULL);
TRACE_((THIS_FILE, "Silence detected: %d", is_silence)); // 添加这行日志以查看是否检测到静音
TRACE_((THIS_FILE, "PJMEDIA_CODEC_MAX_SILENCE_PERIOD: %d", PJMEDIA_CODEC_MAX_SILENCE_PERIOD)); // 打印 PJMEDIA_CODEC_MAX_SILENCE_PERIOD 的值
TRACE_((THIS_FILE, "priv->last_tx: %d", priv->last_tx)); // 打印 priv->last_tx 的值
TRACE_((THIS_FILE, "input->timestamp: %d", input->timestamp)); // 打印 input->timestamp 的值
if (is_silence &&
(PJMEDIA_CODEC_MAX_SILENCE_PERIOD == -1 ||
silence_period < PJMEDIA_CODEC_MAX_SILENCE_PERIOD*8000/1000))
{
TRACE_((THIS_FILE, "Silence period within threshold. Sending silence."));
output->type = PJMEDIA_FRAME_TYPE_NONE;
output->buf = NULL;
output->size = 0;
output->timestamp = input->timestamp;
return PJ_SUCCESS;
} else {
TRACE_((THIS_FILE, "Not silence or silence period exceeds threshold. Proceeding with encoding."));
priv->last_tx = input->timestamp;
}
}
Due to the needs of project development, I gave up using VAD for RTP keep-alive, and instead used the PJMEDIA_STREAM_ENABLE_KA mechanism for keep-alive. Currently, this system works normally and can send empty packets regularly according to the set cycle.
Understood. I will close the issue then.
Describe the bug
I implemented a logic in my application. After I established a call, I would disable the local microphone to implement a function similar to one-way intercom. However, after my testing, I found that although the mute effect can be achieved, the After capturing the packet, I found that the device did not send a silent packet to the other party. I don’t know whether it is a BUG or a problem with my application?
this is my mute code
i also try this code to mute ,it's also not work
this is no any frame after "mute"
Steps to reproduce
PJSIP version
2.13
Context
android 9.0
Log, call stack, etc