mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Replace interface{} with any
This commit is contained in:
@@ -48,7 +48,7 @@ func (d *DataChannel) OnOpen(f func()) {
|
||||
oldHandler := d.onOpenHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onOpenHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onOpenHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -63,7 +63,7 @@ func (d *DataChannel) OnClose(f func()) {
|
||||
oldHandler := d.onCloseHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onCloseHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onCloseHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -78,7 +78,7 @@ func (d *DataChannel) OnClosing(f func()) {
|
||||
oldHandler := d.onClosingHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onClosingHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onClosingHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -91,7 +91,7 @@ func (d *DataChannel) OnError(f func(err error)) {
|
||||
oldHandler := d.onErrorHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onErrorHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onErrorHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
event := args[0]
|
||||
errorObj := event.Get("error")
|
||||
// FYI RTCError has some extra properties, e.g. `errorDetail`:
|
||||
@@ -111,7 +111,7 @@ func (d *DataChannel) OnMessage(f func(msg DataChannelMessage)) {
|
||||
oldHandler := d.onMessageHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onMessageHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onMessageHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
// pion/webrtc/projects/15
|
||||
data := args[0].Get("data")
|
||||
go func() {
|
||||
@@ -300,7 +300,7 @@ func (d *DataChannel) OnBufferedAmountLow(f func()) {
|
||||
oldHandler := d.onBufferedAmountLow
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onBufferedAmountLow := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onBufferedAmountLow := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -336,7 +336,7 @@ func valueToDataChannelMessage(val js.Value) DataChannelMessage {
|
||||
// channel to signal when reading is done.
|
||||
reader := js.Global().Get("FileReader").New()
|
||||
doneChan := make(chan struct{})
|
||||
reader.Call("addEventListener", "loadend", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
reader.Call("addEventListener", "loadend", js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go func() {
|
||||
// Signal that the FileReader is done reading/loading by sending through
|
||||
// the doneChan.
|
||||
|
@@ -95,7 +95,7 @@ func TestE2E_Audio(t *testing.T) {
|
||||
var result string
|
||||
if err := page.RunScript(
|
||||
"pc.setRemoteDescription(JSON.parse(answer))",
|
||||
map[string]interface{}{"answer": string(answerBytes)},
|
||||
map[string]any{"answer": string(answerBytes)},
|
||||
&result,
|
||||
); err != nil {
|
||||
t.Fatalf("Failed to run script to set SDP: %v", err)
|
||||
@@ -235,7 +235,7 @@ func TestE2E_DataChannel(t *testing.T) {
|
||||
var result string
|
||||
if err := page.RunScript(
|
||||
"pc.setRemoteDescription(JSON.parse(answer))",
|
||||
map[string]interface{}{"answer": string(answerBytes)},
|
||||
map[string]any{"answer": string(answerBytes)},
|
||||
&result,
|
||||
); err != nil {
|
||||
t.Fatalf("Failed to run script to set SDP: %v", err)
|
||||
|
@@ -24,22 +24,22 @@ type customLogger struct{}
|
||||
|
||||
// Print all messages except trace.
|
||||
func (c customLogger) Trace(string) {}
|
||||
func (c customLogger) Tracef(string, ...interface{}) {}
|
||||
func (c customLogger) Tracef(string, ...any) {}
|
||||
|
||||
func (c customLogger) Debug(msg string) { fmt.Printf("customLogger Debug: %s\n", msg) }
|
||||
func (c customLogger) Debugf(format string, args ...interface{}) {
|
||||
func (c customLogger) Debugf(format string, args ...any) {
|
||||
c.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (c customLogger) Info(msg string) { fmt.Printf("customLogger Info: %s\n", msg) }
|
||||
func (c customLogger) Infof(format string, args ...interface{}) {
|
||||
func (c customLogger) Infof(format string, args ...any) {
|
||||
c.Trace(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (c customLogger) Warn(msg string) { fmt.Printf("customLogger Warn: %s\n", msg) }
|
||||
func (c customLogger) Warnf(format string, args ...interface{}) {
|
||||
func (c customLogger) Warnf(format string, args ...any) {
|
||||
c.Warn(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (c customLogger) Error(msg string) { fmt.Printf("customLogger Error: %s\n", msg) }
|
||||
func (c customLogger) Errorf(format string, args ...interface{}) {
|
||||
func (c customLogger) Errorf(format string, args ...any) {
|
||||
c.Error(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ func main() {
|
||||
})
|
||||
|
||||
// Set up global callbacks which will be triggered on button clicks.
|
||||
/*js.Global().Set("sendMessage", js.FuncOf(func(_ js.Value, _ []js.Value) interface{} {
|
||||
/*js.Global().Set("sendMessage", js.FuncOf(func(_ js.Value, _ []js.Value) any {
|
||||
go func() {
|
||||
el := getElementByID("message")
|
||||
message := el.Get("value").String()
|
||||
@@ -121,7 +121,7 @@ func main() {
|
||||
}()
|
||||
return js.Undefined()
|
||||
}))*/
|
||||
js.Global().Set("startSession", js.FuncOf(func(_ js.Value, _ []js.Value) interface{} {
|
||||
js.Global().Set("startSession", js.FuncOf(func(_ js.Value, _ []js.Value) any {
|
||||
go func() {
|
||||
el := getElementByID("remoteSessionDescription")
|
||||
sd := el.Get("value").String()
|
||||
|
@@ -82,7 +82,7 @@ func main() {
|
||||
})
|
||||
|
||||
// Set up global callbacks which will be triggered on button clicks.
|
||||
js.Global().Set("sendMessage", js.FuncOf(func(_ js.Value, _ []js.Value) interface{} {
|
||||
js.Global().Set("sendMessage", js.FuncOf(func(_ js.Value, _ []js.Value) any {
|
||||
go func() {
|
||||
el := getElementByID("message")
|
||||
message := el.Get("value").String()
|
||||
@@ -96,7 +96,7 @@ func main() {
|
||||
}()
|
||||
return js.Undefined()
|
||||
}))
|
||||
js.Global().Set("startSession", js.FuncOf(func(_ js.Value, _ []js.Value) interface{} {
|
||||
js.Global().Set("startSession", js.FuncOf(func(_ js.Value, _ []js.Value) any {
|
||||
go func() {
|
||||
el := getElementByID("remoteSessionDescription")
|
||||
sd := el.Get("value").String()
|
||||
@@ -113,7 +113,7 @@ func main() {
|
||||
}()
|
||||
return js.Undefined()
|
||||
}))
|
||||
js.Global().Set("copySDP", js.FuncOf(func(_ js.Value, _ []js.Value) interface{} {
|
||||
js.Global().Set("copySDP", js.FuncOf(func(_ js.Value, _ []js.Value) any {
|
||||
go func() {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
|
18
iceserver.go
18
iceserver.go
@@ -18,7 +18,7 @@ import (
|
||||
type ICEServer struct {
|
||||
URLs []string `json:"urls"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Credential interface{} `json:"credential,omitempty"`
|
||||
Credential any `json:"credential,omitempty"`
|
||||
CredentialType ICECredentialType `json:"credentialType,omitempty"`
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func (s ICEServer) urls() ([]*stun.URI, error) { //nolint:cyclop
|
||||
return urls, nil
|
||||
}
|
||||
|
||||
func iceserverUnmarshalUrls(val interface{}) (*[]string, error) {
|
||||
s, ok := val.([]interface{})
|
||||
func iceserverUnmarshalUrls(val any) (*[]string, error) {
|
||||
s, ok := val.([]any)
|
||||
if !ok {
|
||||
return nil, errInvalidICEServer
|
||||
}
|
||||
@@ -90,8 +90,8 @@ func iceserverUnmarshalUrls(val interface{}) (*[]string, error) {
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func iceserverUnmarshalOauth(val interface{}) (*OAuthCredential, error) {
|
||||
c, ok := val.(map[string]interface{})
|
||||
func iceserverUnmarshalOauth(val any) (*OAuthCredential, error) {
|
||||
c, ok := val.(map[string]any)
|
||||
if !ok {
|
||||
return nil, errInvalidICEServer
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func iceserverUnmarshalOauth(val interface{}) (*OAuthCredential, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ICEServer) iceserverUnmarshalFields(fields map[string]interface{}) error { //nolint:cyclop
|
||||
func (s *ICEServer) iceserverUnmarshalFields(fields map[string]any) error { //nolint:cyclop
|
||||
if val, ok := fields["urls"]; ok {
|
||||
u, err := iceserverUnmarshalUrls(val)
|
||||
if err != nil {
|
||||
@@ -160,12 +160,12 @@ func (s *ICEServer) iceserverUnmarshalFields(fields map[string]interface{}) erro
|
||||
|
||||
// UnmarshalJSON parses the JSON-encoded data and stores the result.
|
||||
func (s *ICEServer) UnmarshalJSON(b []byte) error {
|
||||
var tmp interface{}
|
||||
var tmp any
|
||||
err := json.Unmarshal(b, &tmp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if m, ok := tmp.(map[string]interface{}); ok {
|
||||
if m, ok := tmp.(map[string]any); ok {
|
||||
return s.iceserverUnmarshalFields(m)
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func (s *ICEServer) UnmarshalJSON(b []byte) error {
|
||||
|
||||
// MarshalJSON returns the JSON encoding.
|
||||
func (s ICEServer) MarshalJSON() ([]byte, error) {
|
||||
m := make(map[string]interface{})
|
||||
m := make(map[string]any)
|
||||
m["urls"] = s.URLs
|
||||
if s.Username != "" {
|
||||
m["username"] = s.Username
|
||||
|
@@ -18,7 +18,7 @@ type ICEServer struct {
|
||||
URLs []string
|
||||
Username string
|
||||
// Note: TURN is not supported in the WASM bindings yet
|
||||
Credential interface{}
|
||||
Credential any
|
||||
CredentialType ICECredentialType
|
||||
}
|
||||
|
||||
|
10
js_utils.go
10
js_utils.go
@@ -19,7 +19,7 @@ func awaitPromise(promise js.Value) (js.Value, error) {
|
||||
resultsChan := make(chan js.Value)
|
||||
errChan := make(chan js.Error)
|
||||
|
||||
thenFunc := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
thenFunc := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go func() {
|
||||
resultsChan <- args[0]
|
||||
}()
|
||||
@@ -27,7 +27,7 @@ func awaitPromise(promise js.Value) (js.Value, error) {
|
||||
})
|
||||
defer thenFunc.Release()
|
||||
|
||||
catchFunc := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
catchFunc := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go func() {
|
||||
errChan <- js.Error{args[0]}
|
||||
}()
|
||||
@@ -75,7 +75,7 @@ func uint8ToValueOrUndefined(val uint8) js.Value {
|
||||
return js.ValueOf(val)
|
||||
}
|
||||
|
||||
func interfaceToValueOrUndefined(val interface{}) js.Value {
|
||||
func interfaceToValueOrUndefined(val any) js.Value {
|
||||
if val == nil {
|
||||
return js.Undefined()
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func boolPointerToValue(val *bool) js.Value {
|
||||
}
|
||||
|
||||
func stringsToValue(strings []string) js.Value {
|
||||
val := make([]interface{}, len(strings))
|
||||
val := make([]any, len(strings))
|
||||
for i, s := range strings {
|
||||
val[i] = s
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func stringEnumToValueOrUndefined(s string) js.Value {
|
||||
}
|
||||
|
||||
// Converts the return value of recover() to an error.
|
||||
func recoveryToError(e interface{}) error {
|
||||
func recoveryToError(e any) error {
|
||||
switch e := e.(type) {
|
||||
case error:
|
||||
return e
|
||||
|
@@ -361,7 +361,7 @@ func TestPeerConnection_ShutdownNoDTLS(t *testing.T) {
|
||||
|
||||
assert.NoError(t, signalPair(offerPC, answerPC))
|
||||
|
||||
iceComplete := make(chan interface{})
|
||||
iceComplete := make(chan any)
|
||||
answerPC.OnICEConnectionStateChange(func(iceState ICEConnectionState) {
|
||||
if iceState == ICEConnectionStateConnected {
|
||||
time.Sleep(time.Second) // Give time for DTLS to start
|
||||
@@ -569,7 +569,7 @@ func TestPeerConnection_IceLite(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, signalPair(offerPC, answerPC))
|
||||
|
||||
dataChannelOpen := make(chan interface{})
|
||||
dataChannelOpen := make(chan any)
|
||||
answerPC.OnDataChannel(func(_ *DataChannel) {
|
||||
close(dataChannelOpen)
|
||||
})
|
||||
@@ -595,7 +595,7 @@ func TestOnICEGatheringStateChange(t *testing.T) {
|
||||
seenGathering := &atomicBool{}
|
||||
seenComplete := &atomicBool{}
|
||||
|
||||
seenGatheringAndComplete := make(chan interface{})
|
||||
seenGatheringAndComplete := make(chan any)
|
||||
|
||||
peerConn, err := NewPeerConnection(Configuration{})
|
||||
assert.NoError(t, err)
|
||||
@@ -1923,15 +1923,15 @@ type testICELogger struct {
|
||||
}
|
||||
|
||||
func (t *testICELogger) Trace(string) {}
|
||||
func (t *testICELogger) Tracef(string, ...interface{}) {}
|
||||
func (t *testICELogger) Tracef(string, ...any) {}
|
||||
func (t *testICELogger) Debug(string) {}
|
||||
func (t *testICELogger) Debugf(string, ...interface{}) {}
|
||||
func (t *testICELogger) Debugf(string, ...any) {}
|
||||
func (t *testICELogger) Info(string) {}
|
||||
func (t *testICELogger) Infof(string, ...interface{}) {}
|
||||
func (t *testICELogger) Infof(string, ...any) {}
|
||||
func (t *testICELogger) Warn(string) {}
|
||||
func (t *testICELogger) Warnf(string, ...interface{}) {}
|
||||
func (t *testICELogger) Warnf(string, ...any) {}
|
||||
func (t *testICELogger) Error(msg string) { t.lastErrorMessage = msg }
|
||||
func (t *testICELogger) Errorf(format string, args ...interface{}) {
|
||||
func (t *testICELogger) Errorf(format string, args ...any) {
|
||||
t.lastErrorMessage = fmt.Sprintf(format, args...)
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState)) {
|
||||
oldHandler := pc.onSignalingStateChangeHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onSignalingStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onSignalingStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
state := newSignalingState(args[0].String())
|
||||
go f(state)
|
||||
return js.Undefined()
|
||||
@@ -87,7 +87,7 @@ func (pc *PeerConnection) OnDataChannel(f func(*DataChannel)) {
|
||||
oldHandler := pc.onDataChannelHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onDataChannelHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onDataChannelHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
// pion/webrtc/projects/15
|
||||
// This reference to the underlying DataChannel doesn't know
|
||||
// about any other references to the same DataChannel. This might result in
|
||||
@@ -112,7 +112,7 @@ func (pc *PeerConnection) OnNegotiationNeeded(f func()) {
|
||||
oldHandler := pc.onNegotiationNeededHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onNegotiationNeededHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onNegotiationNeededHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -127,7 +127,7 @@ func (pc *PeerConnection) OnICEConnectionStateChange(f func(ICEConnectionState))
|
||||
oldHandler := pc.onICEConnectionStateChangeHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onICEConnectionStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onICEConnectionStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
connectionState := NewICEConnectionState(pc.underlying.Get("iceConnectionState").String())
|
||||
go f(connectionState)
|
||||
return js.Undefined()
|
||||
@@ -143,7 +143,7 @@ func (pc *PeerConnection) OnConnectionStateChange(f func(PeerConnectionState)) {
|
||||
oldHandler := pc.onConnectionStateChangeHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onConnectionStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onConnectionStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
connectionState := newPeerConnectionState(pc.underlying.Get("connectionState").String())
|
||||
go f(connectionState)
|
||||
return js.Undefined()
|
||||
@@ -335,7 +335,7 @@ func (pc *PeerConnection) OnICECandidate(f func(candidate *ICECandidate)) {
|
||||
oldHandler := pc.onICECandidateHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onICECandidateHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onICECandidateHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
candidate := valueToICECandidate(args[0].Get("candidate"))
|
||||
if candidate == nil && pc.onGatherCompleteHandler != nil {
|
||||
go pc.onGatherCompleteHandler()
|
||||
@@ -355,7 +355,7 @@ func (pc *PeerConnection) OnICEGatheringStateChange(f func()) {
|
||||
oldHandler := pc.onICEGatheringStateChangeHandler
|
||||
defer oldHandler.Release()
|
||||
}
|
||||
onICEGatheringStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
onICEGatheringStateChangeHandler := js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
go f()
|
||||
return js.Undefined()
|
||||
})
|
||||
@@ -545,7 +545,7 @@ func (pc *PeerConnection) SCTP() *SCTPTransport {
|
||||
// through to the JavaScript WebRTC API. Any zero values are converted to
|
||||
// js.Undefined(), which will result in the default value being used.
|
||||
func configurationToValue(configuration Configuration) js.Value {
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"iceServers": iceServersToValue(configuration.ICEServers),
|
||||
"iceTransportPolicy": stringEnumToValueOrUndefined(configuration.ICETransportPolicy.String()),
|
||||
"bundlePolicy": stringEnumToValueOrUndefined(configuration.BundlePolicy.String()),
|
||||
@@ -562,7 +562,7 @@ func iceServersToValue(iceServers []ICEServer) js.Value {
|
||||
if len(iceServers) == 0 {
|
||||
return js.Undefined()
|
||||
}
|
||||
maps := make([]interface{}, len(iceServers))
|
||||
maps := make([]any, len(iceServers))
|
||||
for i, server := range iceServers {
|
||||
maps[i] = iceServerToValue(server)
|
||||
}
|
||||
@@ -570,7 +570,7 @@ func iceServersToValue(iceServers []ICEServer) js.Value {
|
||||
}
|
||||
|
||||
func oauthCredentialToValue(o OAuthCredential) js.Value {
|
||||
out := map[string]interface{}{
|
||||
out := map[string]any{
|
||||
"MACKey": o.MACKey,
|
||||
"AccessToken": o.AccessToken,
|
||||
}
|
||||
@@ -578,7 +578,7 @@ func oauthCredentialToValue(o OAuthCredential) js.Value {
|
||||
}
|
||||
|
||||
func iceServerToValue(server ICEServer) js.Value {
|
||||
out := map[string]interface{}{
|
||||
out := map[string]any{
|
||||
"urls": stringsToValue(server.URLs), // required
|
||||
}
|
||||
if server.Username != "" {
|
||||
@@ -624,7 +624,7 @@ func valueToICEServers(iceServersValue js.Value) []ICEServer {
|
||||
return iceServers
|
||||
}
|
||||
|
||||
func valueToICECredential(iceCredentialValue js.Value) interface{} {
|
||||
func valueToICECredential(iceCredentialValue js.Value) any {
|
||||
if iceCredentialValue.IsNull() || iceCredentialValue.IsUndefined() {
|
||||
return nil
|
||||
}
|
||||
@@ -704,7 +704,7 @@ func sessionDescriptionToValue(desc *SessionDescription) js.Value {
|
||||
if desc == nil {
|
||||
return js.Undefined()
|
||||
}
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"type": desc.Type.String(),
|
||||
"sdp": desc.SDP,
|
||||
})
|
||||
@@ -724,7 +724,7 @@ func offerOptionsToValue(offerOptions *OfferOptions) js.Value {
|
||||
if offerOptions == nil {
|
||||
return js.Undefined()
|
||||
}
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"iceRestart": offerOptions.ICERestart,
|
||||
"voiceActivityDetection": offerOptions.VoiceActivityDetection,
|
||||
})
|
||||
@@ -734,13 +734,13 @@ func answerOptionsToValue(answerOptions *AnswerOptions) js.Value {
|
||||
if answerOptions == nil {
|
||||
return js.Undefined()
|
||||
}
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"voiceActivityDetection": answerOptions.VoiceActivityDetection,
|
||||
})
|
||||
}
|
||||
|
||||
func iceCandidateInitToValue(candidate ICECandidateInit) js.Value {
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"candidate": candidate.Candidate,
|
||||
"sdpMid": stringPointerToValue(candidate.SDPMid),
|
||||
"sdpMLineIndex": uint16PointerToValue(candidate.SDPMLineIndex),
|
||||
@@ -754,7 +754,7 @@ func dataChannelInitToValue(options *DataChannelInit) js.Value {
|
||||
}
|
||||
|
||||
maxPacketLifeTime := uint16PointerToValue(options.MaxPacketLifeTime)
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"ordered": boolPointerToValue(options.Ordered),
|
||||
"maxPacketLifeTime": maxPacketLifeTime,
|
||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=696681
|
||||
@@ -768,7 +768,7 @@ func dataChannelInitToValue(options *DataChannelInit) js.Value {
|
||||
}
|
||||
|
||||
func rtpTransceiverInitInitToValue(init RTPTransceiverInit) js.Value {
|
||||
return js.ValueOf(map[string]interface{}{
|
||||
return js.ValueOf(map[string]any{
|
||||
"direction": init.Direction.String(),
|
||||
})
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ func TestValueToICECandidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
v := map[string]interface{}{}
|
||||
v := map[string]any{}
|
||||
err := json.Unmarshal([]byte(testCase.jsonCandidate), &v)
|
||||
if err != nil {
|
||||
t.Errorf("Case %d: bad test, got error: %v", i, err)
|
||||
|
@@ -372,15 +372,15 @@ func TestPeerConnection_Media_Disconnected(t *testing.T) { //nolint:cyclop
|
||||
type undeclaredSsrcLogger struct{ unhandledSimulcastError chan struct{} }
|
||||
|
||||
func (u *undeclaredSsrcLogger) Trace(string) {}
|
||||
func (u *undeclaredSsrcLogger) Tracef(string, ...interface{}) {}
|
||||
func (u *undeclaredSsrcLogger) Tracef(string, ...any) {}
|
||||
func (u *undeclaredSsrcLogger) Debug(string) {}
|
||||
func (u *undeclaredSsrcLogger) Debugf(string, ...interface{}) {}
|
||||
func (u *undeclaredSsrcLogger) Debugf(string, ...any) {}
|
||||
func (u *undeclaredSsrcLogger) Info(string) {}
|
||||
func (u *undeclaredSsrcLogger) Infof(string, ...interface{}) {}
|
||||
func (u *undeclaredSsrcLogger) Infof(string, ...any) {}
|
||||
func (u *undeclaredSsrcLogger) Warn(string) {}
|
||||
func (u *undeclaredSsrcLogger) Warnf(string, ...interface{}) {}
|
||||
func (u *undeclaredSsrcLogger) Warnf(string, ...any) {}
|
||||
func (u *undeclaredSsrcLogger) Error(string) {}
|
||||
func (u *undeclaredSsrcLogger) Errorf(format string, _ ...interface{}) {
|
||||
func (u *undeclaredSsrcLogger) Errorf(format string, _ ...any) {
|
||||
if format == incomingUnhandledRTPSsrc {
|
||||
close(u.unhandledSimulcastError)
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ type Sample struct {
|
||||
Duration time.Duration
|
||||
PacketTimestamp uint32
|
||||
PrevDroppedPackets uint16
|
||||
Metadata interface{}
|
||||
Metadata any
|
||||
|
||||
// RTP headers of RTP packets forming this Sample. (Optional)
|
||||
// Useful for accessing RTP extensions associated to the Sample.
|
||||
|
@@ -47,7 +47,7 @@ type SampleBuilder struct {
|
||||
paddingPackets uint16
|
||||
|
||||
// allows inspecting head packets of each sample and then returns a custom metadata
|
||||
packetHeadHandler func(headPacket interface{}) interface{}
|
||||
packetHeadHandler func(headPacket any) any
|
||||
|
||||
// return array of RTP headers as Sample.RTPHeaders
|
||||
returnRTPHeaders bool
|
||||
@@ -289,7 +289,7 @@ func (s *SampleBuilder) buildSample(purgingBuffers bool) *media.Sample {
|
||||
|
||||
// merge all the buffers into a sample
|
||||
data := []byte{}
|
||||
var metadata interface{}
|
||||
var metadata any
|
||||
var rtpHeaders []*rtp.Header
|
||||
for i := consume.head; i != consume.tail; i++ {
|
||||
payload, err := s.depacketizer.Unmarshal(s.buffer[i].Payload)
|
||||
@@ -378,7 +378,7 @@ func WithPacketReleaseHandler(h func(*rtp.Packet)) Option {
|
||||
|
||||
// WithPacketHeadHandler set a head packet handler to allow inspecting
|
||||
// the packet to extract certain information and return as custom metadata.
|
||||
func WithPacketHeadHandler(h func(headPacket interface{}) interface{}) Option {
|
||||
func WithPacketHeadHandler(h func(headPacket any) any) Option {
|
||||
return func(o *SampleBuilder) {
|
||||
o.packetHeadHandler = h
|
||||
}
|
||||
|
@@ -497,7 +497,7 @@ func TestSampleBuilderWithPacketHeadHandler(t *testing.T) {
|
||||
}
|
||||
|
||||
headCount := 0
|
||||
s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(interface{}) interface{} {
|
||||
s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(any) any {
|
||||
headCount++
|
||||
|
||||
return true
|
||||
|
@@ -61,7 +61,7 @@ type RTPReceiver struct {
|
||||
|
||||
tracks []trackStreams
|
||||
|
||||
closed, received chan interface{}
|
||||
closed, received chan any
|
||||
mu sync.RWMutex
|
||||
|
||||
tr *RTPTransceiver
|
||||
@@ -82,10 +82,10 @@ func (api *API) NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) (*RT
|
||||
kind: kind,
|
||||
transport: transport,
|
||||
api: api,
|
||||
closed: make(chan interface{}),
|
||||
received: make(chan interface{}),
|
||||
closed: make(chan any),
|
||||
received: make(chan any),
|
||||
tracks: []trackStreams{},
|
||||
rtxPool: sync.Pool{New: func() interface{} {
|
||||
rtxPool: sync.Pool{New: func() any {
|
||||
return make([]byte, api.settingEngine.getReceiveMTU())
|
||||
}},
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@ func (s *TrackLocalStaticRTP) Codec() RTPCodecCapability {
|
||||
// packetPool is a pool of packets used by WriteRTP and Write below
|
||||
// nolint:gochecknoglobals
|
||||
var rtpPacketPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &rtp.Packet{}
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user