Skip to content

Implement BlackMagic ATEM integration with real-time preview/program monitoring#42

Draft
Keboo with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-381208a7-3d56-4549-b8b4-1567ea4c285e
Draft

Implement BlackMagic ATEM integration with real-time preview/program monitoring#42
Keboo with Copilot wants to merge 5 commits into
masterfrom
copilot/fix-381208a7-3d56-4549-b8b4-1567ea4c285e

Conversation

Copilot AI commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR implements integration with BlackMagic ATEM video switchers, enabling real-time monitoring of Preview and Program inputs directly from HueCue's status bar.

Changes

Core ATEM Connection Service

  • New AtemConnection.cs: Complete UDP-based ATEM protocol implementation
    • Handshake and connection management
    • Real-time packet parsing for Preview (PrvI) and Program (PrgI) commands
    • Automatic ACK handling
    • Event-driven architecture with Connected, Disconnected, PreviewInputChanged, and ProgramInputChanged events
    • Comprehensive input source mapping (40+ standard ATEM sources including Cameras, Media Players, Color sources, etc.)

ViewModel Integration

  • Added three new observable properties to MainWindowViewModel:
    • AtemPreviewInput - Current preview input name
    • AtemProgramInput - Current program input name
    • AtemConnected - Connection status
  • Added ConnectToAtemCommand for toggling ATEM connection
  • Thread-safe event handlers using Application.Current.Dispatcher.Invoke to marshal updates from background UDP thread to UI thread
  • Proper cleanup in Dispose() method

UI Updates

  • File Menu: Added "Connect to ATEM" menu item that dynamically changes to "Disconnect from ATEM" when connected
  • Status Bar: Added ATEM Preview and Program displays with smart visibility (hidden when not connected)
  • Professional layout with separators between status items

Testing

  • New AtemConnectionTests.cs with unit tests for connection initialization, disposal, and cleanup
  • Updated MainWindowViewModelTests.cs to include ATEM properties in existing tests
  • All tests pass and follow existing patterns

Documentation

  • Updated README with ATEM integration in features list
  • Added usage instructions
  • Updated technical details to mention ATEM protocol implementation

Configuration

  • Default ATEM IP: 192.168.10.240 (can be modified in code)
  • Port: 9910 (standard ATEM control port)
  • Protocol: UDP

Example Usage

1. Launch HueCue
2. File → Connect to ATEM
3. Status bar shows: "ATEM Preview: Camera 1 | ATEM Program: Camera 2"
4. Switch inputs on your ATEM - status bar updates in real-time!
5. File → Disconnect from ATEM to disconnect

Technical Implementation

The implementation uses a background thread for UDP communication with proper thread synchronization:

  • UDP socket on background thread handles packet receive loop
  • Events raised from background thread
  • UI updates marshaled to UI thread via Dispatcher.Invoke
  • Async/await pattern for non-blocking connection
  • Proper resource cleanup with IDisposable

Dependencies

No additional dependencies required - implementation uses only standard .NET networking libraries.

Testing Notes

While unit tests are included, manual testing on Windows with an actual ATEM switcher is recommended to verify:

  • Connection success/failure handling
  • Real-time preview/program updates
  • Graceful disconnection
  • Proper cleanup on app close

Fixes #41

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement BlackMagic ATEM integration</issue_title>
<issue_description>Implement integration connecting to a black magic ATEM.

Include UI status bar updates showing with scene is preview and which is program.

A sample of doing this integration can be found in this repository. https://github.com/LibAtem/LibAtem</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #41

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits October 5, 2025 17:00
Co-authored-by: Keboo <952248+Keboo@users.noreply.github.com>
Co-authored-by: Keboo <952248+Keboo@users.noreply.github.com>
Co-authored-by: Keboo <952248+Keboo@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement BlackMagic ATEM integration Implement BlackMagic ATEM integration with real-time preview/program monitoring Oct 5, 2025
Copilot AI requested a review from Keboo October 5, 2025 17:07
Comment thread Directory.Packages.props Outdated
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.9" />
<PackageVersion Include="Velopack" Version="0.0.1362-gfa48e3c" />
<PackageVersion Include="log4net" Version="3.0.1" />

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this reference and all usages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed log4net package reference from both Directory.Packages.props and HueCue.csproj. The package was not being used in the code. (commit 6eb8d2c)

Co-authored-by: Keboo <952248+Keboo@users.noreply.github.com>
Copilot AI requested a review from Keboo October 5, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement BlackMagic ATEM integration

2 participants