Skip to content

Commit

Permalink
Merge pull request #8 from SuperFlyTV/fix/caspar-2.3-compatibility
Browse files Browse the repository at this point in the history
Fix: Caspar 2.2 and 2.3 compatibility
  • Loading branch information
ianshade authored May 20, 2020
2 parents 6dca1c5 + 03922d3 commit bad8489
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/imageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ImageProvider {
private frameCounter = 0

private wasDisconnected: boolean = false
private versionBelow220: boolean = false

constructor () {
console.log(`Connecting to CasparCG at ${config.casparHost}, port ${config.casparPort}...`)
Expand All @@ -71,6 +72,7 @@ export class ImageProvider {
}

async init () {
await this.checkVersion()

const casparConfig = await this.casparcg.infoConfig()

Expand Down Expand Up @@ -223,21 +225,28 @@ export class ImageProvider {
const qmax = config.stream && config.stream.qmax || 5

const streamProducerId = 998
try {
await this.casparcg.do(
new AMCP.CustomCommand({
channel: myStream.channel,
command: (
`REMOVE ${myStream.channel}-${streamProducerId}`
)
})
)
} catch (e) {
console.log(`Cannot remove consumer ${myStream.channel}-${streamProducerId}.`)
}

await this.casparcg.do(
new AMCP.CustomCommand({
channel: myStream.channel,
command: (
`REMOVE ${myStream.channel}-${streamProducerId}`
)
})
)
const params = this.versionBelow220 ?
`-f mpjpeg -multiple_requests 1 -qmin ${qmin} -qmax ${qmax}` :
`-format mpjpeg -multiple_requests 1 -qmin:v ${qmin} -qmax:v ${qmax}`

await this.casparcg.do(
new AMCP.CustomCommand({
channel: myStream.channel,
command: (
`ADD ${myStream.channel}-${streamProducerId} STREAM http://127.0.0.1:${config.port}/feed/${myStream.id} -f mpjpeg -multiple_requests 1 -qmin ${qmin} -qmax ${qmax}`
`ADD ${myStream.channel}-${streamProducerId} STREAM http://127.0.0.1:${config.port}/feed/${myStream.id} ${params}`
)
})
)
Expand Down Expand Up @@ -505,6 +514,13 @@ export class ImageProvider {
})
)
}
private async checkVersion () {
const versionCommand = await this.casparcg.version()
const versionParts = versionCommand.response.data.toString().split('.')
if (parseInt(versionParts[0], 10) === 2 && parseInt(versionParts[1], 10) < 2) {
this.versionBelow220 = true
}
}
}
interface Region {
id: string
Expand Down

0 comments on commit bad8489

Please sign in to comment.