-
Notifications
You must be signed in to change notification settings - Fork 24
feat: lookahead offset #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release53
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -313,6 +313,15 @@ export class CasparCGDevice extends DeviceWithState<State, CasparCGDeviceTypes, | |
| const holdOnFirstFrame = !isForeground || layerProps.isLookahead | ||
| const loopingPlayTime = content.loop && !content.seek && !content.inPoint && !content.length | ||
|
|
||
| const seekOffsetByLookahead = | ||
| content.seek && layerProps.lookaheadOffset | ||
| ? content.seek + layerProps.lookaheadOffset | ||
| : content.seek | ||
| ? content.seek | ||
| : layerProps.lookaheadOffset | ||
| ? layerProps.lookaheadOffset | ||
| : undefined | ||
|
Comment on lines
+316
to
+323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix truthiness check to handle 0 values correctly. The current logic uses truthiness checks ( For example:
This is the same issue as in the Quantel integration. 🔧 Proposed fix using explicit undefined checks- const seekOffsetByLookahead =
- content.seek && layerProps.lookaheadOffset
- ? content.seek + layerProps.lookaheadOffset
- : content.seek
- ? content.seek
- : layerProps.lookaheadOffset
- ? layerProps.lookaheadOffset
- : undefined
+ const seekOffsetByLookahead =
+ content.seek !== undefined || layerProps.lookaheadOffset !== undefined
+ ? (content.seek ?? 0) + (layerProps.lookaheadOffset ?? 0)
+ : undefinedThis approach:
🤖 Prompt for AI Agents |
||
|
|
||
| stateLayer = literal<MediaLayer>({ | ||
| id: layer.id, | ||
| layerNo: mapping.layer, | ||
|
|
@@ -324,7 +333,7 @@ export class CasparCGDevice extends DeviceWithState<State, CasparCGDeviceTypes, | |
| playing: !layerProps.isLookahead && (content.playing !== undefined ? content.playing : isForeground), | ||
|
|
||
| looping: content.loop, | ||
| seek: content.seek, | ||
| seek: !layerProps.isLookahead ? content.seek : seekOffsetByLookahead, | ||
| inPoint: content.inPoint, | ||
| length: content.length, | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -124,6 +124,15 @@ function setPortStateFromLayer( | |||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| const startTime = layer.instance.originalStart || layer.instance.start | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const inPointSeekOffsetByLookahead = | ||||||||||||||||||||||||||
| content.inPoint && layer.lookaheadOffset | ||||||||||||||||||||||||||
| ? content.inPoint + layer.lookaheadOffset | ||||||||||||||||||||||||||
| : content.inPoint | ||||||||||||||||||||||||||
| ? content.inPoint | ||||||||||||||||||||||||||
| : layer.lookaheadOffset | ||||||||||||||||||||||||||
| ? layer.lookaheadOffset | ||||||||||||||||||||||||||
| : undefined | ||||||||||||||||||||||||||
|
Comment on lines
+127
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix truthiness check to handle 0 values correctly. The current logic uses truthiness checks ( For example:
🔧 Proposed fix using explicit undefined checks- const inPointSeekOffsetByLookahead =
- content.inPoint && layer.lookaheadOffset
- ? content.inPoint + layer.lookaheadOffset
- : content.inPoint
- ? content.inPoint
- : layer.lookaheadOffset
- ? layer.lookaheadOffset
- : undefined
+ const inPointSeekOffsetByLookahead =
+ content.inPoint !== undefined || layer.lookaheadOffset !== undefined
+ ? (content.inPoint ?? 0) + (layer.lookaheadOffset ?? 0)
+ : undefinedThis approach:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| port.timelineObjId = layer.id | ||||||||||||||||||||||||||
| port.notOnAir = content.notOnAir || isLookahead | ||||||||||||||||||||||||||
| port.outTransition = content.outTransition | ||||||||||||||||||||||||||
|
|
@@ -137,7 +146,7 @@ function setPortStateFromLayer( | |||||||||||||||||||||||||
| pauseTime: content.pauseTime, | ||||||||||||||||||||||||||
| playing: isLookahead ? false : content.playing ?? true, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| inPoint: content.inPoint, | ||||||||||||||||||||||||||
| inPoint: !isLookahead ? content.inPoint : inPointSeekOffsetByLookahead, | ||||||||||||||||||||||||||
| length: content.length, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| playTime: (content.noStarttime || isLookahead ? null : startTime) || null, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the meaning of what "offsetting the look-ahead" means here needs to be clarified.