-
Notifications
You must be signed in to change notification settings - Fork 41
fix: slow rampup on vp9/h264 codec #2056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d8e4f7
set start bitrate as 1000
santhoshvai f53251f
clear comment
santhoshvai 49d4e3b
add test and address reviews
santhoshvai 4f908ab
target specific mid
santhoshvai a91e6ea
fix test
santhoshvai c861d6f
remove map
santhoshvai c7dbea9
Merge branch 'main' into start-bitrate-test
santhoshvai d132aa1
simplification
santhoshvai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/client/src/rtc/helpers/__tests__/sdp.startBitrate.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { setStartBitrate } from '../sdp'; | ||
|
|
||
| describe('sdp - setStartBitrate', () => { | ||
| it('adds x-google-start-bitrate for AV1/VP9/H264 fmtp lines (but not VP8)', () => { | ||
| const offerSdp = `v=0 | ||
| o=- 123 2 IN IP4 127.0.0.1 | ||
| s=- | ||
| t=0 0 | ||
| m=video 9 UDP/TLS/RTP/SAVPF 96 98 103 45 | ||
| c=IN IP4 0.0.0.0 | ||
| a=mid:0 | ||
| a=rtpmap:96 VP8/90000 | ||
| a=rtpmap:98 VP9/90000 | ||
| a=fmtp:98 profile-id=0 | ||
| a=rtpmap:103 H264/90000 | ||
| a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f | ||
| a=rtpmap:45 AV1/90000 | ||
| a=fmtp:45 level-idx=5;profile=0;tier=0 | ||
| `; | ||
|
|
||
| const result = setStartBitrate(offerSdp, 1500, 0.5, '0'); // 750kbps | ||
|
|
||
| expect(result).toContain( | ||
| 'a=fmtp:98 profile-id=0;x-google-start-bitrate=750', | ||
| ); | ||
| expect(result).toContain( | ||
| 'a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-start-bitrate=750', | ||
| ); | ||
| expect(result).toContain( | ||
| 'a=fmtp:45 level-idx=5;profile=0;tier=0;x-google-start-bitrate=750', | ||
| ); | ||
|
|
||
| // VP8 is not a target codec | ||
| expect(result).not.toContain('a=fmtp:96'); | ||
| expect(result).not.toContain( | ||
| 'a=rtpmap:96 VP8/90000;x-google-start-bitrate', | ||
| ); | ||
| }); | ||
|
|
||
| it('does not add x-google-start-bitrate if already present', () => { | ||
| const offerSdp = `v=0 | ||
| o=- 123 2 IN IP4 127.0.0.1 | ||
| s=- | ||
| t=0 0 | ||
| m=video 9 UDP/TLS/RTP/SAVPF 103 | ||
| c=IN IP4 0.0.0.0 | ||
| a=mid:0 | ||
| a=rtpmap:103 H264/90000 | ||
| a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-start-bitrate=500 | ||
| `; | ||
|
|
||
| const result = setStartBitrate(offerSdp, 1500, 0.9, '0'); | ||
| expect(result).toContain('x-google-start-bitrate=500'); | ||
| expect(result).not.toContain('x-google-start-bitrate=1350'); | ||
|
|
||
| // Ensure it's only present once | ||
| expect(result.match(/x-google-start-bitrate/g)).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('clamps computed start bitrate to a minimum of 300kbps', () => { | ||
| const offerSdp = `v=0 | ||
| o=- 123 2 IN IP4 127.0.0.1 | ||
| s=- | ||
| t=0 0 | ||
| m=video 9 UDP/TLS/RTP/SAVPF 98 | ||
| c=IN IP4 0.0.0.0 | ||
| a=mid:0 | ||
| a=rtpmap:98 VP9/90000 | ||
| a=fmtp:98 profile-id=0 | ||
| `; | ||
|
|
||
| const result = setStartBitrate(offerSdp, 1500, 0.1, '0'); // 150 -> clamped to 300 | ||
| expect(result).toContain( | ||
| 'a=fmtp:98 profile-id=0;x-google-start-bitrate=300', | ||
| ); | ||
| }); | ||
|
|
||
| it('can scope the change to a specific mid', () => { | ||
| const offerSdp = `v=0 | ||
| o=- 123 2 IN IP4 127.0.0.1 | ||
| s=- | ||
| t=0 0 | ||
| m=video 9 UDP/TLS/RTP/SAVPF 98 | ||
| c=IN IP4 0.0.0.0 | ||
| a=mid:0 | ||
| a=rtpmap:98 VP9/90000 | ||
| a=fmtp:98 profile-id=0 | ||
| m=video 9 UDP/TLS/RTP/SAVPF 103 | ||
| c=IN IP4 0.0.0.0 | ||
| a=mid:1 | ||
| a=rtpmap:103 H264/90000 | ||
| a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f | ||
| `; | ||
|
|
||
| const result = setStartBitrate(offerSdp, 1500, 0.7, '0'); // 1050kbps | ||
|
|
||
| // mid:0 updated | ||
| expect(result).toContain( | ||
| 'a=fmtp:98 profile-id=0;x-google-start-bitrate=1050', | ||
| ); | ||
|
|
||
| // mid:1 untouched | ||
| expect(result).toContain( | ||
| 'a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f', | ||
| ); | ||
| expect(result).not.toContain( | ||
| 'a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-start-bitrate=1050', | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.