Commit Graph

310 Commits

Author SHA1 Message Date
Joe Turki
d475f2c9ee Implement write deadline 2025-12-18 15:00:48 +02:00
Joe Turki
3ea3643340 Fix wrong stub comments 2025-12-17 14:23:12 +02:00
Joe Turki
79d7571f25 Implement deadlines for mux 2025-12-09 15:36:41 +02:00
Joe Turki
5a0e56e105 Prefer makezero with a cap 2025-09-19 06:19:21 +03:00
Pion
cda9130802 Update CI configs to v0.11.25
Update lint scripts and CI configs.
2025-08-31 23:04:59 -04:00
Joe Turki
740e5166c5 Update lint rules, force testify/assert for tests
Use testify's assert package instead of the standard library's testing
package.
2025-03-27 12:08:37 +02:00
Alessandro Ros
969ab684e3 Fix matching codecs with different rate or channels
Currently codecs are matched regardless of the clock
rate and the channel count, and this makes impossible to fully support
codecs that might have a clock rate or channel count different than the
default one, in particular LPCM, PCMU, PCMA and multiopus (the last one
is a custom Opus variant present in the Chrome source code to support
multichannel Opus).

For instance, let's suppose a peer (receiver) wants to receive an audio
track encoded with LPCM, 48khz sample rate and 2 channels. This receiver
doesn't know the audio codec yet, therefore it advertises all supported
sample rates in the SDP:

```
LPCM/44100
LPCM/48000
LPCM/44100/2
LPCM/48000/2
```

The other peer (sender) receives the SDP, but since the clock rate and
channel count are not taken into consideration when matching codecs, the
sender codec `LPCM/48000/2` is wrongly associated with the receiver
codec `LPCM/44100`. The result is that the audio track cannot be decoded
correctly from the receiver side.

This patch fixes the issue and has been running smoothly in MediaMTX for
almost a year.

Unfortunately, in lots of examples and tests, clock rate and/or channels
are not present (and in fact they are producing horrible SDPs that
contain `VP8/0` instead of `VP8/90000` and are incompatible with lots of
servers) therefore this new check causes troubles in existing code. In
order to maintain compatibility, default clock rates and channels are
provided for most codecs.

In the future, it might be better to update examples (i can do it in a
future patch) and remove the exception.
2025-02-15 21:16:47 -05:00
Joe Turki
feeeebf251 Upgrade golangci-lint, more linters
Introduces new linters, upgrade golangci-lint to version (v1.63.4)
2025-01-18 07:16:06 -06:00
sukun
28adb77ee6 Fix Mux logging on Close 2024-09-10 17:43:18 +05:30
sukun
1a214d2fcb Use Mutex for Mux
We only read from one goroutine, the RWMutex doesn't help improve
performance in this case
2024-09-10 17:43:18 +05:30
Sean DuBois
3aab0355e0 Upgrade dtls, ice, stun and turn
New major version of all packages caused by DTLS upgrade
2024-08-12 13:45:35 -04:00
Eric Daniels
78c8a2e07c Add PeerConnection.GracefulClose 2024-08-06 09:51:54 -04:00
lactyy
cbe3465c8b Adding pendingQueue to internal/mux
Buffer a small amount of packets in the internal/mux to allow remotes to
send DTLS traffic before ICE has completed
2024-08-01 23:11:35 -04:00
Sean DuBois
f388de6581 Update module github.com/pion/dtls/v2 to v3
Generated by renovateBot
2024-07-25 11:16:12 -05:00
aler9
a868a14ec8 Add links to RTP payload format specifications 2024-06-25 16:56:07 -04:00
aler9
31c2c0dfc1 Fix AV1 and VP9 codec matching
Currently, AV1 or VP9 formats are matched regardless of the profile
parameter. This was not noticeable until browsers started advertising
multiple VP9 formats at the same time, each with a different profile
ID, in order to allow the counterpart to send different streams on the
basis of supported profiles.

This causes two issues: first, the library includes in the SDP all
formats passed by the browser, regardless of the fact that the profile
ID is registered in the API or not. Then, the library is unable to
choose the correct format for streaming, causing an intermittent
failure.

This patch fixes the matching algorithm and also covers the case in
which the profile ID is missing, by using values dictated by
specifications.

Tests were refactored since previous ones covered the same lines
multiple times.
2024-06-25 22:10:39 +02:00
knowmost
a97c420d0c Fix typos in multiple comments 2024-04-27 23:27:55 -04:00
Sean DuBois
60eea430ac Close PeerConnection on DTLS CloseNotify
Resolves #1767
Resolves pion/dtls#151
2023-09-05 04:52:17 -04:00
renovate[bot]
ea23dec2b9 Update module transport, srtp, ice and turn
ReplayDetector introduced a breaking change
2023-09-03 23:59:43 -04:00
Steffen Vogel
683fc837d0 Make repo REUSE compliant 2023-05-05 11:58:49 -04:00
Pion
308f8616a3 Update CI configs to v0.10.6
Update lint scripts and CI configs.
2023-04-08 14:24:19 -04:00
Steffen Vogel
eafdc7742a Use new pion/transport Net interface
This change adapts pion/ice to use a new interface for most network
related operations. The interface was formerly a simple struct vnet.Net
which was originally intended to facilicate testing. By replacing it
with an interface we have greater flexibility and allow users to hook
into the networking stack by providing their own implementation of
the interface.
2023-02-09 09:39:33 +01:00
Aditya Kumar
dfbbd22c3d Fix case insensitive mimetype check
Relates to pion/webrtc #2241
2022-05-24 21:16:47 -07:00
Pion
5b4afbb934 Update CI configs to v0.7.5
Update lint scripts and CI configs.
2022-05-09 12:08:35 -04:00
Pion
c1467e4871 Update CI configs to v0.7.2
Update lint scripts and CI configs.
2022-04-27 23:00:19 -04:00
rob
1368fe899e Drop packets when buffer is full in mux
Resolves #2180
2022-04-20 00:34:59 -04:00
Sean DuBois
c8ae82a0bd Unlock on error in internal/mux
Resolves #2154
2022-03-21 15:58:53 -04:00
rob
93b0f2a75e Wait and re-try when Mux destination ErrFull
Resolves #2152
2022-03-20 17:25:25 -07:00
Ryan Shumate
2d529be571 Improved h264 fmtp line parsing
Implements h264 fmtp parsing based on RFC 6184 Section 8.2.2
2021-07-30 13:23:07 -04:00
Antoine Baché
7e049ec5ec Update examples
TestNonFatalRead now has an timeout.
Examples now use Mime types, instead of raw strings.

