Skip to content

Commit d3bca83

Browse files
Merge pull request #39 from StartAutomating/obs-powershell-improvements
obs-powershell 0.1.3
2 parents b350949 + 1cead42 commit d3bca83

File tree

8 files changed

+167
-12
lines changed

8 files changed

+167
-12
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## obs-powershell 0.1.3:
2+
3+
* Requiring ThreadJob Module (Thanks @nyanhp!) (Fixes #36)
4+
* Fixing Add-OBSBrowserSource (Fixes #34)
5+
* Improving Batch Processing Capabilities (Fixes #38)
6+
* Requiring PowerShell Version 7
7+
8+
---
9+
10+
111
## obs-powershell 0.1.2:
212

313
* New Commands

Commands/Send-OBS.ps1

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@ function Send-OBS
1111
Watch-OBS
1212
#>
1313
param(
14+
# The data to send to the obs websocket.
1415
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
1516
[Alias('Payload')]
16-
$MessageData
17+
$MessageData,
18+
19+
# If provided, will sleep after each step.
20+
# If -StepTime is less than 10000 ticks, it will be treated as frames per second.
21+
# If -SerialFrame was provied, -StepTime will be the number of frames to wait.
22+
[Parameter(ValueFromPipelineByPropertyName)]
23+
[timespan]
24+
$StepTime,
25+
26+
# If set, will process a batch of requests in parallel.
27+
[switch]
28+
$Parallel,
29+
30+
# If set, will process a batch of requests in parallel.
31+
[switch]
32+
$SerialFrame
1733
)
1834

1935
begin {
@@ -103,6 +119,26 @@ function Send-OBS
103119

104120
process {
105121
$allMessages.Enqueue($MessageData)
122+
if ($StepTime.TotalMilliseconds -gt 0) {
123+
if ($SerialFrame) {
124+
$allMessages.Enqueue([PSCustomObject][Ordered]@{
125+
requestType = 'Sleep'
126+
requestData = @{
127+
sleepFrames = [int]$StepTime.Ticks
128+
}
129+
})
130+
} else {
131+
if ($StepTime.Ticks -lt 10000) {
132+
$StepTime = [TimeSpan]::FromMilliseconds(1000 / $StepTime.Ticks)
133+
}
134+
$allMessages.Enqueue([PSCustomObject][Ordered]@{
135+
requestType = 'Sleep'
136+
requestData = @{
137+
sleepMillis = [int]$StepTime.TotalMilliseconds
138+
}
139+
})
140+
}
141+
}
106142
}
107143

108144
end {
@@ -119,7 +155,14 @@ function Send-OBS
119155
[PSCustomObject]@{
120156
op = 8
121157
d = [Ordered]@{
122-
requestID = "Batch.$($script:ObsRequestsCounts["Batch"])"
158+
requestId = "Batch.$([guid]::NewGuid())"
159+
executionType = if ($Parallel) {
160+
2
161+
} elseif ($SerialFrame) {
162+
1
163+
} else {
164+
0
165+
}
123166
requests = $allMessages.ToArray()
124167
}
125168
} | SendSingleMessageToOBS

Commands/Sources/Add-OBSBrowserSource.ps.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,24 @@ function Add-OBSBrowserSource
112112
}
113113
}
114114

115-
if ($fps -ne 30) {
115+
if ($fps -and $fps -ne 30) {
116116
$myParameterData["custom_fps"] = $true
117117
}
118-
119118
if ($uri.Scheme -eq 'File') {
120119
if (Test-Path $uri.AbsolutePath) {
121-
$myParameterData["local_file"] = "$uri"
120+
$myParameterData["local_file"] = "$uri" -replace '[\\/]', '/' -replace '^file:///'
122121
$myParameterData["is_local_file"] = $true
123122
}
124123
}
125124
else
126125
{
127-
$myParameterData["url"] = "$uri"
126+
if (Test-Path $uri) {
127+
$rp = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($uri)
128+
$myParameterData["local_file"] = "$rp" -replace '[\\/]', '/' -replace '^file:///'
129+
$myParameterData["is_local_file"] = $true
130+
} else {
131+
$myParameterData["url"] = "$uri"
132+
}
128133
}
129134

130135

Commands/Sources/Add-OBSBrowserSource.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,24 @@ dynamicParam {
130130
}
131131
}
132132
}
133-
if ($fps -ne 30) {
133+
if ($fps -and $fps -ne 30) {
134134
$myParameterData["custom_fps"] = $true
135135
}
136136
if ($uri.Scheme -eq 'File') {
137137
if (Test-Path $uri.AbsolutePath) {
138-
$myParameterData["local_file"] = "$uri"
138+
$myParameterData["local_file"] = "$uri" -replace '[\\/]', '/' -replace '^file:///'
139139
$myParameterData["is_local_file"] = $true
140140
}
141141
}
142142
else
143143
{
144-
$myParameterData["url"] = "$uri"
144+
if (Test-Path $uri) {
145+
$rp = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($uri)
146+
$myParameterData["local_file"] = "$rp" -replace '[\\/]', '/' -replace '^file:///'
147+
$myParameterData["is_local_file"] = $true
148+
} else {
149+
$myParameterData["url"] = "$uri"
150+
}
145151
}
146152

147153
if (-not $Name) {

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## obs-powershell 0.1.3:
2+
3+
* Requiring ThreadJob Module (Thanks @nyanhp!) (Fixes #36)
4+
* Fixing Add-OBSBrowserSource (Fixes #34)
5+
* Improving Batch Processing Capabilities (Fixes #38)
6+
* Requiring PowerShell Version 7
7+
8+
---
9+
10+
111
## obs-powershell 0.1.2:
212

313
* New Commands

docs/Send-OBS.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Sends one or more messages to the OBS websocket.
2222
### Parameters
2323
#### **MessageData**
2424

25+
The data to send to the obs websocket.
26+
27+
28+
2529
> **Type**: ```[Object]```
2630
2731
> **Required**: false
@@ -32,9 +36,62 @@ Sends one or more messages to the OBS websocket.
3236
3337

3438

39+
---
40+
#### **StepTime**
41+
42+
If provided, will sleep after each step.
43+
If -StepTime is less than 10000 ticks, it will be treated as frames per second.
44+
If -SerialFrame was provied, -StepTime will be the number of frames to wait.
45+
46+
47+
48+
> **Type**: ```[TimeSpan]```
49+
50+
> **Required**: false
51+
52+
> **Position**: 2
53+
54+
> **PipelineInput**:true (ByPropertyName)
55+
56+
57+
58+
---
59+
#### **Parallel**
60+
61+
If set, will process a batch of requests in parallel.
62+
63+
64+
65+
> **Type**: ```[Switch]```
66+
67+
> **Required**: false
68+
69+
> **Position**: named
70+
71+
> **PipelineInput**:false
72+
73+
74+
75+
---
76+
#### **SerialFrame**
77+
78+
If set, will process a batch of requests in parallel.
79+
80+
81+
82+
> **Type**: ```[Switch]```
83+
84+
> **Required**: false
85+
86+
> **Position**: named
87+
88+
> **PipelineInput**:false
89+
90+
91+
3592
---
3693
### Syntax
3794
```PowerShell
38-
Send-OBS [[-MessageData] <Object>] [<CommonParameters>]
95+
Send-OBS [[-MessageData] <Object>] [[-StepTime] <TimeSpan>] [-Parallel] [-SerialFrame] [<CommonParameters>]
3996
```
4097
---

obs-powershell.ps.psd1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.1.2'
2+
ModuleVersion = '0.1.3'
33
RootModule = 'obs-powershell.psm1'
44
Description = 'Script OBS with PowerShell'
55
Guid = '1417123e-a932-439f-9b68-a7313cf1e170'
@@ -8,12 +8,24 @@
88
Copyright = '2022 Start-Automating'
99
FormatsToProcess = 'obs-powershell.format.ps1xml'
1010
TypesToProcess = 'obs-powershell.types.ps1xml'
11+
RequiredModules = 'ThreadJob'
12+
PowerShellVersion = '7.0'
1113
PrivateData = @{
1214
PSData = @{
1315
Tags = 'PowerShell', 'OBS'
1416
ProjectURI = 'https://github.com/StartAutomating/obs-powershell'
1517
LicenseURI = 'https://github.com/StartAutomating/obs-powershell/blob/main/LICENSE'
1618
ReleaseNotes = @'
19+
20+
## obs-powershell 0.1.3:
21+
22+
* Requiring ThreadJob Module (Thanks @nyanhp!) (Fixes #36)
23+
* Fixing Add-OBSBrowserSource (Fixes #34)
24+
* Improving Batch Processing Capabilities (Fixes #38)
25+
* Requiring PowerShell Version 7
26+
27+
---
28+
1729
## obs-powershell 0.1.2:
1830
1931
* New Commands

obs-powershell.psd1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.1.2'
2+
ModuleVersion = '0.1.3'
33
RootModule = 'obs-powershell.psm1'
44
Description = 'Script OBS with PowerShell'
55
Guid = '1417123e-a932-439f-9b68-a7313cf1e170'
@@ -8,12 +8,24 @@
88
Copyright = '2022 Start-Automating'
99
FormatsToProcess = 'obs-powershell.format.ps1xml'
1010
TypesToProcess = 'obs-powershell.types.ps1xml'
11+
RequiredModules = 'ThreadJob'
12+
PowerShellVersion = '7.0'
1113
PrivateData = @{
1214
PSData = @{
1315
Tags = 'PowerShell', 'OBS'
1416
ProjectURI = 'https://github.com/StartAutomating/obs-powershell'
1517
LicenseURI = 'https://github.com/StartAutomating/obs-powershell/blob/main/LICENSE'
1618
ReleaseNotes = @'
19+
20+
## obs-powershell 0.1.3:
21+
22+
* Requiring ThreadJob Module (Thanks @nyanhp!) (Fixes #36)
23+
* Fixing Add-OBSBrowserSource (Fixes #34)
24+
* Improving Batch Processing Capabilities (Fixes #38)
25+
* Requiring PowerShell Version 7
26+
27+
---
28+
1729
## obs-powershell 0.1.2:
1830
1931
* New Commands

0 commit comments

Comments
 (0)