Skip to content

Commit

Permalink
Add support for IS-04/IS-05 Senders
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-recoseanu committed Feb 12, 2025
1 parent 2503438 commit 1ffd12b
Show file tree
Hide file tree
Showing 10 changed files with 760 additions and 8 deletions.
29 changes: 28 additions & 1 deletion code/src/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export class Configuration implements IConfiguration
public node_id: string;
public device_id: string;
public receiver_id: string;
public source_id: string;
public flow_id: string;
public sender_id: string;
public address: string;
public port: number;
public base_label: string;
Expand All @@ -30,6 +33,9 @@ export class Configuration implements IConfiguration
this.node_id = config.node_id;
this.device_id = config.device_id;
this.receiver_id = config.receiver_id;
this.source_id = config.source_id;
this.flow_id = config.flow_id;
this.sender_id = config.sender_id;
this.base_label = config.base_label;
this.address = config.address;
this.port = config.port;
Expand Down Expand Up @@ -71,6 +77,24 @@ export class Configuration implements IConfiguration
shouldWriteConfig = true;
}

if(this.source_id == null)
{
this.source_id = uuidv4().toString();
shouldWriteConfig = true;
}

if(this.flow_id == null)
{
this.flow_id = uuidv4().toString();
shouldWriteConfig = true;
}

if(this.sender_id == null)
{
this.sender_id = uuidv4().toString();
shouldWriteConfig = true;
}

if(shouldWriteConfig)
this.WriteConfig();
}
Expand Down Expand Up @@ -101,7 +125,7 @@ export class Configuration implements IConfiguration

if(this.function == null)
{
this.function = "UHD Decoder";
this.function = "UHD Encoder/Decoder";
shouldWriteConfig = true;
}

Expand Down Expand Up @@ -137,6 +161,9 @@ export interface IConfiguration
node_id: string;
device_id: string;
receiver_id: string;
source_id: string;
flow_id: string;
sender_id: string;
address: string;
port: number;
base_label: string;
Expand Down
49 changes: 49 additions & 0 deletions code/src/NmosDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { NmosResource } from './NmosResource';
import { NmosReceiverActiveRtp } from './NmosReceiverActiveRtp';
import { NmosReceiverVideo } from './NmosReceiverVideo';
import { RegistrationClient } from './RegistrationClient';
import { NmosSender } from './NmosSender';
import { NmosSenderActiveRtp } from './NmosSenderActiveRtp';
import { NmosSenderVideo } from './NmosSenderVideo';

export class NmosDevice extends NmosResource
{
Expand All @@ -29,6 +32,9 @@ export class NmosDevice extends NmosResource
@jsonIgnore()
public receiverObjects: NmosReceiverCore[];

@jsonIgnore()
public senderObjects: NmosSender[];

public constructor(
id: string,
node_id: string,
Expand Down Expand Up @@ -58,6 +64,7 @@ export class NmosDevice extends NmosResource
};

this.receiverObjects = [];
this.senderObjects = [];

this.receivers = [];
this.senders = [];
Expand Down Expand Up @@ -112,6 +119,48 @@ export class NmosDevice extends NmosResource
return uris;
}

public AddSender(sender: NmosSender)
{
this.senderObjects.push(sender);
this.senders.push(sender.id);
}

public FindSender(id: string) : boolean
{
let sender = this.senders.find(e => e === id);
if(sender === undefined)
return false;
else
return true;
}

public FetchSender(id: string)
{
return this.senderObjects.find(e => e.id === id);
}

public FetchSenders() {
return this.senderObjects;
}

public ChangeSenderSettings(id: string, settings: NmosSenderActiveRtp)
{
let sender = this.senderObjects.find(e => e.id === id);
if(sender)
(sender as NmosSenderVideo).ChangeSenderSettings(settings);
}

public FetchSendersUris()
{
let uris: string[] = [];

this.senders.forEach( (senderId) => {
uris.push(`${senderId}/`);
});

return uris;
}

