Skip to content

Commit

Permalink
Merge branch 'master' into av1-sample-buffer-support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpokotilo authored Apr 15, 2024
2 parents 75ee6c6 + 74a9dc7 commit 59359f2
Show file tree
Hide file tree
Showing 21 changed files with 1,232 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

name: Generate Authors

name: API
on:
pull_request:

jobs:
generate:
uses: pion/.goassets/.github/workflows/generate-authors.reusable.yml@master
secrets:
token: ${{ secrets.PIONBOT_PRIVATE_KEY }}
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
Expand Up @@ -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
Expand Up @@ -23,21 +23,23 @@ jobs:
uses: pion/.goassets/.github/workflows/test.reusable.yml@master
strategy:
matrix:
go: ['1.20', '1.19'] # auto-update/supported-go-version-list
go: ["1.22", "1.21"] # 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.20', '1.19'] # auto-update/supported-go-version-list
go: ["1.22", "1.21"] # 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.22" # 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
Expand Up @@ -22,4 +22,4 @@ jobs:
tidy:
uses: pion/.goassets/.github/workflows/tidy-check.reusable.yml@master
with:
go-version: '1.20' # auto-update/latest-go-version
go-version: "1.22" # auto-update/latest-go-version
26 changes: 7 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

linters-settings:
govet:
check-shadowing: true
enable:
- shadow
misspell:
locale: US
exhaustive:
Expand All @@ -29,7 +30,6 @@ linters:
- bodyclose # checks whether HTTP response body is closed successfully
- contextcheck # check the function whether use a non-inherited context
- decorder # check declaration order and count of types, constants, variables and functions
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- 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
Expand Down Expand Up @@ -63,7 +63,6 @@ linters:
- importas # Enforces consistent import aliases
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
- nakedret # Finds naked returns in functions greater than a specified function length
- 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.
- noctx # noctx finds sending http request without context.Context
Expand All @@ -81,6 +80,7 @@ linters:
- 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
Expand All @@ -94,6 +94,7 @@ linters:
- 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
- nolintlint # Reports ill-formed or insufficient nolint directives
Expand All @@ -110,28 +111,15 @@ linters:

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

# Allow complex main function in examples
- path: examples
text: "of func `main` is high"
linters:
- gocognit

# Allow forbidden identifiers in examples
- path: examples
linters:
- forbidigo

# Allow forbidden identifiers in CLI commands
- 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
Expand Up @@ -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

Expand Down
45 changes: 0 additions & 45 deletions AUTHORS.txt

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We are always looking to support **your projects**. Please reach out if you have
If you need commercial support or don't want to use public methods you can contact us at [[email protected]](mailto:[email protected])

### Contributing
Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible: [AUTHORS.txt](./AUTHORS.txt)
Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible

### License
MIT License - see [LICENSE](LICENSE) for full text
MIT License - see [LICENSE](LICENSE) for full text
16 changes: 16 additions & 0 deletions abscapturetimeextension.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ func (t AbsCaptureTimeExtension) EstimatedCaptureClockOffsetDuration() *time.Dur
return nil
}
offset := *t.EstimatedCaptureClockOffset
negative := false
if offset < 0 {
offset = -offset
negative = true
}
duration := time.Duration(offset/(1<<32))*time.Second + time.Duration((offset&0xFFFFFFFF)*1e9/(1<<32))*time.Nanosecond
if negative {
duration = -duration
}
return &duration
}

