Skip to content

Commit

Permalink
Allow to select from publishing RTMP and SRT streams
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Jan 19, 2024
1 parent 42013ec commit d74438e
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 27 deletions.
33 changes: 33 additions & 0 deletions src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,39 @@ class API {
expect: 'json',
});
}

async RTMPChannels() {
const res = await this._GET('/v3/rtmp', {
expect: 'json',
});

if (res.err !== null) {
return res;
}

res.val = res.val.map((f) => f.name);

return res;
}

async SRTChannels() {
const res = await this._GET('/v3/srt', {
expect: 'json',
});

if (res.err !== null) {
return res;
}

const val = res.val;
res.val = [];

for (let path in val.publisher) {
res.val.push(path);
}

return res;
}
}

export default API;
50 changes: 50 additions & 0 deletions src/utils/restreamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,26 @@ class Restreamer {
}
}

let channels = (await this.ListRTMPChannels()).map((name) => {
return {
media: 'rtmp',
id: name,
name: name,
};
});

skills.sources['network'].push(...channels);

channels = (await this.ListSRTChannels()).map((name) => {
return {
media: 'srt',
id: name,
name: name,
};
});

skills.sources['network'].push(...channels);

this.skills = skills;
}

Expand Down Expand Up @@ -2773,6 +2793,18 @@ class Restreamer {
return data;
}

// RTMP

async ListRTMPChannels() {
return await this._listRTMPChannels();
}

// SRT

async ListSRTChannels() {
return await this._listSRTChannels();
}

// Expert Mode

IsExpert() {
Expand Down Expand Up @@ -3268,6 +3300,24 @@ class Restreamer {
return val.map((f) => f.name);
}

async _listRTMPChannels() {
const [val, err] = await this._call(this.api.RTMPChannels);
if (err !== null) {
return [];
}

return val;
}

async _listSRTChannels() {
const [val, err] = await this._call(this.api.SRTChannels);
if (err !== null) {
return [];
}

return val;
}

async _getAboutDebug() {
const about = await this.About();

Expand Down
Loading

0 comments on commit d74438e

Please sign in to comment.