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); \
88 static const char *jitter_buffer_return_codes[] = {
101 static void test_jb_populate_config(
struct jb_conf *jbconf)
117 static void __attribute__((format(printf, 1, 2))) test_jb_debug_output(const
char *fmt, ...)
123 vsnprintf(buf,
sizeof(buf), fmt, args);
133 static void __attribute__((format(printf, 1, 2))) test_jb_warn_output(const
char *fmt, ...)
139 vsnprintf(buf,
sizeof(buf), fmt, args);
142 ast_log(AST_LOG_WARNING,
"%s", buf);
149 static void __attribute__((format(printf, 1, 2))) test_jb_error_output(const
char *fmt, ...)
155 vsnprintf(buf,
sizeof(buf), fmt, args);
158 ast_log(AST_LOG_ERROR,
"%s", buf);
169 for (i = 0; i < 40; i++) {
170 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5) == JB_DROP) {
171 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", i);
182 enum ast_test_result_state result = AST_TEST_FAIL;
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";
197 return AST_TEST_NOT_RUN;
202 JB_TEST_BEGIN(
"jitterbuffer_nominal_voice_frames");
205 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
209 test_jb_populate_config(&jbconf);
211 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
215 if (test_jb_nominal_frame_insertion(test, jb,
JB_TYPE_VOICE)) {
219 for (i = 0; i < 40; i++) {
220 enum jb_return_code ret;
222 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
223 ast_test_status_update(test,
224 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
225 jitter_buffer_return_codes[ret], i);
228 JB_NUMERIC_TEST(frame.ms, 20);
230 JB_NUMERIC_TEST(
jb_next(jb), (i + 1) * 20 + 5);
233 result = AST_TEST_PASS;
236 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
239 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
240 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
241 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
242 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
243 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
244 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
245 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
251 while (
jb_getall(jb, &frame) == JB_OK) { }
262 enum ast_test_result_state result = AST_TEST_FAIL;
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";
277 return AST_TEST_NOT_RUN;
282 JB_TEST_BEGIN(
"jitterbuffer_nominal_control_frames");
285 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
289 test_jb_populate_config(&jbconf);
291 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
299 for (i = 0; i < 40; i++) {
300 enum jb_return_code ret;
302 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
303 ast_test_status_update(test,
304 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
305 jitter_buffer_return_codes[ret], i);
308 JB_NUMERIC_TEST(frame.ms, 20);
313 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
316 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
317 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
318 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
319 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
320 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
321 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
322 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
324 result = AST_TEST_PASS;
330 while (
jb_getall(jb, &frame) == JB_OK) { }
343 static int test_jb_out_of_order_frame_insertion(
struct ast_test *test,
struct jitterbuf *jb,
enum jb_frame_type frame_type)
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) {
351 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", (i+1));
356 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5) == JB_DROP) {
357 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", i);
363 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5) == JB_DROP) {
364 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", i);
376 enum ast_test_result_state result = AST_TEST_FAIL;
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.";
393 return AST_TEST_NOT_RUN;
398 JB_TEST_BEGIN(
"jitterbuffer_out_of_order_voice");
401 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
405 test_jb_populate_config(&jbconf);
407 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
411 if (test_jb_out_of_order_frame_insertion(test, jb,
JB_TYPE_VOICE)) {
415 for (i = 0; i < 40; i++) {
416 enum jb_return_code ret;
418 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
419 ast_test_status_update(test,
420 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
421 jitter_buffer_return_codes[ret], i);
424 JB_NUMERIC_TEST(frame.ms, 20);
429 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
432 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
433 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
434 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
435 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
436 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
437 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
438 JB_NUMERIC_TEST(jbinfo.frames_ooo, 10);
440 result = AST_TEST_PASS;
446 while (
jb_getall(jb, &frame) == JB_OK) { }
457 enum ast_test_result_state result = AST_TEST_FAIL;
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.";
474 return AST_TEST_NOT_RUN;
479 JB_TEST_BEGIN(
"jitterbuffer_out_of_order_control");
482 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
486 test_jb_populate_config(&jbconf);
488 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
496 for (i = 0; i < 40; i++) {
497 enum jb_return_code ret;
499 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
500 ast_test_status_update(test,
501 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
502 jitter_buffer_return_codes[ret], i);
505 JB_NUMERIC_TEST(frame.ms, 20);
510 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
513 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
514 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
515 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
516 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
517 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
518 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
519 JB_NUMERIC_TEST(jbinfo.frames_ooo, 10);
521 result = AST_TEST_PASS;
527 while (
jb_getall(jb, &frame) == JB_OK) { }
540 static int test_jb_lost_frame_insertion(
struct ast_test *test,
struct jitterbuf *jb,
enum jb_frame_type frame_type)
544 for (i = 0; i < 40; i++) {
548 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5) == JB_DROP) {
549 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", i);
560 enum ast_test_result_state result = AST_TEST_FAIL;
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.";
576 return AST_TEST_NOT_RUN;
581 JB_TEST_BEGIN(
"jitterbuffer_lost_voice");
584 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
588 test_jb_populate_config(&jbconf);
590 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
598 for (i = 0; i < 40; i++) {
599 enum jb_return_code ret;
600 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
602 if (!((ret == JB_INTERP && i % 5 == 0) || (ret == JB_NOFRAME && i == 0))) {
603 ast_test_status_update(test,
604 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
605 jitter_buffer_return_codes[ret], i);
609 JB_NUMERIC_TEST(frame.ms, 20);
615 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
618 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
622 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
623 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
624 JB_NUMERIC_TEST(jbinfo.frames_lost, 7);
625 JB_NUMERIC_TEST(jbinfo.frames_in, 32);
626 JB_NUMERIC_TEST(jbinfo.frames_out, 32);
627 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
629 result = AST_TEST_PASS;
635 while (
jb_getall(jb, &frame) == JB_OK) { }
646 enum ast_test_result_state result = AST_TEST_FAIL;
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";
662 return AST_TEST_NOT_RUN;
667 JB_TEST_BEGIN(
"jitterbuffer_lost_control");
670 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
674 test_jb_populate_config(&jbconf);
676 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
684 for (i = 0; i < 40; i++) {
685 enum jb_return_code ret;
686 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
688 if (!(ret == JB_NOFRAME && i % 5 == 0)) {
689 ast_test_status_update(test,
690 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
691 jitter_buffer_return_codes[ret], i);
695 JB_NUMERIC_TEST(frame.ms, 20);
701 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
704 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
708 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
709 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
710 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
711 JB_NUMERIC_TEST(jbinfo.frames_in, 32);
712 JB_NUMERIC_TEST(jbinfo.frames_out, 32);
713 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
715 result = AST_TEST_PASS;
721 while (
jb_getall(jb, &frame) == JB_OK) { }
734 static int test_jb_late_frame_insertion(
struct ast_test *test,
struct jitterbuf *jb,
enum jb_frame_type frame_type)
738 for (i = 0; i < 40; i++) {
741 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 20) == JB_DROP) {
742 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", (i+1));
747 if (
jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5) == JB_DROP) {
748 ast_test_status_update(test,
"Jitter buffer dropped packet %d\n", i);
760 enum ast_test_result_state result = AST_TEST_FAIL;
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";
775 return AST_TEST_NOT_RUN;
780 JB_TEST_BEGIN(
"jitterbuffer_late_voice");
783 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
787 test_jb_populate_config(&jbconf);
789 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
797 for (i = 0; i < 40; i++) {
798 enum jb_return_code ret;
800 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
801 ast_test_status_update(test,
802 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
803 jitter_buffer_return_codes[ret], i);
806 JB_NUMERIC_TEST(frame.ms, 20);
811 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
814 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
815 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
816 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
817 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
818 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
819 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
820 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
822 result = AST_TEST_PASS;
828 while (
jb_getall(jb, &frame) == JB_OK) { }
839 enum ast_test_result_state result = AST_TEST_FAIL;
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";
854 return AST_TEST_NOT_RUN;
859 JB_TEST_BEGIN(
"jitterbuffer_late_voice");
862 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
866 test_jb_populate_config(&jbconf);
868 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
876 for (i = 0; i < 40; i++) {
877 enum jb_return_code ret;
879 if ((ret =
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN)) != JB_OK) {
880 ast_test_status_update(test,
881 "Unexpected jitter buffer return code [%s] when retrieving frame %d\n",
882 jitter_buffer_return_codes[ret], i);
885 JB_NUMERIC_TEST(frame.ms, 20);
890 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
893 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
894 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
895 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
896 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
897 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
898 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
899 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
901 result = AST_TEST_PASS;
907 while (
jb_getall(jb, &frame) == JB_OK) { }
924 for (i = 0; i < 100; i++) {
925 jb_put(jb, NULL, frame_type, 20, i * 20, i * 20 + 5);
931 enum ast_test_result_state result = AST_TEST_FAIL;
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";
944 return AST_TEST_NOT_RUN;
949 JB_TEST_BEGIN(
"jitterbuffer_overflow_voice");
952 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
956 test_jb_populate_config(&jbconf);
958 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
964 while (
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN) == JB_OK) {
965 JB_NUMERIC_TEST(frame.ms, 20);
971 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
975 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
976 JB_NUMERIC_TEST(jbinfo.frames_dropped, 49);
977 JB_NUMERIC_TEST(jbinfo.frames_out, 51);
978 JB_NUMERIC_TEST(jbinfo.frames_in, 51);
979 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
981 JB_NUMERIC_TEST(jbinfo.frames_lost, 1);
982 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
984 result = AST_TEST_PASS;
990 while (
jb_getall(jb, &frame) == JB_OK) { }
1001 enum ast_test_result_state result = AST_TEST_FAIL;
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";
1014 return AST_TEST_NOT_RUN;
1019 JB_TEST_BEGIN(
"jitterbuffer_overflow_control");
1022 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
1026 test_jb_populate_config(&jbconf);
1028 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
1034 while (
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN) == JB_OK) {
1035 JB_NUMERIC_TEST(frame.ms, 20);
1041 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
1045 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
1046 JB_NUMERIC_TEST(jbinfo.frames_dropped, 49);
1047 JB_NUMERIC_TEST(jbinfo.frames_out, 51);
1048 JB_NUMERIC_TEST(jbinfo.frames_in, 51);
1049 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
1050 JB_NUMERIC_TEST(jbinfo.frames_lost, 0);
1051 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
1053 result = AST_TEST_PASS;
1059 while (
jb_getall(jb, &frame) == JB_OK) { }
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);
1087 enum ast_test_result_state result = AST_TEST_FAIL;
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 "
1104 return AST_TEST_NOT_RUN;
1109 JB_TEST_BEGIN(
"jitterbuffer_resynch_control");
1112 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
1116 test_jb_populate_config(&jbconf);
1119 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
1125 for (i = 0; i <= 40; i++) {
1126 if (
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN) == JB_INTERP) {
1127 ++interpolated_frames;
1132 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
1136 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
1137 JB_NUMERIC_TEST(jbinfo.frames_dropped, 0);
1138 JB_NUMERIC_TEST(jbinfo.frames_out, 40);
1139 JB_NUMERIC_TEST(jbinfo.frames_in, 40);
1141 JB_NUMERIC_TEST(jbinfo.frames_lost, interpolated_frames);
1142 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
1143 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
1145 result = AST_TEST_PASS;
1151 while (
jb_getall(jb, &frame) == JB_OK) { }
1162 enum ast_test_result_state result = AST_TEST_FAIL;
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.";
1179 return AST_TEST_NOT_RUN;
1184 JB_TEST_BEGIN(
"jitterbuffer_resynch_voice");
1187 ast_test_status_update(test,
"Failed to allocate memory for jitterbuffer\n");
1191 test_jb_populate_config(&jbconf);
1194 ast_test_status_update(test,
"Failed to set jitterbuffer configuration\n");
1200 for (i = 0; i <= 40; i++) {
1201 if (
jb_get(jb, &frame, i * 20 + 5, DEFAULT_CODEC_INTERP_LEN) == JB_INTERP) {
1202 ++interpolated_frames;
1207 ast_test_status_update(test,
"Failed to get jitterbuffer information\n");
1211 JB_INFO_PRINT_FRAME_DEBUG(jbinfo);
1212 JB_NUMERIC_TEST(jbinfo.frames_dropped, 3);
1213 JB_NUMERIC_TEST(jbinfo.frames_out, 37);
1214 JB_NUMERIC_TEST(jbinfo.frames_in, 37);
1216 JB_NUMERIC_TEST(jbinfo.frames_lost, interpolated_frames);
1217 JB_NUMERIC_TEST(jbinfo.frames_late, 0);
1218 JB_NUMERIC_TEST(jbinfo.frames_ooo, 0);
1221 result = AST_TEST_PASS;
1227 while (
jb_getall(jb, &frame) == JB_OK) { }
1236 static int unload_module(
void)
1238 AST_TEST_UNREGISTER(jitterbuffer_nominal_voice_frames);
1239 AST_TEST_UNREGISTER(jitterbuffer_nominal_control_frames);
1240 AST_TEST_UNREGISTER(jitterbuffer_out_of_order_voice);
1241 AST_TEST_UNREGISTER(jitterbuffer_out_of_order_control);
1242 AST_TEST_UNREGISTER(jitterbuffer_lost_voice);
1243 AST_TEST_UNREGISTER(jitterbuffer_lost_control);
1244 AST_TEST_UNREGISTER(jitterbuffer_late_voice);
1245 AST_TEST_UNREGISTER(jitterbuffer_late_control);
1246 AST_TEST_UNREGISTER(jitterbuffer_overflow_voice);
1247 AST_TEST_UNREGISTER(jitterbuffer_overflow_control);
1248 AST_TEST_UNREGISTER(jitterbuffer_resynch_voice);
1249 AST_TEST_UNREGISTER(jitterbuffer_resynch_control);
1253 static int load_module(
void)
1256 AST_TEST_REGISTER(jitterbuffer_nominal_voice_frames);
1257 AST_TEST_REGISTER(jitterbuffer_nominal_control_frames);
1260 AST_TEST_REGISTER(jitterbuffer_out_of_order_voice);
1261 AST_TEST_REGISTER(jitterbuffer_out_of_order_control);
1264 AST_TEST_REGISTER(jitterbuffer_lost_voice);
1265 AST_TEST_REGISTER(jitterbuffer_lost_control);
1268 AST_TEST_REGISTER(jitterbuffer_late_voice);
1269 AST_TEST_REGISTER(jitterbuffer_late_control);
1272 AST_TEST_REGISTER(jitterbuffer_overflow_voice);
1273 AST_TEST_REGISTER(jitterbuffer_overflow_control);
1276 AST_TEST_REGISTER(jitterbuffer_resynch_voice);
1277 AST_TEST_REGISTER(jitterbuffer_resynch_control);
Asterisk main include file. File version handling, generic pbx functions.
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
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...
jitterbuf * jb_new(void)
new jitterbuf
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...
static void cleanup(void)
Clean up any old apps that we don't need any more.
#define ast_debug(level,...)
Log a DEBUG message.
jitterbuf: an application-independent jitterbuffer jitterbuf.c
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
set jitterbuf conf
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
get jitterbuf info: only "statistics" may be valid
#define AST_TEST_DEFINE(hdr)
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