| 194 | } |
| 195 | |
| 196 | void MacroConditionStats::OutputInfo::Update(obs_output_t *output) |
| 197 | { |
| 198 | uint64_t totalBytes = output ? obs_output_get_total_bytes(output) : 0; |
| 199 | uint64_t curTime = os_gettime_ns(); |
| 200 | uint64_t bytesSent = totalBytes; |
| 201 | |
| 202 | if (bytesSent < lastBytesSent) |
| 203 | bytesSent = 0; |
| 204 | if (bytesSent == 0) |
| 205 | lastBytesSent = 0; |
| 206 | |
| 207 | uint64_t bitsBetween = (bytesSent - lastBytesSent) * 8; |
| 208 | long double timePassed = |
| 209 | (long double)(curTime - lastBytesSentTime) / 1000000000.0l; |
| 210 | kbps = (long double)bitsBetween / timePassed / 1000.0l; |
| 211 | |
| 212 | if (timePassed < 0.01l) |
| 213 | kbps = 0.0l; |
| 214 | |
| 215 | int total = output ? obs_output_get_total_frames(output) : 0; |
| 216 | int dropped = output ? obs_output_get_frames_dropped(output) : 0; |
| 217 | |
| 218 | if (total < first_total || dropped < first_dropped) { |
| 219 | first_total = 0; |
| 220 | first_dropped = 0; |
| 221 | } |
| 222 | |
| 223 | total -= first_total; |
| 224 | dropped -= first_dropped; |
| 225 | |
| 226 | dropped_relative = |
| 227 | total ? (long double)dropped / (long double)total * 100.0l |
| 228 | : 0.0l; |
| 229 | |
| 230 | lastBytesSent = bytesSent; |
| 231 | lastBytesSentTime = curTime; |
| 232 | } |
| 233 | |
| 234 | bool MacroConditionStats::CheckStreamDroppedFrames() |
| 235 | { |
no outgoing calls
no test coverage detected