Skip to content

Commit

Permalink
Merge pull request #194 from SuperFlyTV/fix/bug-deserialize-info-channel
Browse files Browse the repository at this point in the history
fix: bug fix in INFO CHANNEL deserializer
  • Loading branch information
nytamin authored Oct 17, 2023
2 parents 81757d1 + 985417b commit 1a929da
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/__tests__/deserializers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,38 @@ describe('deserializers', () => {
})
)
})
it('should deserialize INFO Channel (empty channel)', async () => {
const input = [
`<?xml version="1.0" encoding="utf-8"?>
<channel>
<framerate>50</framerate>
<framerate>1</framerate>
<mixer>
<audio>
<volume>0</volume>
<volume>0</volume>
</audio>
</mixer>
</channel>`,
]

const output = await deserializers[Commands.InfoChannel](input)

expect(output).toMatchObject(
literal<InfoChannelEntry>({
channel: {
framerate: 50,
mixer: {
audio: {
volumes: [0, 0],
},
},

layers: [],
},
})
)
})
it('should deserialize INFO Channel', async () => {
const input = [
`<?xml version="1.0" encoding="utf-8"?>
Expand Down
3 changes: 2 additions & 1 deletion src/deserializers/deserializeInfoChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const deserializeInfoChannel = async (line: string): Promise<InfoChannelE
const channel = ensureArray(parsed.channel)[0]
const mixer = ensureArray(channel.mixer)[0]
const mixerStage = ensureArray(channel.stage)[0]
const mixerLayer = ensureArray(mixerStage?.layer)[0] ?? {}

const data: InfoChannelEntry = {
channel: {
Expand All @@ -23,7 +24,7 @@ export const deserializeInfoChannel = async (line: string): Promise<InfoChannelE
},

layers: compact(
Object.entries(ensureArray(mixerStage.layer)[0]).map(([layerName, layer0]) => {
Object.entries(mixerLayer).map(([layerName, layer0]) => {
const m = layerName.match(/layer_(\d+)/)
if (!m) return undefined

Expand Down

0 comments on commit 1a929da

Please sign in to comment.