Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pion/webrtc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0-beta.13
Choose a base ref
...
head repository: pion/webrtc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 11,653 additions and 4,026 deletions.
  1. +20 −0 .github/workflows/api.yaml
  2. +1 −1 .github/workflows/release.yml
  3. +5 −3 .github/workflows/test.yaml
  4. +1 −1 .github/workflows/tidy-check.yaml
  5. +36 −24 .golangci.yml
  6. +1 −1 .reuse/dep5
  7. +18 −7 README.md
  8. +12 −12 api.go
  9. +1 −1 api_js.go
  10. +0 −3 api_test.go
  11. +1 −0 atomicbool.go
  12. +4 −3 bundlepolicy.go
  13. +26 −14 certificate.go
  14. +1 −0 configuration_common.go
  15. +2 −2 configuration_test.go
  16. +17 −11 constants.go
  17. +139 −28 datachannel.go
  18. +180 −21 datachannel_go_test.go
  19. +48 −1 datachannel_js.go
  20. +27 −14 datachannel_test.go
  21. +4 −3 datachannelstate.go
  22. +1 −1 dtlsfingerprint.go
  23. +2 −2 dtlsrole.go
  24. +1 −0 dtlsrole_test.go
  25. +90 −33 dtlstransport.go
  26. +5 −0 dtlstransport_js.go
  27. +16 −8 dtlstransport_test.go
  28. +4 −3 dtlstransportstate.go
  29. +1 −1 e2e/Dockerfile
  30. +91 −57 errors.go
  31. +77 −19 examples/bandwidth-estimation-from-disk/main.go
  32. +60 −14 examples/broadcast/main.go
  33. +21 −17 examples/custom-logger/main.go
  34. +1 −1 examples/data-channels-detach/README.md
  35. +60 −9 examples/data-channels-detach/jsfiddle/main.go
  36. +79 −20 examples/data-channels-detach/main.go
  37. +35 −28 examples/data-channels-flow-control/main.go
  38. +57 −3 examples/data-channels/jsfiddle/main.go
  39. +78 −20 examples/data-channels/main.go
  40. +12 −6 examples/examples.go
  41. +1 −1 examples/ice-restart/README.md
  42. +5 −4 examples/ice-restart/main.go
  43. +5 −5 examples/ice-single-port/main.go
  44. +6 −5 examples/ice-tcp/main.go
  45. +1 −1 examples/insertable-streams/README.md
  46. +68 −13 examples/insertable-streams/main.go
  47. +0 −31 examples/internal/signal/http.go
  48. +0 −19 examples/internal/signal/rand.go
  49. +0 −114 examples/internal/signal/signal.go
  50. +85 −16 examples/ortc-media/main.go
  51. +90 −12 examples/ortc/main.go
  52. +1 −1 examples/pion-to-pion/answer/Dockerfile
  53. +49 −32 examples/pion-to-pion/answer/main.go
  54. +1 −1 examples/pion-to-pion/offer/Dockerfile
  55. +49 −28 examples/pion-to-pion/offer/main.go
  56. +18 −2 examples/play-from-disk-renegotiation/README.md
  57. +56 −39 examples/play-from-disk-renegotiation/main.go
  58. +69 −15 examples/play-from-disk/main.go
  59. +72 −19 examples/reflect/main.go
  60. +52 −3 examples/rtcp-processing/main.go
  61. +82 −31 examples/rtp-forwarder/main.go
  62. +54 −4 examples/rtp-to-webrtc/main.go
  63. +2 −2 examples/save-to-disk-av1/README.md
  64. +71 −15 examples/save-to-disk-av1/main.go
  65. +4 −2 examples/save-to-disk/README.md
  66. +1 −3 examples/save-to-disk/jsfiddle/demo.js
  67. +75 −21 examples/save-to-disk/main.go
  68. +97 −25 examples/simulcast/main.go
  69. +7 −2 examples/stats/README.md
  70. +89 −14 examples/stats/main.go
  71. +68 −13 examples/swap-tracks/main.go
  72. +8 −7 examples/trickle-ice/main.go
  73. +26 −22 examples/vnet/show-network-usage/main.go
  74. +43 −0 examples/whip-whep/README.md
  75. +86 −0 examples/whip-whep/index.html
  76. +204 −0 examples/whip-whep/main.go
  77. +4 −2 gathering_complete_promise.go
  78. +29 −17 go.mod
  79. +40 −104 go.sum
  80. +102 −32 icecandidate.go
  81. +172 −1 icecandidate_test.go
  82. +1 −1 icecandidateinit.go
  83. +3 −2 icecandidatepair.go
  84. +7 −5 icecandidatetype.go
  85. +1 −1 icecomponent.go
  86. +2 −2 iceconnectionstate.go
  87. +3 −2 icecredentialtype.go
  88. +90 −49 icegatherer.go
  89. +70 −1 icegatherer_test.go
  90. +1 −1 icegathererstate.go
  91. +2 −2 icegatheringstate.go
  92. +1 −1 icemux.go
  93. +2 −2 iceprotocol.go
  94. +4 −3 icerole.go
  95. +15 −9 iceserver.go
  96. +1 −1 iceserver_js.go
  97. +2 −1 iceserver_test.go
  98. +93 −25 icetransport.go
  99. +5 −0 icetransport_js.go
  100. +28 −5 icetransport_test.go
  101. +5 −4 icetransportpolicy.go
  102. +52 −9 icetransportstate.go
  103. +1 −1 icetransportstate_test.go
  104. +51 −20 interceptor.go
  105. +238 −31 interceptor_test.go
  106. +42 −0 internal/fmtp/av1.go
  107. +128 −38 internal/fmtp/fmtp.go
  108. +668 −79 internal/fmtp/fmtp_test.go
  109. +5 −3 internal/fmtp/h264.go
  110. +0 −145 internal/fmtp/h264_test.go
  111. +42 −0 internal/fmtp/vp9.go
  112. +24 −10 internal/mux/endpoint.go
  113. +83 −26 internal/mux/mux.go
  114. +51 −16 internal/mux/mux_test.go
  115. +9 −7 internal/mux/muxfunc.go
  116. +5 −3 internal/util/util.go
  117. +235 −86 mediaengine.go
  118. +367 −160 mediaengine_test.go
  119. +4 −4 networktype.go
  120. +1 −1 offeransweroptions.go
  121. +79 −17 operations.go
  122. +51 −3 operations_test.go
  123. +0 −3 ortc_media_test.go
  124. +3 −2 package.json
  125. +651 −286 peerconnection.go
  126. +150 −2 peerconnection_close_test.go
  127. +326 −42 peerconnection_go_test.go
  128. +2 −2 peerconnection_js.go
  129. +496 −77 peerconnection_media_test.go
  130. +183 −59 peerconnection_renegotiation_test.go
  131. +25 −14 peerconnection_test.go
  132. +1 −12 peerconnectionstate.go
  133. +10 −4 pkg/media/h264reader/h264reader.go
  134. +2 −2 pkg/media/h264reader/h264reader_test.go
  135. +7 −6 pkg/media/h264reader/nalunittype.go
  136. +5 −5 pkg/media/h264writer/h264writer.go
  137. +37 −0 pkg/media/h264writer/h264writer_test.go
  138. +22 −7 pkg/media/ivfreader/ivfreader.go
  139. +1 −1 pkg/media/ivfreader/ivfreader_test.go
  140. +193 −85 pkg/media/ivfwriter/ivfwriter.go
  141. +104 −17 pkg/media/ivfwriter/ivfwriter_test.go
  142. +2 −2 pkg/media/media.go
  143. +21 −17 pkg/media/oggreader/oggreader.go
  144. +3 −1 pkg/media/oggreader/oggreader_test.go
  145. +30 −22 pkg/media/oggwriter/oggwriter.go
  146. +8 −8 pkg/media/rtpdump/reader.go
  147. +5 −3 pkg/media/rtpdump/reader_test.go
  148. +23 −23 pkg/media/rtpdump/rtpdump.go
  149. +2 −2 pkg/media/rtpdump/rtpdump_test.go
  150. +2 −2 pkg/media/rtpdump/writer.go
  151. +1 −0 pkg/media/samplebuilder/sampleSequenceLocation.go
  152. +29 −35 pkg/media/samplebuilder/samplebuilder.go
  153. +211 −144 pkg/media/samplebuilder/samplebuilder_test.go
  154. +36 −36 pkg/null/null.go
  155. +4 −3 rtcpmuxpolicy.go
  156. +58 −13 rtpcodec.go
  157. +7 −0 rtpcodingparameters.go
  158. +1 −1 rtpreceiveparameters.go
  159. +111 −41 rtpreceiver.go
  160. +54 −14 rtpreceiver_go_test.go
  161. +5 −0 rtpreceiver_js.go
  162. +3 −2 rtpreceiver_test.go
  163. +86 −34 rtpsender.go
  164. +5 −0 rtpsender_js.go
  165. +153 −16 rtpsender_test.go
  166. +1 −1 rtpsendparameters.go
  167. +44 −19 rtptransceiver.go
  168. +5 −0 rtptransceiver_js.go
  169. +15 −15 rtptransceiver_test.go
  170. +7 −3 rtptransceiverdirection.go
  171. +2 −1 rtptransceiverinit.go
  172. +2 −2 rtptransceiverinit_go_test.go
  173. +70 −38 sctptransport.go
  174. +5 −0 sctptransport_js.go
  175. +215 −2 sctptransport_test.go
  176. +1 −1 sctptransportstate.go
  177. +365 −149 sdp.go
  178. +650 −60 sdp_test.go
  179. +5 −4 sdpsemantics.go
  180. +23 −6 sdpsemantics_test.go
  181. +4 −4 sdptype.go
  182. +2 −1 sessiondescription.go
  183. +1 −0 sessiondescription_test.go
  184. +124 −36 settingengine.go
  185. +260 −47 settingengine_test.go
  186. +6 −4 signalingstate.go
  187. +3 −2 srtp_writer_future.go
  188. +421 −14 stats.go
  189. +12 −6 stats_go.go
  190. +315 −155 stats_go_test.go
  191. +1 −1 test-wasm/node_shim.js
  192. +31 −17 track_local.go
  193. +95 −39 track_local_static.go
  194. +189 −16 track_local_static_test.go
  195. +38 −19 track_remote.go
  196. +16 −5 vnet_test.go
  197. +48 −468 yarn.lock