Expand All @@ -80,9 +88,17 @@ func NewAbsCaptureTimeExtension(captureTime time.Time) *AbsCaptureTimeExtension
// NewAbsCaptureTimeExtensionWithCaptureClockOffset makes new AbsCaptureTimeExtension from time.Time and a clock offset.
func NewAbsCaptureTimeExtensionWithCaptureClockOffset(captureTime time.Time, captureClockOffset time.Duration) *AbsCaptureTimeExtension {
ns := captureClockOffset.Nanoseconds()
negative := false
if ns < 0 {
ns = -ns
negative = true
}
lsb := (ns / 1e9) & 0xFFFFFFFF
msb := (((ns % 1e9) * (1 << 32)) / 1e9) & 0xFFFFFFFF
offset := (lsb << 32) | msb
if negative {
offset = -offset
}
return &AbsCaptureTimeExtension{
Timestamp: toNtpTime(captureTime),
EstimatedCaptureClockOffset: &offset,
Expand Down
106 changes: 73 additions & 33 deletions abscapturetimeextension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,78 @@ import (
)

func TestAbsCaptureTimeExtension_Roundtrip(t *testing.T) {
t0 := time.Now()
e1 := NewAbsCaptureTimeExtension(t0)
b1, err1 := e1.Marshal()
if err1 != nil {
t.Fatal(err1)
}
var o1 AbsCaptureTimeExtension
if err := o1.Unmarshal(b1); err != nil {
t.Fatal(err)
}
dt1 := o1.CaptureTime().Sub(t0).Seconds()
if dt1 < -0.001 || dt1 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o1.CaptureTime(), dt1)
}
if o1.EstimatedCaptureClockOffsetDuration() != nil {
t.Fatalf("duration differs, want nil got %d", o1.EstimatedCaptureClockOffsetDuration())
}
t.Run("positive captureClockOffset", func(t *testing.T) {
t0 := time.Now()
e1 := NewAbsCaptureTimeExtension(t0)
b1, err1 := e1.Marshal()
if err1 != nil {
t.Fatal(err1)
}
var o1 AbsCaptureTimeExtension
if err := o1.Unmarshal(b1); err != nil {
t.Fatal(err)
}
dt1 := o1.CaptureTime().Sub(t0).Seconds()
if dt1 < -0.001 || dt1 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o1.CaptureTime(), dt1)
}
if o1.EstimatedCaptureClockOffsetDuration() != nil {
t.Fatalf("duration differs, want nil got %d", o1.EstimatedCaptureClockOffsetDuration())
}

e2 := NewAbsCaptureTimeExtensionWithCaptureClockOffset(t0, 1250*time.Millisecond)
b2, err2 := e2.Marshal()
if err2 != nil {
t.Fatal(err2)
}
var o2 AbsCaptureTimeExtension
if err := o2.Unmarshal(b2); err != nil {
t.Fatal(err)
}
dt2 := o1.CaptureTime().Sub(t0).Seconds()
if dt2 < -0.001 || dt2 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o2.CaptureTime(), dt2)
}
if *o2.EstimatedCaptureClockOffsetDuration() != 1250*time.Millisecond {
t.Fatalf("duration differs, want 250ms got %d", *o2.EstimatedCaptureClockOffsetDuration())
}
e2 := NewAbsCaptureTimeExtensionWithCaptureClockOffset(t0, 1250*time.Millisecond)
b2, err2 := e2.Marshal()
if err2 != nil {
t.Fatal(err2)
}
var o2 AbsCaptureTimeExtension
if err := o2.Unmarshal(b2); err != nil {
t.Fatal(err)
}
dt2 := o1.CaptureTime().Sub(t0).Seconds()
if dt2 < -0.001 || dt2 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o2.CaptureTime(), dt2)
}
if *o2.EstimatedCaptureClockOffsetDuration() != 1250*time.Millisecond {
t.Fatalf("duration differs, want 250ms got %d", *o2.EstimatedCaptureClockOffsetDuration())
}
})

// This test can verify the for for the issue 247
t.Run("negative captureClockOffset", func(t *testing.T) {
t0 := time.Now()
e1 := NewAbsCaptureTimeExtension(t0)
b1, err1 := e1.Marshal()
if err1 != nil {
t.Fatal(err1)
}
var o1 AbsCaptureTimeExtension
if err := o1.Unmarshal(b1); err != nil {
t.Fatal(err)
}
dt1 := o1.CaptureTime().Sub(t0).Seconds()
if dt1 < -0.001 || dt1 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o1.CaptureTime(), dt1)
}
if o1.EstimatedCaptureClockOffsetDuration() != nil {
t.Fatalf("duration differs, want nil got %d", o1.EstimatedCaptureClockOffsetDuration())
}

e2 := NewAbsCaptureTimeExtensionWithCaptureClockOffset(t0, -250*time.Millisecond)
b2, err2 := e2.Marshal()
if err2 != nil {
t.Fatal(err2)
}
var o2 AbsCaptureTimeExtension
if err := o2.Unmarshal(b2); err != nil {
t.Fatal(err)
}
dt2 := o1.CaptureTime().Sub(t0).Seconds()
if dt2 < -0.001 || dt2 > 0.001 {
t.Fatalf("timestamp differs, want %v got %v (dt=%f)", t0, o2.CaptureTime(), dt2)
}
if *o2.EstimatedCaptureClockOffsetDuration() != -250*time.Millisecond {
t.Fatalf("duration differs, want -250ms got %v", *o2.EstimatedCaptureClockOffsetDuration())
}
})
}
16 changes: 16 additions & 0 deletions codecs/av1/obu/leb128.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,19 @@ func SizeLeb128(leb128 uint) uint {
}
return 1
}

// WriteToLeb128 writes a uint to a LEB128 encoded byte slice.
func WriteToLeb128(in uint) []byte {
b := make([]byte, 10)

for i := 0; i < len(b); i++ {
b[i] = byte(in & 0x7f)
in >>= 7
if in == 0 {
return b[:i+1]
}
b[i] |= 0x80
}

return b // unreachable
}
Loading

0 comments on commit 59359f2

Please sign in to comment.