The WebSocket Vendor API provides remote control and automation capabilities for the OBS Polyemesis plugin through the obs-websocket protocol. This enables automated testing, CI/CD integration, and external control applications.
- WebSocket API architecture designed
- 16 vendor request handlers implemented
- Event emission system designed
- Integration with plugin main module
- Global state accessor functions
- Type-safe API client access
- obs-websocket-api headers required: The implementation is complete but requires obs-websocket development headers to compile
- Installation of obs-websocket development package
- Build system integration with obs-websocket
To use the WebSocket API, you need:
- obs-websocket plugin (installed) ✅
- obs-websocket development headers (not available) ❌
git clone https://github.com/obsproject/obs-websocket.git
cd obs-websocket
# Copy headers to your OBS installation
cp -r src/obs-websocket-api.h /path/to/obs/include/# Example for Linux
sudo apt-get install obs-websocket-dev
# Example for macOS with Homebrew
brew install obs-websocket --HEADCreateProfile- Create a new streaming profileDeleteProfile- Delete an existing profileDuplicateProfile- Duplicate a profile with a new nameGetProfiles- List all profiles with status
AddDestination- Add streaming destination to profileRemoveDestination- Remove destination from profileEditDestination- Modify existing destination
StartProfile- Start streaming for a profileStopProfile- Stop streaming for a profileStartAllProfiles- Start all inactive profilesStopAllProfiles- Stop all active profiles
GetPluginState- Get overall plugin stateGetProfileState- Get detailed state of specific profileGetConnectionStatus- Get Restreamer connection statusGetButtonStates- Get UI button states (for testing)
ConnectToServer- Connect to Restreamer server
ProfileCreated- Fired when profile is createdProfileDeleted- Fired when profile is deletedProfileStateChanged- Fired when profile status changesConnectionStatusChanged- Fired when Restreamer connection changesButtonStatesChanged- Fired when UI button states changeErrorOccurred- Fired on errors
from obswebsocket import obsws, requests
# Connect to OBS WebSocket
ws = obsws("localhost", 4455, "your-password")
ws.connect()
# Create a profile
response = ws.call(requests.CallVendorRequest(
vendorName="polyemesis",
requestType="CreateProfile",
requestData={"profileName": "My Profile"}
))
profile_id = response.datain['responseData']['profileId']
print(f"Created profile: {profile_id}")
# Add destination
ws.call(requests.CallVendorRequest(
vendorName="polyemesis",
requestType="AddDestination",
requestData={
"profileId": profile_id,
"name": "Twitch",
"url": "rtmp://live.twitch.tv/app/",
"streamKey": "your_stream_key"
}
))
# Start streaming
ws.call(requests.CallVendorRequest(
vendorName="polyemesis",
requestType="StartProfile",
requestData={"profileId": profile_id}
))
# Get profile state
state = ws.call(requests.CallVendorRequest(
vendorName="polyemesis",
requestType="GetProfileState",
requestData={"profileId": profile_id}
))
print(f"Profile status: {state.datain['responseData']['status']}")
ws.disconnect()src/websocket-api.h- WebSocket API header declarationssrc/websocket-api.cpp- WebSocket API implementationsrc/plugin-main.h- Global accessor functions- Updated
src/plugin-main.c- WebSocket initialization/shutdown - Updated
src/restreamer-dock.h- Public accessor methods - Updated
src/restreamer-dock-bridge.cpp- Accessor implementation - Updated
CMakeLists.txt- Build configuration
Once obs-websocket development headers are available:
cmake --build build-test --config ReleaseThe plugin will automatically register the "polyemesis" vendor with obs-websocket on startup.
See tests/websocket/ directory for automated test suite (pending completion of Python test framework).
Cause: obs-websocket development headers not installed
Solution:
- Install obs-websocket development package
- OR temporarily disable WebSocket API by commenting out initialization in
plugin-main.c
Cause: obs-websocket plugin not loaded or incompatible version
Solution:
- Ensure obs-websocket 5.x+ is installed
- Check OBS logs for obs-websocket errors
- Verify obs-websocket is enabled in OBS settings
- Install obs-websocket development headers
- Build plugin with WebSocket API enabled
- Create Python test automation framework
- Implement automated workflow tests
- Add CI/CD integration tests