Skip to content

Commit

Permalink
fix: some broken cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jun 20, 2019
1 parent 957ed76 commit 9ebde2e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/commands/Macro/MacroPropertiesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class MacroPropertiesCommand extends AbstractCommand {

deserialize (rawCommand: Buffer) {
this.macroIndexID = rawCommand.readUInt16BE(0)
const descLen = rawCommand.readUInt16BE(4)
const nameLen = rawCommand.readUInt16BE(6)
const nameLen = rawCommand.readUInt16BE(4)
const descLen = rawCommand.readUInt16BE(6)

this.properties = {
description: '',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/Media/MediaPoolFrameDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MediaPoolFrameDescriptionCommand extends AbstractCommand {
this.frameIndex = rawCommand.readUInt16BE(2)
this.properties = {
isUsed: rawCommand[4] === 1,
hash: Util.bufToNullTerminatedString(rawCommand, 5, 16),
hash: Util.bufToBase64String(rawCommand, 5, 16),
fileName: Util.bufToNullTerminatedString(rawCommand, 24, rawCommand[23])
}
}
Expand Down
47 changes: 42 additions & 5 deletions src/commands/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ const commandConverters: CommandTestConverterSet = {
'gain': (v: number) => ({ val: Math.round(v * 100) / 100 })
}
},
'AMMO': {
idAliases: {},
propertyAliases: {
'programOutFollowFadeToBlack': (val: any) => ({ val, name: 'followFadeToBlack' }),
'balance': (v: number) => ({ val: Math.round(v * 10) / 10 }),
'gain': (v: number) => ({ val: Math.round(v * 100) / 100 })
}
},
'_top': {
idAliases: {},
propertyAliases: {
Expand Down Expand Up @@ -258,6 +266,14 @@ const commandConverters: CommandTestConverterSet = {
'borderWidth': (v: number) => ({ val: Math.round(v * 100) })
}
},
'TrPs': {
idAliases: {
'mixEffect': 'index'
},
propertyAliases: {
'handlePosition': (v: number) => ({ val: Math.round(v * 10000) })
}
},
'MRPr': {
idAliases: {},
propertyAliases: {
Expand Down Expand Up @@ -288,6 +304,32 @@ const commandConverters: CommandTestConverterSet = {
},
propertyAliases: {}
},
'MPCS': {
idAliases: {
'mediaPool': 'index'
},
propertyAliases: {},
customMutate: (obj: any) => {
obj.frames = []
return obj
}
},
'MPfe': {
idAliases: {
'mediaPool': 'bank',
'frameIndex': 'index'
},
propertyAliases: {
'filename': (val: any) => ({ val, name: 'fileName' }),
// 'hash': (v: string) => ({ val: Buffer.from(v, 'base64').toString('ascii') })
}
},
'MPrp': {
idAliases: {},
propertyAliases: {
'index': (val: any) => ({ val, name: 'macroIndex' })
}
},
'PrgI': {
idAliases: {
'mixEffect': 'index'
Expand Down Expand Up @@ -347,12 +389,7 @@ describe('Commands v7.2', () => {
// Temporarily ignore the failures
case 'AMIP':
case '_top':

//
case 'AMMO':
case 'MPrp':
case 'MPfe':
case 'MPCS':
case 'KKFP':
case 'TrPs':
return
Expand Down
4 changes: 4 additions & 0 deletions src/lib/atemUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export namespace Util {
return array
}

export function bufToBase64String (buffer: Buffer, start: number, length: number): string {
return buffer.toString('base64', start, start + length)
}

export function bufToNullTerminatedString (buffer: Buffer, start: number, length: number): string {
const slice = buffer.slice(start, start + length)
const nullIndex = slice.indexOf('\0')
Expand Down

0 comments on commit 9ebde2e

Please sign in to comment.