Skip to content

Commit

Permalink
Send full candidate in message
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb9696 committed Nov 6, 2024
1 parent 9b69d2e commit bb727bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:8123/",
"webRoot": "${workspaceFolder}/hass_frontend",
//"webRoot": "${workspaceFolder}/hass_frontend",
"disableNetworkCache": true,
"preLaunchTask": "Develop Frontend",
"outFiles": ["${workspaceFolder}/hass_frontend/frontend_latest/*.js"]
"preLaunchTask": "Develop Frontend"
//"outFiles": ["${workspaceFolder}/hass_frontend/frontend_latest/*.js"]
},
{
"name": "Debug Gallery",
Expand Down
14 changes: 3 additions & 11 deletions src/components/ha-web-rtc-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,11 @@ class HaWebRtcPlayer extends LitElement {
if (event.type === "session") {
this._sessionId = event.session_id;
this._candidatesList.forEach((candidate) =>
// sdpMLineIndex is always populated
addWebRtcCandidate(
this.hass,
this.entityid!,
event.session_id,
candidate.candidate,
candidate.sdpMLineIndex || 0
candidate
)
);
this._candidatesList = [];
Expand All @@ -269,10 +267,7 @@ class HaWebRtcPlayer extends LitElement {

try {
await this._peerConnection?.addIceCandidate(
new RTCIceCandidate({
candidate: event.candidate,
sdpMLineIndex: event.sdp_m_line_index,
})
new RTCIceCandidate(event.candidate)
);
} catch (err: any) {
// eslint-disable-next-line no-console
Expand All @@ -297,14 +292,11 @@ class HaWebRtcPlayer extends LitElement {
);

if (this._sessionId) {
// sdpMLineIndex is always populated
const sdpMLineIndex = event.candidate?.sdpMLineIndex || 0;
addWebRtcCandidate(
this.hass,
this.entityid,
this._sessionId,
event.candidate?.candidate,
sdpMLineIndex
event.candidate
);
} else {
this._candidatesList.push(event.candidate);
Expand Down
7 changes: 2 additions & 5 deletions src/data/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export interface WebRtcAnswer {

export interface WebRtcCandidate {
type: "candidate";
candidate: string;
sdp_m_line_index: number;
candidate: RTCIceCandidate;
}

export interface WebRtcError {
Expand Down Expand Up @@ -140,15 +139,13 @@ export const addWebRtcCandidate = (
hass: HomeAssistant,
entity_id: string,
session_id: string,
candidate: string,
sdpMLineIndex: number
candidate: RTCIceCandidate
) =>
hass.callWS({
type: "camera/webrtc/candidate",
entity_id,
session_id,
candidate: candidate,
sdp_m_line_index: sdpMLineIndex,
});

export const fetchCameraPrefs = (hass: HomeAssistant, entityId: string) =>
Expand Down

0 comments on commit bb727bd

Please sign in to comment.