Repository: pion/webrtc
Pull request #2510 (2023-07-10 19:47:50)

Add IceTransport.GetLocalParameters
Defined in w3c-peerconnection[0]

[0] https://www.w3.org/TR/webrtc/#dom-rtcicetransport-getlocalparameters


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pion/webrtc/pull/2510?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) Report
Patch coverage: **`40.00`**% and project coverage change: **`-0.07`** :warning:
> Comparison is base [(`53d8f74`)](https://app.codecov.io/gh/pion/webrtc/commit/53d8f7405cc1e9b703ebc51160987ee6a6cf436c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) 77.65% compared to head [(`f781e48`)](https://app.codecov.io/gh/pion/webrtc/pull/2510?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) 77.58%.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #2510      +/-   ##
==========================================
- Coverage   77.65%   77.58%   -0.07%     
==========================================
  Files          87       87              
  Lines        9343     9348       +5     
==========================================
- Hits         7255     7253       -2     
- Misses       1659     1663       +4     
- Partials      429      432       +3     
```

| Flag | Coverage Δ | |
|---|---|---|
| go | `79.35% <40.00%> (-0.08%)` | :arrow_down: |
| wasm | `70.15% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://app.codecov.io/gh/pion/webrtc/pull/2510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | Coverage Δ | |
|---|---|---|
| [icetransport.go](https://app.codecov.io/gh/pion/webrtc/pull/2510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#diff-aWNldHJhbnNwb3J0Lmdv) | `69.04% <40.00%> (-0.59%)` | :arrow_down: |

... and [3 files with indirect coverage changes](https://app.codecov.io/gh/pion/webrtc/pull/2510/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion)


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pion/webrtc/pull/2510?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion).


Patch:
diff --git a/icetransport.go b/icetransport.go
index f3b6925c..469aafbd 100644
--- a/icetransport.go
+++ b/icetransport.go
@@ -303,6 +303,16 @@ func (t *ICETransport) State() ICETransportState {
 	return ICETransportState(0)
 }
 
+// GetLocalParameters returns an IceParameters object which provides information
+// uniquely identifying the local peer for the duration of the ICE session.
+func (t *ICETransport) GetLocalParameters() (ICEParameters, error) {
+	if err := t.ensureGatherer(); err != nil {
+		return ICEParameters{}, err
+	}
+
+	return t.gatherer.GetLocalParameters()
+}
+
 func (t *ICETransport) setState(i ICETransportState) {
 	t.state.Store(i)
 }


Test patch:
diff --git a/icetransport_test.go b/icetransport_test.go
index e01f834f..55867d39 100644
--- a/icetransport_test.go
+++ b/icetransport_test.go
@@ -116,3 +116,20 @@ func TestICETransport_GetSelectedCandidatePair(t *testing.T) {
 
 	closePairNow(t, offerer, answerer)
 }
+
+func TestICETransport_GetLocalParameters(t *testing.T) {
+	offerer, answerer, err := newPair()
+	assert.NoError(t, err)
+
+	peerConnectionConnected := untilConnectionState(PeerConnectionStateConnected, offerer, answerer)
+
+	assert.NoError(t, signalPair(offerer, answerer))
+	peerConnectionConnected.Wait()
+
+	localParameters, err := offerer.SCTP().Transport().ICETransport().GetLocalParameters()
+	assert.NoError(t, err)
+	assert.NotEqual(t, localParameters.UsernameFragment, "")
+	assert.NotEqual(t, localParameters.Password, "")
+
+	closePairNow(t, offerer, answerer)
+}