github.com/pion/webrtc/v3@v3.2.24/api_js.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  //go:build js && wasm
     5  // +build js,wasm
     6  
     7  package webrtc
     8  
     9  // API bundles the global funcions of the WebRTC and ORTC API.
    10  type API struct {
    11  	settingEngine *SettingEngine
    12  }
    13  
    14  // NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
    15  func NewAPI(options ...func(*API)) *API {
    16  	a := &API{}
    17  
    18  	for _, o := range options {
    19  		o(a)
    20  	}
    21  
    22  	if a.settingEngine == nil {
    23  		a.settingEngine = &SettingEngine{}
    24  	}
    25  
    26  	return a
    27  }
    28  
    29  // WithSettingEngine allows providing a SettingEngine to the API.
    30  // Settings should not be changed after passing the engine to an API.
    31  func WithSettingEngine(s SettingEngine) func(a *API) {
    32  	return func(a *API) {
    33  		a.settingEngine = &s
    34  	}
    35  }