Add better support for handling device capabilities and receiver objects

This commit is contained in:
hensm
2022-04-17 07:49:01 +01:00
parent 1da709eb5e
commit b672b8d722
13 changed files with 159 additions and 77 deletions

View File

@@ -27,13 +27,15 @@ export default class Remote extends CastClient {
constructor(private host: string, private options?: CastRemoteOptions) {
super();
super.connect(host, {
onReceiverMessage: message => {
this.onReceiverMessage(message);
}
}).then(() => {
this.sendReceiverMessage({ type: "GET_STATUS" });
});
super
.connect(host, {
onReceiverMessage: message => {
this.onReceiverMessage(message);
}
})
.then(() => {
this.sendReceiverMessage({ type: "GET_STATUS" });
});
}
disconnect() {

View File

@@ -16,6 +16,8 @@ interface CastRecord {
md: string;
// Friendly name (user-visible)
fn: string;
// Capabilities
ca: string;
// Version (?)
ve: string;
// Icon path (?)
@@ -23,7 +25,6 @@ interface CastRecord {
cd: string;
rm: string;
ca: string;
st: string;
bs: string;
nf: string;
@@ -71,16 +72,18 @@ browser.on("serviceUp", service => {
const record = service.txtRecord as CastRecord;
const device: ReceiverDevice = {
id: record.id,
friendlyName: record.fn,
modelName: record.md,
capabilities: parseInt(record.ca),
host: service.addresses[0],
port: service.port,
id: service.name,
friendlyName: record.fn
port: service.port
};
sendMessage({
subject: "main:receiverDeviceUp",
data: {
deviceId: service.name,
deviceId: device.id,
deviceInfo: device
}
});

View File

@@ -7,10 +7,21 @@ import {
Volume
} from "./components/cast/types";
export enum ReceiverDeviceCapabilities {
NONE = 0,
VIDEO_OUT = 1,
VIDEO_IN = 2,
AUDIO_OUT = 4,
AUDIO_IN = 8,
MULTIZONE_GROUP = 32
}
export interface ReceiverDevice {
host: string;
friendlyName: string;
id: string;
friendlyName: string;
modelName: string;
capabilities: ReceiverDeviceCapabilities;
host: string;
port: number;
status?: ReceiverStatus;
}