ring-client-api
Version:
Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting
47 lines (46 loc) • 1.27 kB
JavaScript
import { generateUuid } from "../util.js";
function liveViewUrl(path) {
return `https://api.ring.com/integrations/v1/liveview/${path}`;
}
export class SimpleWebRtcSession {
sessionId = generateUuid();
camera;
restClient;
constructor(camera, restClient) {
this.camera = camera;
this.restClient = restClient;
}
async start(sdp) {
const response = await this.restClient.request({
method: 'POST',
url: liveViewUrl('start'),
json: {
session_id: this.sessionId,
device_id: this.camera.id,
sdp,
protocol: 'webrtc',
},
});
return response.sdp;
}
async end() {
const resp = await this.restClient.request({
method: 'POST',
url: liveViewUrl('end'),
json: {
session_id: this.sessionId,
},
});
return resp;
}
async activateCameraSpeaker() {
await this.restClient.request({
method: 'PATCH',
url: liveViewUrl('options'),
json: {
session_id: this.sessionId,
actions: ['turn_off_stealth_mode'],
},
});
}
}