[Live-devel] Retrieving stats for ProxyServerMediaSession

Ross Finlayson finlayson at live555.com
Tue Nov 7 10:35:46 PST 2023



> On Nov 7, 2023, at 2:57 AM, Andy Hawkins <Andy.Hawkins at uniguest.com> wrote:
> 
> Ok, I'm now successfully iterating over the ClientConnections and ClientSessions, how can I get the amount of data transmitted to each of these?

First, you don’t do anything with the “RTSPClientConnection” objects; those represent only the TCP connections that clients use to send RTSP commands.  What you need are the “RTSPClientSession” objects.

If you haven’t already done so, you will need to subclass “RTSPClientSession”, then, in a member function of your subclass (because this code accesses ‘protected’ member variables), do:
	for (unsigned i = 0; i < fNumStreamStates; ++i) {
		RTPSink const* rtpSink;
		RTCPInstance const* rtcpInstance; // not used

		getRTPSinkandRTCP(fStreamStates[i].streamToken, rtpSink, rtcpInstance);
		if (rtpSink != NULL) {
			// There are several functions you can call on “rtpSink” to get data transmission stats:
			//	packetCount(): the total number of RTP packets sent
			//	octetCount(): the total number of ‘payload’ bytes sent - i.e., not including RTP headers
			// Note that these two functions return 32-bit integers, so they will often wrap around

			// You can also call:
			//	getTotalBitrate() (see “liveMedia/include/RTPSink.hh”), which returns the total amount of data that was sent (including RTP
			//		headers, but not IP and UDP headers) since the last time that function was called.  (This also returns the time that has
			//		elapsed since then, so you can divide the count by the time to get a bitrate in bytes-per-second.)
		}
	}


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list