20 changes: 20 additions & 0 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

name: API
on:
pull_request:

jobs:
check:
uses: pion/.goassets/.github/workflows/api.reusable.yml@master
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -21,4 +21,4 @@ jobs:
release:
uses: pion/.goassets/.github/workflows/release.reusable.yml@master
with:
go-version: '1.20' # auto-update/latest-go-version
go-version: "1.22" # auto-update/latest-go-version
8 changes: 5 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -23,21 +23,23 @@ jobs:
uses: pion/.goassets/.github/workflows/test.reusable.yml@master
strategy:
matrix:
go: ['1.21', '1.20'] # auto-update/supported-go-version-list
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
fail-fast: false
with:
go-version: ${{ matrix.go }}
secrets: inherit

test-i386:
uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master
strategy:
matrix:
go: ['1.21', '1.20'] # auto-update/supported-go-version-list
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
fail-fast: false
with:
go-version: ${{ matrix.go }}

test-wasm:
uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master
with:
go-version: '1.20' # auto-update/latest-go-version
go-version: "1.23" # auto-update/latest-go-version
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/tidy-check.yaml
Original file line number Diff line number Diff line change
@@ -22,4 +22,4 @@ jobs:
tidy:
uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master
with:
go-version: '1.21' # auto-update/latest-go-version
go-version: "1.22" # auto-update/latest-go-version
60 changes: 36 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

