Compare commits
No commits in common. "master" and "v1.1.0" have entirely different histories.
24
README.md
24
README.md
@ -1,31 +1,9 @@
|
|||||||
StreamDeck OBS Replay
|
StreamDeck OBS Replay
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
Enables toggling replay recording and saving replays from Stream Deck with feedback shown on the icons.
|
Installation
|
||||||
|
|
||||||
Installation - OBS Studio
|
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Install [obs-websocket](https://github.com/Palakis/obs-websocket) and configure
|
Install [obs-websocket](https://github.com/Palakis/obs-websocket) and configure
|
||||||
|
|
||||||
Add plugin to Stream Deck (double click) and configure your icons with the host, port (default: 4444) and password (if configured).
|
Add plugin to Stream Deck (double click) and configure your icons with the host, port (default: 4444) and password (if configured).
|
||||||
|
|
||||||
Installation - Streamlabs OBS
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Set port to `59650` and the plugin will auto detect.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
-------
|
|
||||||
|
|
||||||
StreamLabs OBS (Base software)
|
|
||||||
|
|
||||||
OBS Studio (Base software)
|
|
||||||
|
|
||||||
Stéphane Lepin ([obs-websocket](https://github.com/Palakis/obs-websocket))
|
|
||||||
|
|
||||||
Chris de Graaf ([go-obs-websocket](https://github.com/christopher-dG/go-obs-websocket))
|
|
||||||
|
|
||||||
Elgato/Corsair for Stream Deck + SDK/Documentation
|
|
||||||
|
|
||||||
Bumbler (https://bumbler.tv) for icons/plugin icon
|
|
||||||
@ -8,14 +8,13 @@ import (
|
|||||||
type SlobsClient struct {
|
type SlobsClient struct {
|
||||||
client *slobs.Client
|
client *slobs.Client
|
||||||
key string
|
key string
|
||||||
password string
|
|
||||||
recording bool
|
recording bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSlobsClient(key, host string, port int, password string) *SlobsClient {
|
func NewSlobsClient(key, host string, port int, password string) *SlobsClient {
|
||||||
slobsc := slobs.NewClient(host + ":" + strconv.Itoa(port))
|
slobsc := slobs.NewClient(host + ":" + strconv.Itoa(port))
|
||||||
|
|
||||||
return &SlobsClient{client: slobsc, key: key, password: password}
|
return &SlobsClient{client: slobsc, key: key}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -32,19 +31,6 @@ func (c *SlobsClient) Connect() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client.Auth(c.password, func(err error) {
|
|
||||||
if err != nil {
|
|
||||||
// TODO alert that it failed to startup?
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.requestInitialData()
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *SlobsClient) requestInitialData() {
|
|
||||||
c.client.SendRPC("StreamingService", "getModel", func(e *slobs.RPCResponse) {
|
c.client.SendRPC("StreamingService", "getModel", func(e *slobs.RPCResponse) {
|
||||||
state := &slobs.IStreamingState{}
|
state := &slobs.IStreamingState{}
|
||||||
|
|
||||||
@ -77,6 +63,8 @@ func (c *SlobsClient) requestInitialData() {
|
|||||||
c.recording = false
|
c.recording = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SlobsClient) Disconnect() error {
|
func (c *SlobsClient) Disconnect() error {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -3,9 +3,11 @@ module meow.tf/streamdeck/obs-replay
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
|
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
|
||||||
github.com/gorilla/websocket v1.4.1
|
github.com/gorilla/websocket v1.4.1
|
||||||
github.com/mitchellh/mapstructure v1.1.2
|
github.com/mitchellh/mapstructure v1.1.2
|
||||||
|
github.com/mordillo123/sockjs-go-client v0.0.0-20161009150606-c1486c966a40
|
||||||
github.com/valyala/fastjson v1.4.1
|
github.com/valyala/fastjson v1.4.1
|
||||||
meow.tf/streamdeck/sdk v0.0.0-20190519021527-54a933f8777d
|
meow.tf/streamdeck/sdk v0.0.0-20190519021527-54a933f8777d
|
||||||
)
|
)
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -1,9 +1,13 @@
|
|||||||
|
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||||
|
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 h1:74lLNRzvsdIlkTgfDSMuaPjBr4cf6k7pwQQANm/yLKU=
|
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 h1:74lLNRzvsdIlkTgfDSMuaPjBr4cf6k7pwQQANm/yLKU=
|
||||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4=
|
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4=
|
||||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/mordillo123/sockjs-go-client v0.0.0-20161009150606-c1486c966a40 h1:d/FazCBU+C1trw+F+Gdah5Q3QX5kNsOigUCes3z0gVc=
|
||||||
|
github.com/mordillo123/sockjs-go-client v0.0.0-20161009150606-c1486c966a40/go.mod h1:b+6Qgn9fCwiTtpRr6lHe51DY2g69kcMnWc53J4EV4Jc=
|
||||||
github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE=
|
github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE=
|
||||||
github.com/valyala/fastjson v1.4.1/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
|
github.com/valyala/fastjson v1.4.1/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
|
||||||
meow.tf/streamdeck/sdk v0.0.0-20190519021527-54a933f8777d h1:PPZHRoZFy9p4GjXssLvTneJfX6cS0bEm51md5TqXFgU=
|
meow.tf/streamdeck/sdk v0.0.0-20190519021527-54a933f8777d h1:PPZHRoZFy9p4GjXssLvTneJfX6cS0bEm51md5TqXFgU=
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
"Icon": "images/pluginIcon",
|
"Icon": "images/pluginIcon",
|
||||||
"CategoryIcon": "images/pluginIcon",
|
"CategoryIcon": "images/pluginIcon",
|
||||||
"URL": "https://streamdeck.meow.tf/obsreplay",
|
"URL": "https://streamdeck.meow.tf/obsreplay",
|
||||||
"Version": "1.1.2",
|
"Version": "1.1.0",
|
||||||
"SDKVersion": 2,
|
"SDKVersion": 2,
|
||||||
"OS": [
|
"OS": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -85,38 +85,12 @@ func (c *Client) Connect() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Auth(key string, callback func(error)) {
|
|
||||||
c.SendRPC("TcpServerService", "auth", func(response *RPCResponse) {
|
|
||||||
if response.Error != nil {
|
|
||||||
callback(errors.New(response.Error.Message))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var result bool
|
|
||||||
|
|
||||||
json.Unmarshal(*response.Result, &result)
|
|
||||||
|
|
||||||
if !result {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(nil)
|
|
||||||
}, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Disconnect() error {
|
func (c *Client) Disconnect() error {
|
||||||
return c.conn.Close()
|
return c.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Subscribe(resource, method string, handler SubscriptionHandler) error {
|
func (c *Client) Subscribe(resource, method string, handler SubscriptionHandler) {
|
||||||
responseCh := make(chan error, 1)
|
|
||||||
|
|
||||||
c.SendRPC(resource, method, func(response *RPCResponse) {
|
c.SendRPC(resource, method, func(response *RPCResponse) {
|
||||||
if response.Error != nil {
|
|
||||||
responseCh <- errors.New(response.Error.Message)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
res := &ResourceEvent{}
|
res := &ResourceEvent{}
|
||||||
|
|
||||||
json.Unmarshal(*response.Result, &res)
|
json.Unmarshal(*response.Result, &res)
|
||||||
@ -124,18 +98,14 @@ func (c *Client) Subscribe(resource, method string, handler SubscriptionHandler)
|
|||||||
c.subscriptionLock.Lock()
|
c.subscriptionLock.Lock()
|
||||||
c.subscriptions[res.ResourceId] = handler
|
c.subscriptions[res.ResourceId] = handler
|
||||||
c.subscriptionLock.Unlock()
|
c.subscriptionLock.Unlock()
|
||||||
|
|
||||||
close(responseCh)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return <-responseCh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SendRPC(resource, method string, handler ResponseHandler, args ...string) error {
|
func (c *Client) SendRPC(resource, method string, handler ResponseHandler) error {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
|
|
||||||
m["resource"] = resource
|
m["resource"] = resource
|
||||||
m["args"] = args
|
m["args"] = []string{}
|
||||||
|
|
||||||
atomic.AddInt32(&c.requestId, 1)
|
atomic.AddInt32(&c.requestId, 1)
|
||||||
|
|
||||||
|
|||||||
@ -14,21 +14,12 @@ func Test_StreamlabsOBS(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
closeCh := make(chan struct{}, 1)
|
|
||||||
|
|
||||||
c.Auth("a", func(err error) {
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
closeCh <- struct{}{}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Subscribe("StreamingService", "replayBufferStatusChange", func(event *ResourceEvent) {
|
c.Subscribe("StreamingService", "replayBufferStatusChange", func(event *ResourceEvent) {
|
||||||
var status string
|
var status string
|
||||||
event.DecodeTo(&status)
|
event.DecodeTo(&status)
|
||||||
log.Println("Event received:", status)
|
log.Println("Event received:", status)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
<-closeCh
|
ch := make(chan struct{}, 1)
|
||||||
|
<-ch
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user