Skip to content

Add two-way audio to the WebRTC camera player#4994

Draft
bgoncal wants to merge 2 commits into
mainfrom
2wayaudio
Draft

Add two-way audio to the WebRTC camera player#4994
bgoncal wants to merge 2 commits into
mainfrom
2wayaudio

Conversation

@bgoncal

@bgoncal bgoncal commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Adds two-way audio to the in-app WebRTC camera player. A mic toggle appears in the player when the camera reports the TWO_WAY_AUDIO feature, enabling it adds a local microphone track and renegotiates the session via camera/webrtc/re_offer.

Depends on backend support from home-assistant/core#148282.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Copilot AI review requested due to automatic review settings July 8, 2026 21:13
@bgoncal bgoncal changed the title Add two-way audio (talkback) to the WebRTC camera player Add two-way audio to the WebRTC camera player Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ Unused L10n strings detected

Found 2 unused localization strings in the codebase.

Click to see details
Parsing Strings.swift...
Found 1881 L10n strings

Reading all Swift source code...
Read 6359687 characters of Swift code

Checking for unused strings...
Checked 100/1881 strings...
Checked 200/1881 strings...
Checked 300/1881 strings...
Checked 400/1881 strings...
Checked 500/1881 strings...
Checked 600/1881 strings...
Checked 700/1881 strings...
Checked 800/1881 strings...
Checked 900/1881 strings...
Checked 1000/1881 strings...
Checked 1100/1881 strings...
Checked 1200/1881 strings...
Checked 1300/1881 strings...
Checked 1400/1881 strings...
Checked 1500/1881 strings...
Checked 1600/1881 strings...
Checked 1700/1881 strings...
Checked 1800/1881 strings...

================================================================================
UNUSED STRINGS REPORT
================================================================================

Found 2 unused strings:


CONNECTION:
  - L10n.Connection.Permission.InternalUrl.body1
    Key: connection.permission.internal_url.body1
    Line: 1370
  - L10n.Connection.Permission.InternalUrl.body2
    Key: connection.permission.internal_url.body2
    Line: 1372

================================================================================
Total unused: 2
================================================================================

================================================================================
Copy-paste these keys into the "Lokalise: Delete Keys" workflow (keys input):
================================================================================
connection.permission.internal_url.body1,connection.permission.internal_url.body2

To remove them, run the
Lokalise: Delete Keys
workflow — it deletes the keys from Lokalise and opens a PR removing them from
Localizable.strings and regenerating Strings.swift. Copy-paste these keys into the keys input:

connection.permission.internal_url.body1,connection.permission.internal_url.body2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two-way audio (“talkback”) support to the in-app WebRTC camera player by introducing a microphone toggle (when supported by the camera entity) and renegotiating the WebRTC session using camera/webrtc/re_offer.

Changes:

  • Adds localized strings and SwiftGen accessors for talkback UI labels and microphone-permission messaging.
  • Extends the WebRTC player/view model to detect talkback support, request microphone permission, and trigger WebRTC re-offer renegotiation.
  • Updates WebRTCClient to support an optional local microphone track and to preserve mute state when remote audio tracks change.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Sources/Shared/Resources/Swiftgen/Strings.swift Adds SwiftGen accessors for new talkback localization keys.
Sources/App/Resources/en.lproj/Localizable.strings Adds English strings for talkback labels and microphone-denied messaging.
Sources/App/Cameras/CameraPlayer/WebRTC/WebRTCViewPlayerViewModel.swift Implements talkback state, mic permission request, and re-offer signaling handling.
Sources/App/Cameras/CameraPlayer/WebRTC/WebRTCVideoPlayerView.swift Adds mic toggle to the player toolbar (shown only when talkback is supported).
Sources/App/Cameras/CameraPlayer/WebRTC/WebRTCClient.swift Adds optional microphone-track support and separates playback vs recording peer-connection factories.

Comment thread Sources/App/Cameras/CameraPlayer/WebRTC/WebRTCViewPlayerViewModel.swift Outdated
Comment thread Sources/App/Cameras/CameraPlayer/WebRTC/WebRTCClient.swift
@bgoncal bgoncal marked this pull request as draft July 8, 2026 21:34
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@912126e). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4994   +/-   ##
=======================================
  Coverage        ?   52.01%           
=======================================
  Files           ?      299           
  Lines           ?    19656           
  Branches        ?        0           
=======================================
  Hits            ?    10225           
  Misses          ?     9431           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal bgoncal changed the base branch from main to camera-player-enhancements July 9, 2026 09:50
Base automatically changed from camera-player-enhancements to main July 9, 2026 10:34
bgoncal added 2 commits July 9, 2026 12:37
Flips on the talkback UI shipped hidden in the camera-player UI PR:
- WebRTCClient: recording-capable audio factory + mic track, setMicrophoneEnabled,
  playAndRecord/videoChat audio session, and audio-session release on closeConnection.
- ViewModel: detect TWO_WAY_AUDIO via supported_features (connection.caches.states),
  connect with/without talkback, request mic permission, real toggleTalkback, onClientReady.
- ViewController: attach the video renderer once the client is created (async).
Reset the process-wide RTCAudioSessionConfiguration back to playback and
deactivate the session on closeConnection, so a talkback session's
playAndRecord/videoChat configuration no longer persists to later WebRTC
playback sessions. Talkback-capable cameras re-arm it on connect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants