-
Notifications
You must be signed in to change notification settings - Fork 30
[ts-sdk] Added stats handle #1827
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
Open
JBRS307
wants to merge
17
commits into
master
Choose a base branch
from
@jbrs/ts-sdk-stats
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
68a4052
Added api `stats()` method
JBRS307 fe6a260
Added `.stats()` method to `Smelter` class
JBRS307 33bb685
Added `Smelter.stats()` wrappers to packages
JBRS307 6c1fdab
Added `JsonSchema` trait to stats reports
JBRS307 a7d2fb5
Added `StatsReport` to `api.types` json schema
JBRS307 23de1d8
Regenerated ts api types from new schema
JBRS307 b144b7e
WIP: Adding types to ts-sdk stats
JBRS307 a691672
Added types for output stats
JBRS307 008bac9
Correct imports in `smelter-node`, output types added to `stats.ts`
JBRS307 75dd486
Added `StatsReport` type
JBRS307 184a3ac
`StatsResponse` is now typed with `StatsReport`
JBRS307 b6d2ca5
Correct type for rtp input fields
JBRS307 84ef2fd
Removed stats endpoint from wasm
JBRS307 f397a39
WIP: test example
JBRS307 52fe41a
Converting stats from api to ts type
JBRS307 8039dfd
Restored examples to match `origin/master`
JBRS307 b68e669
Small modification of `.claude`
JBRS307 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
Some comments aren't visible on the classic Files Changed page.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,62 @@ | ||
| import type { Api, StatsReport, InputStatsReport, OutputStatsReport } from '@swmansion/smelter'; | ||
| import { | ||
| fromApiRtpInputStats, | ||
| fromApiWhipInputStats, | ||
| fromApiWhepInputStats, | ||
| fromApiHlsInputStats, | ||
| fromApiRtmpInputStats, | ||
| fromApiMp4InputStats, | ||
| } from './stats/inputs.js'; | ||
| import { | ||
| fromApiWhepOutputStats, | ||
| fromApiWhipOutputStats, | ||
| fromApiHlsOutputStats, | ||
| fromApiMp4OutputStats, | ||
| fromApiRtmpOutputStats, | ||
| fromApiRtpOutputStats, | ||
| } from './stats/outputs.js'; | ||
|
|
||
| export function fromApiStatsReport(report: Api.StatsReport): StatsReport { | ||
| return { | ||
| inputs: Object.fromEntries( | ||
| Object.entries(report.inputs).map(([id, input]) => [id, fromApiInputStatsReport(input)]) | ||
| ), | ||
| outputs: Object.fromEntries( | ||
| Object.entries(report.outputs).map(([id, output]) => [id, fromApiOutputStatsReport(output)]) | ||
| ), | ||
| }; | ||
| } | ||
|
|
||
| function fromApiInputStatsReport(report: Api.InputStatsReport): InputStatsReport { | ||
| if ('rtp' in report) { | ||
| return { rtp: fromApiRtpInputStats(report.rtp) }; | ||
| } else if ('whip' in report) { | ||
| return { whip: fromApiWhipInputStats(report.whip) }; | ||
| } else if ('whep' in report) { | ||
| return { whep: fromApiWhepInputStats(report.whep) }; | ||
| } else if ('hls' in report) { | ||
| return { hls: fromApiHlsInputStats(report.hls) }; | ||
| } else if ('rtmp' in report) { | ||
| return { rtmp: fromApiRtmpInputStats(report.rtmp) }; | ||
| } else if ('mp4' in report) { | ||
| return { mp4: fromApiMp4InputStats(report.mp4) }; | ||
| } | ||
| throw new Error(`Unknown input stats report type: ${JSON.stringify(report)}`); | ||
| } | ||
|
|
||
| function fromApiOutputStatsReport(report: Api.OutputStatsReport): OutputStatsReport { | ||
| if ('whep' in report) { | ||
| return { whep: fromApiWhepOutputStats(report.whep) }; | ||
| } else if ('whip' in report) { | ||
| return { whip: fromApiWhipOutputStats(report.whip) }; | ||
| } else if ('hls' in report) { | ||
| return { hls: fromApiHlsOutputStats(report.hls) }; | ||
| } else if ('mp4' in report) { | ||
| return { mp4: fromApiMp4OutputStats(report.mp4) }; | ||
| } else if ('rtmp' in report) { | ||
| return { rtmp: fromApiRtmpOutputStats(report.rtmp) }; | ||
| } else if ('rtp' in report) { | ||
| return { rtp: fromApiRtpOutputStats(report.rtp) }; | ||
| } | ||
| throw new Error(`Unknown output stats report type: ${JSON.stringify(report)}`); | ||
| } |
Oops, something went wrong.
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.