Skip to content

Commit 7a379a8

Browse files
committed
Merge branch 'develop' into master
2 parents 6c7daf1 + d1e0874 commit 7a379a8

15 files changed

+274
-414
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<name>obs-websocket-java</name>
77
<groupId>net.twasi</groupId>
88
<artifactId>obs-websocket-java</artifactId>
9-
<version>1.0.7</version>
9+
<version>1.1.0</version>
1010

1111
<description>Library to connect to the OBS WebSocket interface.</description>
1212
<url>https://github.com/Twasi/obs-websocket-java</url>

src/main/java/net/twasi/obsremotejava/OBSCommunicator.java

Lines changed: 89 additions & 72 deletions
Large diffs are not rendered by default.

src/main/java/net/twasi/obsremotejava/OBSRemoteController.java

Lines changed: 88 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,39 @@
33
import net.twasi.obsremotejava.callbacks.Callback;
44
import net.twasi.obsremotejava.callbacks.ErrorCallback;
55
import net.twasi.obsremotejava.callbacks.StringCallback;
6+
import net.twasi.obsremotejava.callbacks.VoidCallback;
7+
import net.twasi.obsremotejava.events.responses.*;
68
import net.twasi.obsremotejava.objects.throwables.OBSResponseError;
9+
import net.twasi.obsremotejava.requests.GetCurrentProfile.GetCurrentProfileResponse;
10+
import net.twasi.obsremotejava.requests.GetCurrentScene.GetCurrentSceneResponse;
11+
import net.twasi.obsremotejava.requests.GetPreviewScene.GetPreviewSceneResponse;
12+
import net.twasi.obsremotejava.requests.GetSceneList.GetSceneListResponse;
13+
import net.twasi.obsremotejava.requests.GetSourceSettings.GetSourceSettingsResponse;
14+
import net.twasi.obsremotejava.requests.GetStreamingStatus.GetStreamingStatusResponse;
15+
import net.twasi.obsremotejava.requests.GetStudioModeEnabled.GetStudioModeEnabledResponse;
16+
import net.twasi.obsremotejava.requests.GetTransitionDuration.GetTransitionDurationResponse;
17+
import net.twasi.obsremotejava.requests.GetTransitionList.GetTransitionListResponse;
18+
import net.twasi.obsremotejava.requests.GetVersion.GetVersionResponse;
19+
import net.twasi.obsremotejava.requests.GetVolume.GetVolumeResponse;
20+
import net.twasi.obsremotejava.requests.ListProfiles.ListProfilesResponse;
21+
import net.twasi.obsremotejava.requests.SaveReplayBuffer.SaveReplayBufferResponse;
22+
import net.twasi.obsremotejava.requests.SetCurrentProfile.SetCurrentProfileResponse;
23+
import net.twasi.obsremotejava.requests.SetCurrentScene.SetCurrentSceneResponse;
24+
import net.twasi.obsremotejava.requests.SetCurrentTransition.SetCurrentTransitionResponse;
25+
import net.twasi.obsremotejava.requests.SetMute.SetMuteResponse;
26+
import net.twasi.obsremotejava.requests.SetPreviewScene.SetPreviewSceneResponse;
27+
import net.twasi.obsremotejava.requests.SetSceneItemProperties.SetSceneItemPropertiesResponse;
28+
import net.twasi.obsremotejava.requests.SetSourceSettings.SetSourceSettingsResponse;
29+
import net.twasi.obsremotejava.requests.SetStudioModeEnabled.SetStudioModeEnabledResponse;
30+
import net.twasi.obsremotejava.requests.SetTransitionDuration.SetTransitionDurationResponse;
31+
import net.twasi.obsremotejava.requests.SetVolume.SetVolumeResponse;
32+
import net.twasi.obsremotejava.requests.StartRecording.StartRecordingResponse;
33+
import net.twasi.obsremotejava.requests.StartReplayBuffer.StartReplayBufferResponse;
34+
import net.twasi.obsremotejava.requests.StartStreaming.StartStreamingResponse;
35+
import net.twasi.obsremotejava.requests.StopRecording.StopRecordingResponse;
36+
import net.twasi.obsremotejava.requests.StopReplayBuffer.StopReplayBufferResponse;
37+
import net.twasi.obsremotejava.requests.StopStreaming.StopStreamingResponse;
38+
import net.twasi.obsremotejava.requests.TransitionToProgram.TransitionToProgramResponse;
739
import org.eclipse.jetty.websocket.api.Session;
840
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
941
import org.eclipse.jetty.websocket.client.WebSocketClient;
@@ -84,7 +116,7 @@ public void connect() {
84116
public void disconnect() {
85117
// wait for closed socket connection
86118
try {
87-
if(debug) {
119+
if (debug) {
88120
log.debug("Closing connection.");
89121
}
90122
communicator.awaitClose(1, TimeUnit.SECONDS);
@@ -94,7 +126,7 @@ public void disconnect() {
94126

95127
if (!client.isStopped() && !client.isStopping()) {
96128
try {
97-
if(debug) {
129+
if (debug) {
98130
log.debug("Stopping client.");
99131
}
100132
client.stop();
@@ -108,7 +140,7 @@ public boolean isFailed() {
108140
return failed;
109141
}
110142

111-
public void getScenes(Callback callback) {
143+
public void getScenes(Callback<GetSceneListResponse> callback) {
112144
communicator.getScenes(callback);
113145
}
114146

@@ -117,11 +149,11 @@ public void registerOnError(ErrorCallback onError) {
117149
communicator.registerOnError(onError);
118150
}
119151

120-
public void registerConnectCallback(Callback onConnect) {
152+
public void registerConnectCallback(Callback<GetVersionResponse> onConnect) {
121153
communicator.registerOnConnect(onConnect);
122154
}
123155

124-
public void registerDisconnectCallback(Callback onDisconnect) {
156+
public void registerDisconnectCallback(VoidCallback onDisconnect) {
125157
communicator.registerOnDisconnect(onDisconnect);
126158
}
127159

@@ -130,67 +162,75 @@ public void registerConnectionFailedCallback(StringCallback onConnectionFailed)
130162
communicator.registerOnConnectionFailed(onConnectionFailed);
131163
}
132164

133-
public void registerRecordingStartedCallback(Callback onRecordingStarted) {
165+
public void registerRecordingStartedCallback(VoidCallback onRecordingStarted) {
134166
communicator.registerOnRecordingStarted(onRecordingStarted);
135167
}
136168

137-
public void registerRecordingStoppedCallback(Callback onRecordingStopped) {
169+
public void registerRecordingStoppedCallback(VoidCallback onRecordingStopped) {
138170
communicator.registerOnRecordingStopped(onRecordingStopped);
139171
}
140172

141-
public void registerReplayStartedCallback(Callback onReplayStarted) {
173+
public void registerReplayStartedCallback(VoidCallback onReplayStarted) {
142174
communicator.registerOnReplayStarted(onReplayStarted);
143175
}
144176

145-
public void registerReplayStartingCallback(Callback onReplayStarting) {
177+
public void registerReplayStartingCallback(VoidCallback onReplayStarting) {
146178
communicator.registerOnReplayStarting(onReplayStarting);
147179
}
148180

149-
public void registerReplayStoppedCallback(Callback onReplayStopped) {
181+
public void registerReplayStoppedCallback(VoidCallback onReplayStopped) {
150182
communicator.registerOnReplayStopped(onReplayStopped);
151183
}
152184

153-
public void registerReplayStoppingCallback(Callback onReplayStopping) {
185+
public void registerReplayStoppingCallback(VoidCallback onReplayStopping) {
154186
communicator.registerOnReplayStopping(onReplayStopping);
155187
}
156188

157-
public void registerStreamStartedCallback(Callback onRecordingStarted) {
189+
public void registerStreamStartedCallback(VoidCallback onRecordingStarted) {
158190
communicator.registerOnStreamStarted(onRecordingStarted);
159191
}
160192

161-
public void registerStreamStoppedCallback(Callback onRecordingStopped) {
193+
public void registerStreamStoppedCallback(VoidCallback onRecordingStopped) {
162194
communicator.registerOnStreamStopped(onRecordingStopped);
163195
}
164196

165-
public void registerSwitchScenesCallback(Callback onSwitchScenes) {
197+
public void registerSwitchScenesCallback(Callback<SwitchScenesResponse> onSwitchScenes) {
166198
communicator.registerOnSwitchScenes(onSwitchScenes);
167199
}
168200

169-
public void registerScenesChangedCallback(Callback onScenesChanged) {
201+
public void registerScenesChangedCallback(Callback<ScenesChangedResponse> onScenesChanged) {
170202
communicator.registerOnScenesChanged(onScenesChanged);
171203
}
172204

173-
public void registerTransitionBeginCallback(Callback onTransitionBegin) {
205+
public void registerSwitchTransitionCallback(Callback<SwitchTransitionResponse> onSwitchTransition) {
206+
communicator.registerOnSwitchTransition(onSwitchTransition);
207+
}
208+
209+
public void registerTransitionListChangedCallback(Callback<TransitionListChangedResponse> onTransitionListChanged) {
210+
communicator.registerOnTransitionListChanged(onTransitionListChanged);
211+
}
212+
213+
public void registerTransitionBeginCallback(Callback<TransitionBeginResponse> onTransitionBegin) {
174214
communicator.registerOnTransitionBegin(onTransitionBegin);
175215
}
176216

177-
public void registerTransitionEndCallback(Callback onTransitionEnd) {
217+
public void registerTransitionEndCallback(Callback<TransitionEndResponse> onTransitionEnd) {
178218
communicator.registerOnTransitionEnd(onTransitionEnd);
179219
}
180220

181221
public void await() throws InterruptedException {
182222
communicator.await();
183223
}
184224

185-
public void setCurrentScene(String szene, Callback callback) {
186-
communicator.setCurrentScene(szene, callback);
225+
public void setCurrentScene(String scene, Callback<SetCurrentSceneResponse> callback) {
226+
communicator.setCurrentScene(scene, callback);
187227
}
188228

189-
public void setCurrentTransition(String transition, Callback callback) {
229+
public void setCurrentTransition(String transition, Callback<SetCurrentTransitionResponse> callback) {
190230
communicator.setCurrentTransition(transition, callback);
191231
}
192232

193-
public void changeSceneWithTransition(final String scene, String transition, final Callback callback) {
233+
public void changeSceneWithTransition(final String scene, String transition, final Callback<SetCurrentSceneResponse> callback) {
194234
communicator.setCurrentTransition(transition, response -> {
195235
if (!response.getStatus().equals("ok")) {
196236
log.error("Failed to change transition. Pls fix.");
@@ -200,112 +240,112 @@ public void changeSceneWithTransition(final String scene, String transition, fin
200240
});
201241
}
202242

203-
public void setSourceVisibility(String scene, String source, boolean visibility, Callback callback) {
243+
public void setSourceVisibility(String scene, String source, boolean visibility, Callback<SetSceneItemPropertiesResponse> callback) {
204244
communicator.setSourceVisiblity(scene, source, visibility, callback);
205245
}
206246

207-
public void getSceneItemProperties(String scene, String source, Callback callback) {
247+
public void getSceneItemProperties(String scene, String source, Callback<SetSceneItemPropertiesResponse> callback) {
208248
communicator.getSceneItemProperties(scene, source, callback);
209249
}
210250

211-
public void getTransitionList(Callback callback) {
251+
public void getTransitionList(Callback<GetTransitionListResponse> callback) {
212252
communicator.getTransitionList(callback);
213253
}
214254

215-
public void transitionToProgram(String transitionName, int duration, Callback callback) {
255+
public void transitionToProgram(String transitionName, int duration, Callback<TransitionToProgramResponse> callback) {
216256
communicator.transitionToProgram(transitionName, duration, callback);
217257
}
218258

219-
public void getSourceSettings(String sourceName, Callback callback) {
259+
public void getSourceSettings(String sourceName, Callback<GetSourceSettingsResponse> callback) {
220260
communicator.getSourceSettings(sourceName, callback);
221261
}
222262

223-
public void setSourceSettings(String sourceName, Map<String, Object> settings, Callback callback) {
263+
public void setSourceSettings(String sourceName, Map<String, Object> settings, Callback<SetSourceSettingsResponse> callback) {
224264
communicator.setSourceSettings(sourceName, settings, callback);
225265
}
226266

227-
public void getStreamingStatus(Callback callback) {
267+
public void getStreamingStatus(Callback<GetStreamingStatusResponse> callback) {
228268
communicator.getStreamingStatus(callback);
229269
}
230270

231-
public void startStreaming(Callback callback) {
271+
public void startStreaming(Callback<StartStreamingResponse> callback) {
232272
communicator.startStreaming(callback);
233273
}
234274

235-
public void stopStreaming(Callback callback) {
275+
public void stopStreaming(Callback<StopStreamingResponse> callback) {
236276
communicator.stopStreaming(callback);
237277
}
238278

239-
public void startRecording(Callback callback) {
279+
public void startRecording(Callback<StartRecordingResponse> callback) {
240280
communicator.startRecording(callback);
241281
}
242282

243-
public void stopRecording(Callback callback) {
283+
public void stopRecording(Callback<StopRecordingResponse> callback) {
244284
communicator.stopRecording(callback);
245285
}
246286

247-
public void listProfiles(Callback callback) {
287+
public void listProfiles(Callback<ListProfilesResponse> callback) {
248288
communicator.listProfiles(callback);
249289
}
250290

251-
public void getCurrentProfile(Callback callback) {
291+
public void getCurrentProfile(Callback<GetCurrentProfileResponse> callback) {
252292
communicator.getCurrentProfile(callback);
253293
}
254294

255-
public void setCurrentProfile(String profile, Callback callback) {
295+
public void setCurrentProfile(String profile, Callback<SetCurrentProfileResponse> callback) {
256296
communicator.setCurrentProfile(profile, callback);
257297
}
258298

259-
public void getCurrentScene(Callback callback) {
299+
public void getCurrentScene(Callback<GetCurrentSceneResponse> callback) {
260300
communicator.getCurrentScene(callback);
261301
}
262302

263-
public void getVolume(String source, Callback callback) {
303+
public void getVolume(String source, Callback<GetVolumeResponse> callback) {
264304
communicator.getVolume(source, callback);
265305
}
266306

267-
public void setVolume(String source, double volume, Callback callback) {
307+
public void setVolume(String source, double volume, Callback<SetVolumeResponse> callback) {
268308
communicator.setVolume(source, volume, callback);
269309
}
270310

271-
public void setMute(String source, boolean mute, Callback callback) {
311+
public void setMute(String source, boolean mute, Callback<SetMuteResponse> callback) {
272312
communicator.setMute(source, mute, callback);
273313
}
274314

275-
public void getPreviewScene(Callback callback) {
315+
public void getPreviewScene(Callback<GetPreviewSceneResponse> callback) {
276316
communicator.getPreviewScene(callback);
277317
}
278318

279-
public void setPreviewScene(String name, Callback callback) {
319+
public void setPreviewScene(String name, Callback<SetPreviewSceneResponse> callback) {
280320
communicator.setPreviewScene(name, callback);
281321
}
282322

283-
public void getTransitionDuration(Callback callback) {
323+
public void getTransitionDuration(Callback<GetTransitionDurationResponse> callback) {
284324
communicator.getTransitionDuration(callback);
285325
}
286326

287-
public void setTransitionDuration(int duration, Callback callback) {
327+
public void setTransitionDuration(int duration, Callback<SetTransitionDurationResponse> callback) {
288328
communicator.setTransitionDuration(duration, callback);
289329
}
290330

291331

292-
public void getStudioModeEnabled(Callback callback) {
332+
public void getStudioModeEnabled(Callback<GetStudioModeEnabledResponse> callback) {
293333
communicator.getStudioModeEnabled(callback);
294334
}
295335

296-
public void setStudioModeEnabled(boolean enabled, Callback callback) {
336+
public void setStudioModeEnabled(boolean enabled, Callback<SetStudioModeEnabledResponse> callback) {
297337
communicator.setStudioModeEnabled(enabled, callback);
298338
}
299339

300-
public void startReplayBuffer(Callback callback) {
340+
public void startReplayBuffer(Callback<StartReplayBufferResponse> callback) {
301341
communicator.startReplayBuffer(callback);
302342
}
303343

304-
public void stopReplayBuffer(Callback callback) {
344+
public void stopReplayBuffer(Callback<StopReplayBufferResponse> callback) {
305345
communicator.stopReplayBuffer(callback);
306346
}
307347

308-
public void saveReplayBuffer(Callback callback) {
348+
public void saveReplayBuffer(Callback<SaveReplayBufferResponse> callback) {
309349
communicator.saveReplayBuffer(callback);
310350
}
311351

src/main/java/net/twasi/obsremotejava/callbacks/Callback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import net.twasi.obsremotejava.requests.ResponseBase;
44

5-
public interface Callback {
5+
public interface Callback<ResponseType extends ResponseBase> {
66

7-
void run(ResponseBase response);
7+
void run(ResponseType response);
88

99
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package net.twasi.obsremotejava.callbacks;
2+
3+
public interface VoidCallback {
4+
5+
void run();
6+
7+
}

src/main/java/net/twasi/obsremotejava/events/EventType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public enum EventType {
1111
StreamStopped,
1212
SwitchScenes,
1313
ScenesChanged,
14+
SwitchTransition,
15+
TransitionListChanged,
1416
TransitionBegin,
1517
TransitionEnd
1618
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package net.twasi.obsremotejava.events.responses;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import net.twasi.obsremotejava.requests.ResponseBase;
5+
6+
public class SwitchTransitionResponse extends ResponseBase {
7+
@SerializedName("transition-name")
8+
private String transitionName;
9+
10+
public String getTransitionName() {
11+
return transitionName;
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package net.twasi.obsremotejava.events.responses;
2+
3+
import net.twasi.obsremotejava.objects.Transition;
4+
import net.twasi.obsremotejava.requests.ResponseBase;
5+
6+
import java.util.List;
7+
8+
public class TransitionListChangedResponse extends ResponseBase {
9+
// Note: enabled these when https://github.com/Palakis/obs-websocket/blob/4.x-current/src/WSEvents.cpp#L561 is released.
10+
// private List<Transition> transitions;
11+
12+
// public List<Transition> getTransitions() { return transitions; }
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.twasi.obsremotejava.objects;
2+
3+
public class Transition {
4+
private String name;
5+
6+
public String getName() {
7+
return name;
8+
}
9+
}

0 commit comments

Comments
 (0)