Exemple #1
0
static void
dump_1mem(struct prog_arg *a, double time_delta, long long cycle_delta)
{
    dump_throughput(a, time_delta, 1);
}
Exemple #2
0
static int stream_stats_dump(char *buf, unsigned int szbuf, STREAM_STATS_T *pStats, int urlidx) {
    int rc;
    uint32_t durationms;
    float fracLost, f;
    unsigned int idxbuf = 0;
    STREAM_RTP_INIT_T *pRtpInit;
    char buftmp[2048];

    if(pStats->tvstart.tv_sec > 0) {
        durationms = TIME_TV_DIFF_MS(pStats->tv_last, pStats->tvstart);
    } else {
        durationms = 0;
    }

    printDuration(buftmp, sizeof(buftmp), durationms);

    if((urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "&method%d=%s&duration%d=%s&host%d=%s:%d",
                                 urlidx, devtype_methodstr(pStats->method), urlidx, buftmp, urlidx,
                                 inet_ntoa(pStats->saRemote.sin_addr), htons(pStats->saRemote.sin_port))) > 0) ||
            (!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "%7s %s -> %15s:%d",
                                       devtype_methodstr(pStats->method), buftmp,
                                       inet_ntoa(pStats->saRemote.sin_addr), htons(pStats->saRemote.sin_port))) > 0)) {
        idxbuf += rc;
    }

    if(pStats->pRtpDest && pStats->pRtpDest->pRtpMulti) {
        pRtpInit = &pStats->pRtpDest->pRtpMulti->init;
        if((urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "&pt%d=%d", urlidx, pRtpInit->pt)) > 0) ||
                (!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, " pt:%3d", pRtpInit->pt)) > 0)) {
            idxbuf += rc;
        }
    }

    if((rc = snprintf(&buf[idxbuf], szbuf - idxbuf,
                      "%s", dump_throughput(buftmp, sizeof(buftmp), "", &pStats->throughput_last[0], urlidx))) > 0) {
        idxbuf += rc;
    }

    if(pStats->numWr > 1 && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf,
                                           "%s", dump_throughput(buftmp, sizeof(buftmp), "rtcp ", &pStats->throughput_last[1], urlidx))) > 0) {
        idxbuf += rc;
    }

    if(pStats->ctr_last.ctr_rrRcvd > 0) {
        //fprintf(fp, " ctr_last.ctr_rrRcvd:%d", pStats->ctr_last.ctr_rrRcvd);
        if(pStats->ctr_last.ctr_rrdelaySamples > 0) {
            f = (float) pStats->ctr_last.ctr_rrdelayMsTot / pStats->ctr_last.ctr_rrdelaySamples;

            if((urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "&rtdelay%d=%.1f", urlidx, f)) > 0) ||
                    (!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, ", rtdelay: %.1f", f)) > 0)) {
                idxbuf += rc;
            }
        }

        if(pStats->ctr_last.ctr_fracLostSamples > 0) {
            fracLost = pStats->ctr_last.ctr_fracLostTot / pStats->ctr_last.ctr_fracLostSamples;

            if((urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "&fraclost%d=%.2f", urlidx, fracLost)) > 0) ||
                    (!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, ", frac-lost: %.2f%%", fracLost)) > 0)) {
                idxbuf += rc;
            }
        }

        if(pStats->ctr_last.cumulativeSeqNum > 0) {
            fracLost = (float) 100.0f * pStats->ctr_last.cumulativeLostPrev / pStats->ctr_last.cumulativeSeqNum;
        } else {
            fracLost = 0;
        }

        if((urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "&cml-lost%d=%d&cml-pkts%d=%u&tot-lost%d=%u&tot%d=%u&fractotlost%d=%.2f",
                                     urlidx, pStats->ctr_last.ctr_cumulativeLost,
                                     urlidx, pStats->ctr_last.ctr_countseqRr,
                                     urlidx, pStats->ctr_last.cumulativeLostPrev,
                                     urlidx, pStats->ctr_last.cumulativeSeqNum,
                                     urlidx, fracLost)) > 0) ||

                (!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf,
                                           ", cml-lost: %d/%d (all:%d/%d, %.2f%%)", pStats->ctr_last.ctr_cumulativeLost,
                                           pStats->ctr_last.ctr_countseqRr, pStats->ctr_last.cumulativeLostPrev, pStats->ctr_last.cumulativeSeqNum, fracLost)) > 0)) {

            idxbuf += rc;
        }
    }

    if(!urlidx && (rc = snprintf(&buf[idxbuf], szbuf - idxbuf, "\n")) > 0) {
        idxbuf += rc;
    }

    return (int) idxbuf;
}