- Timestamp:
- Mar 11, 2009 11:28:44 AM (16 years ago)
- Location:
- pjproject/branches/projects/aps-direct
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiotest.h
r2470 r2503 58 58 59 59 /** 60 * Average inter-frame arrival time, in milliseconds 61 */ 62 unsigned avg_interval; 63 64 /** 65 * Standard deviation of inter-frame arrival time, in milliseconds 66 */ 67 unsigned dev_interval; 68 69 /** 60 70 * Maximum number of frame burst 61 71 */ -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/audiotest.c
r2468 r2503 31 31 #define SKIP_DURATION 1000 32 32 33 /* Max frames per sec (to calculate number of delays to keep). */ 34 #define MAX_FRAMES_PER_SEC 100 35 36 /* Number of frame durations to keep */ 37 #define MAX_DELAY_COUNTER (((DURATION/1000)+1)*MAX_FRAMES_PER_SEC) 38 33 /* Division helper */ 34 #define DIV_ROUND_UP(a,b) (((a) + ((b) - 1)) / (b)) 35 #define DIV_ROUND(a,b) (((a) + ((b)/2 - 1)) / (b)) 39 36 40 37 struct stream_data … … 43 40 pj_uint32_t last_timestamp; 44 41 pj_timestamp last_called; 45 unsigned counter; 46 unsigned min_delay; 47 unsigned max_delay; 48 unsigned delay[MAX_DELAY_COUNTER]; 42 pj_math_stat delay; 49 43 }; 50 44 … … 52 46 { 53 47 pj_pool_t *pool; 54 const pjmedia_aud_param 48 const pjmedia_aud_param *param; 55 49 pjmedia_aud_test_results *result; 56 50 pj_bool_t running; … … 80 74 81 75 if (strm_data->last_called.u64 == 0) { 76 /* Init vars. */ 82 77 pj_get_timestamp(&strm_data->last_called); 83 /* Init min_delay to one frame */ 84 strm_data->min_delay = test_data->param->samples_per_frame * 1000000 / 85 test_data->param->clock_rate; 78 pj_math_stat_init(&strm_data->delay); 86 79 strm_data->first_timestamp = frame->timestamp.u32.lo; 87 88 } else if (strm_data->counter <= MAX_DELAY_COUNTER) { 80 } else { 89 81 pj_timestamp now; 90 82 unsigned delay; 91 83 84 /* Calculate frame interval */ 92 85 pj_get_timestamp(&now); 93 94 /* Calculate frame interval */95 86 delay = pj_elapsed_usec(&strm_data->last_called, &now); 96 if (delay < strm_data->min_delay)97 strm_data->min_delay = delay;98 if (delay > strm_data->max_delay)99 strm_data->max_delay = delay;100 101 87 strm_data->last_called = now; 102 88 103 /* Save the frame interval for later calculation */ 104 strm_data->delay[strm_data->counter] = delay; 105 ++strm_data->counter; 106 107 } else { 108 109 /* No space, can't take anymore frames */ 110 test_data->running = 0; 111 89 /* Update frame interval statistic */ 90 pj_math_stat_update(&strm_data->delay, delay); 112 91 } 113 92 … … 136 115 137 116 if (strm_data->last_called.u64 == 0) { 117 /* Init vars. */ 138 118 pj_get_timestamp(&strm_data->last_called); 139 /* Init min_delay to one frame */ 140 strm_data->min_delay = test_data->param->samples_per_frame * 1000000 / 141 test_data->param->clock_rate; 119 pj_math_stat_init(&strm_data->delay); 142 120 strm_data->first_timestamp = frame->timestamp.u32.lo; 143 144 } else if (strm_data->counter <= MAX_DELAY_COUNTER) { 121 } else { 145 122 pj_timestamp now; 146 123 unsigned delay; 147 124 125 /* Calculate frame interval */ 148 126 pj_get_timestamp(&now); 149 150 /* Calculate frame interval */151 127 delay = pj_elapsed_usec(&strm_data->last_called, &now); 152 if (delay < strm_data->min_delay)153 strm_data->min_delay = delay;154 if (delay > strm_data->max_delay)155 strm_data->max_delay = delay;156 157 128 strm_data->last_called = now; 158 129 159 /* Save the frame interval for later calculation */ 160 strm_data->delay[strm_data->counter] = delay; 161 ++strm_data->counter; 162 163 } else { 164 165 /* No space, can't take anymore frames */ 166 test_data->running = 0; 167 130 /* Update frame interval statistic */ 131 pj_math_stat_update(&strm_data->delay, delay); 168 132 } 169 133 … … 188 152 pjmedia_aud_stream *strm; 189 153 struct test_data test_data; 154 unsigned ptime, tmp; 190 155 191 156 /* … … 256 221 * Gather results 257 222 */ 258 result->rec.frame_cnt = test_data.capture_data.counter; 259 result->rec.min_interval = test_data.capture_data.min_delay / 1000; 260 result->rec.max_interval = test_data.capture_data.max_delay / 1000; 261 result->rec.max_burst = test_data.capture_data.max_delay / 1000 / 262 (param->samples_per_frame * 1000 / param->clock_rate); 263 264 result->play.frame_cnt = test_data.playback_data.counter; 265 result->play.min_interval = test_data.playback_data.min_delay / 1000; 266 result->play.max_interval = test_data.playback_data.max_delay / 1000; 267 result->play.max_burst = test_data.playback_data.max_delay / 1000 / 268 (param->samples_per_frame * 1000 / param->clock_rate); 223 ptime = param->samples_per_frame * 1000 / param->clock_rate; 224 225 tmp = pj_math_stat_get_stddev(&test_data.capture_data.delay); 226 result->rec.frame_cnt = test_data.capture_data.delay.n; 227 result->rec.min_interval = DIV_ROUND(test_data.capture_data.delay.min, 1000); 228 result->rec.max_interval = DIV_ROUND(test_data.capture_data.delay.max, 1000); 229 result->rec.avg_interval = DIV_ROUND(test_data.capture_data.delay.mean, 1000); 230 result->rec.dev_interval = DIV_ROUND(tmp, 1000); 231 result->rec.max_burst = DIV_ROUND_UP(result->rec.max_interval, ptime); 232 233 tmp = pj_math_stat_get_stddev(&test_data.playback_data.delay); 234 result->play.frame_cnt = test_data.playback_data.delay.n; 235 result->play.min_interval = DIV_ROUND(test_data.playback_data.delay.min, 1000); 236 result->play.max_interval = DIV_ROUND(test_data.playback_data.delay.max, 1000); 237 result->play.avg_interval = DIV_ROUND(test_data.capture_data.delay.mean, 1000); 238 result->play.dev_interval = DIV_ROUND(tmp, 1000); 239 result->play.max_burst = DIV_ROUND_UP(result->play.max_interval, ptime); 269 240 270 241 /* Check drifting */ -
pjproject/branches/projects/aps-direct/pjsip-apps/src/samples/auddemo.c
r2468 r2503 193 193 PJ_LOG(1,(THIS_FILE, "Error: no frames captured!")); 194 194 } else { 195 PJ_LOG(3,(THIS_FILE, " %-20s: max interval=%u, burst=%u",195 PJ_LOG(3,(THIS_FILE, " %-20s: interval (min/max/avg/dev)=%u/%u/%u/%u, burst=%u", 196 196 "Recording result", 197 result.rec.min_interval, 197 198 result.rec.max_interval, 199 result.rec.avg_interval, 200 result.rec.dev_interval, 198 201 result.rec.max_burst)); 199 202 } … … 204 207 PJ_LOG(1,(THIS_FILE, "Error: no playback!")); 205 208 } else { 206 PJ_LOG(3,(THIS_FILE, " %-20s: max interval=%u, burst=%u",209 PJ_LOG(3,(THIS_FILE, " %-20s: interval (min/max/avg/dev)=%u/%u/%u/%u, burst=%u", 207 210 "Playback result", 211 result.play.min_interval, 208 212 result.play.max_interval, 213 result.play.avg_interval, 214 result.play.dev_interval, 209 215 result.play.max_burst)); 210 216 } … … 212 218 213 219 if (dir==PJMEDIA_DIR_CAPTURE_PLAYBACK) { 214 if (result.rec_drift_per_sec ) {220 if (result.rec_drift_per_sec == 0) { 215 221 PJ_LOG(3,(THIS_FILE, " No clock drift detected")); 216 222 } else {
Note: See TracChangeset
for help on using the changeset viewer.