Set-VmsCameraStream improvements - #123
Conversation
947b44b to
5543b46
Compare
19e5c1d to
4cbbe19
Compare
4cbbe19 to
e27b46f
Compare
|
I'm working through this @Silex. As-is, this failed the integration tests and I've made changes to get them to pass, but I'm still observing some annoying behavior that was present before, and your originally reported issue doesn't seem totally resolved. When using the latest released version, v25.2.21, updating the stream and live mode at the same time does work, but the updated resolution isn't reflected in the local I'm not sure what my next step is going to be - I feel like a significant rewrite of the command (while maintaining compatibility) is needed as it was spaghetti code to begin with. In any case, here are some of my observations using the released version of the module for reference. I'm using a StableFPS camera with three streams, and it starts with only Video Stream 1 enabled: # Initial resolution and livemode is 555x555 and WhenNeeded
$stream = $camera | Get-VmsCameraStream -LiveDefault
# Changing to 111x111 and Always
$stream | set-vmscamerastream -Settings @{Resolution='111x111'} -LiveMode Always
# Locally, the resolution doesn't seem to change but LiveMode does.
# On the server, both settings were changed as expected.
$stream.Update()
# Now, after manually calling Update() on the local VmsCameraStreamConfig object,
# the resolution shows what I see in Management Client
$stream.Settings.Resolution
111x111So the command technically worked, but it failed to call Next, if I try to enable Video Stream 2, make that the default live stream, set LiveMode to Always, and change the resolution: $stream = $camera | Get-VmsCameraStream -Name 'Video stream 2'
$stream | Set-VmsCameraStream -Settings @{Resolution='111x111'} -LiveDefault -LiveMode Always
$stream
$stream.Settings.Resolution
<#
Camera Name DisplayName Enabled LiveMode LiveDefault Recorded
------ ---- ----------- ------- -------- ----------- --------
Camera 1 Video stream 2 Video stream 2 True Always True False
555x555
#>Once again, all the settings take effect on the server, but the local Multiple streams in the pipelineIf I make changes to multiple streams, I see the same issue with stale resolution values, and I start to see a failure to update all the stream usage properties: $streams = $camera | Get-VmsCameraStream
<# INITIAL STATE
Camera Name DisplayName Enabled LiveMode LiveDefault Recorded RecordingTrack PlaybackDefault UseEdge
------ ---- ----------- ------- -------- ----------- -------- -------------- --------------- -------
Camera 1 Video stream 1 Video stream 1 True WhenNeeded True True Primary recording True True
Camera 1 Video stream 2 False False False No recording False False
Camera 1 Video stream 3 False False False No recording False False
555x555
555x555
555x555
#>
$streams | Set-VmsCameraStream -Settings @{ Resolution = '111x111' } -LiveMode Always
<# NEW STATE
Camera Name DisplayName Enabled LiveMode LiveDefault Recorded RecordingTrack PlaybackDefault UseEdge
------ ---- ----------- ------- -------- ----------- -------- -------------- --------------- -------
Camera 1 Video stream 1 Video stream 1 True WhenNeeded True True Primary recording True True
Camera 1 Video stream 2 Video stream 2 True WhenNeeded False False No recording False False
Camera 1 Video stream 3 Video stream 3 True Always False False No recording False False
555x555
111x111
111x111
#>LiveModeThe local state matches what I see in Management Client, so that's good. However, only the third stream was correctly set to ResolutionThe resolutions are all correct in Management Client, but only 2/3 of the local stream objects show the updated value. Running |
|
Not sure what to suggest here, you know this much better than I do. Given most of your pains are with MIPSDK, maybe a "multiple pass" approach could work:
And I don't think that the lost performance matters much in that case, correctness is more important. Or maybe a "treat fire with a stick approach" like for at least 5 times do: get the streams, if settings are correct return, if not try to set all properties, repeat. |
|
I'm experimenting with a C# replacement for the powershell This is one of the few commands in the module where I'm trying to go out of my way to represent something in a different way than the SDK by combining stream settings and "usages" into a custom class, and that choice is biting me squarely in the butt 😅 |
Well the SDK design is quite dated so I think you did the right thing by trying to make it better. I guess eventually we should stop using the SDK and use the REST API only, when it's mature enough. |
094efb0 to
959d65d
Compare
|
I've rewritten the Most of the logic for reading & updating stream and streamusage settings has been moved into the new .NET class with proper getters and setters which has simplified the PowerShell function a lot. A few private static members in the Performance is improved by lazy loading properties of stream objects returned by Performance snapshotHere's a quick look at the performance difference on a test system with 42 streams. Time is in milliseconds. MilestonePSTools v25.2.21New versionChangesThis adds # Using the new shorthand
$stream | Set-VmsCameraStream -Resolution 1920x1080
# Passing a hashtable to the Settings parameter
$settings = @{
Resolution = '1920x1080'
}
$stream | Set-VmsCameraStream -Settings $settings
# Splat
$splat = @{
Settings = @{
Resolution = '1920x1080'
}
}
$stream | Set-VmsCameraStream @splat
|
|
Good results testing this build against the Next Gen Demo system (NGD). These results are just for Get-VmsCameraStreamThis is faster because the object returned by Measure-Command { $streams = get-vmscamera -EnableFilter All | Get-VmsCameraStream } | Select-Object TotalMilliseconds
# v25.2.21
TotalMilliseconds
-----------------
101775.5128
# New build
TotalMilliseconds
-----------------
9269.4193Get-VmsCameraReportSince Measure-Command { $report = Get-VmsCameraReport } | Select-Object TotalMilliseconds
# v25.2.21
TotalMilliseconds
-----------------
28050.2215
# New build
TotalMilliseconds
-----------------
18893.0988 |
|
Nice! When I see |
|
Good thinking - the odds of a collision between a stream property and the parameters on the cmdlet are pretty low I think. And the way parameter binding works, the existing parameters will always win. Looking at our NGD demo system with ~50 different camera models there are no collisions 😎 |
Tarterman
left a comment
There was a problem hiding this comment.
Tested various aspects and looked over code. Everything looks good to me.
-WhatIfthat displays empty stream names.Write-Verboseto correct place (it was in deprecated-Recordedpath).Parts of it is AI generated so please double check.