Skip to content
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

Feat/vmix media reload retrying #277

Merged
merged 22 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8ceddb2
fix(vmix): fix scenario where the media load retry system would load …
Abrahamic-God Jul 27, 2023
2877b3e
refactor: improve type safety and reduce the odds of forgetting to up…
Abrahamic-God Jul 31, 2023
386fbb4
chore: wait only 5 seconds as a backoff
Abrahamic-God Jul 31, 2023
4df7032
docs: comments for future me
Abrahamic-God Jul 31, 2023
fecb7c7
chore: fix tests
Abrahamic-God Aug 14, 2023
478d256
chore: disable retry/enforcement system in tests
Abrahamic-God Aug 14, 2023
00bad3d
chore: change how the polling/enforcement system is disabled in tests
Abrahamic-God Aug 14, 2023
2ac0c4f
Merge pull request #272 from tv2norge-collab/fix/media-load-retrying
jesperstarkar Aug 14, 2023
867f30f
fix: media re-playing shortly after completing
Abrahamic-God Aug 15, 2023
4780fcf
fix: prevent conflicts with sisyfos
Abrahamic-God Aug 15, 2023
ccf2b3d
chore: refactor for simplicity and clarity
Abrahamic-God Aug 15, 2023
ddac35f
chore: rename variable
Abrahamic-God Aug 15, 2023
266969d
Merge branch 'fix/media-load-retrying' into feat/vmix-media-reload-re…
jesperstarkar Aug 15, 2023
c75d4d8
fix: another potential fix for this system not working as intended
Abrahamic-God Aug 15, 2023
b0c2df7
Merge commit 'c75d4d8ee6271be95d1fcd60f8741c3281db0521' into feat/vmi…
jesperstarkar Aug 15, 2023
feb709b
fix: add a future-proof "resetResolver" event
Abrahamic-God Aug 28, 2023
a8fedc9
Merge branch 'release50' into feat/vmix-media-reload-retrying
jesperstarkar Sep 20, 2023
47732f5
Merge commit 'feb709b5f4a80ce0ebcbe13329c86cec9904fbec' into feat/vmi…
jesperstarkar Sep 20, 2023
14c73fa
chore: fix tests
Abrahamic-God Sep 20, 2023
6b0dfe4
Merge commit '14c73faa69f1a4cbdc007fcf4fe301bef3999519' into feat/vmi…
jesperstarkar Sep 20, 2023
a482e57
feat: changes the logic for setting a pollInterval
jesperstarkar Nov 15, 2023
88b875d
feat: changes the implementation of how to assign a pollTime.
jesperstarkar Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export interface VMixOptions {
host: string
port: number
/**
* How often, in milliseconds, to try re-sending certain failed commands. Defaults to 10 seconds. Set to 0 to disable. As of June 9th, 2023, this only works for media loading commands.
* How often, in milliseconds, for when we should poll vMix to query its actual state. Used to know when to re-send certain failed commands. Values <= 0 disables the polling. Defaults to 10000ms.
*/
retryInterval?: number
pollInterval?: number
}

