Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jbuf frame completeness #2754

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/examples/config
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ rtp_tos 184
rtp_video_tos 136
#rtp_ports 10000-20000
#rtp_bandwidth 512-1024 # [kbit/s]
audio_jitter_buffer_type fixed # off, fixed, adaptive
audio_jitter_buffer_delay 5-10 # (min. frames)-(max. packets)
video_jitter_buffer_type fixed # off, fixed, adaptive
video_jitter_buffer_delay 5-10 # (min. frames)-(max. packets)
audio_jitter_buffer_type fixed # off, fixed
audio_jitter_buffer_delay 5-10 # (min. frames)-(max. frames)
video_jitter_buffer_type fixed # off, fixed
video_jitter_buffer_delay 5-10 # (min. frames)-(max. frames)
video_jitter_buffer_size 500 # max. packets
rtp_stats no
#rtp_timeout 60
#avt_bundle no
Expand Down Expand Up @@ -292,7 +293,7 @@ video_selfview window # {window,pip}
# multicast receivers (in priority order)- port number must be even
#multicast_call_prio 0
#multicast_ttl 1
#multicast_jbuf_type fixed # off, fixed, adaptive
#multicast_jbuf_type fixed # off, fixed
#multicast_jbuf_delay 5-10 # frames
#multicast_jbuf_wish 6 # frames for start
#multicast_listener 224.0.2.21:50000
Expand Down
10 changes: 6 additions & 4 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ enum sipansbeep {
/** Jitter buffer type */
enum jbuf_type {
JBUF_OFF,
JBUF_FIXED,
JBUF_ADAPTIVE
JBUF_FIXED
};

struct account;
Expand Down Expand Up @@ -400,6 +399,7 @@ struct config_avt {
struct {
enum jbuf_type jbtype; /**< Jitter buffer type */
struct range jbuf_del; /**< Delay, number of frames*/
uint32_t jbuf_size; /**< Size of packet pool */
} video;
bool rtp_stats; /**< Enable RTP statistics */
uint32_t rtp_timeout; /**< RTP Timeout in seconds (0=off) */
Expand Down Expand Up @@ -1479,21 +1479,23 @@ struct jbuf_stat {
uint32_t n_late; /**< Number of frames arriving too late */
uint32_t n_lost; /**< Number of lost frames */
uint32_t n_overflow; /**< Number of overflows */
uint32_t n_underflow; /**< Number of underflows */
uint32_t n_underrun; /**< Number of underruns */
uint32_t n_flush; /**< Number of times jitter buffer flushed */
};


int jbuf_alloc(struct jbuf **jbp, uint32_t min, uint32_t max);
int jbuf_resize(struct jbuf *jb, uint32_t packets);
int jbuf_set_type(struct jbuf *jb, enum jbuf_type jbtype);
int jbuf_put(struct jbuf *jb, const struct rtp_header *hdr, void *mem);
int jbuf_get(struct jbuf *jb, struct rtp_header *hdr, void **mem);
int jbuf_drain(struct jbuf *jb, struct rtp_header *hdr, void **mem);
void jbuf_flush(struct jbuf *jb);
int jbuf_stats(const struct jbuf *jb, struct jbuf_stat *jstat);
int jbuf_debug(struct re_printf *pf, const struct jbuf *jb);
uint32_t jbuf_frames(const struct jbuf *jb);
uint32_t jbuf_packets(const struct jbuf *jb);
uint32_t jbuf_frames(const struct jbuf *jb);
uint32_t jbuf_complete_frames(const struct jbuf *jb);


/*
Expand Down
2 changes: 1 addition & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ enum jbuf_type conf_get_jbuf_type(const struct pl *pl)
{
if (0 == pl_strcasecmp(pl, "off")) return JBUF_OFF;
if (0 == pl_strcasecmp(pl, "fixed")) return JBUF_FIXED;
if (0 == pl_strcasecmp(pl, "adaptive")) return JBUF_ADAPTIVE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a warning about the config option has been removed?

if (0 == pl_strcasecmp(pl, "on")) return JBUF_FIXED;

warning("unsupported jitter buffer type (%r)\n", pl);
return JBUF_FIXED;
Expand Down
23 changes: 14 additions & 9 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static struct config core_config = {
{
JBUF_FIXED,
{5, 50},
500,
},
false,
0,
Expand Down Expand Up @@ -242,8 +243,6 @@ static const char *jbuf_type_str(enum jbuf_type jbtype)
return "off";
case JBUF_FIXED:
return "fixed";
case JBUF_ADAPTIVE:
return "adaptive";
}

return "?";
Expand Down Expand Up @@ -466,6 +465,9 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
(void)conf_get_range(conf, "video_jitter_buffer_delay",
&cfg->avt.video.jbuf_del);

(void)conf_get_u32(conf, "video_jitter_buffer_size",
&cfg->avt.video.jbuf_size);

(void)conf_get_bool(conf, "rtp_stats", &cfg->avt.rtp_stats);
(void)conf_get_u32(conf, "rtp_timeout", &cfg->avt.rtp_timeout);

Expand Down Expand Up @@ -613,6 +615,7 @@ int config_print(struct re_printf *pf, const struct config *cfg)
"audio_jitter_buffer_delay\t%H\n"
"video_jitter_buffer_type\t%s\n"
"video_jitter_buffer_delay\t%H\n"
"video_jitter_buffer_size\t%u\n"
"rtp_stats\t\t%s\n"
"rtp_timeout\t\t%u # in seconds\n"
"avt_bundle\t\t%s\n"
Expand All @@ -630,6 +633,7 @@ int config_print(struct re_printf *pf, const struct config *cfg)
range_print, &cfg->avt.audio.jbuf_del,
jbuf_type_str(cfg->avt.video.jbtype),
range_print, &cfg->avt.video.jbuf_del,
cfg->avt.video.jbuf_size,
cfg->avt.rtp_stats ? "yes" : "no",
cfg->avt.rtp_timeout,
cfg->avt.bundle ? "yes" : "no",
Expand Down Expand Up @@ -832,14 +836,14 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"rtp_video_tos\t\t136\n"
"#rtp_ports\t\t10000-20000\n"
"#rtp_bandwidth\t\t512-1024 # [kbit/s]\n"
"audio_jitter_buffer_type\tfixed\t\t# off, fixed,"
" adaptive\n"
"audio_jitter_buffer_type\tfixed\t\t# off, fixed\n"
"audio_jitter_buffer_delay\t%u-%u\t\t"
"# (min. frames)-(max. packets)\n"
"video_jitter_buffer_type\tfixed\t\t# off, fixed,"
" adaptive\n"
"# (min. frames)-(max. frames)\n"
"video_jitter_buffer_type\tfixed\t\t# off, fixed\n"
"video_jitter_buffer_delay\t%u-%u\t\t"
"# (min. frames)-(max. packets)\n"
"# (min. frames)-(max. frames)\n"
"video_jitter_buffer_size\t%u\t\t"
"# max. packets\n"
"rtp_stats\t\tno\n"
"#rtp_timeout\t\t60\n"
"#avt_bundle\t\tno\n"
Expand All @@ -858,6 +862,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
cfg->avt.audio.jbuf_del.max,
cfg->avt.video.jbuf_del.min,
cfg->avt.video.jbuf_del.max,
cfg->avt.video.jbuf_size,
default_interface_print, NULL);

return err;
Expand Down Expand Up @@ -1277,7 +1282,7 @@ int config_write_template(const char *file, const struct config *cfg)
"#multicast_call_prio\t0\n"
"#multicast_ttl\t1\n"
"#multicast_jbuf_type\tfixed\t\t"
"# off, fixed, adaptive\n"
"# off, fixed\n"
"#multicast_jbuf_delay\t5-10\t\t# frames\n"
"#multicast_listener\t224.0.2.21:50000\n"
"#multicast_listener\t224.0.2.21:50002\n");
Expand Down