Repository: pion/webrtc (go)

Issue:
 examples/bandwidth-estimation-from-disk currentTimestamp not updated correctly
In the `examples/bandwidth-estimation-from-disk/main.go` file, the `currentTimestamp` variable is intended to track the current video frame's timestamp to ensure correct playback when switching video quality levels. However, `currentTimestamp` is not being updated correctly and remains at its initial value.

Update currentTimestamp after each video frame is read and sent. Here is the code snippet:

```
    // ... 
for ; true; <-ticker.C {
    targetBitrate := estimator.GetTargetBitrate()
    switch {

    // ... 

    default:
        frame, frameHeader, err = ivf.ParseNextFrame() // modify this section
    }

    switch {
    // If we have reached the end of the file, start again
    case errors.Is(err, io.EOF):
        ivf.ResetReader(setReaderFile(qualityLevels[currentQuality].fileName))

    // No error, write the video frame
    case err == nil:
        currentTimestamp = frameHeader.Timestamp // Update currentTimestamp
        if err = videoTrack.WriteSample(media.Sample{Data: frame, Duration: time.Second}); err != nil {
            panic(err)
        }
    // Handle other unknown errors
    default:
        panic(err)
    }
}
```

Pull request:
fix examples/bandwidth-estimation-from-disk
#### Description

#### Reference issue
Fixes #2896


Patch:
diff --git a/examples/bandwidth-estimation-from-disk/main.go b/examples/bandwidth-estimation-from-disk/main.go
index e1a12baf..39aa35bc 100644
--- a/examples/bandwidth-estimation-from-disk/main.go
+++ b/examples/bandwidth-estimation-from-disk/main.go
@@ -225,7 +225,7 @@ func main() {
 
 		// Adjust outbound bandwidth for probing
 		default:
-			frame, _, err = ivf.ParseNextFrame()
+			frame, frameHeader, err = ivf.ParseNextFrame()
 		}
 
 		switch {
diff --git a/stats.go b/stats.go
index 7e435044..7221fbcb 100644
--- a/stats.go
+++ b/stats.go
@@ -567,6 +567,9 @@ type InboundRTPStreamStats struct {
 	// these numbers are not expected to match the numbers seen on sending. Not all
 	// OSes make this information available.
 	PerDSCPPacketsReceived map[string]uint32 `json:"perDscpPacketsReceived"`
+
+	// Identifies the decoder implementation used. This is useful for diagnosing interoperability issues.
+	DecoderImplementation string `json:"decoderImplementation"`
 }
 
 func (s InboundRTPStreamStats) statsMarker() {}
@@ -806,6 +809,9 @@ type OutboundRTPStreamStats struct {
 	// Active indicates whether this RTP stream is configured to be sent or disabled. Note that an
 	// active stream can still not be sending, e.g. when being limited by network conditions.
 	Active bool `json:"active"`
+
+	// Identifies the encoder implementation used. This is useful for diagnosing interoperability issues.
+	EncoderImplementation string `json:"encoderImplementation"`
 }
 
 func (s OutboundRTPStreamStats) statsMarker() {}


Test patch:
diff --git a/stats_go_test.go b/stats_go_test.go
index 9ebbce30..0d26958d 100644
--- a/stats_go_test.go
+++ b/stats_go_test.go
@@ -144,6 +144,7 @@ func getStatsSamples() []statSample {
 		PerDSCPPacketsReceived: map[string]uint32{
 			"123": 23,
 		},
+		DecoderImplementation: "libvpx",
 	}
 	inboundRTPStreamStatsJSON := `
 {
@@ -210,7 +211,8 @@ func getStatsSamples() []statSample {
   "packetsDuplicated": 22,
   "perDscpPacketsReceived": {
     "123": 23
-  }
+  },
+  "decoderImplementation": "libvpx"
 }
 `
 	outboundRTPStreamStats := OutboundRTPStreamStats{
@@ -264,7 +266,8 @@ func getStatsSamples() []statSample {
 		PerDSCPPacketsSent: map[string]uint32{
 			"123": 23,
 		},
-		Active: true,
+		Active:                true,
+		EncoderImplementation: "libvpx",
 	}
 	outboundRTPStreamStatsJSON := `
 {
@@ -318,7 +321,8 @@ func getStatsSamples() []statSample {
   "perDscpPacketsSent": {
     "123": 23
   },
-  "active": true
+  "active": true,
+  "encoderImplementation": "libvpx"
 }
 `
 	remoteInboundRTPStreamStats := RemoteInboundRTPStreamStats{