@@ -306,46 +306,12 @@ func (g *ICEGatherer) collectStats(collector *statsReportCollector) {
306
306
for _ , candidatePairStats := range agent .GetCandidatePairsStats () {
307
307
collector .Collecting ()
308
308
309
- state , err := toStatsICECandidatePairState (candidatePairStats . State )
309
+ stats , err := toICECandidatePairStats (candidatePairStats )
310
310
if err != nil {
311
311
g .log .Error (err .Error ())
312
+ continue
312
313
}
313
314
314
- pairID := newICECandidatePairStatsID (candidatePairStats .LocalCandidateID ,
315
- candidatePairStats .RemoteCandidateID )
316
-
317
- stats := ICECandidatePairStats {
318
- Timestamp : statsTimestampFrom (candidatePairStats .Timestamp ),
319
- Type : StatsTypeCandidatePair ,
320
- ID : pairID ,
321
- // TransportID:
322
- LocalCandidateID : candidatePairStats .LocalCandidateID ,
323
- RemoteCandidateID : candidatePairStats .RemoteCandidateID ,
324
- State : state ,
325
- Nominated : candidatePairStats .Nominated ,
326
- PacketsSent : candidatePairStats .PacketsSent ,
327
- PacketsReceived : candidatePairStats .PacketsReceived ,
328
- BytesSent : candidatePairStats .BytesSent ,
329
- BytesReceived : candidatePairStats .BytesReceived ,
330
- LastPacketSentTimestamp : statsTimestampFrom (candidatePairStats .LastPacketSentTimestamp ),
331
- LastPacketReceivedTimestamp : statsTimestampFrom (candidatePairStats .LastPacketReceivedTimestamp ),
332
- FirstRequestTimestamp : statsTimestampFrom (candidatePairStats .FirstRequestTimestamp ),
333
- LastRequestTimestamp : statsTimestampFrom (candidatePairStats .LastRequestTimestamp ),
334
- LastResponseTimestamp : statsTimestampFrom (candidatePairStats .LastResponseTimestamp ),
335
- TotalRoundTripTime : candidatePairStats .TotalRoundTripTime ,
336
- CurrentRoundTripTime : candidatePairStats .CurrentRoundTripTime ,
337
- AvailableOutgoingBitrate : candidatePairStats .AvailableOutgoingBitrate ,
338
- AvailableIncomingBitrate : candidatePairStats .AvailableIncomingBitrate ,
339
- CircuitBreakerTriggerCount : candidatePairStats .CircuitBreakerTriggerCount ,
340
- RequestsReceived : candidatePairStats .RequestsReceived ,
341
- RequestsSent : candidatePairStats .RequestsSent ,
342
- ResponsesReceived : candidatePairStats .ResponsesReceived ,
343
- ResponsesSent : candidatePairStats .ResponsesSent ,
344
- RetransmissionsReceived : candidatePairStats .RetransmissionsReceived ,
345
- RetransmissionsSent : candidatePairStats .RetransmissionsSent ,
346
- ConsentRequestsSent : candidatePairStats .ConsentRequestsSent ,
347
- ConsentExpiredTimestamp : statsTimestampFrom (candidatePairStats .ConsentExpiredTimestamp ),
348
- }
349
315
collector .Collect (stats .ID , stats )
350
316
}
351
317
@@ -407,3 +373,23 @@ func (g *ICEGatherer) collectStats(collector *statsReportCollector) {
407
373
collector .Done ()
408
374
}(collector , agent )
409
375
}
376
+
377
+ func (g * ICEGatherer ) getSelectedCandidatePairStats () (ICECandidatePairStats , bool ) {
378
+ agent := g .getAgent ()
379
+ if agent == nil {
380
+ return ICECandidatePairStats {}, false
381
+ }
382
+
383
+ selectedCandidatePairStats , isAvailable := agent .GetSelectedCandidatePairStats ()
384
+ if ! isAvailable {
385
+ return ICECandidatePairStats {}, false
386
+ }
387
+
388
+ stats , err := toICECandidatePairStats (selectedCandidatePairStats )
389
+ if err != nil {
390
+ g .log .Error (err .Error ())
391
+ return ICECandidatePairStats {}, false
392
+ }
393
+
394
+ return stats , true
395
+ }
0 commit comments