This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
requests_scene_items.go
1139 lines (1083 loc) · 29.9 KB
/
requests_scene_items.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package obsws
import (
"errors"
"time"
)
// This file is automatically generated.
// https://github.com/christopher-dG/go-obs-websocket/blob/master/codegen/protocol.py
// GetSceneItemPropertiesRequest : Gets the scene specific properties of the specified source item.
// Coordinates are relative to the item's parent (the scene or group it belongs to).
//
// Since obs-websocket version: 4.3.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#getsceneitemproperties
type GetSceneItemPropertiesRequest struct {
// the name of the scene that the source item belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// The name of the source.
// Required: Yes.
Item string `json:"item"`
_request `json:",squash"`
response chan GetSceneItemPropertiesResponse
}
// NewGetSceneItemPropertiesRequest returns a new GetSceneItemPropertiesRequest.
func NewGetSceneItemPropertiesRequest(
sceneName string,
item string,
) GetSceneItemPropertiesRequest {
return GetSceneItemPropertiesRequest{
sceneName,
item,
_request{
ID_: GetMessageID(),
Type_: "GetSceneItemProperties",
err: make(chan error, 1),
},
make(chan GetSceneItemPropertiesResponse, 1),
}
}
// Send sends the request.
func (r *GetSceneItemPropertiesRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp GetSceneItemPropertiesResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r GetSceneItemPropertiesRequest) Receive() (GetSceneItemPropertiesResponse, error) {
if !r.sent {
return GetSceneItemPropertiesResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return GetSceneItemPropertiesResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return GetSceneItemPropertiesResponse{}, err
case <-time.After(receiveTimeout):
return GetSceneItemPropertiesResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r GetSceneItemPropertiesRequest) SendReceive(c Client) (GetSceneItemPropertiesResponse, error) {
if err := r.Send(c); err != nil {
return GetSceneItemPropertiesResponse{}, err
}
return r.Receive()
}
// GetSceneItemPropertiesResponse : Response for GetSceneItemPropertiesRequest.
//
// Since obs-websocket version: 4.3.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#getsceneitemproperties
type GetSceneItemPropertiesResponse struct {
// The name of the source.
// Required: Yes.
Name string `json:"name"`
// The x position of the source from the left.
// Required: Yes.
PositionX int `json:"position.x"`
// The y position of the source from the top.
// Required: Yes.
PositionY int `json:"position.y"`
// The point on the source that the item is manipulated from.
// Required: Yes.
PositionAlignment int `json:"position.alignment"`
// The clockwise rotation of the item in degrees around the point of alignment.
// Required: Yes.
Rotation float64 `json:"rotation"`
// The x-scale factor of the source.
// Required: Yes.
ScaleX float64 `json:"scale.x"`
// The y-scale factor of the source.
// Required: Yes.
ScaleY float64 `json:"scale.y"`
// The number of pixels cropped off the top of the source before scaling.
// Required: Yes.
CropTop int `json:"crop.top"`
// The number of pixels cropped off the right of the source before scaling.
// Required: Yes.
CropRight int `json:"crop.right"`
// The number of pixels cropped off the bottom of the source before scaling.
// Required: Yes.
CropBottom int `json:"crop.bottom"`
// The number of pixels cropped off the left of the source before scaling.
// Required: Yes.
CropLeft int `json:"crop.left"`
// If the source is visible.
// Required: Yes.
Visible bool `json:"visible"`
// If the source's transform is locked.
// Required: Yes.
Locked bool `json:"locked"`
// Type of bounding box.
// Can be "OBS_BOUNDS_STRETCH", "OBS_BOUNDS_SCALE_INNER", "OBS_BOUNDS_SCALE_OUTER", "OBS_BOUNDS_SCALE_TO_WIDTH", "OBS_BOUNDS_SCALE_TO_HEIGHT", "OBS_BOUNDS_MAX_ONLY" or "OBS_BOUNDS_NONE".
// Required: Yes.
BoundsType string `json:"bounds.type"`
// Alignment of the bounding box.
// Required: Yes.
BoundsAlignment int `json:"bounds.alignment"`
// Width of the bounding box.
// Required: Yes.
BoundsX float64 `json:"bounds.x"`
// Height of the bounding box.
// Required: Yes.
BoundsY float64 `json:"bounds.y"`
// Base width (without scaling) of the source.
// Required: Yes.
SourceWidth int `json:"sourceWidth"`
// Base source (without scaling) of the source.
// Required: Yes.
SourceHeight int `json:"sourceHeight"`
// Scene item width (base source width multiplied by the horizontal scaling factor).
// Required: Yes.
Width float64 `json:"width"`
// Scene item height (base source height multiplied by the vertical scaling factor).
// Required: Yes.
Height float64 `json:"height"`
_response `json:",squash"`
}
// SetSceneItemPropertiesRequest : Sets the scene specific properties of a source
// Unspecified properties will remain unchanged.
// Coordinates are relative to the item's parent (the scene or group it belongs to).
//
// Since obs-websocket version: 4.3.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemproperties
type SetSceneItemPropertiesRequest struct {
// the name of the scene that the source item belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// The name of the source.
// Required: Yes.
Item string `json:"item"`
// The new x position of the source.
// Required: No.
PositionX int `json:"position.x"`
// The new y position of the source.
// Required: No.
PositionY int `json:"position.y"`
// The new alignment of the source.
// Required: No.
PositionAlignment int `json:"position.alignment"`
// The new clockwise rotation of the item in degrees.
// Required: No.
Rotation float64 `json:"rotation"`
// The new x scale of the item.
// Required: No.
ScaleX float64 `json:"scale.x"`
// The new y scale of the item.
// Required: No.
ScaleY float64 `json:"scale.y"`
// The new amount of pixels cropped off the top of the source before scaling.
// Required: No.
CropTop int `json:"crop.top"`
// The new amount of pixels cropped off the bottom of the source before scaling.
// Required: No.
CropBottom int `json:"crop.bottom"`
// The new amount of pixels cropped off the left of the source before scaling.
// Required: No.
CropLeft int `json:"crop.left"`
// The new amount of pixels cropped off the right of the source before scaling.
// Required: No.
CropRight int `json:"crop.right"`
// The new visibility of the source.
// 'true' shows source, 'false' hides source.
// Required: No.
Visible bool `json:"visible"`
// The new locked status of the source.
// 'true' keeps it in its current position, 'false' allows movement.
// Required: No.
Locked bool `json:"locked"`
// The new bounds type of the source.
// Can be "OBS_BOUNDS_STRETCH", "OBS_BOUNDS_SCALE_INNER", "OBS_BOUNDS_SCALE_OUTER", "OBS_BOUNDS_SCALE_TO_WIDTH", "OBS_BOUNDS_SCALE_TO_HEIGHT", "OBS_BOUNDS_MAX_ONLY" or "OBS_BOUNDS_NONE".
// Required: No.
BoundsType string `json:"bounds.type"`
// The new alignment of the bounding box.
// (0-2, 4-6, 8-10).
// Required: No.
BoundsAlignment int `json:"bounds.alignment"`
// The new width of the bounding box.
// Required: No.
BoundsX float64 `json:"bounds.x"`
// The new height of the bounding box.
// Required: No.
BoundsY float64 `json:"bounds.y"`
_request `json:",squash"`
response chan SetSceneItemPropertiesResponse
}
// NewSetSceneItemPropertiesRequest returns a new SetSceneItemPropertiesRequest.
func NewSetSceneItemPropertiesRequest(
sceneName string,
item string,
positionX int,
positionY int,
positionAlignment int,
rotation float64,
scaleX float64,
scaleY float64,
cropTop int,
cropBottom int,
cropLeft int,
cropRight int,
visible bool,
locked bool,
boundsType string,
boundsAlignment int,
boundsX float64,
boundsY float64,
) SetSceneItemPropertiesRequest {
return SetSceneItemPropertiesRequest{
sceneName,
item,
positionX,
positionY,
positionAlignment,
rotation,
scaleX,
scaleY,
cropTop,
cropBottom,
cropLeft,
cropRight,
visible,
locked,
boundsType,
boundsAlignment,
boundsX,
boundsY,
_request{
ID_: GetMessageID(),
Type_: "SetSceneItemProperties",
err: make(chan error, 1),
},
make(chan SetSceneItemPropertiesResponse, 1),
}
}
// Send sends the request.
func (r *SetSceneItemPropertiesRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp SetSceneItemPropertiesResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r SetSceneItemPropertiesRequest) Receive() (SetSceneItemPropertiesResponse, error) {
if !r.sent {
return SetSceneItemPropertiesResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemPropertiesResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemPropertiesResponse{}, err
case <-time.After(receiveTimeout):
return SetSceneItemPropertiesResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r SetSceneItemPropertiesRequest) SendReceive(c Client) (SetSceneItemPropertiesResponse, error) {
if err := r.Send(c); err != nil {
return SetSceneItemPropertiesResponse{}, err
}
return r.Receive()
}
// SetSceneItemPropertiesResponse : Response for SetSceneItemPropertiesRequest.
//
// Since obs-websocket version: 4.3.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemproperties
type SetSceneItemPropertiesResponse struct {
_response `json:",squash"`
}
// ResetSceneItemRequest : Reset a scene item.
//
// Since obs-websocket version: 4.2.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#resetsceneitem
type ResetSceneItemRequest struct {
// Name of the scene the source belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// Name of the source item.
// Required: Yes.
Item string `json:"item"`
_request `json:",squash"`
response chan ResetSceneItemResponse
}
// NewResetSceneItemRequest returns a new ResetSceneItemRequest.
func NewResetSceneItemRequest(
sceneName string,
item string,
) ResetSceneItemRequest {
return ResetSceneItemRequest{
sceneName,
item,
_request{
ID_: GetMessageID(),
Type_: "ResetSceneItem",
err: make(chan error, 1),
},
make(chan ResetSceneItemResponse, 1),
}
}
// Send sends the request.
func (r *ResetSceneItemRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp ResetSceneItemResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r ResetSceneItemRequest) Receive() (ResetSceneItemResponse, error) {
if !r.sent {
return ResetSceneItemResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return ResetSceneItemResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return ResetSceneItemResponse{}, err
case <-time.After(receiveTimeout):
return ResetSceneItemResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r ResetSceneItemRequest) SendReceive(c Client) (ResetSceneItemResponse, error) {
if err := r.Send(c); err != nil {
return ResetSceneItemResponse{}, err
}
return r.Receive()
}
// ResetSceneItemResponse : Response for ResetSceneItemRequest.
//
// Since obs-websocket version: 4.2.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#resetsceneitem
type ResetSceneItemResponse struct {
_response `json:",squash"`
}
// SetSceneItemRenderRequest : Show or hide a specified source item in a specified scene.
//
// Since obs-websocket version: 0.3.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemrender
type SetSceneItemRenderRequest struct {
// Scene item name in the specified scene.
// Required: Yes.
Source string `json:"source"`
// true = shown ; false = hidden.
// Required: Yes.
Render bool `json:"render"`
// Name of the scene where the source resides.
// Defaults to the currently active scene.
// Required: No.
SceneName string `json:"scene-name"`
_request `json:",squash"`
response chan SetSceneItemRenderResponse
}
// NewSetSceneItemRenderRequest returns a new SetSceneItemRenderRequest.
func NewSetSceneItemRenderRequest(
source string,
render bool,
sceneName string,
) SetSceneItemRenderRequest {
return SetSceneItemRenderRequest{
source,
render,
sceneName,
_request{
ID_: GetMessageID(),
Type_: "SetSceneItemRender",
err: make(chan error, 1),
},
make(chan SetSceneItemRenderResponse, 1),
}
}
// Send sends the request.
func (r *SetSceneItemRenderRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp SetSceneItemRenderResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r SetSceneItemRenderRequest) Receive() (SetSceneItemRenderResponse, error) {
if !r.sent {
return SetSceneItemRenderResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemRenderResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemRenderResponse{}, err
case <-time.After(receiveTimeout):
return SetSceneItemRenderResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r SetSceneItemRenderRequest) SendReceive(c Client) (SetSceneItemRenderResponse, error) {
if err := r.Send(c); err != nil {
return SetSceneItemRenderResponse{}, err
}
return r.Receive()
}
// SetSceneItemRenderResponse : Response for SetSceneItemRenderRequest.
//
// Since obs-websocket version: 0.3.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemrender
type SetSceneItemRenderResponse struct {
_response `json:",squash"`
}
// SetSceneItemPositionRequest : Sets the coordinates of a specified source item.
//
// Since obs-websocket version: 4.0.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemposition
type SetSceneItemPositionRequest struct {
// The name of the scene that the source item belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// The name of the source item.
// Required: Yes.
Item string `json:"item"`
// X coordinate.
// Required: Yes.
X float64 `json:"x"`
// Y coordinate.
// Required: Yes.
Y float64 `json:"y"`
_request `json:",squash"`
response chan SetSceneItemPositionResponse
}
// NewSetSceneItemPositionRequest returns a new SetSceneItemPositionRequest.
func NewSetSceneItemPositionRequest(
sceneName string,
item string,
x float64,
y float64,
) SetSceneItemPositionRequest {
return SetSceneItemPositionRequest{
sceneName,
item,
x,
y,
_request{
ID_: GetMessageID(),
Type_: "SetSceneItemPosition",
err: make(chan error, 1),
},
make(chan SetSceneItemPositionResponse, 1),
}
}
// Send sends the request.
func (r *SetSceneItemPositionRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp SetSceneItemPositionResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r SetSceneItemPositionRequest) Receive() (SetSceneItemPositionResponse, error) {
if !r.sent {
return SetSceneItemPositionResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemPositionResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemPositionResponse{}, err
case <-time.After(receiveTimeout):
return SetSceneItemPositionResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r SetSceneItemPositionRequest) SendReceive(c Client) (SetSceneItemPositionResponse, error) {
if err := r.Send(c); err != nil {
return SetSceneItemPositionResponse{}, err
}
return r.Receive()
}
// SetSceneItemPositionResponse : Response for SetSceneItemPositionRequest.
//
// Since obs-websocket version: 4.0.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemposition
type SetSceneItemPositionResponse struct {
_response `json:",squash"`
}
// SetSceneItemTransformRequest : Set the transform of the specified source item.
//
// Since obs-websocket version: 4.0.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemtransform
type SetSceneItemTransformRequest struct {
// The name of the scene that the source item belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// The name of the source item.
// Required: Yes.
Item string `json:"item"`
// Width scale factor.
// Required: Yes.
XScale float64 `json:"x-scale"`
// Height scale factor.
// Required: Yes.
YScale float64 `json:"y-scale"`
// Source item rotation (in degrees).
// Required: Yes.
Rotation float64 `json:"rotation"`
_request `json:",squash"`
response chan SetSceneItemTransformResponse
}
// NewSetSceneItemTransformRequest returns a new SetSceneItemTransformRequest.
func NewSetSceneItemTransformRequest(
sceneName string,
item string,
xScale float64,
yScale float64,
rotation float64,
) SetSceneItemTransformRequest {
return SetSceneItemTransformRequest{
sceneName,
item,
xScale,
yScale,
rotation,
_request{
ID_: GetMessageID(),
Type_: "SetSceneItemTransform",
err: make(chan error, 1),
},
make(chan SetSceneItemTransformResponse, 1),
}
}
// Send sends the request.
func (r *SetSceneItemTransformRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp SetSceneItemTransformResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r SetSceneItemTransformRequest) Receive() (SetSceneItemTransformResponse, error) {
if !r.sent {
return SetSceneItemTransformResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemTransformResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemTransformResponse{}, err
case <-time.After(receiveTimeout):
return SetSceneItemTransformResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r SetSceneItemTransformRequest) SendReceive(c Client) (SetSceneItemTransformResponse, error) {
if err := r.Send(c); err != nil {
return SetSceneItemTransformResponse{}, err
}
return r.Receive()
}
// SetSceneItemTransformResponse : Response for SetSceneItemTransformRequest.
//
// Since obs-websocket version: 4.0.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemtransform
type SetSceneItemTransformResponse struct {
_response `json:",squash"`
}
// SetSceneItemCropRequest : Sets the crop coordinates of the specified source item.
//
// Since obs-websocket version: 4.1.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemcrop
type SetSceneItemCropRequest struct {
// the name of the scene that the source item belongs to.
// Defaults to the current scene.
// Required: No.
SceneName string `json:"scene-name"`
// The name of the source.
// Required: Yes.
Item string `json:"item"`
// Pixel position of the top of the source item.
// Required: Yes.
Top int `json:"top"`
// Pixel position of the bottom of the source item.
// Required: Yes.
Bottom int `json:"bottom"`
// Pixel position of the left of the source item.
// Required: Yes.
Left int `json:"left"`
// Pixel position of the right of the source item.
// Required: Yes.
Right int `json:"right"`
_request `json:",squash"`
response chan SetSceneItemCropResponse
}
// NewSetSceneItemCropRequest returns a new SetSceneItemCropRequest.
func NewSetSceneItemCropRequest(
sceneName string,
item string,
top int,
bottom int,
left int,
right int,
) SetSceneItemCropRequest {
return SetSceneItemCropRequest{
sceneName,
item,
top,
bottom,
left,
right,
_request{
ID_: GetMessageID(),
Type_: "SetSceneItemCrop",
err: make(chan error, 1),
},
make(chan SetSceneItemCropResponse, 1),
}
}
// Send sends the request.
func (r *SetSceneItemCropRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp SetSceneItemCropResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r SetSceneItemCropRequest) Receive() (SetSceneItemCropResponse, error) {
if !r.sent {
return SetSceneItemCropResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemCropResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return SetSceneItemCropResponse{}, err
case <-time.After(receiveTimeout):
return SetSceneItemCropResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r SetSceneItemCropRequest) SendReceive(c Client) (SetSceneItemCropResponse, error) {
if err := r.Send(c); err != nil {
return SetSceneItemCropResponse{}, err
}
return r.Receive()
}
// SetSceneItemCropResponse : Response for SetSceneItemCropRequest.
//
// Since obs-websocket version: 4.1.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#setsceneitemcrop
type SetSceneItemCropResponse struct {
_response `json:",squash"`
}
// DeleteSceneItemRequest : Deletes a scene item.
//
// Since obs-websocket version: 4.5.0.
//
// https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/protocol.md#deletesceneitem
type DeleteSceneItemRequest struct {
// Name of the scene the source belongs to.
// Defaults to the current scene.
// Required: No.
Scene string `json:"scene"`
// item to delete (required).
// Required: Yes.
Item map[string]interface{} `json:"item"`
// name of the scene item (prefer `id`, including both is acceptable).
// Required: Yes.
ItemName string `json:"item.name"`
// id of the scene item.
// Required: Yes.
ItemID int `json:"item.id"`
_request `json:",squash"`
response chan DeleteSceneItemResponse
}
// NewDeleteSceneItemRequest returns a new DeleteSceneItemRequest.
func NewDeleteSceneItemRequest(
scene string,
item map[string]interface{},
itemName string,
itemID int,
) DeleteSceneItemRequest {
return DeleteSceneItemRequest{
scene,
item,
itemName,
itemID,
_request{
ID_: GetMessageID(),
Type_: "DeleteSceneItem",
err: make(chan error, 1),
},
make(chan DeleteSceneItemResponse, 1),
}
}
// Send sends the request.
func (r *DeleteSceneItemRequest) Send(c Client) error {
if r.sent {
return ErrAlreadySent
}
future, err := c.SendRequest(r)
if err != nil {
return err
}
r.sent = true
go func() {
m := <-future
var resp DeleteSceneItemResponse
if err = mapToStruct(m, &resp); err != nil {
r.err <- err
} else if resp.Status() != StatusOK {
r.err <- errors.New(resp.Error())
} else {
r.response <- resp
}
}()
return nil
}
// Receive waits for the response.
func (r DeleteSceneItemRequest) Receive() (DeleteSceneItemResponse, error) {
if !r.sent {
return DeleteSceneItemResponse{}, ErrNotSent
}
if receiveTimeout == 0 {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return DeleteSceneItemResponse{}, err
}
} else {
select {
case resp := <-r.response:
return resp, nil
case err := <-r.err:
return DeleteSceneItemResponse{}, err
case <-time.After(receiveTimeout):
return DeleteSceneItemResponse{}, ErrReceiveTimeout
}
}
}
// SendReceive sends the request then immediately waits for the response.
func (r DeleteSceneItemRequest) SendReceive(c Client) (DeleteSceneItemResponse, error) {
if err := r.Send(c); err != nil {
return DeleteSceneItemResponse{}, err