public ToJson()
{
return JSON.stringify(this, jsonIgnoreReplacer);
Expand Down
43 changes: 43 additions & 0 deletions code/src/NmosFlow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { jsonIgnoreReplacer } from "json-ignore";
import { NmosResource } from "./NmosResource";
import { RegistrationClient } from "./RegistrationClient";

export class NmosFlow extends NmosResource
{
public source_id: string;
public device_id: string;
public parents: string[];
public grain_rate: object;

public constructor(
id: string,
source_id: string,
device_id: string,
base_label: string,
parents: string[],
grain_rate_numerator: number,
grain_rate_denominator: number,
registrationClient: RegistrationClient)
{
super(id, `${base_label} flow`, registrationClient);

this.source_id = source_id;
this.device_id = device_id;
this.parents = parents;
this.grain_rate = {
"numerator": grain_rate_numerator,
"denominator": grain_rate_denominator
};
this.tags = {};
}

public ToJson()
{
return JSON.stringify(this, jsonIgnoreReplacer);
}

public ToJsonArray()
{
return JSON.stringify([this], jsonIgnoreReplacer);
}
}
50 changes: 50 additions & 0 deletions code/src/NmosFlowVideo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { jsonIgnoreReplacer } from "json-ignore";
import { RegistrationClient } from "./RegistrationClient";
import { NmosFlow } from "./NmosFlow";

export class NmosFlowVideo extends NmosFlow
{
public format: string;
public frame_width: number;
public frame_height: number;
public colorspace: string;
public interlace_mode: string;
public transfer_characteristic: string;
public media_type: string;
public components: object[];

public constructor(
id: string,
source_id: string,
device_id: string,
label: string,
parents: string[],
grain_rate_numerator: number,
grain_rate_denominator: number,
format: string,
frame_width: number,
frame_height: number,
colorspace: string,
interlace_mode: string,
transfer_characteristic: string,
media_type: string,
components: object[],
registrationClient: RegistrationClient)
{
super(id, source_id, device_id, label, parents, grain_rate_numerator, grain_rate_denominator, registrationClient);

this.format = format;
this.frame_width = frame_width;
this.frame_height = frame_height;
this.colorspace = colorspace;
this.interlace_mode = interlace_mode;
this.transfer_characteristic = transfer_characteristic;
this.media_type = media_type;
this.components = components;
}

public ToJson()
{
return JSON.stringify(this, jsonIgnoreReplacer);
}
}
99 changes: 99 additions & 0 deletions code/src/NmosSender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { jsonIgnore, jsonIgnoreReplacer } from "json-ignore";
import { NmosResource } from "./NmosResource";
import { RegistrationClient } from "./RegistrationClient";
import { NmosActivation, TransportParamsSet } from "./NmosReceiverCore";

export abstract class NmosSender extends NmosResource
{
public flow_id: string;
public device_id: string;
public transport: string;
public interface_bindings: string[];
public subscription: object;
public manifest_href: string;

@jsonIgnore()
public constraints: object[];

@jsonIgnore()
public active: NmosSenderActive | null;

@jsonIgnore()
public staged: NmosSenderActive | null;

public caps: object;

public constructor(
id: string,
flow_id: string,
device_id: string,
base_label: string,
transport: string,
manifest_href: string,
registrationClient: RegistrationClient)
{
super(id, `${base_label} sender`, registrationClient);

this.flow_id = flow_id;
this.device_id = device_id;
this.transport = transport;
this.interface_bindings = [ 'eth0' ];
this.manifest_href = manifest_href;
this.subscription = {
"receiver_id": null,
"active": true
};
this.tags = {};
this.caps = {};

this.active = null;
this.staged = null;
this.constraints = [];
}

public ToJson()
{
return JSON.stringify(this, jsonIgnoreReplacer);
}

public FetchTransportType()
{
let split = this.transport.split('.');
split.pop();
return split.join('.');
}

public abstract FetchActive() : NmosSenderActive | null;

public abstract FetchStaged() : NmosSenderActive | null;

public abstract FetchConstraints() : object | null;

public abstract FetchSdp(): string | null;
}

export abstract class NmosSenderActive
{
public receiver_id: string | null;
public master_enable: boolean;
public activation: NmosActivation;

public transport_params: TransportParamsSet[] | null

public constructor(
receiver_id: string | null,
master_enable: boolean,
activation: NmosActivation,
transport_params: TransportParamsSet[])
{
this.receiver_id = receiver_id;
this.master_enable = master_enable;
this.activation = activation;
this.transport_params = transport_params;
}

public ToJson()
{
return JSON.stringify(this, jsonIgnoreReplacer);
}
}
Loading

0 comments on commit 1ffd12b

Please sign in to comment.