run:
timeout: 5m

linters-settings:
govet:
check-shadowing: true
enable:
- shadow
misspell:
locale: US
exhaustive:
@@ -21,17 +25,32 @@ linters-settings:
- ^os.Exit$
- ^panic$
- ^print(ln)?$
varnamelen:
max-distance: 12
min-name-length: 2
ignore-type-assert-ok: true
ignore-map-index-ok: true
ignore-chan-recv-ok: true
ignore-decls:
- i int
- n int
- w io.Writer
- r io.Reader
- b []byte

linters:
enable:
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- bidichk # Checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- containedctx # containedctx is a linter that detects struct contained context.Context field
- contextcheck # check the function whether use a non-inherited context
- cyclop # checks function and package cyclomatic complexity
- decorder # check declaration order and count of types, constants, variables and functions
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- dupl # Tool for code clone detection
- durationcheck # check for two durations multiplied together
- err113 # Golang linter to check the errors handling expressions
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
@@ -42,74 +61,70 @@ linters:
- forcetypeassert # finds forced type assertions
- gci # Gci control golang package import order and make it always deterministic.
- gochecknoglobals # Checks that no globals are present in Go code
- gochecknoinits # Checks that no init functions are present in Go code
- gocognit # Computes and checks the cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # The most opinionated Go source code linter
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- godox # Tool for detection of FIXME, TODO and other comment keywords
- goerr113 # Golang linter to check the errors handling expressions
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
- goheader # Checks is file header matches to pattern
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
- gosec # Inspects source code for security problems
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- grouper # An analyzer to analyze expression groups.
- importas # Enforces consistent import aliases
- ineffassign # Detects when assignments to existing variables are not used
- lll # Reports long lines
- maintidx # maintidx measures the maintainability index of each function.
- makezero # Finds slice declarations with non-zero initial length
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
- nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- noctx # noctx finds sending http request without context.Context
- predeclared # find code that shadows one of Go's predeclared identifiers
- revive # golint replacement, finds style mistakes
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- stylecheck # Stylecheck is a replacement for golint
- tagliatelle # Checks the struct tags.
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unconvert # Remove unnecessary type conversions
- unparam # Reports unused function parameters
- unused # Checks Go code for unused constants, variables, functions and types
- varnamelen # checks that the length of a variable's name matches its scope
- wastedassign # wastedassign finds wasted assignment statements
- whitespace # Tool for detection of leading and trailing whitespace
disable:
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- containedctx # containedctx is a linter that detects struct contained context.Context field
- cyclop # checks function and package cyclomatic complexity
- exhaustivestruct # Checks if all struct's fields are initialized
- funlen # Tool for detection of long functions
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- gomnd # An analyzer to detect magic numbers.
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
- gochecknoinits # Checks that no init functions are present in Go code
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
- interfacebloat # A linter that checks length of interface.
- ireturn # Accept Interfaces, Return Concrete Types
- lll # Reports long lines
- maintidx # maintidx measures the maintainability index of each function.
- makezero # Finds slice declarations with non-zero initial length
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- mnd # An analyzer to detect magic numbers
- nolintlint # Reports ill-formed or insufficient nolint directives
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
- prealloc # Finds slice declarations that could potentially be preallocated
- promlinter # Check Prometheus metrics naming via promlint
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
- testpackage # linter that makes you use a separate _test package
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- varnamelen # checks that the length of a variable's name matches its scope
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- wrapcheck # Checks that errors returned from external packages are wrapped
- wsl # Whitespace Linter - Forces you to use empty lines!