Fixes #839
2021-07-02 11:49:55 -04:00
Juliusz Chroboczek
d625f6f637 Optimise mux.dispatch
Uncurry the function MuxRange and avoid allocating a reader in
isRTCP.  The included benchmark indicates that we avoid five
allocations per packet.
2021-05-07 11:09:09 -07:00
Sean DuBois
dab8a4a104 Handle errors properly in mux readLoop
Before io.ErrShortBuffer and packetio.ErrTimeout would incorrectly end
the read loop. Now they are only printed.

Resolves #1720
2021-03-22 11:16:11 -07:00
Sean DuBois
9c345e24b6 Remove unused functions from internal/mux
Related to #1720
2021-03-22 11:16:11 -07:00
Sean DuBois
9715626a0c Revert "Read/Write RTP/RTCP packets with context"
This change caused a ~24% performance decrease

Relates to pion/webrtc#1564

This reverts commit 47a7a64898.
2020-12-02 20:11:06 -08:00
Atsushi Watanabe
47a7a64898 Read/Write RTP/RTCP packets with context
Control cancel/timeout by context.
2020-12-01 11:08:48 +09:00
Sean DuBois
804a12fed3 Update CI configs to v0.4.7
Update lint scripts and CI configs.
2020-09-30 09:06:34 -07:00
Henry
940d6aae86 Update pion/quic binings
* fix gathering for quic transport test
* quic e2e test: make sure data is received
* fix loggingFactory setup
* CI: add '-tags quic' in 'go test'
* CI: add --build-tags to golangci-lint.
* use latest pion/quic@v0.1.2
2020-07-25 15:57:47 -07:00
Atsushi Watanabe
0157f347e4 Fix randoms
Use seeded mathematical random where uniqueness is needed
but not required to be cryptographic.
2020-07-13 14:42:53 +09:00
Sean DuBois
bb3aa9717f Move to pion/ice@v2
Removed support for trickle ice

Resolves #1274
2020-06-28 00:01:47 -07:00
Atsushi Watanabe
975a63fb43 Make FlattenErrs result comparable
Support Go 1.13 error.Is.
2020-03-24 06:53:31 +09:00
Atsushi Watanabe
27d9bbb7bd Upgrade golangci-lint to 1.19.1
Fix whitespace and stylecheck errors.
Disable godox.
2020-01-11 22:59:33 -08:00
Hugo Arregui
6997cc792c Linter fixes
Disable funlen and some fixes

Co-authored-by: Sean DuBois <sean@siobud.com>
2019-09-10 21:48:25 -07:00
Hongchao Ma
0e257f6c3d Fix crash in mux logging
Check buffer length is 0 or not, display a different error message
if we have no contents to display
2019-09-08 03:53:49 -04:00
Sean DuBois
10d2ca3d88 Enable gochecknoglobals linter
Resolves #434
2019-07-09 23:31:56 +01:00
Sean DuBois
2838b1a836 Move ICE code out of internal
Users are unable to use the callbacks inside `internal/ice`.
Even though we alias things like OnSelectedCandidatePairChange
are unusable since in the package they use `ice.Candidate` instead of
`ICECandidate`
2019-06-15 01:29:08 -07:00
Sean DuBois
0d773a38f6 Don't error when no candidate pairs
Fix inconsistency with error handling when we have no candidate pairs.
Before we had custom code in RTP handling that would discard errors
if it was because we had no candidate pairs. Move this logic into the
mux so we have consistent behavior with Datachannels

This can be expected and is a soft failure. Every subsystem is expected
to handle lossy communication.

Resolves #706
2019-06-08 17:51:18 -07:00
Konstantin Itskov
8c7f769e86 Fix race issue caused by multiple gathering
resolves #707
2019-06-07 20:05:55 -07:00
Sean DuBois
9014863dc5 Revert "Moved internal/ice package to pkg/ice"
I made this change because I assumed godoc doesn't support
internal packages, this is not true. Godoc is actually having
issues because it doesn't support modules yet. So reverting
this change because we would prefer this be internal.

This reverts commit 8b09ced24b.
2019-06-06 11:42:49 -07:00
Adam Kiss
8b09ced24b Moved internal/ice package to pkg/ice
Moved internal/ice package to pkg/ice so godocs is properly generated
for it.
2019-06-06 00:52:45 -07:00
Hugo Arregui
8572527a86 Expose new ICE options
Expose new ICE timeouts in the setting engine
2019-06-05 14:19:01 -07:00