Skip to content

Commit

Permalink
wip: lib and bits
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 15, 2024
1 parent 3988e8e commit f64ccc7
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 374 deletions.
1 change: 1 addition & 0 deletions build-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ module.exports = {
// /^(atemSocketChild)$/i,
],
forceRemoveNodeGypFromPkg: true,
prebuilds: ['@julusian/image-rs'],
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"@atem-connection/camera-control": "^0.2.0",
"@companion-module/base": "~1.9.0",
"@julusian/image-rs": "^1.1.1",
"atem-connection": "3.6.0-nightly-master-20240419-215343-75a89856.0",
"lodash-es": "^4.17.21",
"type-fest": "^4.24.0"
Expand Down
31 changes: 20 additions & 11 deletions src/feedback/mediaPool.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AtemMediaPlayerPicker, AtemMediaPlayerSourcePicker } from '../input.js'
import { AtemMediaPlayerSourcePicker } from '../input.js'
import type { ModelSpec } from '../models/index.js'
import type { MyAdvancedFeedbackEvent, MyFeedbackDefinitions } from './types.js'
import { FeedbackId } from './FeedbackId.js'
import type { MediaPoolPreviewOptions, StateWrapper } from '../state.js'
import type { StateWrapper } from '../state.js'
import type { MediaPoolPreviewOptions } from '../mediaPoolPreviews.js'
import type { MyOptionsHelper } from '../common.js'

export interface AtemMediaPoolFeedbacks {
[FeedbackId.MediaPoolPreview]: {
mediaplayer: number
// TODO - clip vs still?
source: number

Expand All @@ -31,7 +31,6 @@ export function createMediaPoolFeedbacks(
name: 'Media pool: Preview image',
description: 'Preview of the specified media pool slot',
options: {
mediaplayer: AtemMediaPlayerPicker(model),
source: AtemMediaPlayerSourcePicker(model, state.state),

crop: {
Expand All @@ -56,20 +55,33 @@ export function createMediaPoolFeedbacks(
{ id: 'center', label: 'Center' },
{ id: 'bottom', label: 'Bottom' },
],
isVisible: (options) => options['crop'] !== 'none',
isVisible: (options) => options['crop'] === 'none',
},
},
callback: async ({ id, options, image }) => {
console.log('check feedback', id, options.getJson())
callback: async ({ options, image }) => {
const source = options.getPlainNumber('source')

const previewOptions = parsePreviewOptions(options, image)
if (!previewOptions) return {}

const imageBuffer = await state.mediaPoolCache.getPreviewImage(options.getPlainNumber('source'), previewOptions)
const imageBuffer = await state.mediaPoolCache.getPreviewImage(source, previewOptions)
if (imageBuffer) {
return imageBuffer
}

// make sure the load was triggered
state.mediaPoolCache.ensureLoaded(source)

const isSlotOccupied = state.mediaPoolCache.isSlotOccupied(source)
if (!isSlotOccupied) {
return {
text: 'Empty',
size: 'auto',
bgcolor: 0,
fgcolor: 0xffffff,
}
}

// TODO
return {
text: 'Loading...',
Expand All @@ -79,9 +91,6 @@ export function createMediaPoolFeedbacks(
}
},
subscribe: ({ id, options }) => {
// const previewOptions = parsePreviewOptions(options)
// if (!previewOptions) return

state.mediaPoolCache.subscribe(options.getPlainNumber('source'), id)
},
unsubscribe: ({ id, options }) => {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { GetFeedbacksList } from './feedback/index.js'
import { FeedbackId } from './feedback/FeedbackId.js'
import { GetAutoDetectModel, GetModelSpec, GetParsedModelSpec, type ModelSpec } from './models/index.js'
import { GetPresetsList } from './presets/index.js'
import { MediaPoolPreviewCache, type StateWrapper } from './state.js'
import { type StateWrapper } from './state.js'
import { MediaPoolPreviewCache } from './mediaPoolPreviews.js'
import { MODEL_AUTO_DETECT } from './models/types.js'
import {
InitVariables,
Expand Down Expand Up @@ -71,10 +72,9 @@ class AtemInstance extends InstanceBase<AtemConfig> {
emptyState,
async (isClip, slot) => {
if (!this.atem) throw new Error('Atem not initialised')
// TODO
// return this.atem?.downloadStill(0)

if (isClip) {
// TODO
throw new Error('Not implemented!')
} else {
const buffer = await this.atem.downloadStill(slot /* 'raw'*/) // TODO - perform optimised conversions
Expand Down
Loading

0 comments on commit f64ccc7

Please sign in to comment.