mirror of
https://github.com/pion/mediadevices.git
synced 2025-10-24 09:03:35 +08:00
Compare commits
37 Commits
v0.7.2
...
add-svt-av
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cd2e7dc65 | ||
|
|
5aad703236 | ||
|
|
e15e8f6880 | ||
|
|
dd99235d6f | ||
|
|
a38279006f | ||
|
|
a5e2538787 | ||
|
|
9547f15638 | ||
|
|
9c9f9e3550 | ||
|
|
3efb8d5f48 | ||
|
|
5e91c919df | ||
|
|
ffe2fcb74d | ||
|
|
77eba99fbc | ||
|
|
5468c360f0 | ||
|
|
057e6a8466 | ||
|
|
4adbe9020c | ||
|
|
cb24697808 | ||
|
|
29cee4bd00 | ||
|
|
5879326c1e | ||
|
|
ca4f2fa186 | ||
|
|
accb12f0d5 | ||
|
|
6cbe3de4a3 | ||
|
|
1258ff726b | ||
|
|
89cbba8b77 | ||
|
|
a74a31d62a | ||
|
|
807eaefef8 | ||
|
|
60ef86b312 | ||
|
|
47ef30e9b3 | ||
|
|
bf655c675c | ||
|
|
8840daf7ea | ||
|
|
a68a5ba4a6 | ||
|
|
5a0a5b00d4 | ||
|
|
d864136608 | ||
|
|
9a9a5631ed | ||
|
|
799d1efb81 | ||
|
|
92dfa9bc75 | ||
|
|
077ff4c0f2 | ||
|
|
f5fbc53145 |
21
.github/workflows/ci.yaml
vendored
21
.github/workflows/ci.yaml
vendored
@@ -13,14 +13,11 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go:
|
||||
- '1.21' # oldest version this package supports
|
||||
- '1.22' # oldstable Go version
|
||||
- '1.23' # stable Go version
|
||||
go: ["1.25", "1.24"] # auto-update/supported-go-version-list
|
||||
name: Linux Go ${{ matrix.go }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
@@ -30,6 +27,7 @@ jobs:
|
||||
sudo apt-get update -qq \
|
||||
&& sudo apt-get install --no-install-recommends -y \
|
||||
libopus-dev \
|
||||
libsvtav1enc-dev \
|
||||
libva-dev \
|
||||
libvpx-dev \
|
||||
libx11-dev \
|
||||
@@ -44,14 +42,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go:
|
||||
- '1.22'
|
||||
- '1.23'
|
||||
go: ["1.25", "1.24"] # auto-update/supported-go-version-list
|
||||
runs-on: macos-latest
|
||||
name: Darwin Go ${{ matrix.go }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
@@ -60,9 +56,10 @@ jobs:
|
||||
run: |
|
||||
which brew
|
||||
brew install \
|
||||
pkg-config \
|
||||
opus \
|
||||
libvpx \
|
||||
opus \
|
||||
pkg-config \
|
||||
svt-av1 \
|
||||
x264
|
||||
- name: Run Test Suite
|
||||
run: make test
|
||||
@@ -74,7 +71,7 @@ jobs:
|
||||
name: Check Licenses
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
|
||||
6
.github/workflows/renovate-go-mod-fix.yaml
vendored
6
.github/workflows/renovate-go-mod-fix.yaml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: fix
|
||||
@@ -20,4 +20,6 @@ jobs:
|
||||
github_token: ${{ secrets.PIONBOT_GITHUB_TOKEN }}
|
||||
commit_style: squash
|
||||
push: force
|
||||
go_mod_paths: ./
|
||||
go_mod_paths: |
|
||||
./
|
||||
./examples/
|
||||
|
||||
@@ -149,6 +149,14 @@ A codec library which supports H.264 encoding and decoding. It is suitable for u
|
||||
* Package: [github.com/pion/mediadevices/pkg/codec/openh264](https://pkg.go.dev/github.com/pion/mediadevices/pkg/codec/openh264)
|
||||
* Installation: no installation needed, included as a static binary
|
||||
|
||||
##### svtav1
|
||||
A free software video codec library from the Alliance for Open Media that implements AV1 video coding formats.
|
||||
|
||||
* Package: [github.com/pion/mediadevices/pkg/codec/svtav1](https://pkg.go.dev/github.com/pion/mediadevices/pkg/codec/svtav1)
|
||||
* Installation:
|
||||
* Mac: `brew install svt-av1`
|
||||
* Ubuntu: `apt install libsvtav1enc-dev`
|
||||
|
||||
##### vpx
|
||||
A free software video codec library from Google and the Alliance for Open Media that implements VP8/VP9 video coding formats.
|
||||
|
||||
|
||||
@@ -5,28 +5,28 @@ go 1.21
|
||||
require (
|
||||
github.com/esimov/pigo v1.4.6
|
||||
github.com/pion/mediadevices v0.0.0
|
||||
github.com/pion/webrtc/v4 v4.1.2
|
||||
github.com/pion/webrtc/v4 v4.1.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/blackjack/webcam v0.6.1 // indirect
|
||||
github.com/gen2brain/malgo v0.11.23 // indirect
|
||||
github.com/gen2brain/malgo v0.11.24 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.6 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.7 // indirect
|
||||
github.com/pion/ice/v4 v4.0.10 // indirect
|
||||
github.com/pion/interceptor v0.1.40 // indirect
|
||||
github.com/pion/logging v0.2.3 // indirect
|
||||
github.com/pion/interceptor v0.1.41 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.15 // indirect
|
||||
github.com/pion/rtp v1.8.18 // indirect
|
||||
github.com/pion/rtcp v1.2.16 // indirect
|
||||
github.com/pion/rtp v1.8.24 // indirect
|
||||
github.com/pion/sctp v1.8.39 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.13 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.5 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.16 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.8 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.8 // indirect
|
||||
github.com/pion/turn/v4 v4.1.1 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/image v0.23.0 // indirect
|
||||
|
||||
@@ -6,47 +6,47 @@ github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44am
|
||||
github.com/esimov/pigo v1.4.6 h1:wpB9FstbqeGP/CZP+nTR52tUJe7XErq8buG+k4xCXlw=
|
||||
github.com/esimov/pigo v1.4.6/go.mod h1:uqj9Y3+3IRYhFK071rxz1QYq0ePhA6+R9jrUZavi46M=
|
||||
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
github.com/gen2brain/malgo v0.11.23 h1:3/VAI8DP9/Wyx1CUDNlUQJVdWUvGErhjHDqYcHVk9ME=
|
||||
github.com/gen2brain/malgo v0.11.23/go.mod h1:f9TtuN7DVrXMiV/yIceMeWpvanyVzJQMlBecJFVMxww=
|
||||
github.com/gen2brain/malgo v0.11.24 h1:hHcIJVfzWcEDHFdPl5Dl/CUSOjzOleY0zzAV8Kx+imE=
|
||||
github.com/gen2brain/malgo v0.11.24/go.mod h1:f9TtuN7DVrXMiV/yIceMeWpvanyVzJQMlBecJFVMxww=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
|
||||
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
||||
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
|
||||
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
|
||||
github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q=
|
||||
github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8=
|
||||
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
|
||||
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
|
||||
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
|
||||
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
|
||||
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
|
||||
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
|
||||
github.com/pion/interceptor v0.1.41 h1:NpvX3HgWIukTf2yTBVjVGFXtpSpWgXjqz7IIpu7NsOw=
|
||||
github.com/pion/interceptor v0.1.41/go.mod h1:nEt4187unvRXJFyjiw00GKo+kIuXMWQI9K89fsosDLY=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
|
||||
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
|
||||
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
|
||||
github.com/pion/rtp v1.8.18 h1:yEAb4+4a8nkPCecWzQB6V/uEU18X1lQCGAQCjP+pyvU=
|
||||
github.com/pion/rtp v1.8.18/go.mod h1:bAu2UFKScgzyFqvUKmbvzSdPr+NGbZtv6UB2hesqXBk=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.8.24 h1:+ICyZXUQDv95EsHN70RrA4XKJf5MGWyC6QQc1u6/ynI=
|
||||
github.com/pion/rtp v1.8.24/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE=
|
||||
github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE=
|
||||
github.com/pion/sdp/v3 v3.0.13 h1:uN3SS2b+QDZnWXgdr69SM8KB4EbcnPnPf2Laxhty/l4=
|
||||
github.com/pion/sdp/v3 v3.0.13/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E=
|
||||
github.com/pion/srtp/v3 v3.0.5 h1:8XLB6Dt3QXkMkRFpoqC3314BemkpMQK2mZeJc4pUKqo=
|
||||
github.com/pion/srtp/v3 v3.0.5/go.mod h1:r1G7y5r1scZRLe2QJI/is+/O83W2d+JoEsuIexpw+uM=
|
||||
github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo=
|
||||
github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
|
||||
github.com/pion/srtp/v3 v3.0.8 h1:RjRrjcIeQsilPzxvdaElN0CpuQZdMvcl9VZ5UY9suUM=
|
||||
github.com/pion/srtp/v3 v3.0.8/go.mod h1:2Sq6YnDH7/UDCvkSoHSDNDeyBcFgWL0sAVycVbAsXFg=
|
||||
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
|
||||
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU=
|
||||
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
|
||||
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
|
||||
github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM=
|
||||
github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA=
|
||||
github.com/pion/webrtc/v4 v4.1.2 h1:mpuUo/EJ1zMNKGE79fAdYNFZBX790KE7kQQpLMjjR54=
|
||||
github.com/pion/webrtc/v4 v4.1.2/go.mod h1:xsCXiNAmMEjIdFxAYU0MbB3RwRieJsegSB2JZsGN+8U=
|
||||
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
|
||||
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc=
|
||||
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8=
|
||||
github.com/pion/webrtc/v4 v4.1.5 h1:hJqfKPdRAVcXV9rsg2xcCiuXuMJ38BLW/87GsYJUtUU=
|
||||
github.com/pion/webrtc/v4 v4.1.5/go.mod h1:vzHh7egVnZRgkK83lYzciWVszdDs759y3/eyu6AvZRA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
|
||||
20
go.mod
20
go.mod
@@ -4,14 +4,14 @@ go 1.21
|
||||
|
||||
require (
|
||||
github.com/blackjack/webcam v0.6.1
|
||||
github.com/gen2brain/malgo v0.11.23
|
||||
github.com/gen2brain/malgo v0.11.24
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/kbinani/screenshot v0.0.0-20250624051815-089614a94018
|
||||
github.com/pion/interceptor v0.1.40
|
||||
github.com/pion/interceptor v0.1.41
|
||||
github.com/pion/logging v0.2.4
|
||||
github.com/pion/rtcp v1.2.15
|
||||
github.com/pion/rtp v1.8.19
|
||||
github.com/pion/webrtc/v4 v4.1.2
|
||||
github.com/pion/rtcp v1.2.16
|
||||
github.com/pion/rtp v1.8.24
|
||||
github.com/pion/webrtc/v4 v4.1.5
|
||||
github.com/stretchr/testify v1.11.1
|
||||
golang.org/x/image v0.23.0
|
||||
)
|
||||
@@ -23,16 +23,16 @@ require (
|
||||
github.com/jezek/xgb v1.1.1 // indirect
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.6 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.7 // indirect
|
||||
github.com/pion/ice/v4 v4.0.10 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/sctp v1.8.39 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.13 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.5 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.16 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.8 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.8 // indirect
|
||||
github.com/pion/turn/v4 v4.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
|
||||
40
go.sum
40
go.sum
@@ -2,8 +2,8 @@ github.com/blackjack/webcam v0.6.1 h1:K0T6Q0zto23U99gNAa5q/hFoye6uGcKr2aE6hFoxVo
|
||||
github.com/blackjack/webcam v0.6.1/go.mod h1:zs+RkUZzqpFPHPiwBZ6U5B34ZXXe9i+SiHLKnnukJuI=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gen2brain/malgo v0.11.23 h1:3/VAI8DP9/Wyx1CUDNlUQJVdWUvGErhjHDqYcHVk9ME=
|
||||
github.com/gen2brain/malgo v0.11.23/go.mod h1:f9TtuN7DVrXMiV/yIceMeWpvanyVzJQMlBecJFVMxww=
|
||||
github.com/gen2brain/malgo v0.11.24 h1:hHcIJVfzWcEDHFdPl5Dl/CUSOjzOleY0zzAV8Kx+imE=
|
||||
github.com/gen2brain/malgo v0.11.24/go.mod h1:f9TtuN7DVrXMiV/yIceMeWpvanyVzJQMlBecJFVMxww=
|
||||
github.com/gen2brain/shm v0.1.0 h1:MwPeg+zJQXN0RM9o+HqaSFypNoNEcNpeoGp0BTSx2YY=
|
||||
github.com/gen2brain/shm v0.1.0/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
@@ -24,36 +24,36 @@ github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
|
||||
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
|
||||
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
||||
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
|
||||
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
|
||||
github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q=
|
||||
github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8=
|
||||
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
|
||||
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
|
||||
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
|
||||
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
|
||||
github.com/pion/interceptor v0.1.41 h1:NpvX3HgWIukTf2yTBVjVGFXtpSpWgXjqz7IIpu7NsOw=
|
||||
github.com/pion/interceptor v0.1.41/go.mod h1:nEt4187unvRXJFyjiw00GKo+kIuXMWQI9K89fsosDLY=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
|
||||
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
|
||||
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
|
||||
github.com/pion/rtp v1.8.19 h1:jhdO/3XhL/aKm/wARFVmvTfq0lC/CvN1xwYKmduly3c=
|
||||
github.com/pion/rtp v1.8.19/go.mod h1:bAu2UFKScgzyFqvUKmbvzSdPr+NGbZtv6UB2hesqXBk=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.8.24 h1:+ICyZXUQDv95EsHN70RrA4XKJf5MGWyC6QQc1u6/ynI=
|
||||
github.com/pion/rtp v1.8.24/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE=
|
||||
github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE=
|
||||
github.com/pion/sdp/v3 v3.0.13 h1:uN3SS2b+QDZnWXgdr69SM8KB4EbcnPnPf2Laxhty/l4=
|
||||
github.com/pion/sdp/v3 v3.0.13/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E=
|
||||
github.com/pion/srtp/v3 v3.0.5 h1:8XLB6Dt3QXkMkRFpoqC3314BemkpMQK2mZeJc4pUKqo=
|
||||
github.com/pion/srtp/v3 v3.0.5/go.mod h1:r1G7y5r1scZRLe2QJI/is+/O83W2d+JoEsuIexpw+uM=
|
||||
github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo=
|
||||
github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
|
||||
github.com/pion/srtp/v3 v3.0.8 h1:RjRrjcIeQsilPzxvdaElN0CpuQZdMvcl9VZ5UY9suUM=
|
||||
github.com/pion/srtp/v3 v3.0.8/go.mod h1:2Sq6YnDH7/UDCvkSoHSDNDeyBcFgWL0sAVycVbAsXFg=
|
||||
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
|
||||
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU=
|
||||
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
|
||||
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
|
||||
github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM=
|
||||
github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA=
|
||||
github.com/pion/webrtc/v4 v4.1.2 h1:mpuUo/EJ1zMNKGE79fAdYNFZBX790KE7kQQpLMjjR54=
|
||||
github.com/pion/webrtc/v4 v4.1.2/go.mod h1:xsCXiNAmMEjIdFxAYU0MbB3RwRieJsegSB2JZsGN+8U=
|
||||
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
|
||||
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc=
|
||||
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8=
|
||||
github.com/pion/webrtc/v4 v4.1.5 h1:hJqfKPdRAVcXV9rsg2xcCiuXuMJ38BLW/87GsYJUtUU=
|
||||
github.com/pion/webrtc/v4 v4.1.5/go.mod h1:vzHh7egVnZRgkK83lYzciWVszdDs759y3/eyu6AvZRA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
|
||||
127
pkg/codec/svtav1/bridge.h
Normal file
127
pkg/codec/svtav1/bridge.h
Normal file
@@ -0,0 +1,127 @@
|
||||
#include <EbSvtAv1.h>
|
||||
#include <EbSvtAv1Enc.h>
|
||||
#include <EbSvtAv1ErrorCodes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ERR_INIT_ENC_HANDLER 1
|
||||
#define ERR_SET_ENC_PARAM 2
|
||||
#define ERR_ENC_INIT 3
|
||||
#define ERR_SEND_PICTURE 4
|
||||
#define ERR_GET_PACKET 5
|
||||
|
||||
typedef struct Encoder {
|
||||
EbSvtAv1EncConfiguration *param;
|
||||
EbComponentType *handle;
|
||||
EbBufferHeaderType *in_buf;
|
||||
|
||||
bool force_keyframe;
|
||||
} Encoder;
|
||||
|
||||
int enc_free(Encoder *e) {
|
||||
free(e->in_buf->p_buffer);
|
||||
free(e->in_buf);
|
||||
free(e->param);
|
||||
free(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_new(Encoder **e) {
|
||||
*e = malloc(sizeof(Encoder));
|
||||
(*e)->param = malloc(sizeof(EbSvtAv1EncConfiguration));
|
||||
(*e)->in_buf = malloc(sizeof(EbBufferHeaderType));
|
||||
|
||||
memset((*e)->in_buf, 0, sizeof(EbBufferHeaderType));
|
||||
(*e)->in_buf->p_buffer = malloc(sizeof(EbSvtIOFormat));
|
||||
(*e)->in_buf->size = sizeof(EbBufferHeaderType);
|
||||
|
||||
#if SVT_AV1_CHECK_VERSION(3, 0, 0)
|
||||
const EbErrorType sret = svt_av1_enc_init_handle(&(*e)->handle, (*e)->param);
|
||||
#else
|
||||
const EbErrorType sret = svt_av1_enc_init_handle(&(*e)->handle, NULL, (*e)->param);
|
||||
#endif
|
||||
if (sret != EB_ErrorNone) {
|
||||
enc_free(*e);
|
||||
return ERR_INIT_ENC_HANDLER;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_init(Encoder *e) {
|
||||
EbErrorType sret;
|
||||
|
||||
e->param->encoder_bit_depth = 8;
|
||||
e->param->encoder_color_format = EB_YUV420;
|
||||
|
||||
sret = svt_av1_enc_set_parameter(e->handle, e->param);
|
||||
if (sret != EB_ErrorNone) {
|
||||
return ERR_SET_ENC_PARAM;
|
||||
}
|
||||
|
||||
sret = svt_av1_enc_init(e->handle);
|
||||
if (sret != EB_ErrorNone) {
|
||||
return ERR_ENC_INIT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_apply_param(Encoder *e) {
|
||||
const EbErrorType sret = svt_av1_enc_set_parameter(e->handle, e->param);
|
||||
if (sret != EB_ErrorNone) {
|
||||
return ERR_SET_ENC_PARAM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_force_keyframe(Encoder *e) {
|
||||
e->force_keyframe = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_send_frame(Encoder *e, uint8_t *y, uint8_t *cb, uint8_t *cr, int ystride, int cstride) {
|
||||
EbSvtIOFormat *in_data = (EbSvtIOFormat *)e->in_buf->p_buffer;
|
||||
in_data->luma = y;
|
||||
in_data->cb = cb;
|
||||
in_data->cr = cr;
|
||||
in_data->y_stride = ystride;
|
||||
in_data->cb_stride = cstride;
|
||||
in_data->cr_stride = cstride;
|
||||
|
||||
e->in_buf->pic_type = EB_AV1_INVALID_PICTURE; // auto
|
||||
if (e->force_keyframe) {
|
||||
e->in_buf->pic_type = EB_AV1_KEY_PICTURE;
|
||||
e->force_keyframe = false;
|
||||
}
|
||||
e->in_buf->flags = 0;
|
||||
e->in_buf->pts++;
|
||||
e->in_buf->n_filled_len = ystride * e->param->source_height;
|
||||
e->in_buf->n_filled_len += 2 * cstride * e->param->source_height / 2;
|
||||
|
||||
const EbErrorType sret = svt_av1_enc_send_picture(e->handle, e->in_buf);
|
||||
if (sret != EB_ErrorNone) {
|
||||
return ERR_SEND_PICTURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int enc_get_packet(Encoder *e, EbBufferHeaderType **out) {
|
||||
const EbErrorType sret = svt_av1_enc_get_packet(e->handle, out, 0);
|
||||
if (sret == EB_NoErrorEmptyQueue) {
|
||||
return 0;
|
||||
}
|
||||
if (sret != EB_ErrorNone) {
|
||||
return ERR_GET_PACKET;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void memcpy_uint8(uint8_t *dst, const uint8_t *src, size_t n) {
|
||||
// Just make CGO types compatible
|
||||
memcpy(dst, src, n);
|
||||
}
|
||||
14
pkg/codec/svtav1/errors.go
Normal file
14
pkg/codec/svtav1/errors.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package svtav1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrUnknownErrorCode = errors.New("unknown error code")
|
||||
ErrInitEncHandler = errors.New("failed to initialize encoder handler")
|
||||
ErrSetEncParam = errors.New("failed to set encoder parameters")
|
||||
ErrEncInit = errors.New("failed to initialize encoder")
|
||||
ErrSendPicture = errors.New("failed to send picture")
|
||||
ErrGetPacket = errors.New("failed to get packet")
|
||||
)
|
||||
47
pkg/codec/svtav1/params.go
Normal file
47
pkg/codec/svtav1/params.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package svtav1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/pion/mediadevices/pkg/codec"
|
||||
"github.com/pion/mediadevices/pkg/io/video"
|
||||
"github.com/pion/mediadevices/pkg/prop"
|
||||
)
|
||||
|
||||
// Params stores libx264 specific encoding parameters.
|
||||
type Params struct {
|
||||
codec.BaseParams
|
||||
|
||||
// Preset configuration number of SVT-AV1
|
||||
// 1-3: extremely high efficiency but heavy
|
||||
// 4-6: a balance of efficiency and reasonable compute time
|
||||
// 7-13: real-time encoding
|
||||
Preset int
|
||||
|
||||
StartingBufferLevel time.Duration
|
||||
OptimalBufferLevel time.Duration
|
||||
MaximumBufferSize time.Duration
|
||||
}
|
||||
|
||||
// NewParams returns default x264 codec specific parameters.
|
||||
func NewParams() (Params, error) {
|
||||
return Params{
|
||||
BaseParams: codec.BaseParams{
|
||||
KeyFrameInterval: 60,
|
||||
},
|
||||
Preset: 9,
|
||||
StartingBufferLevel: 400 * time.Millisecond,
|
||||
OptimalBufferLevel: 200 * time.Millisecond,
|
||||
MaximumBufferSize: 500 * time.Millisecond,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RTPCodec represents the codec metadata
|
||||
func (p *Params) RTPCodec() *codec.RTPCodec {
|
||||
return codec.NewRTPAV1Codec(90000)
|
||||
}
|
||||
|
||||
// BuildVideoEncoder builds x264 encoder with given params
|
||||
func (p *Params) BuildVideoEncoder(r video.Reader, property prop.Media) (codec.ReadCloser, error) {
|
||||
return newEncoder(r, property, *p)
|
||||
}
|
||||
184
pkg/codec/svtav1/svtav1.go
Normal file
184
pkg/codec/svtav1/svtav1.go
Normal file
@@ -0,0 +1,184 @@
|
||||
// Package svtav1 implements AV1 encoder.
|
||||
// This package requires libSvtAv1Enc headers and libraries to be built.
|
||||
package svtav1
|
||||
|
||||
// #cgo pkg-config: SvtAv1Enc
|
||||
// #include "bridge.h"
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"image"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/pion/mediadevices/pkg/codec"
|
||||
"github.com/pion/mediadevices/pkg/io/video"
|
||||
"github.com/pion/mediadevices/pkg/prop"
|
||||
)
|
||||
|
||||
type encoder struct {
|
||||
engine *C.Encoder
|
||||
r video.Reader
|
||||
mu sync.Mutex
|
||||
closed bool
|
||||
|
||||
outPool sync.Pool
|
||||
}
|
||||
|
||||
func newEncoder(r video.Reader, p prop.Media, params Params) (codec.ReadCloser, error) {
|
||||
var enc *C.Encoder
|
||||
|
||||
if p.FrameRate == 0 {
|
||||
p.FrameRate = 30
|
||||
}
|
||||
|
||||
if err := errFromC(C.enc_new(&enc)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
enc.param.source_width = C.uint32_t(p.Width)
|
||||
enc.param.source_height = C.uint32_t(p.Height)
|
||||
enc.param.profile = C.MAIN_PROFILE
|
||||
enc.param.enc_mode = C.int8_t(params.Preset)
|
||||
enc.param.rate_control_mode = C.SVT_AV1_RC_MODE_CBR
|
||||
enc.param.pred_structure = C.SVT_AV1_PRED_LOW_DELAY_B
|
||||
enc.param.target_bit_rate = C.uint32_t(params.BitRate)
|
||||
enc.param.frame_rate_numerator = C.uint32_t(p.FrameRate * 1000)
|
||||
enc.param.frame_rate_denominator = 1000
|
||||
enc.param.intra_refresh_type = C.SVT_AV1_KF_REFRESH
|
||||
enc.param.intra_period_length = C.int32_t(params.KeyFrameInterval)
|
||||
enc.param.starting_buffer_level_ms = C.int64_t(params.StartingBufferLevel.Milliseconds())
|
||||
enc.param.optimal_buffer_level_ms = C.int64_t(params.OptimalBufferLevel.Milliseconds())
|
||||
enc.param.maximum_buffer_size_ms = C.int64_t(params.MaximumBufferSize.Milliseconds())
|
||||
|
||||
if err := errFromC(C.enc_init(enc)); err != nil {
|
||||
_ = C.enc_free(enc)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
e := encoder{
|
||||
engine: enc,
|
||||
r: video.ToI420(r),
|
||||
outPool: sync.Pool{
|
||||
New: func() any {
|
||||
return []byte(nil)
|
||||
},
|
||||
},
|
||||
}
|
||||
return &e, nil
|
||||
}
|
||||
|
||||
func errFromC(ret C.int) error {
|
||||
switch ret {
|
||||
case 0:
|
||||
return nil
|
||||
case C.ERR_INIT_ENC_HANDLER:
|
||||
return ErrInitEncHandler
|
||||
case C.ERR_SET_ENC_PARAM:
|
||||
return ErrSetEncParam
|
||||
case C.ERR_ENC_INIT:
|
||||
return ErrEncInit
|
||||
case C.ERR_SEND_PICTURE:
|
||||
return ErrSendPicture
|
||||
case C.ERR_GET_PACKET:
|
||||
return ErrGetPacket
|
||||
default:
|
||||
return ErrUnknownErrorCode
|
||||
}
|
||||
}
|
||||
|
||||
func (e *encoder) Read() ([]byte, func(), error) {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
if e.closed {
|
||||
return nil, func() {}, io.EOF
|
||||
}
|
||||
|
||||
for {
|
||||
img, release, err := e.r.Read()
|
||||
if err != nil {
|
||||
return nil, func() {}, err
|
||||
}
|
||||
defer release()
|
||||
yuvImg := img.(*image.YCbCr)
|
||||
|
||||
if err := errFromC(C.enc_send_frame(
|
||||
e.engine,
|
||||
(*C.uchar)(&yuvImg.Y[0]),
|
||||
(*C.uchar)(&yuvImg.Cb[0]),
|
||||
(*C.uchar)(&yuvImg.Cr[0]),
|
||||
C.int(yuvImg.YStride),
|
||||
C.int(yuvImg.CStride),
|
||||
)); err != nil {
|
||||
return nil, func() {}, err
|
||||
}
|
||||
|
||||
var buf *C.EbBufferHeaderType
|
||||
if err := errFromC(C.enc_get_packet(e.engine, &buf)); err != nil {
|
||||
return nil, func() {}, err
|
||||
}
|
||||
if buf == nil {
|
||||
// Feed frames until receiving a packet
|
||||
continue
|
||||
}
|
||||
|
||||
n := int(buf.n_filled_len)
|
||||
outBuf := e.outPool.Get().([]byte)
|
||||
if cap(outBuf) < n {
|
||||
outBuf = make([]byte, n)
|
||||
} else {
|
||||
outBuf = outBuf[:n]
|
||||
}
|
||||
|
||||
C.memcpy_uint8((*C.uchar)(&outBuf[0]), buf.p_buffer, C.size_t(n))
|
||||
C.svt_av1_enc_release_out_buffer(&buf)
|
||||
|
||||
return outBuf, func() {
|
||||
e.outPool.Put(outBuf)
|
||||
}, err
|
||||
}
|
||||
}
|
||||
|
||||
func (e *encoder) ForceKeyFrame() error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
if err := errFromC(C.enc_force_keyframe(e.engine)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *encoder) SetBitRate(bitrate int) error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
e.engine.param.target_bit_rate = C.uint32_t(bitrate)
|
||||
|
||||
if err := errFromC(C.enc_apply_param(e.engine)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *encoder) Controller() codec.EncoderController {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *encoder) Close() error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
if e.closed {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := errFromC(C.enc_free(e.engine)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e.closed = true
|
||||
return nil
|
||||
}
|
||||
146
pkg/codec/svtav1/svtav1_test.go
Normal file
146
pkg/codec/svtav1/svtav1_test.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package svtav1
|
||||
|
||||
import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/pion/mediadevices/pkg/codec"
|
||||
"github.com/pion/mediadevices/pkg/codec/internal/codectest"
|
||||
"github.com/pion/mediadevices/pkg/frame"
|
||||
"github.com/pion/mediadevices/pkg/io/video"
|
||||
"github.com/pion/mediadevices/pkg/prop"
|
||||
)
|
||||
|
||||
func getTestVideoEncoder() (codec.ReadCloser, error) {
|
||||
p, err := NewParams()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.BitRate = 200000
|
||||
enc, err := p.BuildVideoEncoder(video.ReaderFunc(func() (image.Image, func(), error) {
|
||||
return image.NewYCbCr(
|
||||
image.Rect(0, 0, 256, 144),
|
||||
image.YCbCrSubsampleRatio420,
|
||||
), nil, nil
|
||||
}), prop.Media{
|
||||
Video: prop.Video{
|
||||
Width: 256,
|
||||
Height: 144,
|
||||
FrameFormat: frame.FormatI420,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return enc, nil
|
||||
}
|
||||
|
||||
func TestEncoder(t *testing.T) {
|
||||
t.Run("SimpleRead", func(t *testing.T) {
|
||||
p, err := NewParams()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.BitRate = 200000
|
||||
codectest.VideoEncoderSimpleReadTest(t, &p,
|
||||
prop.Media{
|
||||
Video: prop.Video{
|
||||
Width: 256,
|
||||
Height: 144,
|
||||
FrameFormat: frame.FormatI420,
|
||||
},
|
||||
},
|
||||
image.NewYCbCr(
|
||||
image.Rect(0, 0, 256, 144),
|
||||
image.YCbCrSubsampleRatio420,
|
||||
),
|
||||
)
|
||||
})
|
||||
t.Run("CloseTwice", func(t *testing.T) {
|
||||
p, err := NewParams()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.BitRate = 200000
|
||||
codectest.VideoEncoderCloseTwiceTest(t, &p, prop.Media{
|
||||
Video: prop.Video{
|
||||
Width: 640,
|
||||
Height: 480,
|
||||
FrameRate: 30,
|
||||
FrameFormat: frame.FormatI420,
|
||||
},
|
||||
})
|
||||
})
|
||||
t.Run("ReadAfterClose", func(t *testing.T) {
|
||||
p, err := NewParams()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.BitRate = 200000
|
||||
codectest.VideoEncoderReadAfterCloseTest(t, &p,
|
||||
prop.Media{
|
||||
Video: prop.Video{
|
||||
Width: 256,
|
||||
Height: 144,
|
||||
FrameFormat: frame.FormatI420,
|
||||
},
|
||||
},
|
||||
image.NewYCbCr(
|
||||
image.Rect(0, 0, 256, 144),
|
||||
image.YCbCrSubsampleRatio420,
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func TestShouldImplementKeyFrameControl(t *testing.T) {
|
||||
e := &encoder{}
|
||||
if _, ok := e.Controller().(codec.KeyFrameController); !ok {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoErrorOnForceKeyFrame(t *testing.T) {
|
||||
enc, err := getTestVideoEncoder()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kfc, ok := enc.Controller().(codec.KeyFrameController)
|
||||
if !ok {
|
||||
t.Fatal("Failed to get KeyFrameController")
|
||||
}
|
||||
if err := kfc.ForceKeyFrame(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, rel, err := enc.Read() // try to read the encoded frame
|
||||
rel()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldImplementBitRateControl(t *testing.T) {
|
||||
e := &encoder{}
|
||||
if _, ok := e.Controller().(codec.BitRateController); !ok {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoErrorOnSetBitRate(t *testing.T) {
|
||||
enc, err := getTestVideoEncoder()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
brc, ok := enc.Controller().(codec.BitRateController)
|
||||
if !ok {
|
||||
t.Fatal("Failed to get BitRateController")
|
||||
}
|
||||
if err := brc.SetBitRate(1000); err != nil { // 1000 bit/second is ridiculously low, but this is a testcase.
|
||||
t.Error(err)
|
||||
}
|
||||
_, rel, err := enc.Read() // try to read the encoded frame
|
||||
rel()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -86,10 +86,8 @@ func (p *Media) merge(o any, set setterFn) {
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: Replace this with fieldB.IsZero() when we move to go1.13
|
||||
// If non-boolean or non-discrete values are zeroes we skip them
|
||||
if fieldB.Interface() == reflect.Zero(fieldB.Type()).Interface() &&
|
||||
fieldB.Kind() != reflect.Bool {
|
||||
if fieldB.IsZero() && fieldB.Kind() != reflect.Bool {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user