void* RTPSessionInterface::PacketLossPercent(QTSSDictionary* inSession, UInt32* outLen) { RTPSessionInterface* theSession = (RTPSessionInterface*)inSession; RTPStream* theStream = NULL; UInt32 theLen = sizeof(theStream); SInt64 packetsLost = 0; SInt64 packetsSent = 0; for (int x = 0; theSession->GetValue(qtssCliSesStreamObjects, x, (void*)&theStream, &theLen) == QTSS_NoErr; x++) { if (theStream != NULL) { UInt32 streamCurPacketsLost = 0; theLen = sizeof(UInt32); (void)theStream->GetValue(qtssRTPStrCurPacketsLostInRTCPInterval, 0, &streamCurPacketsLost, &theLen); //qtss_printf("stream = %d streamCurPacketsLost = %" _U32BITARG_ " \n",x, streamCurPacketsLost); UInt32 streamCurPackets = 0; theLen = sizeof(UInt32); (void)theStream->GetValue(qtssRTPStrPacketCountInRTCPInterval, 0, &streamCurPackets, &theLen); //qtss_printf("stream = %d streamCurPackets = %" _U32BITARG_ " \n",x, streamCurPackets); packetsSent += (SInt64)streamCurPackets; packetsLost += (SInt64)streamCurPacketsLost; //qtss_printf("stream calculated loss = %f \n",x, (Float32) streamCurPacketsLost / (Float32) streamCurPackets); } theStream = NULL; theLen = sizeof(UInt32); } //Assert(packetsLost <= packetsSent); if (packetsSent > 0) { if (packetsLost <= packetsSent) theSession->fPacketLossPercent = (Float32)((((Float32)packetsLost / (Float32)packetsSent) * 100.0)); else theSession->fPacketLossPercent = 100.0; } else theSession->fPacketLossPercent = 0.0; //qtss_printf("Session loss percent packetsLost = %qd packetsSent= %qd theSession->fPacketLossPercent=%f\n",packetsLost,packetsSent,theSession->fPacketLossPercent); // Return the result *outLen = sizeof(theSession->fPacketLossPercent); return &theSession->fPacketLossPercent; }