Hi,<br><br>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:<br>
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"> const GValue *val = gst_structure_get_value(stats, "internal");<br> if (g_value_get_boolean(val)) // is-internal<br>
return;<br></blockquote><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><div> </div></blockquote><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
GTimeVal currentTime;<br> g_get_current_time (&currentTime);<br> static GTimeVal previousTime = currentTime;<br> guint64 elapsed = currentTime.tv_sec - previousTime.tv_sec;<br><br> if (elapsed > 0)<br>
{<br> // in case we're not getting this in our receiver reports for a while (i.e. sender died)<br> if (G_VALUE_HOLDS_UINT64(gst_structure_get_value(stats, "octets-received")))<br> {<br>
guint octets = g_value_get_uint64(gst_structure_get_value(stats, "octets-received"));<br> static guint previousOctets = octets;<br> guint diffOctets = octets - previousOctets;<br>
//LOG_INFO("Diff octets " << diffOctets);<br><br> enum {BITS_PER_BYTE = 8};<br> guint64 bitrate = BITS_PER_BYTE * (diffOctets / elapsed);<br><br> LOG_INFO(sessionName_ << ":BITRATE:" << bitrate);<br>
previousOctets = octets;<br> }<br> }<br> previousTime = currentTime;<br></blockquote><br>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?<br>
<br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com">http://tristanswork.blogspot.com</a><br>