2022-12-16 17:30:06 +00:00
|
|
|
class IVban {
|
2022-10-27 21:20:03 +01:00
|
|
|
[int32]$index
|
2023-08-12 03:09:23 +01:00
|
|
|
[Object]$remote
|
2022-10-27 21:20:03 +01:00
|
|
|
[string]$direction
|
2021-05-11 19:09:57 +01:00
|
|
|
|
2023-08-12 03:09:23 +01:00
|
|
|
IVban ([int]$index, [Object]$remote, [string]$direction) {
|
2022-10-27 21:20:03 +01:00
|
|
|
$this.index = $index
|
2023-08-12 03:09:23 +01:00
|
|
|
$this.remote = $remote
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.direction = $direction
|
|
|
|
}
|
|
|
|
|
|
|
|
[string] identifier () {
|
|
|
|
return "vban." + $this.direction + "stream[" + $this.index + "]"
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[string] ToString() {
|
|
|
|
return $this.GetType().Name + $this.index
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:30:06 +00:00
|
|
|
[single] Getter ($param) {
|
2023-08-12 03:09:23 +01:00
|
|
|
return $this.remote.Getter("$($this.identifier()).$param")
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:30:06 +00:00
|
|
|
[string] Getter_String ($param) {
|
2023-08-12 03:09:23 +01:00
|
|
|
return $this.remote.Getter_String("$($this.identifier()).$param")
|
2022-01-19 21:52:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:30:06 +00:00
|
|
|
[void] Setter ($param, $val) {
|
2023-08-12 03:09:23 +01:00
|
|
|
$this.remote.Setter("$($this.identifier()).$param", $val)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
2022-12-16 17:30:06 +00:00
|
|
|
}
|
2021-05-11 19:09:57 +01:00
|
|
|
|
2022-12-16 17:30:06 +00:00
|
|
|
class Vban : IVban {
|
2023-08-12 03:09:23 +01:00
|
|
|
Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hidden $_on = $($this | Add-Member ScriptProperty 'on' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('on')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([bool]$arg)
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._on = $this.Setter('on', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_name = $($this | Add-Member ScriptProperty 'name' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter_String('name')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([string]$arg)
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._name = $this.Setter('name', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_ip = $($this | Add-Member ScriptProperty 'ip' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter_String('ip')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([string]$arg)
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._ip = $this.Setter('ip', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_port = $($this | Add-Member ScriptProperty 'port' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('port')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([string]$arg)
|
|
|
|
if ($arg -in 1024..65535) {
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._port = $this.Setter('port', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected value from 1024 to 65535')
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('sr')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([int]$arg)
|
|
|
|
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
|
2021-05-11 19:09:57 +01:00
|
|
|
else {
|
|
|
|
$opts = @(11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
|
2022-06-25 15:20:36 +01:00
|
|
|
if ($opts.Contains($arg)) {
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._port = $this.Setter('sr', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected one of', $opts)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_channel = $($this | Add-Member ScriptProperty 'channel' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('channel')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([int]$arg)
|
|
|
|
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
|
2021-05-11 19:09:57 +01:00
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
if ($arg -in 1..8) {
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._channel = $this.Setter('channel', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected value from 1 to 8')
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_bit = $($this | Add-Member ScriptProperty 'bit' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$val = if ($this.Getter('bit') -eq 1) { 16 } else { 24 }
|
2021-05-11 19:09:57 +01:00
|
|
|
return $val
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([int]$arg)
|
|
|
|
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
|
2021-05-11 19:09:57 +01:00
|
|
|
else {
|
2022-06-25 15:20:36 +01:00
|
|
|
if (@(16, 24).Contains($arg)) {
|
|
|
|
$val = if ($arg -eq 16) { 1 } else { 2 }
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._bit = $this.Setter('bit', $val)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected value 16 or 24')
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_quality = $($this | Add-Member ScriptProperty 'quality' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('quality')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([int]$arg)
|
|
|
|
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
|
2021-05-11 19:09:57 +01:00
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
if ($arg -in 0..4) {
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._quality = $this.Setter('quality', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected value from 0 to 4')
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_route = $($this | Add-Member ScriptProperty 'route' `
|
|
|
|
{
|
2022-12-16 17:30:06 +00:00
|
|
|
$this.Getter('route')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2021-05-11 19:09:57 +01:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([int]$arg)
|
|
|
|
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
|
2021-05-11 19:09:57 +01:00
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
if ($arg -in 0..8) {
|
2022-12-16 17:30:06 +00:00
|
|
|
$this._route = $this.Setter('route', $arg)
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
Write-Warning ('Expected value from 0 to 8')
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-01-06 15:28:28 +00:00
|
|
|
|
|
|
|
class VbanInstream : Vban {
|
2023-08-12 03:09:23 +01:00
|
|
|
VbanInstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-06 15:28:28 +00:00
|
|
|
|
|
|
|
class VbanOutstream : Vban {
|
2023-08-12 03:09:23 +01:00
|
|
|
VbanOutstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
|
2022-01-06 15:28:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-11 17:19:02 +00:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Make_Vban ([Object]$remote) {
|
2022-01-06 15:28:28 +00:00
|
|
|
[System.Collections.ArrayList]$instream = @()
|
|
|
|
[System.Collections.ArrayList]$outstream = @()
|
|
|
|
|
2022-06-25 23:12:02 +01:00
|
|
|
0..$($remote.kind.vban_in - 1) | ForEach-Object {
|
2023-08-12 03:09:23 +01:00
|
|
|
[void]$instream.Add([VbanInstream]::new($_, $remote, "in"))
|
2022-01-06 15:28:28 +00:00
|
|
|
}
|
2022-06-25 23:12:02 +01:00
|
|
|
0..$($remote.kind.vban_out - 1) | ForEach-Object {
|
2023-08-12 03:09:23 +01:00
|
|
|
[void]$outstream.Add([VbanOutstream]::new($_, $remote, "out"))
|
2022-01-06 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
$CustomObject = [pscustomobject]@{
|
2022-06-25 15:20:36 +01:00
|
|
|
instream = $instream
|
2022-01-06 15:28:28 +00:00
|
|
|
outstream = $outstream
|
2022-10-27 21:20:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 17:19:02 +00:00
|
|
|
$CustomObject | Add-Member ScriptProperty 'enable' `
|
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
return Write-Warning ("ERROR: vban.enable is write only")
|
|
|
|
} `
|
2022-01-11 17:19:02 +00:00
|
|
|
{
|
2022-10-27 21:20:03 +01:00
|
|
|
param([bool]$arg)
|
2022-06-25 23:12:02 +01:00
|
|
|
Param_Set -PARAM 'vban.Enable' -Value $(if ($arg) { 1 } else { 0 })
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
2022-01-11 17:19:02 +00:00
|
|
|
|
|
|
|
$CustomObject
|
2022-01-06 15:28:28 +00:00
|
|
|
}
|