@slidevideo/cli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +2 -2
- package/addons/slidevideo/geometry.ts +63 -30
- package/addons/slidevideo/global-top.vue +41 -9
- package/addons/slidevideo/playback-entries.ts +16 -5
- package/addons/slidevideo/preview.ts +26 -14
- package/dist/adapters/powerpoint.d.ts +7 -4
- package/dist/adapters/powerpoint.js +146 -40
- package/dist/adapters/slidev-inspection.d.ts +5 -2
- package/dist/adapters/slidev-inspection.js +3 -2
- package/dist/adapters/slidev.d.ts +3 -4
- package/dist/adapters/slidev.js +20 -19
- package/dist/annotation-paint.d.ts +65 -11
- package/dist/annotation-paint.js +290 -10
- package/dist/annotations.d.ts +13 -8
- package/dist/annotations.js +619 -88
- package/dist/assembly.d.ts +4 -2
- package/dist/assembly.js +23 -18
- package/dist/cli.js +102 -16
- package/dist/compositor.d.ts +10 -5
- package/dist/compositor.js +215 -128
- package/dist/contracts.d.ts +93 -30
- package/dist/contracts.js +2 -1
- package/dist/media.d.ts +5 -0
- package/dist/media.js +30 -0
- package/dist/pipeline.d.ts +37 -9
- package/dist/pipeline.js +62 -10
- package/dist/preview/contracts.d.ts +3 -3
- package/dist/preview/player.js +20 -15
- package/dist/preview/server.d.ts +2 -1
- package/dist/preview/server.js +6 -5
- package/dist/setup.d.ts +3 -0
- package/dist/setup.js +16 -1
- package/dist/skill-install.d.ts +35 -0
- package/dist/skill-install.js +132 -0
- package/dist/storyboard.js +9 -0
- package/package.json +4 -1
- package/schemas/annotation-geometry.v1.json +260 -28
- package/schemas/run-manifest.v1.json +31 -0
- package/schemas/schedule.v1.json +448 -182
- package/schemas/storyboard.v1.json +358 -174
- package/skills/slidevideo/SKILL.md +11 -9
- package/skills/slidevideo/references/decks.md +228 -0
- package/skills/slidevideo/references/production.md +14 -10
- package/skills/slidevideo/references/storyboard.md +69 -37
- package/tools/powerpoint/Native.cs +85 -1
- package/tools/powerpoint/powerpoint.ps1 +188 -101
- package/tools/powerpoint/preview.ps1 +10 -9
|
@@ -123,7 +123,7 @@ function Read-Package([string]$file) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
if ($entry.FullName -match '\.(gif|
|
|
126
|
+
if ($entry.FullName -match '\.(gif|glb|gltf)$' -or $entry.FullName -match '(^|/)(activeX|embeddings)/') {
|
|
127
127
|
$unsupported.Add(@{ slide = ''; reason = ('Dynamic or externally controlled package content is unsupported: ' + $entry.FullName) })
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -138,14 +138,35 @@ function Read-Package([string]$file) {
|
|
|
138
138
|
$relationshipId = $slideId.GetAttribute('id', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')
|
|
139
139
|
$part = Part-Name 'ppt/presentation.xml' $mapping[$relationshipId]
|
|
140
140
|
$slideXml = Read-Part $zip $part
|
|
141
|
+
$entranceClickByShape = @{}
|
|
142
|
+
$animReasonsByShape = @{}
|
|
143
|
+
$mainSeq = $slideXml.SelectSingleNode('//*[local-name()="cTn"][@nodeType="mainSeq"]')
|
|
144
|
+
if ($null -ne $mainSeq) {
|
|
145
|
+
$seqClick = 0
|
|
146
|
+
foreach ($effectNode in $mainSeq.SelectNodes('.//*[local-name()="cTn"][@nodeType="clickEffect" or @nodeType="withEffect" or @nodeType="afterEffect"]')) {
|
|
147
|
+
if ($effectNode.GetAttribute('nodeType') -eq 'clickEffect') { $seqClick++ }
|
|
148
|
+
$presetClass = $effectNode.GetAttribute('presetClass')
|
|
149
|
+
$hasGeometryMotion = $null -ne $effectNode.SelectSingleNode('.//*[local-name()="animMotion" or local-name()="animScale" or local-name()="animRot" or local-name()="anim"]')
|
|
150
|
+
foreach ($spTarget in $effectNode.SelectNodes('.//*[local-name()="spTgt"][@spid]')) {
|
|
151
|
+
$spid = [int]$spTarget.GetAttribute('spid')
|
|
152
|
+
if ($presetClass -eq 'entr') {
|
|
153
|
+
$prev = $(if ($entranceClickByShape.ContainsKey($spid)) { [int]$entranceClickByShape[$spid] } else { 0 })
|
|
154
|
+
$entranceClickByShape[$spid] = [Math]::Max($prev, $seqClick)
|
|
155
|
+
}
|
|
156
|
+
if ($presetClass -eq 'path' -or ($presetClass -ne 'entr' -and $hasGeometryMotion)) {
|
|
157
|
+
if (!$animReasonsByShape.ContainsKey($spid)) { $animReasonsByShape[$spid] = [Collections.Generic.List[string]]::new() }
|
|
158
|
+
$animReasonsByShape[$spid].Add('moving or resized animated target')
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
141
163
|
foreach ($identity in $slideXml.SelectNodes('//*[local-name()="cNvPr"]')) {
|
|
142
|
-
$
|
|
164
|
+
$spid = [int]$identity.GetAttribute('id')
|
|
143
165
|
$reasons = [Collections.Generic.List[string]]::new()
|
|
144
166
|
if ($identity.GetAttribute('hidden') -in @('1', 'true')) { $reasons.Add('hidden shape') }
|
|
145
|
-
if ($
|
|
146
|
-
$
|
|
147
|
-
|
|
148
|
-
$targets.Add(@{ native_id = $nativeId; id = [int]$identity.GetAttribute('id'); unsupported = @($reasons.ToArray()) })
|
|
167
|
+
if ($animReasonsByShape.ContainsKey($spid)) { foreach ($reason in $animReasonsByShape[$spid]) { $reasons.Add($reason) } }
|
|
168
|
+
$visibleClick = $(if ($entranceClickByShape.ContainsKey($spid)) { [int]$entranceClickByShape[$spid] } else { 0 })
|
|
169
|
+
$targets.Add(@{ native_id = $nativeId; id = $spid; unsupported = @($reasons.ToArray() | Select-Object -Unique); visible_from_click = $visibleClick })
|
|
149
170
|
}
|
|
150
171
|
$slideRelations = @{}
|
|
151
172
|
$relationPart = ([IO.Path]::GetDirectoryName($part).Replace('\', '/') + '/_rels/' + [IO.Path]::GetFileName($part) + '.rels')
|
|
@@ -172,33 +193,28 @@ function Read-Package([string]$file) {
|
|
|
172
193
|
$unsupported.Add(@{ slide = [string]$nativeId; reason = 'Video relationships do not identify one embedded source.' })
|
|
173
194
|
}
|
|
174
195
|
}
|
|
175
|
-
$crop = $picture.SelectSingleNode('.//*[local-name()="srcRect"]')
|
|
176
196
|
$transform = $picture.SelectSingleNode('./*[local-name()="spPr"]/*[local-name()="xfrm"]')
|
|
177
|
-
if ($null -ne $
|
|
178
|
-
$unsupported.Add(@{ slide = [string]$nativeId; reason = ('Video
|
|
197
|
+
if ($null -ne $transform -and ($transform.HasAttribute('rot') -or $transform.HasAttribute('flipH') -or $transform.HasAttribute('flipV'))) {
|
|
198
|
+
$unsupported.Add(@{ slide = [string]$nativeId; reason = ('Video rotation and flipping are unsupported: ' + $shape.GetAttribute('name')) })
|
|
179
199
|
}
|
|
180
200
|
$shapeId = [int]$shape.GetAttribute('id')
|
|
181
201
|
$nativeVideo = $slideXml.SelectSingleNode(('//*[local-name()="video"][.//*[local-name()="spTgt"][@spid="' + $shapeId + '"]]'))
|
|
182
202
|
$fullscreen = 0
|
|
183
203
|
if ($null -ne $nativeVideo -and $nativeVideo.GetAttribute('fullScrn') -in @('1', 'true')) { $fullscreen = -1 }
|
|
184
204
|
foreach ($property in $picture.SelectNodes('./*[local-name()="spPr"]/*')) {
|
|
185
|
-
if ($property.LocalName -notin @('xfrm', 'prstGeom')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = ('
|
|
205
|
+
if ($property.LocalName -notin @('xfrm', 'prstGeom', 'ln', 'effectLst', 'solidFill', 'gradFill', 'noFill')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = ('Unsupported video shape transform or 3D effect: ' + $shape.GetAttribute('name')) }) }
|
|
186
206
|
}
|
|
187
207
|
$media.Add(@{ id = $shape.GetAttribute('name'); native_id = $nativeId; shape = $shapeId; sha256 = (Part-Hash $zip $source); part = $source; fullscreen = $fullscreen })
|
|
188
208
|
}
|
|
189
209
|
if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="sndAc" or local-name()="snd" or local-name()="sndTgt" or local-name()="audio" or local-name()="oleObj" or local-name()="contentPart"]')) {
|
|
190
210
|
$unsupported.Add(@{ slide = [string]$nativeId; reason = 'Native audio, animation or slide sounds, OLE and dynamic content are unsupported.' })
|
|
191
211
|
}
|
|
192
|
-
if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="
|
|
193
|
-
$unsupported.Add(@{ slide = [string]$nativeId; reason = '
|
|
194
|
-
}
|
|
195
|
-
foreach ($effect in $slideXml.SelectNodes('//*[local-name()="animEffect"]')) {
|
|
196
|
-
if ($effect.GetAttribute('filter') -ne 'fade' -or $effect.GetAttribute('transition') -ne 'in') { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Only native entrance Fade animation filters are supported.' }) }
|
|
212
|
+
if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="cmd"]')) {
|
|
213
|
+
$unsupported.Add(@{ slide = [string]$nativeId; reason = 'Command animation behaviors are unsupported.' })
|
|
197
214
|
}
|
|
198
215
|
foreach ($node in $slideXml.SelectNodes('//*[local-name()="cTn"]')) {
|
|
199
216
|
if ($node.HasAttribute('spd') -and $node.GetAttribute('spd') -ne '100000') { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Native animation or media speed transforms are unsupported.' }) }
|
|
200
|
-
if ($node.HasAttribute('
|
|
201
|
-
if ($node.HasAttribute('repeatCount') -or $node.HasAttribute('repeatDur')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Explicit native repeats are unsupported.' }) }
|
|
217
|
+
if (($node.HasAttribute('repeatCount') -and $node.GetAttribute('repeatCount') -eq 'indefinite') -or ($node.HasAttribute('repeatDur') -and $node.GetAttribute('repeatDur') -eq 'indefinite')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Unbounded native animation repeats are unsupported.' }) }
|
|
202
218
|
}
|
|
203
219
|
}
|
|
204
220
|
return @{ media = @($media.ToArray()); unsupported = @($unsupported.ToArray()); targets = @($targets.ToArray()) }
|
|
@@ -216,32 +232,68 @@ function Open-PrivateDeck([bool]$visible) {
|
|
|
216
232
|
$script:presentation = $app.Presentations.Open($privateDeck, 0, 0, $(if ($visible) { -1 } else { 0 }))
|
|
217
233
|
Write-Json 'ownership.json' @{ helper_pid = $PID; helper_started_ticks = ([Diagnostics.Process]::GetCurrentProcess().StartTime.ToUniversalTime().Ticks.ToString()); powerpoint_pid = $processId; powerpoint_started_ticks = $process.StartTime.ToUniversalTime().Ticks.ToString(); application_created = $createdApplication; presentation = $privateDeck }
|
|
218
234
|
}
|
|
219
|
-
function
|
|
235
|
+
function Find-ShapeById($shapes, [int]$targetId, [bool]$ancestorInvalid = $false) {
|
|
236
|
+
$found = [Collections.Generic.List[object]]::new()
|
|
237
|
+
foreach ($shape in $shapes) {
|
|
238
|
+
$invalid = $ancestorInvalid -or ([int]$shape.Visible -ne -1) -or ([Math]::Abs([double]$shape.Rotation % 360) -gt 0.001) -or ([int]$shape.ThreeD.Visible -ne 0) -or ([int]$shape.HorizontalFlip -ne 0) -or ([int]$shape.VerticalFlip -ne 0)
|
|
239
|
+
if ([int]$shape.Id -eq $targetId) { $found.Add(@{ shape = $shape; invalid = $invalid }) }
|
|
240
|
+
if ([int]$shape.Type -eq 6) {
|
|
241
|
+
foreach ($child in (Find-ShapeById $shape.GroupItems $targetId $invalid)) { $found.Add($child) }
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return @($found.ToArray())
|
|
245
|
+
}
|
|
246
|
+
function Inspect-Shapes($slide, $shapes, $package, [bool]$ancestorTransformed, [int]$ancestorVisibleFromClick = 0, [string[]]$ancestorAnimReasons = @()) {
|
|
220
247
|
foreach ($shape in $shapes) {
|
|
221
248
|
Check-Cancel
|
|
222
249
|
$reasons = [Collections.Generic.List[string]]::new()
|
|
250
|
+
$animReasons = [Collections.Generic.List[string]]::new()
|
|
223
251
|
$bounds = @{ x = 0.0; y = 0.0; width = 0.0; height = 0.0 }
|
|
224
|
-
$visibleFromClick =
|
|
252
|
+
$visibleFromClick = $ancestorVisibleFromClick
|
|
253
|
+
$isTransformed = $ancestorTransformed
|
|
254
|
+
foreach ($inherited in $ancestorAnimReasons) {
|
|
255
|
+
$reasons.Add($inherited)
|
|
256
|
+
$animReasons.Add($inherited)
|
|
257
|
+
}
|
|
225
258
|
try {
|
|
226
259
|
$metadata = @($package.targets | Where-Object { $_.native_id -eq $slide.SlideID -and $_.id -eq $shape.Id })
|
|
227
260
|
if ($metadata.Count -ne 1) { $reasons.Add('shape identity is absent or ambiguous in the original slide package') }
|
|
228
|
-
else {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
261
|
+
else {
|
|
262
|
+
foreach ($reason in $metadata[0].unsupported) {
|
|
263
|
+
$reasons.Add($reason)
|
|
264
|
+
if ($reason -ne 'hidden shape') { $animReasons.Add($reason) }
|
|
265
|
+
}
|
|
266
|
+
$visibleFromClick = [Math]::Max($visibleFromClick, [int]$metadata[0].visible_from_click)
|
|
267
|
+
}
|
|
268
|
+
if ($ancestorTransformed) { $reasons.Add('ancestor group is hidden, rotated, flipped or three-dimensional') }
|
|
269
|
+
if ([int]$shape.Visible -ne -1) { $reasons.Add('hidden shape'); $isTransformed = $true }
|
|
270
|
+
if ([Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0) { $reasons.Add('rotated or three-dimensional shape'); $isTransformed = $true }
|
|
271
|
+
if ([int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { $reasons.Add('flipped shape'); $isTransformed = $true }
|
|
233
272
|
$bounds = @{ x = [double]$shape.Left / $presentation.PageSetup.SlideWidth; y = [double]$shape.Top / $presentation.PageSetup.SlideHeight; width = [double]$shape.Width / $presentation.PageSetup.SlideWidth; height = [double]$shape.Height / $presentation.PageSetup.SlideHeight }
|
|
234
273
|
if ($bounds.width -le 0 -or $bounds.height -le 0 -or $bounds.x -lt 0 -or $bounds.y -lt 0 -or $bounds.x + $bounds.width -gt 1.000001 -or $bounds.y + $bounds.height -gt 1.000001) { $reasons.Add('degenerate shape or shape clipped by slide bounds') }
|
|
235
|
-
$click = 0
|
|
236
274
|
foreach ($effect in $slide.TimeLine.MainSequence) {
|
|
237
|
-
if ([int]$effect.Timing.TriggerType -eq 1) { $click++ }
|
|
238
275
|
if ([int]$effect.Shape.Id -ne [int]$shape.Id) { continue }
|
|
239
|
-
if ([int]$effect.
|
|
240
|
-
|
|
276
|
+
if ([int]$effect.Exit -ne 0 -or [int]$effect.Timing.TriggerType -notin @(1, 2, 3) -or [int]$effect.Paragraph -gt 0 -or [int]$effect.EffectInformation.AfterEffect -ne 0 -or [double]$effect.Timing.RepeatCount -lt 0 -or [double]$effect.Timing.RepeatCount -gt 100 -or [double]$effect.Timing.RepeatDuration -lt 0) {
|
|
277
|
+
$reason = 'exited, partial-text, hidden-after-animation or unbounded animated target'
|
|
278
|
+
$reasons.Add($reason)
|
|
279
|
+
$animReasons.Add($reason)
|
|
280
|
+
}
|
|
241
281
|
}
|
|
242
282
|
} catch { $reasons.Add('native target geometry is unavailable: ' + $_.Exception.Message) }
|
|
283
|
+
$children = @()
|
|
284
|
+
if ([int]$shape.Type -eq 6) {
|
|
285
|
+
$children = @(Inspect-Shapes $slide $shape.GroupItems $package $isTransformed $visibleFromClick @($animReasons.ToArray() | Select-Object -Unique))
|
|
286
|
+
foreach ($child in $children) {
|
|
287
|
+
$visibleFromClick = [Math]::Max($visibleFromClick, [int]$child.visible_from_click)
|
|
288
|
+
foreach ($childReason in $child.unsupported) {
|
|
289
|
+
if ($childReason -in @('moving or resized animated target', 'exited, partial-text, hidden-after-animation or unbounded animated target')) {
|
|
290
|
+
$reasons.Add($childReason)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
243
295
|
@{ id = [int]$shape.Id; name = [string]$shape.Name; bounds = $bounds; unsupported = @($reasons.ToArray() | Select-Object -Unique); visible_from_click = $visibleFromClick }
|
|
244
|
-
|
|
296
|
+
foreach ($child in $children) { $child }
|
|
245
297
|
}
|
|
246
298
|
}
|
|
247
299
|
function Inspect-Native($package) {
|
|
@@ -254,7 +306,9 @@ function Inspect-Native($package) {
|
|
|
254
306
|
$effects.Add(@{ type = [int]$effect.EffectType; trigger = [int]$timing.TriggerType; duration_ms = [double]$timing.Duration * 1000; delay_ms = [double]$timing.TriggerDelayTime * 1000; repeat_count = [double]$timing.RepeatCount; repeat_duration_ms = [double]$timing.RepeatDuration * 1000; auto_reverse = [int]$timing.AutoReverse; exit = [int]$effect.Exit; shape = [int]$effect.Shape.Id; paragraph = [int]$effect.Paragraph })
|
|
255
307
|
}
|
|
256
308
|
$shapes = @(Inspect-Shapes $slide $slide.Shapes $package $false)
|
|
257
|
-
$
|
|
309
|
+
$transitionEffect = [int]$slide.SlideShowTransition.EntryEffect
|
|
310
|
+
$transitionDurationMs = $(if ($transitionEffect -ne 0) { [Math]::Round([double]$slide.SlideShowTransition.Duration * 1000) } else { 0 })
|
|
311
|
+
$slides.Add(@{ id = [string]$slide.Name; native_id = [int]$slide.SlideID; index = [int]$slide.SlideIndex; effects = @($effects.ToArray()); shapes = $shapes; transition = $transitionEffect; transition_duration_ms = $transitionDurationMs; auto_advance = [int]$slide.SlideShowTransition.AdvanceOnTime; hidden = [int]$slide.SlideShowTransition.Hidden; interactive = [int]$slide.TimeLine.InteractiveSequences.Count })
|
|
258
312
|
foreach ($shape in $slide.Shapes) {
|
|
259
313
|
if ([int]$shape.Type -eq 16) {
|
|
260
314
|
if ([int]$shape.MediaType -ne 3) { $package.unsupported += @{ slide = [string]$slide.Name; reason = ('Only native video media shapes are supported: ' + $shape.Name) }; continue }
|
|
@@ -282,9 +336,16 @@ function Dependencies {
|
|
|
282
336
|
return @{ powerpoint = [string]$app.Version; office_build = $office; windows = [Environment]::OSVersion.VersionString; powershell = $PSVersionTable.PSVersion.ToString(); ffmpeg = $script:ffmpegVersion }
|
|
283
337
|
}
|
|
284
338
|
function Slide-ById([int]$nativeId) { return $presentation.Slides.FindBySlideID($nativeId) }
|
|
285
|
-
function Select-Slide([int]$nativeId) {
|
|
339
|
+
function Select-Slide([int]$nativeId, [bool]$cut = $false) {
|
|
286
340
|
$slide = Slide-ById $nativeId
|
|
287
|
-
|
|
341
|
+
if ($cut) {
|
|
342
|
+
$saved = [int]$slide.SlideShowTransition.EntryEffect
|
|
343
|
+
$slide.SlideShowTransition.EntryEffect = 0
|
|
344
|
+
try { $show.View.GotoSlide([int]$slide.SlideIndex, -1) }
|
|
345
|
+
finally { $slide.SlideShowTransition.EntryEffect = $saved }
|
|
346
|
+
} else {
|
|
347
|
+
$show.View.GotoSlide([int]$slide.SlideIndex, -1)
|
|
348
|
+
}
|
|
288
349
|
if ([int]$show.View.Slide.SlideID -ne $nativeId -or [int]$show.View.GetClickIndex() -ne 0) { Fail 'POWERPOINT_NAVIGATION' ('Native slide did not reset: ' + $nativeId) }
|
|
289
350
|
}
|
|
290
351
|
function Apply-Operation($operation) {
|
|
@@ -297,48 +358,55 @@ function Apply-Operation($operation) {
|
|
|
297
358
|
if ([int]$show.View.Slide.SlideID -ne $operation.native_id) { Fail 'POWERPOINT_MEDIA' ('Wrong native slide for media ' + $operation.id) }
|
|
298
359
|
$player = $show.View.Player([int]$operation.shape)
|
|
299
360
|
$player.Stop()
|
|
300
|
-
$player.CurrentPosition =
|
|
361
|
+
$player.CurrentPosition = [int][Math]::Round([double]$operation.trim_start_ms)
|
|
301
362
|
$player.Play()
|
|
302
363
|
return $player
|
|
303
364
|
} else { Fail 'POWERPOINT_PROTOCOL' ('Unknown operation ' + $operation.type) }
|
|
304
365
|
}
|
|
366
|
+
function Request-Context($request, [bool]$includeClick = $false) {
|
|
367
|
+
$ids = @($request.annotations)
|
|
368
|
+
$prefix = $(if ($ids.Count -eq 1) { 'Annotation ' + $ids[0] } else { 'Annotations ' + ($ids -join ', ') })
|
|
369
|
+
$suffix = $(if ($includeClick) { ', click ' + $request.click } else { '' })
|
|
370
|
+
return ($prefix + ' (' + $request.key + '), slide ' + $request.slide + ', visit ' + $request.visit + $suffix)
|
|
371
|
+
}
|
|
305
372
|
function Prepare-Annotations($catalog) {
|
|
306
|
-
foreach ($
|
|
307
|
-
$context =
|
|
308
|
-
$visits = @($job.operations | Where-Object { $_.type -eq 'slide' -and $_.id -eq $
|
|
373
|
+
foreach ($request in $job.geometry_requests) {
|
|
374
|
+
$context = Request-Context $request
|
|
375
|
+
$visits = @($job.operations | Where-Object { $_.type -eq 'slide' -and $_.id -eq $request.visit -and $_.native_id -eq $request.native_id -and $_.scene -eq $request.scene })
|
|
309
376
|
if ($visits.Count -ne 1) { Fail 'ANNOTATION_STATE' ($context + ': no unique scheduled slide visit.') }
|
|
310
|
-
if ($
|
|
377
|
+
if ($request.start_ms -lt $visits[0].at_ms + $visits[0].settle_ms -or $request.end_ms -le $request.start_ms -or $request.end_ms -gt $job.duration_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval is outside settled playback.') }
|
|
311
378
|
$click = 0
|
|
312
379
|
foreach ($operation in $job.operations) {
|
|
313
380
|
if ($operation.type -notin @('slide', 'reveal')) { continue }
|
|
314
|
-
if ($operation.at_ms -le $
|
|
381
|
+
if ($operation.at_ms -le $request.start_ms) {
|
|
315
382
|
if ($operation.type -eq 'slide') { $visit = [string]$operation.id; $click = 0 }
|
|
316
383
|
else { $click = [int]$operation.click }
|
|
317
|
-
if ($operation.at_ms + $operation.settle_ms -gt $
|
|
318
|
-
} elseif ($operation.at_ms -lt $
|
|
384
|
+
if ($operation.at_ms + $operation.settle_ms -gt $request.start_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval starts before a native action settles.') }
|
|
385
|
+
} elseif ($operation.at_ms -lt $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': interval crosses a native slide or reveal action.') }
|
|
319
386
|
}
|
|
320
|
-
if ($visit -ne $
|
|
321
|
-
if ($
|
|
322
|
-
if ($
|
|
323
|
-
$slides = @($catalog.slides | Where-Object { $_.native_id -eq $
|
|
324
|
-
$matches = @($slides[0].shapes | Where-Object { $_.id -eq $
|
|
325
|
-
if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $
|
|
326
|
-
if ($matches[0].unsupported.Count -gt 0 -or $
|
|
387
|
+
if ($visit -ne $request.visit -or $click -ne $request.click) { Fail 'ANNOTATION_STATE' ($context + ': resolved click or visit does not match native operations.') }
|
|
388
|
+
if ($request.target.type -eq 'element') { Fail 'ANNOTATION_TARGET' ($context + ': use an existing native shape ID or normalized region; selectors are unsupported.') }
|
|
389
|
+
if ($request.target.type -eq 'shape') {
|
|
390
|
+
$slides = @($catalog.slides | Where-Object { $_.native_id -eq $request.native_id })
|
|
391
|
+
$matches = @($slides[0].shapes | Where-Object { $_.id -eq $request.target.id })
|
|
392
|
+
if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': identity is missing or ambiguous.') }
|
|
393
|
+
if ($matches[0].unsupported.Count -gt 0 -or $request.click -lt $matches[0].visible_from_click) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ' (' + $matches[0].name + '): unsupported or hidden target. ' + ($matches[0].unsupported -join '; ')) }
|
|
327
394
|
}
|
|
328
|
-
$annotationMonitors.Add(@{
|
|
395
|
+
$annotationMonitors.Add(@{ request = $request; geometry = $null; next_sample_ms = [double]$request.start_ms; complete = $false })
|
|
329
396
|
}
|
|
330
397
|
}
|
|
331
|
-
function Measure-Annotation($
|
|
332
|
-
$context =
|
|
398
|
+
function Measure-Annotation($request, [bool]$allowPaused = $false) {
|
|
399
|
+
$context = Request-Context $request $true
|
|
333
400
|
[SlideVideo.Native]::EnsureGeometry($window, $geometry)
|
|
334
|
-
if ($activeVisit -ne $
|
|
335
|
-
if ($
|
|
336
|
-
|
|
401
|
+
if ($activeVisit -ne $request.visit -or $activeScene -ne $request.scene -or [int]$show.View.Slide.SlideID -ne $request.native_id -or [int]$show.View.GetClickIndex() -ne $request.click -or ([int]$show.View.State -ne 1 -and !($allowPaused -and [int]$show.View.State -eq 2))) { Fail 'ANNOTATION_STATE' ($context + ': actual slideshow state changed.') }
|
|
402
|
+
if ($request.target.type -eq 'slide') { return }
|
|
403
|
+
if ($request.target.type -eq 'region') {
|
|
404
|
+
$bounds = @{ x = [double]$request.target.x; y = [double]$request.target.y; width = [double]$request.target.width; height = [double]$request.target.height }
|
|
337
405
|
} else {
|
|
338
|
-
$matches = @($show.View.Slide.Shapes
|
|
339
|
-
if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $
|
|
340
|
-
$shape = $matches[0]
|
|
341
|
-
if (
|
|
406
|
+
$matches = @(Find-ShapeById $show.View.Slide.Shapes ([int]$request.target.id))
|
|
407
|
+
if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual shape is missing or ambiguous.') }
|
|
408
|
+
$shape = $matches[0].shape
|
|
409
|
+
if ($matches[0].invalid) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual target is hidden or transformed.') }
|
|
342
410
|
$bounds = @{ x = [double]$shape.Left / $presentation.PageSetup.SlideWidth; y = [double]$shape.Top / $presentation.PageSetup.SlideHeight; width = [double]$shape.Width / $presentation.PageSetup.SlideWidth; height = [double]$shape.Height / $presentation.PageSetup.SlideHeight }
|
|
343
411
|
}
|
|
344
412
|
foreach ($value in $bounds.Values) { if ([double]::IsNaN($value) -or [double]::IsInfinity($value)) { Fail 'ANNOTATION_GEOMETRY' ($context + ': nonfinite bounds.') } }
|
|
@@ -348,29 +416,33 @@ function Measure-Annotation($annotation, [bool]$allowPaused = $false) {
|
|
|
348
416
|
function Check-Annotations {
|
|
349
417
|
foreach ($monitor in $annotationMonitors) {
|
|
350
418
|
if ($monitor.complete) { continue }
|
|
351
|
-
$
|
|
352
|
-
|
|
419
|
+
$request = $monitor.request
|
|
420
|
+
$context = Request-Context $request $true
|
|
421
|
+
if ($null -eq $monitor.geometry -and $request.start_ms -ge $annotationStartBeforeMs) { continue }
|
|
353
422
|
$now = $clock.Elapsed.TotalMilliseconds - $origin
|
|
354
|
-
if ($now -lt $monitor.next_sample_ms -and $now -lt $
|
|
355
|
-
if ($null -eq $monitor.geometry -and $now -ge $
|
|
356
|
-
$
|
|
423
|
+
if ($now -lt $monitor.next_sample_ms -and $now -lt $request.end_ms) { continue }
|
|
424
|
+
if ($null -eq $monitor.geometry -and $now -ge $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': native playback missed the entire interval.') }
|
|
425
|
+
$fragments = @(Measure-Annotation $request)
|
|
357
426
|
$observed = $clock.Elapsed.TotalMilliseconds - $origin
|
|
358
427
|
if ($null -eq $monitor.geometry) {
|
|
359
|
-
if ($observed -ge $
|
|
360
|
-
if ($observed - $
|
|
361
|
-
$monitor.geometry = @{
|
|
428
|
+
if ($observed -ge $request.end_ms) { Fail 'ANNOTATION_INTERVAL' ($context + ': initial measurement completed after the interval.') }
|
|
429
|
+
if ($observed - $request.start_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ($context + ': initial native measurement exceeded the interval boundary by 100 ms.') }
|
|
430
|
+
$monitor.geometry = @{ key = [string]$request.key; target = $request.target; scene = [string]$request.scene; slide = [string]$request.slide; visit = [string]$request.visit; click = [int]$request.click; start_ms = $request.start_ms; end_ms = $request.end_ms; observed_start_ms = $observed; observed_end_ms = $observed; viewport = @{ width = [int]$job.output.width; height = [int]$job.output.height }; content = @{ x = $outputContent.x; y = $outputContent.y; width = $outputContent.width; height = $outputContent.height }; fragments = @($fragments); samples = 1 }
|
|
362
431
|
$annotationGeometry.Add($monitor.geometry)
|
|
363
432
|
} else {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
433
|
+
if ($fragments.Count -ne $monitor.geometry.fragments.Count) { Fail 'ANNOTATION_MOVING_TARGET' ($context + ': fragment count changed during its native interval.') }
|
|
434
|
+
for ($fragmentIndex = 0; $fragmentIndex -lt $fragments.Count; $fragmentIndex++) {
|
|
435
|
+
foreach ($coord in @('x', 'y', 'width', 'height')) {
|
|
436
|
+
$pixels = $(if ($coord -in @('x', 'width')) { $outputContent.width } else { $outputContent.height })
|
|
437
|
+
if ([Math]::Abs($fragments[$fragmentIndex][$coord] - $monitor.geometry.fragments[$fragmentIndex][$coord]) * $pixels -gt 0.5) { Fail 'ANNOTATION_MOVING_TARGET' ($context + ': target moved during its native interval.') }
|
|
438
|
+
}
|
|
367
439
|
}
|
|
368
440
|
$monitor.geometry.samples++
|
|
369
441
|
$monitor.geometry.observed_end_ms = $observed
|
|
370
442
|
}
|
|
371
|
-
$monitor.next_sample_ms = [Math]::Min($observed + 50, [double]$
|
|
372
|
-
if ($now -ge $
|
|
373
|
-
if ($observed - $
|
|
443
|
+
$monitor.next_sample_ms = [Math]::Min($observed + 50, [double]$request.end_ms)
|
|
444
|
+
if ($now -ge $request.end_ms) {
|
|
445
|
+
if ($observed - $request.end_ms -gt 100) { Fail 'ANNOTATION_INTERVAL' ($context + ': final native measurement exceeded the interval boundary by 100 ms.') }
|
|
374
446
|
$monitor.complete = $true
|
|
375
447
|
}
|
|
376
448
|
}
|
|
@@ -381,11 +453,19 @@ function Check-Media {
|
|
|
381
453
|
$position = [double]$monitor.player.CurrentPosition
|
|
382
454
|
$state = [int]$monitor.player.State
|
|
383
455
|
if ($position -gt $monitor.last_position + 1) { $monitor.last_position = $position; $monitor.advanced_at = $now }
|
|
384
|
-
$
|
|
385
|
-
|
|
456
|
+
$trimStart = [double]$monitor.operation.trim_start_ms
|
|
457
|
+
$trimEnd = [double]$monitor.operation.trim_end_ms
|
|
458
|
+
$elapsed = $now - $monitor.operation.at_ms
|
|
459
|
+
$expected = $trimStart + $elapsed
|
|
460
|
+
$isTrimmedEnd = $trimEnd -lt ([double]$monitor.operation.source_duration_ms - 50)
|
|
461
|
+
if ($isTrimmedEnd -and ($now -ge $monitor.operation.end_ms -or ($position -gt $trimStart + 1 -and $position -ge $trimEnd - 30))) {
|
|
462
|
+
$monitor.player.Pause()
|
|
463
|
+
$events.Add(@{ id = ($monitor.operation.id + ':ended'); type = 'media-ended'; scheduled_ms = $monitor.operation.end_ms; observed_ms = $now; media_ms = $position })
|
|
464
|
+
[void]$activeMedia.Remove($monitor)
|
|
465
|
+
} elseif ($state -in @($ppPaused, $ppStopped) -and $expected -ge $trimEnd - 200 -and $monitor.last_position -ge $trimEnd - 200) {
|
|
386
466
|
$events.Add(@{ id = ($monitor.operation.id + ':ended'); type = 'media-ended'; scheduled_ms = $monitor.operation.end_ms; observed_ms = $now; media_ms = $monitor.last_position })
|
|
387
467
|
[void]$activeMedia.Remove($monitor)
|
|
388
|
-
} elseif ($now -gt $monitor.operation.end_ms + 250 -or ($
|
|
468
|
+
} elseif ($now -gt $monitor.operation.end_ms + 250 -or ($elapsed -gt 300 -and [Math]::Abs($position - $expected) -gt 200) -or ($now - $monitor.advanced_at -gt 250) -or ($elapsed -gt 150 -and $state -ne $ppPlaying)) {
|
|
389
469
|
Fail 'POWERPOINT_MEDIA_STALL' ('Native media stalled: ' + $monitor.operation.id + ', expected ' + [int]$expected + ' ms, observed ' + $position + ' ms, state ' + $state)
|
|
390
470
|
}
|
|
391
471
|
}
|
|
@@ -393,7 +473,7 @@ function Check-Media {
|
|
|
393
473
|
function Wait-MediaCompletion {
|
|
394
474
|
Check-Media
|
|
395
475
|
foreach ($monitor in @($activeMedia.ToArray())) {
|
|
396
|
-
if ($monitor.last_position -lt $monitor.operation.
|
|
476
|
+
if ($monitor.last_position -lt [double]$monitor.operation.trim_end_ms - 200) {
|
|
397
477
|
Fail 'POWERPOINT_MEDIA_STALL' ('Native media is not within completion tolerance at the action boundary: ' + $monitor.operation.id)
|
|
398
478
|
}
|
|
399
479
|
}
|
|
@@ -450,27 +530,32 @@ function Save-Reference([string]$label) {
|
|
|
450
530
|
return $file
|
|
451
531
|
}
|
|
452
532
|
function Rehearse {
|
|
453
|
-
Select-Slide $job.operations[0].native_id
|
|
454
|
-
Wait-Until ($clock.Elapsed.TotalMilliseconds + 300)
|
|
533
|
+
Select-Slide $job.operations[0].native_id $true
|
|
534
|
+
Wait-Until ($clock.Elapsed.TotalMilliseconds + [Math]::Max(300, [double]$job.operations[0].settle_ms + 200))
|
|
455
535
|
$number = 0
|
|
456
536
|
foreach ($operation in $job.operations) {
|
|
457
537
|
Check-Cancel
|
|
458
538
|
$number++
|
|
539
|
+
if ($number -eq 1 -and $operation.type -eq 'slide' -and $operation.at_ms -eq 0) { continue }
|
|
459
540
|
$before = Save-Reference ('reference-' + $number + '-before')
|
|
460
541
|
$exclude = @($job.media | Where-Object { $_.native_id -eq [int]$show.View.Slide.SlideID } | ForEach-Object { @{ left = $_.left; top = $_.top; right = $_.right; bottom = $_.bottom } })
|
|
461
542
|
$player = Apply-Operation $operation
|
|
462
543
|
if ($operation.type -eq 'play') {
|
|
463
544
|
$player.Pause()
|
|
464
|
-
$
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
545
|
+
$trimStart = [double]$operation.trim_start_ms
|
|
546
|
+
$trimEnd = [double]$operation.trim_end_ms
|
|
547
|
+
$clipDuration = $trimEnd - $trimStart
|
|
548
|
+
$offsets = @(500, 1500 | Where-Object { $_ -lt $clipDuration })
|
|
549
|
+
if ($offsets.Count -eq 0) { $offsets = @($clipDuration / 2) }
|
|
550
|
+
foreach ($offset in $offsets) {
|
|
551
|
+
$samplePos = [int][Math]::Round($trimStart + $offset)
|
|
552
|
+
$player.CurrentPosition = $samplePos
|
|
468
553
|
Wait-Until ($clock.Elapsed.TotalMilliseconds + 250)
|
|
469
|
-
if ([Math]::Abs([double]$player.CurrentPosition - $
|
|
470
|
-
$after = Save-Reference ('reference-' + $number + '-sample-' + $
|
|
471
|
-
$references.Add(@{ id = ($operation.id.Replace(':', '-') + '-' + $
|
|
554
|
+
if ([Math]::Abs([double]$player.CurrentPosition - $samplePos) -gt $operation.frame_period_ms) { Fail 'POWERPOINT_REFERENCE' ('Native video seek is unbounded: ' + $operation.id) }
|
|
555
|
+
$after = Save-Reference ('reference-' + $number + '-sample-' + [int]$offset)
|
|
556
|
+
$references.Add(@{ id = ($operation.id.Replace(':', '-') + '-' + [int]$offset); expected_ms = $operation.at_ms + $offset; before = $before; after = $after; mode = 'sample'; frame_period_ms = $operation.frame_period_ms })
|
|
472
557
|
}
|
|
473
|
-
$player.CurrentPosition = [int][Math]::Max(
|
|
558
|
+
$player.CurrentPosition = [int][Math]::Max($trimStart, $trimEnd - $operation.frame_period_ms)
|
|
474
559
|
Wait-Until ($clock.Elapsed.TotalMilliseconds + 200)
|
|
475
560
|
$player.Pause()
|
|
476
561
|
} elseif ($operation.at_ms -gt 0) {
|
|
@@ -521,7 +606,7 @@ try {
|
|
|
521
606
|
if ((File-Hash $job.deck) -ne $job.deck_sha256) { Fail 'POWERPOINT_SOURCE_CHANGED' 'The source presentation changed while PowerPoint opened its private copy.' }
|
|
522
607
|
if ($job.mode -eq 'inspect') { $result = Inspect-Native $package }
|
|
523
608
|
else {
|
|
524
|
-
if ($job.
|
|
609
|
+
if ($job.geometry_requests.Count -gt 0) { Prepare-Annotations (Inspect-Native $package) }
|
|
525
610
|
foreach ($media in $job.media) {
|
|
526
611
|
$matches = @($package.media | Where-Object { $_.native_id -eq $media.native_id -and $_.shape -eq $media.shape -and $_.id -eq $media.id -and $_.sha256 -eq $media.sha256 })
|
|
527
612
|
if ($matches.Count -ne 1 -or (File-Hash $media.src) -ne $media.sha256) { Fail 'MEDIA_SOURCE_MISMATCH' ('Native video bytes no longer match ' + $media.id) }
|
|
@@ -553,11 +638,9 @@ try {
|
|
|
553
638
|
$initialViewState = [int]$show.View.State
|
|
554
639
|
$show.View.State = 1
|
|
555
640
|
$show.View.AcceleratorsEnabled = 0
|
|
556
|
-
$
|
|
557
|
-
$captureHeight = [int][Math]::Round($captureWidth / $deckAspect)
|
|
558
|
-
[SlideVideo.Native]::Place($window, $captureWidth, $captureHeight)
|
|
641
|
+
$windowMode = [SlideVideo.Native]::PlaceForAudience($window, [int]$job.output.width, [int]$job.output.height, $deckAspect, $true, $true)
|
|
559
642
|
$show.View.GotoSlide([int]$markerSlides['#ff00ff'], -1)
|
|
560
|
-
Write-Json 'window.json' @{ hwnd = $window.ToString(); editor_hwnd = $editorWindow.ToString(); description = [SlideVideo.Native]::Describe($window); initial_state = $initialViewState; state = [int]$show.View.State; slide_id = [int]$show.View.Slide.SlideID; marker_slide_id = [int]$presentation.Slides.Item([int]$markerSlides['#ff00ff']).SlideID; marker_rgb = [int]$show.View.Slide.Background.Fill.ForeColor.RGB; follows_master = [int]$show.View.Slide.FollowMasterBackground }
|
|
643
|
+
Write-Json 'window.json' @{ hwnd = $window.ToString(); editor_hwnd = $editorWindow.ToString(); description = [SlideVideo.Native]::Describe($window); mode = $windowMode; initial_state = $initialViewState; state = [int]$show.View.State; slide_id = [int]$show.View.Slide.SlideID; marker_slide_id = [int]$presentation.Slides.Item([int]$markerSlides['#ff00ff']).SlideID; marker_rgb = [int]$show.View.Slide.Background.Fill.ForeColor.RGB; follows_master = [int]$show.View.Slide.FollowMasterBackground }
|
|
561
644
|
$geometry = $null
|
|
562
645
|
$deadline = $clock.Elapsed.TotalMilliseconds + 5000
|
|
563
646
|
do {
|
|
@@ -574,16 +657,17 @@ try {
|
|
|
574
657
|
} while ($null -eq $geometry)
|
|
575
658
|
$scaleFilter = ('scale=' + $job.output.width + ':' + $job.output.height + ':force_original_aspect_ratio=decrease:flags=bicubic,pad=' + $job.output.width + ':' + $job.output.height + ':(ow-iw)/2:(oh-ih)/2,setsar=1')
|
|
576
659
|
$outputContent = [SlideVideo.Native]::OutputContent($geometry, [int]$job.output.width, [int]$job.output.height)
|
|
577
|
-
if ($job.
|
|
660
|
+
if ($job.geometry_requests.Count -gt 0) { $scaleFilter = ('scale=' + $outputContent.width + ':' + $outputContent.height + ':flags=bicubic,format=rgb24,pad=' + $job.output.width + ':' + $job.output.height + ':' + $outputContent.x + ':' + $outputContent.y + ',setsar=1') }
|
|
578
661
|
$captureFilter = ('crop=' + $geometry.width + ':' + $geometry.height + ':' + $geometry.left + ':' + $geometry.top + ':exact=1,' + $scaleFilter)
|
|
579
|
-
Write-Json 'geometry.json' @{ version = 1; hwnd = $window.ToString(); rectangle = $geometry; deck_aspect = $deckAspect; requested = $job.output; filter = $captureFilter }
|
|
662
|
+
Write-Json 'geometry.json' @{ version = 1; hwnd = $window.ToString(); mode = $windowMode; rectangle = $geometry; output_content = $outputContent; scale_x = [double]$outputContent.width / $geometry.width; scale_y = [double]$outputContent.height / $geometry.height; deck_aspect = $deckAspect; requested = $job.output; filter = $captureFilter }
|
|
580
663
|
if ($job.verify_timing) { Rehearse }
|
|
581
664
|
$firstOperation = $job.operations[0]
|
|
582
665
|
if ($firstOperation.type -ne 'slide' -or $firstOperation.at_ms -ne 0) { Fail 'POWERPOINT_PROTOCOL' 'The native schedule must initialize a slide at time zero.' }
|
|
583
|
-
Select-Slide $firstOperation.native_id
|
|
666
|
+
Select-Slide $firstOperation.native_id $true
|
|
667
|
+
$firstOnsetMatchesYellow = [SlideVideo.Native]::ColorPresent($window, $geometry, '#ffff00')
|
|
584
668
|
Wait-Until ($clock.Elapsed.TotalMilliseconds + 200)
|
|
585
669
|
$firstReadback = [SlideVideo.Native]::Readback($window, $geometry)
|
|
586
|
-
$deadline = $clock.Elapsed.TotalMilliseconds + 5000
|
|
670
|
+
$deadline = $clock.Elapsed.TotalMilliseconds + [Math]::Max(5000, [double]$firstOperation.settle_ms + 3000)
|
|
587
671
|
do {
|
|
588
672
|
Wait-Until ($clock.Elapsed.TotalMilliseconds + 30)
|
|
589
673
|
$nextReadback = [SlideVideo.Native]::Readback($window, $geometry)
|
|
@@ -631,21 +715,24 @@ try {
|
|
|
631
715
|
Show-Marker '#ff00ff'
|
|
632
716
|
if ($job.verify_timing) { Show-Marker '#00ffff' }
|
|
633
717
|
Show-Marker '#ffff00'
|
|
718
|
+
$markerReadback = $(if ([double]$firstOperation.settle_ms -gt 0) { [SlideVideo.Native]::Readback($window, $geometry) } else { '' })
|
|
634
719
|
$initialLower = $clock.Elapsed.TotalMilliseconds
|
|
635
|
-
Select-Slide $firstOperation.native_id
|
|
636
|
-
$deadline = $clock.Elapsed.TotalMilliseconds + 5000
|
|
720
|
+
Select-Slide $firstOperation.native_id $true
|
|
721
|
+
$deadline = $clock.Elapsed.TotalMilliseconds + [Math]::Max(5000, [double]$firstOperation.settle_ms + 3000)
|
|
637
722
|
do {
|
|
638
723
|
Check-Cancel
|
|
639
|
-
$
|
|
724
|
+
$currentReadback = [SlideVideo.Native]::Readback($window, $geometry)
|
|
725
|
+
$ready = $(if ([double]$firstOperation.settle_ms -gt 0) { $firstOnsetMatchesYellow -or ($currentReadback -ne $markerReadback) } else { $currentReadback -eq $firstReadback })
|
|
640
726
|
if (!$ready) { Start-Sleep -Milliseconds 1 }
|
|
641
727
|
} while (!$ready -and $clock.Elapsed.TotalMilliseconds -lt $deadline)
|
|
642
|
-
if (!$ready) { Fail 'POWERPOINT_READINESS' 'The actual audience pixels did not
|
|
728
|
+
if (!$ready) { Fail 'POWERPOINT_READINESS' 'The actual audience pixels did not transition to the initialized first-slide state.' }
|
|
643
729
|
$script:origin = $clock.Elapsed.TotalMilliseconds
|
|
644
|
-
|
|
730
|
+
$startupMethod = $(if ([double]$firstOperation.settle_ms -gt 0) { 'native target state and first-slide entry onset readback' } else { 'native target state and matching physical audience readback' })
|
|
731
|
+
Write-Json 'startup.json' @{ version = 1; native_id = $firstOperation.native_id; readback_sha256 = $firstReadback; navigation_started_ms = $initialLower - $origin; initialized_by_ms = 0; method = $startupMethod }
|
|
645
732
|
foreach ($marker in $markers) { $marker.observed_ms -= $origin; $marker.rendered_by_ms -= $origin }
|
|
646
733
|
$script:activeVisit = [string]$firstOperation.id
|
|
647
734
|
$script:activeScene = [string]$firstOperation.scene
|
|
648
|
-
$script:collectAnnotations = $job.
|
|
735
|
+
$script:collectAnnotations = $job.geometry_requests.Count -gt 0
|
|
649
736
|
$initial = $true
|
|
650
737
|
for ($operationIndex = 0; $operationIndex -lt $job.operations.Count; $operationIndex++) {
|
|
651
738
|
$operation = $job.operations[$operationIndex]
|
|
@@ -704,7 +791,7 @@ try {
|
|
|
704
791
|
try { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app) } catch { $cleanup.Add('The COM application reference did not release.') }
|
|
705
792
|
}
|
|
706
793
|
try { Write-Json 'events.json' @{ version = 1; events = @($events.ToArray()); markers = @($markers.ToArray()); failure = $failure } } catch {}
|
|
707
|
-
try { Write-Json 'annotation-geometry.json' @{ version = 1; geometry = @($annotationGeometry.ToArray()); intervals = @($annotationMonitors | ForEach-Object { @{
|
|
794
|
+
try { Write-Json 'annotation-geometry.json' @{ version = 1; geometry = @($annotationGeometry.ToArray()); intervals = @($annotationMonitors | ForEach-Object { @{ key = $_.request.key; annotations = @($_.request.annotations); start_ms = $_.request.start_ms; end_ms = $_.request.end_ms; complete = $_.complete } }); failure = $failure } } catch {}
|
|
708
795
|
try { Write-Json 'cleanup.json' @{ version = 1; gaps = @($cleanup.ToArray()); application_created = $createdApplication } } catch {}
|
|
709
796
|
if ($locked) { $mutex.ReleaseMutex() }
|
|
710
797
|
if ($null -ne $mutex) { $mutex.Dispose() }
|
|
@@ -15,9 +15,7 @@ function Run-Preview {
|
|
|
15
15
|
} while ($window -eq 0 -and $clock.Elapsed.TotalMilliseconds -lt $deadline)
|
|
16
16
|
if ($window -eq 0) { Fail 'POWERPOINT_WINDOW' 'Cannot identify the slideshow owned by the private preview deck.' }
|
|
17
17
|
$show.View.AcceleratorsEnabled = 0
|
|
18
|
-
|
|
19
|
-
$previewHeight = [int][Math]::Round($previewWidth / $deckAspect)
|
|
20
|
-
[SlideVideo.Native]::PlacePreview($window, $previewWidth, $previewHeight)
|
|
18
|
+
[void][SlideVideo.Native]::PlaceForAudience($window, [int]$job.output.width, [int]$job.output.height, $deckAspect, $false, $false)
|
|
21
19
|
$first = $job.operations[0]
|
|
22
20
|
if ($first.type -ne 'slide' -or $first.at_ms -ne 0) { Fail 'POWERPOINT_PROTOCOL' 'The preview schedule must initialize a slide at time zero.' }
|
|
23
21
|
Apply-Operation $first
|
|
@@ -28,6 +26,9 @@ function Run-Preview {
|
|
|
28
26
|
try { $script:geometry = [SlideVideo.Native]::PreviewContent($window, $deckAspect) }
|
|
29
27
|
catch { if ($clock.Elapsed.TotalMilliseconds -gt $deadline) { Fail 'POWERPOINT_GEOMETRY' $_.Exception.Message }; Start-Sleep -Milliseconds 20 }
|
|
30
28
|
} while ($null -eq $geometry)
|
|
29
|
+
$previewViewportWidth = [int]$job.output.width
|
|
30
|
+
$previewViewportHeight = [int]$job.output.height
|
|
31
|
+
$previewContent = [SlideVideo.Native]::OutputContent($geometry, $previewViewportWidth, $previewViewportHeight)
|
|
31
32
|
$previewClock = [Diagnostics.Stopwatch]::new()
|
|
32
33
|
$status = 'paused'
|
|
33
34
|
$nextOperation = 1
|
|
@@ -85,15 +86,15 @@ function Run-Preview {
|
|
|
85
86
|
$status = 'ended'
|
|
86
87
|
}
|
|
87
88
|
if ($null -eq $line) { Start-Sleep -Milliseconds 10; continue }
|
|
88
|
-
$
|
|
89
|
-
foreach ($
|
|
90
|
-
if ($position -ge $
|
|
91
|
-
@{
|
|
89
|
+
$targets = @(
|
|
90
|
+
foreach ($request in $job.geometry_requests) {
|
|
91
|
+
if ($position -ge $request.start_ms -and $position -lt $request.end_ms) {
|
|
92
|
+
@{ key = [string]$request.key; fragments = @(Measure-Annotation $request $true) }
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
)
|
|
95
|
-
$state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms;
|
|
96
|
-
if ($action -eq 'frame') { $state.image = [SlideVideo.Native]::PreviewJpeg($window, $geometry, $
|
|
96
|
+
$state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms; targets = @($targets); viewport = @{ width = $previewViewportWidth; height = $previewViewportHeight }; content = @{ x = $previewContent.x; y = $previewContent.y; width = $previewContent.width; height = $previewContent.height } }
|
|
97
|
+
if ($action -eq 'frame') { $state.image = [SlideVideo.Native]::PreviewJpeg($window, $geometry, $previewViewportWidth, $previewViewportHeight) }
|
|
97
98
|
[Console]::WriteLine('SLIDEVIDEO_PREVIEW ' + (ConvertTo-Json -InputObject @{ id = $command.id; state = $state } -Depth 30 -Compress))
|
|
98
99
|
[Console]::Out.Flush()
|
|
99
100
|
}
|