issues:
exclude-use-default: false
exclude-dirs-use-default: false
exclude-rules:
# Allow complex tests and examples, better to be self contained
- path: (examples|main\.go|_test\.go)
@@ -121,6 +136,3 @@ issues:
- path: cmd
linters:
- forbidigo

run:
skip-dirs-use-default: false
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Pion
Source: https://github.com/pion/

Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples/examples.json
Files: README.md DESIGN.md **/README.md AUTHORS.txt renovate.json go.mod go.sum **/go.mod **/go.sum .eslintrc.json package.json examples.json sfu-ws/flutter/.gitignore sfu-ws/flutter/pubspec.yaml c-data-channels/webrtc.h examples/examples.json
Copyright: 2023 The Pion community <https://pion.ly>
License: MIT

25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,16 @@
</p>
<br>

### New Release

Pion WebRTC v4.0.0 has been released! See the [release notes](https://github.com/pion/webrtc/wiki/Release-WebRTC@v4.0.0) to learn about new features and breaking changes.

If you aren't able to upgrade yet check the [tags](https://github.com/pion/webrtc/tags) for the latest `v3` release.

We would love your feedback! Please create GitHub issues or join [the Slack channel](https://pion.ly/slack) to follow development and speak with the maintainers.

-----

### Usage
[Go Modules](https://blog.golang.org/using-go-modules) are mandatory for using Pion WebRTC. So make sure you set `export GO111MODULE=on`, and explicitly specify `/v4` (or an earlier version) when importing.

@@ -42,16 +52,17 @@ Now go build something awesome! Here are some **ideas** to get your creative jui
* Build a conferencing application that processes audio/video and make decisions off of it.
* Remotely control a robots and stream its cameras in realtime.

### Want to learn more about WebRTC?
Join our [Office Hours](https://github.com/pion/webrtc/wiki/OfficeHours). Come hang out, ask questions, get help debugging and
hear about the cool things being built with WebRTC. We also start every meeting with basic project planning.

### Need Help?
Check out [WebRTC for the Curious](https://webrtcforthecurious.com). A book about WebRTC in depth, not just about the APIs.
Learn the full details of ICE, SCTP, DTLS, SRTP, and how they work together to make up the WebRTC stack.
Learn the full details of ICE, SCTP, DTLS, SRTP, and how they work together to make up the WebRTC stack. This is also a great
resource if you are trying to debug. Learn the tools of the trade and how to approach WebRTC issues. This book is vendor
agnostic and will not have any Pion specific information.

This is also a great resource if you are trying to debug. Learn the tools of the trade and how to approach WebRTC issues.
Pion has an active community on [Slack](https://pion.ly/slack). Please ask for help about anything, questions don't have to be Pion specific!
Come share your interesting project you are working on. We are here to support you.

This book is vendor agnostic and will not have any Pion specific information.
One of the maintainers of Pion [Sean-Der](https://github.com/sean-der) is available to help. Schedule at [siobud.com/meeting](https://siobud.com/meeting)
He is available to talk about Pion or general WebRTC questions, feel free to reach out about anything!

### Features
#### PeerConnection API
24 changes: 12 additions & 12 deletions api.go
Original file line number Diff line number Diff line change
@@ -29,38 +29,38 @@ type API struct {
// It uses the default Codecs and Interceptors unless you customize them
// using WithMediaEngine and WithInterceptorRegistry respectively.
func NewAPI(options ...func(*API)) *API {
a := &API{
api := &API{
interceptor: &interceptor.NoOp{},
settingEngine: &SettingEngine{},
}

for _, o := range options {
o(a)
o(api)
}

if a.settingEngine.LoggerFactory == nil {
a.settingEngine.LoggerFactory = logging.NewDefaultLoggerFactory()
if api.settingEngine.LoggerFactory == nil {
api.settingEngine.LoggerFactory = logging.NewDefaultLoggerFactory()
}

logger := a.settingEngine.LoggerFactory.NewLogger("api")
logger := api.settingEngine.LoggerFactory.NewLogger("api")

if a.mediaEngine == nil {
a.mediaEngine = &MediaEngine{}
err := a.mediaEngine.RegisterDefaultCodecs()
if api.mediaEngine == nil {
api.mediaEngine = &MediaEngine{}
err := api.mediaEngine.RegisterDefaultCodecs()
if err != nil {
logger.Errorf("Failed to register default codecs %s", err)
}
}

if a.interceptorRegistry == nil {
a.interceptorRegistry = &interceptor.Registry{}
err := RegisterDefaultInterceptors(a.mediaEngine, a.interceptorRegistry)
if api.interceptorRegistry == nil {
api.interceptorRegistry = &interceptor.Registry{}
err := RegisterDefaultInterceptors(api.mediaEngine, api.interceptorRegistry)
if err != nil {
logger.Errorf("Failed to register default interceptors %s", err)
}
}

return a
return api
}

// WithMediaEngine allows providing a MediaEngine to the API.
2 changes: 1 addition & 1 deletion api_js.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

package webrtc

// API bundles the global funcions of the WebRTC and ORTC API.
// API bundles the global functions of the WebRTC and ORTC API.
type API struct {
settingEngine *SettingEngine
}
3 changes: 0 additions & 3 deletions api_test.go
Original file line number Diff line number Diff line change
@@ -31,12 +31,9 @@ func TestNewAPI(t *testing.T) {
func TestNewAPI_Options(t *testing.T) {
s := SettingEngine{}
s.DetachDataChannels()
m := MediaEngine{}
assert.NoError(t, m.RegisterDefaultCodecs())

api := NewAPI(
WithSettingEngine(s),
WithMediaEngine(&m),
)

if !api.settingEngine.detach.DataChannels {
1 change: 1 addition & 0 deletions atomicbool.go
Original file line number Diff line number Diff line change
@@ -27,5 +27,6 @@ func (b *atomicBool) swap(value bool) bool {
if value {
i = 1
}

return atomic.SwapInt32(&(b.val), i) != 0
}
7 changes: 4 additions & 3 deletions bundlepolicy.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
type BundlePolicy int

const (
// BundlePolicyUnknown is the enum's zero-value
// BundlePolicyUnknown is the enum's zero-value.
BundlePolicyUnknown BundlePolicy = iota

// BundlePolicyBalanced indicates to gather ICE candidates for each
@@ -67,18 +67,19 @@ func (t BundlePolicy) String() string {
}
}

// UnmarshalJSON parses the JSON-encoded data and stores the result
// UnmarshalJSON parses the JSON-encoded data and stores the result.
func (t *BundlePolicy) UnmarshalJSON(b []byte) error {
var val string
if err := json.Unmarshal(b, &val); err != nil {
return err
}

*t = newBundlePolicy(val)

return nil
}

// MarshalJSON returns the JSON encoding
// MarshalJSON returns the JSON encoding.
func (t BundlePolicy) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
Loading