Ticket #505: ticket505.2.patch
File ticket505.2.patch, 5.1 KB (added by nanang, 16 years ago) |
---|
-
pjmedia/src/test/test.c
35 35 36 36 void app_perror(pj_status_t status, const char *msg) 37 37 { 38 char errbuf[PJ MEDIA_ERR_MSG_SIZE];38 char errbuf[PJ_ERR_MSG_SIZE]; 39 39 40 40 pjmedia_strerror(status, errbuf, sizeof(errbuf)); 41 41 … … 44 44 45 45 int test_main(void) 46 46 { 47 int rc ;47 int rc = 0; 48 48 pj_caching_pool caching_pool; 49 49 50 50 pj_init(); … … 54 54 55 55 mem = &caching_pool.factory; 56 56 57 DO_TEST(sdp_neg_test());57 //DO_TEST(sdp_neg_test()); 58 58 //sdp_test (&caching_pool.factory); 59 59 //rtp_test(&caching_pool.factory); 60 60 //session_test (&caching_pool.factory); 61 //jbuf_main(&caching_pool.factory);61 jbuf_main(&caching_pool.factory); 62 62 63 63 PJ_LOG(3,(THIS_FILE," ")); 64 64 65 on_return:66 67 65 if (rc != 0) { 68 66 PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!")); 69 67 } else { -
pjmedia/src/test/test.h
26 26 int session_test(void); 27 27 int rtp_test(void); 28 28 int sdp_test(void); 29 int jbuf_main( void);29 int jbuf_main(pj_pool_factory *pf); 30 30 int sdp_neg_test(void); 31 31 32 32 extern pj_pool_factory *mem; -
pjmedia/src/test/jbuf_test.c
21 21 #include <pjmedia/jbuf.h> 22 22 #include <pj/pool.h> 23 23 24 #define JB_MIN 1 25 #define JB_MAX 8 26 #define JB_BUF_SIZE 10 24 #define JB_INIT_PREFETCH 0 25 #define JB_MIN_PREFETCH 0 26 #define JB_MAX_PREFETCH 10 27 #define JB_PTIME 20 28 #define JB_BUF_SIZE 20 27 29 28 30 #define REPORT 29 31 //#define PRINT_COMMENT 30 32 31 33 int jbuf_main(pj_pool_factory *pf) 32 34 { 33 pj _jitter_bufferjb;35 pjmedia_jbuf *jb; 34 36 FILE *input = fopen("JBTEST.DAT", "rt"); 35 unsigned lastseq; 36 void *data = "Hello world"; 37 char line[1024], *p; 38 int lastget = 0, lastput = 0; 37 unsigned seq; 38 char line[1024 * 10], *p; 39 39 pj_pool_t *pool; 40 pjmedia_jb_state state; 41 pj_str_t jb_name = {"JBTEST", 6}; 40 42 41 43 pj_init(); 42 44 pool = pj_pool_create(pf, "JBPOOL", 256*16, 256*16, NULL); 43 45 44 pj_jb_init(&jb, pool, JB_MIN, JB_MAX, JB_BUF_SIZE); 46 pjmedia_jbuf_create(pool, &jb_name, 1, JB_PTIME, JB_BUF_SIZE, &jb); 47 pjmedia_jbuf_set_adaptive(jb, JB_INIT_PREFETCH, JB_MIN_PREFETCH, 48 JB_MAX_PREFETCH); 45 49 46 lastseq = 1;47 48 50 while ((p=fgets(line, sizeof(line), input)) != NULL) { 49 51 50 52 while (*p && isspace(*p)) … … 55 57 56 58 if (*p == '#') { 57 59 #ifdef PRINT_COMMENT 58 printf(" \n%s", p);60 printf("%s", p); 59 61 #endif 60 62 continue; 61 63 } 62 64 63 pj_jb_reset(&jb); 65 pjmedia_jbuf_reset(jb); 66 seq = 1; 67 64 68 #ifdef REPORT 65 printf( "Initial\t%c size=%d prefetch=%d level=%d\n", 66 ' ', jb.lst.count, jb.prefetch, jb.level); 69 pjmedia_jbuf_get_state(jb, &state); 70 printf("Initial\tsize=%d\tprefetch=%d\tmin.pftch=%d\tmax.pftch=%d\n", 71 state.size, state.prefetch, state.min_prefetch, state.max_prefetch); 67 72 #endif 68 73 69 74 while (*p) { 70 75 int c; 71 unsigned seq = 0; 72 void *thedata; 73 int status = 1234; 76 char frame[1]; 77 char f_type; 74 78 75 79 c = *p++; 76 80 if (isspace(c)) 77 81 continue; 78 82 79 83 if (c == '/') { 80 char *end;84 putchar('\n'); 81 85 82 printf("/*"); 86 while (*++p && *p != '/') 87 putchar(*p); 83 88 84 do {85 putchar(*++p);86 } while (*p != '/');87 88 89 putchar('\n'); 89 90 90 c = *++p;91 end = p;91 if (*++p == 0) 92 break; 92 93 93 }94 95 if (isspace(c))96 94 continue; 97 98 if (isdigit(c)) {99 seq = c - '0';100 while (*p) {101 c = *p++;102 103 if (isspace(c))104 continue;105 106 if (!isdigit(c))107 break;108 109 seq = seq * 10 + c - '0';110 }111 95 } 112 96 113 if (!*p)114 break;115 116 97 switch (toupper(c)) { 117 98 case 'G': 118 seq = -1; 119 status = pj_jb_get(&jb, &seq, &thedata); 120 lastget = seq; 99 pjmedia_jbuf_get_frame(jb, frame, &f_type); 121 100 break; 122 101 case 'P': 123 if (seq == 0) 124 seq = lastseq++; 125 else 126 lastseq = seq; 127 status = pj_jb_put(&jb, seq, data); 128 if (status == 0) 129 lastput = seq; 102 pjmedia_jbuf_put_frame(jb, (void*)frame, 1, seq); 103 seq++; 130 104 break; 105 case 'L': 106 seq++; 107 printf("Lost\n"); 108 break; 131 109 default: 132 110 printf("Unknown character '%c'\n", c); 133 111 break; 134 112 } 135 113 136 114 #ifdef REPORT 137 printf("seq=%d\t%c rc=%d\tsize=%d\tpfch=%d\tlvl=%d\tmxl=%d\tdelay=%d\n", 138 seq, toupper(c), status, jb.lst.count, jb.prefetch, jb.level, jb.max_level, 139 (lastget>0 && lastput>0) ? lastput-lastget : -1); 115 if (toupper(c) != 'L') { 116 pjmedia_jbuf_get_state(jb, &state); 117 printf("seq=%d\t%c\tsize=%d\tprefetch=%d\n", 118 seq, toupper(c), state.size, state.prefetch); 119 } 140 120 #endif 141 121 } 142 122 } 143 123 144 #ifdef REPORT 145 printf("0\t%c size=%d prefetch=%d level=%d\n", 146 ' ', jb.lst.count, jb.prefetch, jb.level); 147 #endif 124 pjmedia_jbuf_destroy(jb); 148 125 149 126 if (input != stdin) 150 127 fclose(input);