-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add WebRTC stream player #10193
Add WebRTC stream player #10193
Conversation
src/components/ha-web-rtc-player.ts
Outdated
|
||
video { | ||
width: 100%; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block defaults to width: 100%;
video { | |
width: 100%; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually is not a no-op -- however, i am ok with starting over on the CSS given it doesn't render vertical video right yet. When taking this away, the video get wider than the dialog. (I think the default video quality is pretty massive.) hls and the camera itself also have a similar block for what its worth.
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
Also, i'll take a pass at applying these suggestions to the existing hls camera where this was copied from. Thank you. |
src/components/ha-camera-stream.ts
Outdated
supportsFeature(this.stateObj, CAMERA_SUPPORT_STREAM) && | ||
this.stateObj.attributes.stream_type === STREAM_TYPE_WEB_RTC | ||
) { | ||
if (typeof RTCPeerConnection === "undefined") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fallback to mjpeg in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The only flaw I find here is that this basically makes it a silent failure. In the case of nest webrtc for example, mjpeg isn't supported so it just sends an image which doesn't end up loading leaving an empty dialog box.
Perhaps in a follow up PR I can add an onerror
for the image load. Then display the series of errors (web rtc not supported, failed to fetch stream url, failed to load mjpeg url). Is that a worthwhile improvement/idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
Breaking change
Proposed change
Add support for playing WebRTC Streams, initially motivated by Nest Battery Camera / Doorbell.
This is an implementation of home-assistant/architecture#640
This introduces a new element
ha-web-rtc-player
that is used by theha-camera-stream
element for cameras ofstream_type
forSTREAM_TYPE_WEB_RTC
.The stream is initiated by creating a
RTCPeerConnection
which creates anoffer
. This is passed down to core, where the integration is asked to pass theoffer
to the remote device via a signaling path, and the response is ananswer
which contains information for how the javascript client can connect to the remote device. See https://webrtc.org/getting-started/peer-connections for additional detail on establishing a connection. In the specific case of a nest camera, this translates to a GenerateWebRtcStream RPC against the API.Once a connection is established, the remote tracks are added to the local
MediaStream
for playback. See https://webrtc.org/getting-started/remote-streams for more detail. Nest cameras require a data channel, however, it does not appear to actually communicate any information at the moment.Overall tasks I have planned:
Support for
nest
WebRTC is tracked in home-assistant/core#55302Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: