Skip to content

Commit f76974a

Browse files
committed
Remove bridged cameras (#1552)
1 parent 2b801e0 commit f76974a

File tree

8 files changed

+65
-144
lines changed

8 files changed

+65
-144
lines changed

.changeset/afraid-waves-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'homebridge-ring': major
3+
---
4+
5+
Removed bridged cameras. If you already had `unbridgeCameras: true` in your config, this change will not affect you. For those who were still using bridged cameras, you will need to manually add each camera to HomeKit after upgrading. This change allows us to stop requiring special builds of ffmpeg and should make video streaming more reliable. Unbridge cameras are also avoid blocking the whole bridge while waiting for requests (e.g. Snapshot), which leads to a better overall experience. After updating, you can delete the `unbridgeCameras` option from your config.

packages/homebridge-ring/README.md

Lines changed: 22 additions & 23 deletions
Large diffs are not rendered by default.

packages/homebridge-ring/camera-source.ts

Lines changed: 32 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,6 @@ class StreamingSessionWrapper {
7272
videoSplitter = new RtpSplitter()
7373
repacketizeAudioSplitter = new RtpSplitter()
7474

75-
libfdkAacInstalledPromise = doesFfmpegSupportCodec(
76-
'libfdk_aac',
77-
getFfmpegPath(),
78-
)
79-
.then((supported) => {
80-
if (!supported) {
81-
logError(
82-
'Streaming video only - found ffmpeg, but libfdk_aac is not installed. See https://github.com/dgreif/ring/wiki/FFmpeg for details.',
83-
)
84-
}
85-
return supported
86-
})
87-
.catch(() => {
88-
logError(
89-
'Streaming video only - ffmpeg was not found. See https://github.com/dgreif/ring/wiki/FFmpeg for details.',
90-
)
91-
return false
92-
})
93-
9475
constructor(
9576
public streamingSession: StreamingSession,
9677
public prepareStreamRequest: PrepareStreamRequest,
@@ -262,38 +243,19 @@ class StreamingSessionWrapper {
262243
}),
263244
)
264245

265-
const shouldTranscodeAudio = await this.libfdkAacInstalledPromise
266-
if (!shouldTranscodeAudio) {
267-
return this.streamingSession.requestKeyFrame()
268-
}
269-
270246
const transcodingPromise = this.streamingSession.startTranscoding({
271247
input: ['-vn'],
272248
audio: [
273249
'-map',
274250
'0:a',
275251

276-
...(request.audio.codec === AudioStreamingCodecType.OPUS
277-
? [
278-
// OPUS specific - it works, but audio is very choppy
279-
'-acodec',
280-
'libopus',
281-
'-frame_duration',
282-
request.audio.packet_time,
283-
'-application',
284-
'lowdelay',
285-
]
286-
: [
287-
// AAC-eld specific
288-
'-acodec',
289-
'libfdk_aac',
290-
'-profile:a',
291-
'aac_eld',
292-
'-eld_sbr:a',
293-
'1',
294-
'-eld_v2',
295-
'1',
296-
]),
252+
// OPUS specific - it works, but audio is very choppy
253+
'-acodec',
254+
'libopus',
255+
'-frame_duration',
256+
request.audio.packet_time,
257+
'-application',
258+
'lowdelay',
297259

298260
// Shared options
299261
'-flags',
@@ -337,7 +299,6 @@ class StreamingSessionWrapper {
337299

338300
return null
339301
}),
340-
isRingUsingOpus = await this.streamingSession.isUsingOpus,
341302
returnAudioTranscoder = new ReturnAudioTranscoder({
342303
prepareStreamRequest: this.prepareStreamRequest,
343304
startStreamRequest: request,
@@ -347,19 +308,15 @@ class StreamingSessionWrapper {
347308
},
348309
outputArgs: [
349310
'-acodec',
350-
...(isRingUsingOpus
351-
? [
352-
'libopus',
353-
'-ac',
354-
'1',
355-
'-ar',
356-
'24k',
357-
'-b:a',
358-
'24k',
359-
'-application',
360-
'lowdelay',
361-
]
362-
: ['pcm_mulaw', '-ac', 1, '-ar', '8k']),
311+
'libopus',
312+
'-ac',
313+
'1',
314+
'-ar',
315+
'24k',
316+
'-b:a',
317+
'24k',
318+
'-application',
319+
'lowdelay',
363320
'-flags',
364321
'+global_header',
365322
'-f',
@@ -398,10 +355,7 @@ export class CameraSource implements CameraStreamingDelegate {
398355
private sessions: { [sessionKey: string]: StreamingSessionWrapper } = {}
399356
private cachedSnapshot?: Buffer
400357

401-
constructor(
402-
private ringCamera: RingCamera,
403-
private useOpus = false,
404-
) {
358+
constructor(private ringCamera: RingCamera) {
405359
this.controller = new hap.CameraController({
406360
cameraStreamCount: 10,
407361
delegate: this,
@@ -425,28 +379,21 @@ export class CameraSource implements CameraStreamingDelegate {
425379
},
426380
},
427381
audio: {
428-
codecs: this.useOpus
429-
? [
430-
{
431-
type: AudioStreamingCodecType.OPUS,
432-
// required by watch
433-
samplerate: AudioStreamingSamplerate.KHZ_8,
434-
},
435-
{
436-
type: AudioStreamingCodecType.OPUS,
437-
samplerate: AudioStreamingSamplerate.KHZ_16,
438-
},
439-
{
440-
type: AudioStreamingCodecType.OPUS,
441-
samplerate: AudioStreamingSamplerate.KHZ_24,
442-
},
443-
]
444-
: [
445-
{
446-
type: AudioStreamingCodecType.AAC_ELD,
447-
samplerate: AudioStreamingSamplerate.KHZ_16,
448-
},
449-
],
382+
codecs: [
383+
{
384+
type: AudioStreamingCodecType.OPUS,
385+
// required by watch
386+
samplerate: AudioStreamingSamplerate.KHZ_8,
387+
},
388+
{
389+
type: AudioStreamingCodecType.OPUS,
390+
samplerate: AudioStreamingSamplerate.KHZ_16,
391+
},
392+
{
393+
type: AudioStreamingCodecType.OPUS,
394+
samplerate: AudioStreamingSamplerate.KHZ_24,
395+
},
396+
],
450397
},
451398
},
452399
})

packages/homebridge-ring/camera.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export class Camera extends BaseDataAccessory<RingCamera> {
2020
) {
2121
super()
2222

23-
this.cameraSource = new CameraSource(
24-
this.device,
25-
this.config.unbridgeCameras,
26-
)
23+
this.cameraSource = new CameraSource(this.device)
2724

2825
if (!hap.CameraController) {
2926
const error =

packages/homebridge-ring/config.schema.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
"description": "Click \"Generate New Refresh Token\" above to change accounts or if your refresh token has expired",
1717
"placeholder": "Refresh Token"
1818
},
19-
"unbridgeCameras": {
20-
"title": "Unbridge Cameras",
21-
"type": "boolean",
22-
"description": "If enabled, all Ring Cameras we be treated as external accessories, which generally leads to better performance. This means they each need to be individually added to HomeKit. This option will be enabled by default in the next major release. WARNING: If your cameras are already bridged, they will be deleted from HomeKit when you enable this option, and you will need to reconfigure any associated automations or HomeKit settings"
23-
},
2419
"alarmOnEntryDelay": {
2520
"title": "Alarm on Entry Delay",
2621
"type": "boolean",
@@ -157,7 +152,6 @@
157152
"title": "Optional Configuration",
158153
"expandable": true,
159154
"items": [
160-
"unbridgeCameras",
161155
"alarmOnEntryDelay",
162156
"hideLightGroups",
163157
"hideDoorbellSwitch",

packages/homebridge-ring/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface RingPlatformConfig extends RingApiOptions {
2222
nightModeBypassFor: AlarmMode
2323
onlyDeviceTypes?: string[]
2424
showPanicButtons?: boolean
25-
unbridgeCameras?: boolean
2625
disableLogs?: boolean
2726
}
2827

packages/homebridge-ring/ring-platform.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ export class RingPlatform implements DynamicPlatformPlugin {
211211
platformAccessories: PlatformAccessory[] = [],
212212
externalAccessories: PlatformAccessory[] = [],
213213
activeAccessoryIds: string[] = []
214-
let hasBridgedCameras = false
215214

216215
logInfo('Found the following locations:')
217216

@@ -286,8 +285,7 @@ export class RingPlatform implements DynamicPlatformPlugin {
286285
hapDevices.forEach(
287286
({ deviceType, device, isCamera, id, name, AccessoryClass }) => {
288287
const uuid = hap.uuid.generate(debugPrefix + id),
289-
displayName = debugPrefix + name,
290-
isExternalCamera = isCamera && this.config.unbridgeCameras
288+
displayName = debugPrefix + name
291289

292290
if (
293291
!AccessoryClass ||
@@ -302,7 +300,7 @@ export class RingPlatform implements DynamicPlatformPlugin {
302300
return
303301
}
304302

305-
if (isExternalCamera && this.homebridgeAccessories[uuid]) {
303+
if (isCamera && this.homebridgeAccessories[uuid]) {
306304
// Camera was previously bridged. Remove it from the platform so that it can be added as an external accessory
307305
this.log.warn(
308306
`Camera ${displayName} was previously bridged. You will need to manually pair it as a new accessory.`,
@@ -322,7 +320,7 @@ export class RingPlatform implements DynamicPlatformPlugin {
322320
: hap.Categories.SECURITY_SYSTEM,
323321
)
324322

325-
if (isExternalCamera) {
323+
if (isCamera) {
326324
logInfo(
327325
`Configured camera ${uuid} ${deviceType} ${displayName}`,
328326
)
@@ -334,17 +332,6 @@ export class RingPlatform implements DynamicPlatformPlugin {
334332
platformAccessories.push(accessory)
335333
}
336334

337-
if (
338-
isCamera &&
339-
!isExternalCamera &&
340-
typeof hap.Accessory.cleanupAccessoryData === 'function'
341-
) {
342-
// This is a one-time cleanup that will remove persist files for old external accessories from unbridged cameras
343-
hap.Accessory.cleanupAccessoryData(
344-
generateMacAddress(accessory.UUID),
345-
)
346-
}
347-
348335
return accessory
349336
},
350337
homebridgeAccessory =
@@ -358,8 +345,6 @@ export class RingPlatform implements DynamicPlatformPlugin {
358345

359346
this.homebridgeAccessories[uuid] = homebridgeAccessory
360347
activeAccessoryIds.push(uuid)
361-
362-
hasBridgedCameras ||= isCamera && !isExternalCamera
363348
},
364349
)
365350
}),
@@ -406,11 +391,5 @@ export class RingPlatform implements DynamicPlatformPlugin {
406391
})
407392
},
408393
)
409-
410-
if (hasBridgedCameras) {
411-
logError(
412-
'Bridged camera support will be removed in the next major release of homebridge-ring. Please enable the unbridgeCameras option in your configuration and add the individual cameras to HomeKit to prepare for this change.',
413-
)
414-
}
415394
}
416395
}

packages/ring-client-api/ring-camera.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { SocketTicketResponse, RingCameraKind } from './ring-types.ts'
1+
import type { SocketTicketResponse } from './ring-types.ts'
2+
import { RingCameraKind } from './ring-types.ts'
23
import {
34
type CameraData,
45
type CameraDeviceSettingsData,

0 commit comments

Comments
 (0)