40 #define DEFAULT_MAX_JITTERBUFFER 1000 41 #define DEFAULT_RESYNCH_THRESHOLD 1000 42 #define DEFAULT_MAX_CONTIG_INTERP 10 43 #define DEFAULT_TARGET_EXTRA -1 44 #define DEFAULT_CODEC_INTERP_LEN 20 50 #define JB_NUMERIC_TEST(attribute, expected) do { \ 51 if ((attribute) != (expected)) { \ 52 ast_test_status_update(test, #attribute ": expected [%ld]; actual [%ld]\n", (long int)(expected), (attribute)); \ 60 #define JB_INFO_PRINT_FRAME_DEBUG(jbinfo) do { \ 61 ast_debug(1, "JitterBuffer Frame Info:\n" \ 62 "\tFrames In: %ld\n\tFrames Out: %ld\n" \ 63 "\tDropped Frames: %ld\n\tLate Frames: %ld\n" \ 64 "\tLost Frames: %ld\n\tOut of Order Frames: %ld\n" \ 65 "\tCurrent Frame: %ld\n", jbinfo.frames_in, jbinfo.frames_out, \ 66 jbinfo.frames_dropped, jbinfo.frames_late, jbinfo.frames_lost, \ 67 jbinfo.frames_ooo, jbinfo.frames_cur); \ 76 #define JB_TEST_BEGIN(test_name) do { \ 77 jb_setoutput(test_jb_error_output, test_jb_warn_output, test_jb_debug_output); \ 78 ast_debug(1, "Starting %s\n", test_name); \ 84 #define JB_TEST_END do { \ 85 jb_setoutput(NULL, NULL, NULL); \ 123 vsnprintf(buf,
sizeof(buf), fmt, args);
139 vsnprintf(buf,
sizeof(buf), fmt, args);
155 vsnprintf(buf,
sizeof(buf), fmt, args);
169 for (i = 0; i < 40; i++) {
191 info->name =
"jitterbuffer_nominal_voice_frames";
192 info->category =
"/main/jitterbuf/";
193 info->summary =
"Nominal operation of jitter buffer with audio data";
195 "Tests the nominal case of putting audio data into a jitter buffer, " 196 "retrieving the frames, and querying for the next frame";
219 for (i = 0; i < 40; i++) {
224 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
271 info->name =
"jitterbuffer_nominal_control_frames";
272 info->category =
"/main/jitterbuf/";
273 info->summary =
"Nominal operation of jitter buffer with control frames";
275 "Tests the nominal case of putting control frames into a jitter buffer, " 276 "retrieving the frames, and querying for the next frame";
299 for (i = 0; i < 40; i++) {
304 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
347 for (i = 0; i < 40; i++) {
350 if (
jb_put(jb,
NULL, frame_type, 20, (i + 1) * 20, (i + 1) * 20 + 5) ==
JB_DROP) {
385 info->name =
"jitterbuffer_out_of_order_voice";
386 info->category =
"/main/jitterbuf/";
387 info->summary =
"Tests sending out of order audio frames to a jitter buffer";
389 "Every 5th frame sent to a jitter buffer is reversed with the previous " 390 "frame. The expected result is to have a jitter buffer with the frames " 391 "in order, while a total of 10 frames should be recorded as having been " 392 "received out of order.";
415 for (i = 0; i < 40; i++) {
420 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
466 info->name =
"jitterbuffer_out_of_order_voice";
467 info->category =
"/main/jitterbuf/";
468 info->summary =
"Tests sending out of order audio frames to a jitter buffer";
470 "Every 5th frame sent to a jitter buffer is reversed with the previous " 471 "frame. The expected result is to have a jitter buffer with the frames " 472 "in order, while a total of 10 frames should be recorded as having been " 473 "received out of order.";
496 for (i = 0; i < 40; i++) {
501 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
544 for (i = 0; i < 40; i++) {
569 info->name =
"jitterbuffer_lost_voice";
570 info->category =
"/main/jitterbuf/";
571 info->summary =
"Tests missing frames in the jitterbuffer";
573 "Every 5th frame that would be sent to a jitter buffer is instead" 574 "dropped. When reading data from the jitter buffer, the jitter buffer" 575 "should interpolate the voice frame.";
598 for (i = 0; i < 40; i++) {
604 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
655 info->name =
"jitterbuffer_lost_control";
656 info->category =
"/main/jitterbuf/";
657 info->summary =
"Tests missing frames in the jitterbuffer";
659 "Every 5th frame that would be sent to a jitter buffer is instead" 660 "dropped. When reading data from the jitter buffer, the jitter buffer" 661 "simply reports that no frame exists for that time slot";
684 for (i = 0; i < 40; i++) {
690 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
738 for (i = 0; i < 40; i++) {
769 info->name =
"jitterbuffer_late_voice";
770 info->category =
"/main/jitterbuf/";
771 info->summary =
"Tests sending frames to a jitter buffer that arrive late";
773 "Every 5th frame sent to a jitter buffer arrives late, but still in " 774 "order with respect to the previous and next packet";
797 for (i = 0; i < 40; i++) {
802 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
848 info->name =
"jitterbuffer_late_control";
849 info->category =
"/main/jitterbuf/";
850 info->summary =
"Tests sending frames to a jitter buffer that arrive late";
852 "Every 5th frame sent to a jitter buffer arrives late, but still in " 853 "order with respect to the previous and next packet";
876 for (i = 0; i < 40; i++) {
881 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
924 for (i = 0; i < 100; i++) {
925 jb_put(jb,
NULL, frame_type, 20, i * 20, i * 20 + 5);
940 info->name =
"jitterbuffer_overflow_voice";
941 info->category =
"/main/jitterbuf/";
942 info->summary =
"Tests overfilling a jitter buffer with voice frames";
943 info->description =
"Tests overfilling a jitter buffer with voice frames";
1010 info->name =
"jitterbuffer_overflow_control";
1011 info->category =
"/main/jitterbuf/";
1012 info->summary =
"Tests overfilling a jitter buffer with control frames";
1013 info->description =
"Tests overfilling a jitter buffer with control frames";
1076 for (i = 0; i < 20; i++) {
1077 jb_put(jb,
NULL, frame_type, 20, i * 20, i * 20 + 5);
1080 for (i = 20; i < 40; i++) {
1081 jb_put(jb,
NULL, frame_type, 20, i * 20 + 500, i * 20 + 5);
1092 int interpolated_frames = 0;
1097 info->name =
"jitterbuffer_resynch_control";
1098 info->category =
"/main/jitterbuf/";
1099 info->summary =
"Tests sending control frames that force a resynch";
1100 info->description =
"Control frames are sent to a jitter buffer. After some " 1101 "number of frames, the source timestamps jump, forcing a resync of " 1102 "the jitter buffer. Since the frames are control, the resync happens " 1125 for (i = 0; i <= 40; i++) {
1127 ++interpolated_frames;
1167 int interpolated_frames = 0;
1172 info->name =
"jitterbuffer_resynch_voice";
1173 info->category =
"/main/jitterbuf/";
1174 info->summary =
"Tests sending voice frames that force a resynch";
1175 info->description =
"Voice frames are sent to a jitter buffer. After some " 1176 "number of frames, the source timestamps jump, forcing a resync of " 1177 "the jitter buffer. Since the frames are voice, the resync happens " 1178 "after observing three packets that break the resync threshold.";
1200 for (i = 0; i <= 40; i++) {
1202 ++interpolated_frames;
#define JB_NUMERIC_TEST(attribute, expected)
#define DEFAULT_CODEC_INTERP_LEN
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
AST_TEST_DEFINE(jitterbuffer_nominal_voice_frames)
static void test_jb_populate_config(struct jb_conf *jbconf)
#define DEFAULT_MAX_JITTERBUFFER
#define JB_INFO_PRINT_FRAME_DEBUG(jbinfo)
static void test_jb_resynch_frame_insertion(struct jitterbuf *jb, enum jb_frame_type frame_type)
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now)
queue a frame
#define AST_TEST_REGISTER(cb)
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl)
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame! JB_DROP: H...
#define JB_TEST_BEGIN(test_name)
jitterbuf * jb_new(void)
new jitterbuf
static int test_jb_lost_frame_insertion(struct ast_test *test, struct jitterbuf *jb, enum jb_frame_type frame_type)
#define ast_debug(level,...)
Log a DEBUG message.
long jb_next(jitterbuf *jb)
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are adde...
#define ast_test_status_update(a, b, c...)
#define DEFAULT_MAX_CONTIG_INTERP
static void test_jb_warn_output(const char *fmt,...)
jitterbuf: an application-independent jitterbuffer jitterbuf.c
static void test_jb_error_output(const char *fmt,...)
static int load_module(void)
#define AST_TEST_UNREGISTER(cb)
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
static int test_jb_out_of_order_frame_insertion(struct ast_test *test, struct jitterbuf *jb, enum jb_frame_type frame_type)
static void test_jb_overflow_frame_insertion(struct jitterbuf *jb, enum jb_frame_type frame_type)
static const char * jitter_buffer_return_codes[]
static int test_jb_nominal_frame_insertion(struct ast_test *test, struct jitterbuf *jb, enum jb_frame_type frame_type)
static int unload_module(void)
static void * cleanup(void *unused)
#define DEFAULT_RESYNCH_THRESHOLD
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
static void test_jb_debug_output(const char *fmt,...)
static int test_jb_late_frame_insertion(struct ast_test *test, struct jitterbuf *jb, enum jb_frame_type frame_type)
void jb_destroy(jitterbuf *jb)
destroy jitterbuf
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
unconditionally get frames from jitterbuf until empty
static snd_pcm_format_t format