[gst-devel] rtpsource stats: bitrate

Tristan Matthews tristan at sat.qc.ca
Fri Feb 26 17:15:00 CET 2010


Hi,

Currently, in gst-plugins-good/gst/rtpmanager/rtpsource.c, bitrate is
estimated on the sender side. Would it be possible to estimate this on the
receiver side? It would be delta "octets-received" over a given running
time. I've tried to do it in my application but I have a health discrepancy
between my estimation and that on the sender side (about 90000 bits less in
mine). I get the stats every two seconds with the "get-internal-session"
signal. Here's my code, which parses a source's rtp stats and tries to
estimate the bitrate:

    const GValue *val = gst_structure_get_value(stats, "internal");
>     if (g_value_get_boolean(val))   // is-internal
>         return;
>

>
    GTimeVal currentTime;
>     g_get_current_time (&currentTime);
>     static GTimeVal previousTime = currentTime;
>     guint64 elapsed = currentTime.tv_sec - previousTime.tv_sec;
>
>     if (elapsed > 0)
>     {
>         // in case we're not getting this in our receiver reports for a
> while (i.e. sender died)
>         if (G_VALUE_HOLDS_UINT64(gst_structure_get_value(stats,
> "octets-received")))
>         {
>             guint octets =
> g_value_get_uint64(gst_structure_get_value(stats, "octets-received"));
>             static guint previousOctets = octets;
>             guint diffOctets = octets - previousOctets;
>             //LOG_INFO("Diff octets " << diffOctets);
>
>             enum {BITS_PER_BYTE = 8};
>             guint64 bitrate = BITS_PER_BYTE * (diffOctets / elapsed);
>
>             LOG_INFO(sessionName_ << ":BITRATE:" << bitrate);
>             previousOctets = octets;
>         }
>     }
>     previousTime = currentTime;
>

One difference I noticed is that in the rtpsource.c code, the clocktime is
determined from the running time passed to the function, not with
g_get_current_time. Should i be calculating the time from my pipeline
instead? Any other tips?

-- 
Tristan Matthews
email: tristan at sat.qc.ca
web: http://tristanswork.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20100226/e2db62f4/attachment.htm>


More information about the gstreamer-devel mailing list