{"id":20321347,"url":"https://github.com/dolbyio/web-webrtc-stats","last_synced_at":"2025-04-11T19:09:46.265Z","repository":{"id":125603679,"uuid":"601142673","full_name":"DolbyIO/web-webrtc-stats","owner":"DolbyIO","description":"Dolby.io WebRTC statistics parser","archived":false,"fork":false,"pushed_at":"2025-04-10T17:12:10.000Z","size":178,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-10T18:49:47.197Z","etag":null,"topics":["dolbyio","javascript","statistics","typescript","webrtc"],"latest_commit_sha":null,"homepage":"https://api-references.dolby.io/web-webrtc-stats/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DolbyIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-13T13:09:48.000Z","updated_at":"2025-04-10T17:11:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2da8acb-7fd0-48fb-8e2f-98e7f81b808e","html_url":"https://github.com/DolbyIO/web-webrtc-stats","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DolbyIO%2Fweb-webrtc-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DolbyIO%2Fweb-webrtc-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DolbyIO%2Fweb-webrtc-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DolbyIO%2Fweb-webrtc-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DolbyIO","download_url":"https://codeload.github.com/DolbyIO/web-webrtc-stats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465343,"owners_count":21108244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dolbyio","javascript","statistics","typescript","webrtc"],"created_at":"2024-11-14T19:14:15.642Z","updated_at":"2025-04-11T19:09:46.259Z","avatar_url":"https://github.com/DolbyIO.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Package](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/build-package.yml/badge.svg)](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/build-package.yml)\n[![Build Documentation](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/build-documentation.yml/badge.svg)](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/build-documentation.yml)\n[![Publish Package](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/publish-package.yml/badge.svg)](https://github.com/DolbyIO/web-webrtc-stats/actions/workflows/publish-package.yml)\n[![npm](https://img.shields.io/npm/v/@dolbyio/webrtc-stats)](https://www.npmjs.com/package/@dolbyio/webrtc-stats)\n[![License](https://img.shields.io/github/license/DolbyIO/web-webrtc-stats)](LICENSE)\n\n# Dolby.io WebRTC Statistics\n\nThis project is a library to use to parse WebRTC statistics.\n\n## Install this project\n\nRun the following npm command to install the package `@dolbyio/webrtc-stats` into your project:\n\n```bash\nnpm install @dolbyio/webrtc-stats\n```\n\n## Use the library\n\n### Collection\n\nA `WebRTCStats` object needs to be created to start a WebRTC statistics collection. It requires some settings to configure how you want the collection to work. First, import the `WebRTCStats` definition.\n\n```ts\nimport { WebRTCStats } from '@dolbyio/webrtc-stats';\n```\n\nCreate the collection object like this example:\n\n```ts\nconst collection = new WebRTCStats({\n    getStats: () =\u003e {\n        // Get the raw WebRTC statistics from the web browser\n    },\n    getStatsInterval: 1000,\n    includeRawStats: true,\n});\n```\n\nStart the collection with the `start()` function.\n\n```ts\ncollection.start();\n```\n\nStop the collection with the `stop()` function.\n\n```ts\ncollection.stop();\n```\n\n### Events\n\nAfter starting the collection, the `stats` event is triggered when the WebRTC statistics have been collected and parsed.\n\n```ts\nimport { OnStats } from '@dolbyio/webrtc-stats';\n\ncollection.on('stats', (event: OnStats) =\u003e {\n    console.log(event);\n});\n```\n\nThe `error` event is triggered when an error happens during the collection or the parsing of the WebRTC statistics.\n\n```ts\ncollection.on('error', (reason: string) =\u003e {\n    console.error(reason);\n});\n```\n\n### Example\n\nExample on how to start a statistics collection from the [Dolby OptiView](https://docs.optiview.dolby.com/millicast/) SDK.\n\n```ts\nimport { WebRTCStats, OnStats } from '@dolbyio/webrtc-stats';\nimport { Director, Publish } from '@millicast/sdk';\n\nconst PUBLISHER_TOKEN = '';\nconst STREAM_NAME = '';\n\nconst tokenGenerator = () =\u003e\n    Director.getPublisher({\n        token: PUBLISHER_TOKEN,\n        streamName: STREAM_NAME,\n    });\n\nconst publisher = new Publish(STREAM_NAME, tokenGenerator);\n\n// HERE: Publish a stream to Dolby OptiView\n\nconst collection = new WebRTCStats({\n    getStatsInterval: 1000,\n    getStats: () =\u003e {\n        return publisher.webRTCPeer.getRTCPeer().getStats();\n    },\n});\n\n// The stats event is triggered after each interval has elapsed\ncollection.on('stats', (event: OnStats) =\u003e {\n    console.log(event);\n});\n\n// Start the statistics collection\ncollection.start();\n```\n\n## Logs\n\nYou can also print the logs in the console and select the log level by using the following code.\n\n```ts\nimport { Logger } from '@dolbyio/webrtc-stats';\n\nLogger.useDefaults({\n    defaultLevel: Logger.TRACE,\n});\n```\n\n## How to\n\nRun tests:\n\n```bash\nnpm run test\n```\n\nCreate distribution package:\n\n```bash\nnpm run build\n```\n\nThe documentation is built on [TypeDoc](https://typedoc.org), to generate the doc, run the following command. You will find the HTML files in the `docs` folder.\n\n```bash\nnpm run docs\n```\n\n## Related Projects\n\n- [Millicast SDK](https://github.com/millicast/millicast-sdk)\n- [js-logger](https://github.com/jonnyreeves/js-logger)\n- [TypeDoc](https://typedoc.org)\n- [Jest](https://jestjs.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolbyio%2Fweb-webrtc-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdolbyio%2Fweb-webrtc-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdolbyio%2Fweb-webrtc-stats/lists"}