Skip to content

Commit

Permalink
reolink: Add zoom RTSP streams to trackmix cameras (#1635)
Browse files Browse the repository at this point in the history
* Add zoom RTSP streams to trackmix cameras

* update rtmp streams for POE TrackMix (#1)

* update rtmp streams for POE TrackMix

Fixing resolution of main streams too for Trackmix.

* leave in legacy bcs stream

* flv streams removed

* autotrack bcs stream restored

* additional rtsp streams added only to channel 0

---------

Co-authored-by: Gianluca Ruocco <[email protected]>
Co-authored-by: Joshua Seidel <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2024
1 parent c3148b8 commit 4a51caa
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions plugins/reolink/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ class ReolinkCamera extends RtspSmartCamera implements Camera, DeviceProvider, R
this.console.error("Codec query failed. Falling back to known defaults.", e);
}

const channel = (this.getRtspChannel() + 1).toString().padStart(2, '0');
const rtspChannel = this.getRtspChannel();
const channel = (rtspChannel + 1).toString().padStart(2, '0');

const streams: UrlMediaStreamOptions[] = [
{
Expand Down Expand Up @@ -691,7 +692,7 @@ class ReolinkCamera extends RtspSmartCamera implements Camera, DeviceProvider, R
// 1: support main/extern/sub stream
// 2: support main/sub stream

const live = this.storageSettings.values.abilities?.value?.Ability?.abilityChn?.[this.getRtspChannel()].live?.ver;
const live = this.storageSettings.values.abilities?.value?.Ability?.abilityChn?.[rtspChannel].live?.ver;
const [rtmpMain, rtmpExt, rtmpSub, rtspMain, rtspSub] = streams;
streams.splice(0, streams.length);

Expand All @@ -700,7 +701,7 @@ class ReolinkCamera extends RtspSmartCamera implements Camera, DeviceProvider, R
// 1: main stream enc type is H265

// anecdotally, encoders of type h265 do not have a working RTMP main stream.
const mainEncType = this.storageSettings.values.abilities?.value?.Ability?.abilityChn?.[this.getRtspChannel()].mainEncType?.ver;
const mainEncType = this.storageSettings.values.abilities?.value?.Ability?.abilityChn?.[rtspChannel].mainEncType?.ver;

if (live === 2) {
if (mainEncType === 1) {
Expand All @@ -718,22 +719,45 @@ class ReolinkCamera extends RtspSmartCamera implements Camera, DeviceProvider, R
}


if (deviceInfo?.model == "Reolink TrackMix PoE") {
// https://github.com/starkillerOG/reolink_aio/blob/main/reolink_aio/api.py#L93C1-L97C2
// single motion models have 2*2 RTSP channels
if (deviceInfo?.model &&
[
"Reolink TrackMix PoE",
"Reolink TrackMix WiFi",
"RLC-81MA"
].includes(deviceInfo?.model)) {
streams.push({
name: '',
id: 'autotrack.bcs',
container: 'rtmp',
video: { width: 896, height: 512 },
url: '',
});

if (rtspChannel === 0) {
streams.push({
name: '',
id: `h264Preview_02_main`,
container: 'rtsp',
video: { codec: 'h264', width: 3840, height: 2160 },
url: ''
}, {
name: '',
id: `h264Preview_02_sub`,
container: 'rtsp',
video: { codec: 'h264', width: 640, height: 480 },
url: ''
})
}
}

for (const stream of streams) {
var streamUrl;
if (stream.container === 'rtmp') {
streamUrl = new URL(`rtmp://${this.getRtmpAddress()}/bcs/channel${this.getRtspChannel()}_${stream.id}`)
streamUrl = new URL(`rtmp://${this.getRtmpAddress()}/bcs/channel${rtspChannel}_${stream.id}`)
const params = streamUrl.searchParams;
params.set("channel", this.getRtspChannel().toString())
params.set("channel", rtspChannel.toString())
params.set("stream", '0')
stream.url = streamUrl.toString();
stream.name = `RTMP ${stream.id}`;
Expand Down

0 comments on commit 4a51caa

Please sign in to comment.