core
core copied to clipboard
Add async webrtc offer support
Breaking change
Proposed change
Until now, the WebRTC was synced, which means the front end needs to get all candidates upfront. This can take up to 40 seconds. Therefore, this PR adds the async approach.
The Camera Entity will be extended with the following functions, which integrations can overwrite it:
async_handle_webrtc_offer: Async webrtc offer with offer, session id and send_message callbackasync_on_webrtc_candidate: with session ID and candidate. The frontend will call it with any candidate coming in after the offer is sent.close_webrtc_session: The frontend will call it when the stream is closed. Can be used to clean up things.
The synced approach is not deprecated and will be deprecated in a follow-up PR.
As the frontend needs to know if it needs to get candidates upfront or not, the WebRTCClientConfiguration was extended to have a boolean for it.
The CameraWebRTCProvider was refactored to support only the async approach. For integrations that are using the async_register_rtsp_to_web_rtc_provider automatically, a synced (legacy) Provider is created, and they will continue to work without any issues.
The first integration, go2rtc, is implementing the async offer approach and can be used as a guide for other integrations. For the async approach, a dependency bump was required, which cannot be split out due to breaking changes.
Changes: https://github.com/home-assistant-libs/python-go2rtc-client/compare/0.0.1b0...0.0.1b1
Type of change
- [x] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request: https://github.com/home-assistant/developers.home-assistant/pull/2409
Checklist
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. Your PR cannot be merged unless tests pass
- [ ] There is no commented out code in this PR.
- [ ] I have followed the development checklist
- [ ] I have followed the perfect PR recommendations
- [ ] The code has been formatted using Ruff (
ruff format homeassistant tests) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (camera) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of camera can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign cameraRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (websocket_api) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of websocket_api can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign websocket_apiRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (go2rtc) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of go2rtc can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign go2rtcRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Test failure unrelated
Until there is a frontend linked, please use the frontend branch async-webrtc
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
Some tests need updating.
It would be nice to allow entering a go2rtc URL even when running through docker, for Frigate users, for example.
@felipecrs This PR does not change anything in the go2rtc config flow, and therefore, your comment is offtopic. Anyways, the config flow will be removed in https://github.com/home-assistant/core/pull/129020
Indeed my comment is off-topic, but the PRs where this conversation would be relevant were locked. Anyway, thanks for pointing to https://github.com/home-assistant/core/pull/129020.
@felipecrs Please don't comment on PRs with off-topic topics only because the relevant PRs are locked in the future
frontend pr is approved
Waiting on this architecture discussion: https://github.com/home-assistant/architecture/discussions/1165
We also need to rebase here.
We need to rebase again.
We need to rebase again.
🎉
Waiting on this architecture discussion: home-assistant/architecture#1165
We also need to rebase here.
It's approved and we can merge it :D
package_constraints.txt was missed to be updated. Ok, see a PR has been made to fix it.