int qos_start() { if(env == NULL) return -1; if(n_qrec <= 0) return 0; gettimeofday(&qos_tv, NULL); qos_schedule(); return 0; }
void qos_start(void){ // qos_port_init() do below: // 1. init hardware. // 2. enable timer tick isr. if( !qos_port_init() ){ qos_verify( false ); return; } for(;;){ qos_schedule(); } }
static void qos_report(void *clientData) { int i; struct timeval now; long long elapsed; // gettimeofday(&now, NULL); elapsed = tvdiff_us(&now, &qos_tv); for(i = 0; i < n_qrec; i++) { RTPReceptionStatsDB::Iterator statsIter(qrec[i].rtpsrc->receptionStatsDB()); // Assume that there's only one SSRC source (usually the case): RTPReceptionStats* stats = statsIter.next(True); unsigned pkts_expected, dExp; unsigned pkts_received, dRcvd; double KB_received, dKB; // if(stats == NULL) continue; pkts_expected = stats->totNumPacketsExpected(); pkts_received = stats->totNumPacketsReceived(); KB_received = stats->totNumKBytesReceived(); // delta ... dExp = pkts_expected - qrec[i].pkts_expected; dRcvd = pkts_received - qrec[i].pkts_received; dKB = KB_received - qrec[i].KB_received; // show info ga_error("%s-report: %.0fKB rcvd; pkt-loss=%d/%d,%.2f%%; bitrate=%.0fKbps; jitter=%u (freq=%uHz)\n", //now.tv_sec, now.tv_usec, qrec[i].prefix, dKB, dExp-dRcvd, dExp, 100.0*(dExp-dRcvd)/dExp, 8000000.0*dKB/elapsed, stats->jitter(), qrec[i].rtpsrc->timestampFrequency()); // qrec[i].pkts_expected = pkts_expected; qrec[i].pkts_received = pkts_received; qrec[i].KB_received = KB_received; } // schedule next qos qos_tv = now; qos_schedule(); return; }