export interface MappingVmixProgram {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"type": "integer",
"ui:title": "Port"
},
"retryInterval": {
"pollInterval": {
jesperstarkar marked this conversation as resolved.
Show resolved Hide resolved
"type": "number",
"ui:title": "Retry Interval",
"description": "How often, in milliseconds, to try re-sending certain failed commands. Defaults to 10 seconds. Set to 0 to disable. As of June 9th, 2023, this only works for media loading commands."
"ui:title": "Poll Interval",
"description": "How often, in milliseconds, for when we should poll vMix to query its actual state. Used to know when to re-send certain failed commands. Values <= 0 disables the polling. Defaults to 10000ms."
}
},
"required": ["host", "port"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -267,6 +268,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -568,6 +570,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -811,6 +814,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -1121,6 +1125,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -1471,6 +1476,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -1697,6 +1703,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -1825,6 +1832,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -1950,6 +1958,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2075,6 +2084,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2201,6 +2211,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2331,6 +2342,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2462,6 +2474,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2587,6 +2600,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 8099,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2714,6 +2728,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2818,6 +2833,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -2942,6 +2958,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -3020,6 +3037,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -3120,6 +3138,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -3221,6 +3240,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -3339,6 +3359,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down Expand Up @@ -3467,6 +3488,7 @@ describe('vMix', () => {
options: {
host: '127.0.0.1',
port: 9999,
pollInterval: 0,
},
commandReceiver: commandReceiver0,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ describe('vMixAPI', () => {
panY: 0,
zoom: 1,
},
listFilePaths: undefined,
name: 'Cam 1',
overlays: undefined,
playing: true,
solo: false,
},
'2': {
number: 2,
Expand All @@ -92,6 +97,11 @@ describe('vMixAPI', () => {
panY: 0,
zoom: 1,
},
listFilePaths: undefined,
name: 'Cam 2',
overlays: undefined,
playing: true,
solo: false,
},
},
overlays: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export interface Response {
body?: string
}

/**
* This TSR integration polls the state of vMix and merges that into our last-known state.
* However, not all state properties can be retried from vMix's API.
* Therefore, there are some properties that we must "carry over" from our last-known state, every time.
* These are those property keys for the Input state objects.
*/
export type InferredPartialInputStateKeys = 'filePath' | 'fade' | 'audioAuto' | 'restart'

export class BaseConnection extends EventEmitter<ConnectionEvents> {
private _socket?: Socket
private _unprocessedLines: string[] = []
Expand Down Expand Up @@ -313,27 +321,55 @@ export class VMix extends BaseConnection {
version: xmlState['vmix']['version']['_text'],
edition: xmlState['vmix']['edition']['_text'],
inputs: _.indexBy(
(xmlState['vmix']['inputs']['input'] as Array<any>).map((input): VMixInput => {
fixedInputsCount++
return {
number: Number(input['_attributes']['number']),
type: input['_attributes']['type'],
state: input['_attributes']['state'],
position: Number(input['_attributes']['position']) || 0,
duration: Number(input['_attributes']['duration']) || 0,
loop: input['_attributes']['loop'] === 'False' ? false : true,
muted: input['_attributes']['muted'] === 'False' ? false : true,
volume: Number(input['_attributes']['volume'] || 100),
balance: Number(input['_attributes']['balance'] || 0),
audioBuses: input['_attributes']['audiobusses'],
transform: {
panX: Number(input['position'] ? input['position']['_attributes']['panX'] || 0 : 0),
panY: Number(input['position'] ? input['position']['_attributes']['panY'] || 0 : 0),
alpha: -1, // unavailable
zoom: Number(input['position'] ? input['position']['_attributes']['zoomX'] || 1 : 1), // assume that zoomX==zoomY
},
(xmlState['vmix']['inputs']['input'] as Array<any>).map(
(input): Required<Omit<VMixInput, InferredPartialInputStateKeys>> => {
fixedInputsCount++

let fixedListFilePaths: VMixInput['listFilePaths'] = undefined
if (input['_attributes']['type'] === 'VideoList') {
if (Array.isArray(input['list']['item'])) {
// Handles the case where there is more than one item in the list.
fixedListFilePaths = input['list']['item'].map((item) => item['_text'])
} else if (input['list']['item']) {
// Handles the case where there is exactly one item in the list.
fixedListFilePaths = [input['list']['item']['_text']]
}
}

let fixedOverlays: VMixInput['overlays'] = undefined
if (Array.isArray(input['overlay'])) {
// Handles the case where there is more than one item in the list.
fixedOverlays = input['overlay'].map((item) => parseInt(item['_attributes']['index'], 10))
} else if (input['overlay']) {
// Handles the case where there is exactly one item in the list.
fixedOverlays = [parseInt(input['overlay']['_attributes']['index'], 10)]
}

return {
number: Number(input['_attributes']['number']),
type: input['_attributes']['type'],
name: input['_attributes']['title'],
state: input['_attributes']['state'],
playing: input['_attributes']['state'] === 'Running',
position: Number(input['_attributes']['position']) || 0,
duration: Number(input['_attributes']['duration']) || 0,
loop: input['_attributes']['loop'] === 'False' ? false : true,
muted: input['_attributes']['muted'] === 'False' ? false : true,
volume: Number(input['_attributes']['volume'] || 100),
balance: Number(input['_attributes']['balance'] || 0),
solo: input['_attributes']['loop'] === 'False' ? false : true,
audioBuses: input['_attributes']['audiobusses'],
transform: {
panX: Number(input['position'] ? input['position']['_attributes']['panX'] || 0 : 0),
panY: Number(input['position'] ? input['position']['_attributes']['panY'] || 0 : 0),
alpha: -1, // unavailable
zoom: Number(input['position'] ? input['position']['_attributes']['zoomX'] || 1 : 1), // assume that zoomX==zoomY
},
overlays: fixedOverlays!,
listFilePaths: fixedListFilePaths!,
}
}
}),
),
'number'
),
overlays: (xmlState['vmix']['overlays']['overlay'] as Array<any>).map((overlay) => {
Expand Down
Loading
Loading