SCENE_TEST, fix respsonse handling
This commit is contained in:
@@ -14,7 +14,7 @@ class DBus(private val q: Queue<Op>) {
|
|||||||
|
|
||||||
private val thread = thread(
|
private val thread = thread(
|
||||||
start = true,
|
start = true,
|
||||||
isDaemon = false,
|
isDaemon = true,
|
||||||
name = "dbus",
|
name = "dbus",
|
||||||
) {
|
) {
|
||||||
DBusConnectionBuilder.forSessionBus().build().use { dbus ->
|
DBusConnectionBuilder.forSessionBus().build().use { dbus ->
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ object Main {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val q:BlockingQueue<Op> = LinkedBlockingQueue()
|
val q:BlockingQueue<Op> = LinkedBlockingQueue()
|
||||||
DBus(q) // forks non-daemon thread
|
DBus(q) // forks daemon thread
|
||||||
ObsCommunity(q).run() // blocks
|
ObsCommunity(q).run() // blocks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package net.eksb.obsdc
|
package net.eksb.obsdc
|
||||||
|
|
||||||
import io.obswebsocket.community.client.OBSRemoteController
|
import io.obswebsocket.community.client.OBSRemoteController
|
||||||
|
import io.obswebsocket.community.client.message.event.ui.StudioModeStateChangedEvent
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.util.concurrent.BlockingQueue
|
import java.util.concurrent.BlockingQueue
|
||||||
|
|
||||||
|
// protocol docs: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
|
||||||
class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
||||||
|
|
||||||
private val controller = OBSRemoteController.builder()
|
private val controller = OBSRemoteController.builder()
|
||||||
@@ -11,7 +13,17 @@ class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
|||||||
.port(4455)
|
.port(4455)
|
||||||
.password("R3tRkVXhFofJ2wRF") // TODO put this in a file
|
.password("R3tRkVXhFofJ2wRF") // TODO put this in a file
|
||||||
.autoConnect(false)
|
.autoConnect(false)
|
||||||
.lifecycle().onReady(::ready).and()
|
.connectionTimeout(3)
|
||||||
|
.lifecycle()
|
||||||
|
.onReady(::ready)
|
||||||
|
.onClose { code -> log.error("closed:${code}")}
|
||||||
|
.onControllerError { e -> log.error("controller error", e ) }
|
||||||
|
.onCommunicatorError { e -> log.error("comm error", e ) }
|
||||||
|
.onDisconnect { log.info("disconnected") }
|
||||||
|
.and()
|
||||||
|
.registerEventListener(StudioModeStateChangedEvent::class.java) {
|
||||||
|
log.info("studio mode state change: ${it}")
|
||||||
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
fun run() {
|
fun run() {
|
||||||
@@ -23,21 +35,31 @@ class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ready() {
|
private fun ready() {
|
||||||
while (true) {
|
log.info("ready")
|
||||||
val op: Op = q.take() // blocks
|
val op: Op = q.take() // blocks
|
||||||
log.info("op: ${op}")
|
log.info("op: ${op}")
|
||||||
op(op)
|
op(op)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun op(op:Op) {
|
private fun op(op:Op) {
|
||||||
when(op) {
|
when(op) {
|
||||||
|
Op.SCENE_TEST -> {
|
||||||
|
controller.setCurrentProgramScene("test") { response ->
|
||||||
|
log.info("set scene response: ${response.isSuccessful}")
|
||||||
|
ready()
|
||||||
|
}
|
||||||
|
}
|
||||||
Op.STUDIO_TRANSITION -> {
|
Op.STUDIO_TRANSITION -> {
|
||||||
controller.triggerStudioModeTransition { response ->
|
controller.triggerStudioModeTransition { response ->
|
||||||
// This does not get called?
|
// This does not get called?
|
||||||
log.info("Response successful: ${response.isSuccessful}")
|
log.info("Response successful: ${response.isSuccessful}")
|
||||||
|
ready()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Op.TODO -> {
|
||||||
|
log.info("OP=TODO")
|
||||||
|
ready()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +67,3 @@ class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
|||||||
private val log = LoggerFactory.getLogger(ObsCommunity::class.java)
|
private val log = LoggerFactory.getLogger(ObsCommunity::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move window:
|
|
||||||
// https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#setsceneitemtransform
|
|
||||||
|
|||||||
@@ -2,5 +2,7 @@ package net.eksb.obsdc
|
|||||||
|
|
||||||
enum class Op {
|
enum class Op {
|
||||||
STUDIO_TRANSITION,
|
STUDIO_TRANSITION,
|
||||||
|
SCENE_TEST,
|
||||||
|
TODO,
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user