| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Protocol::OBSRemote; |
|
2
|
1
|
|
|
1
|
|
701
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
4
|
1
|
|
|
1
|
|
512
|
use Digest::SHA 'sha256_base64'; |
|
|
1
|
|
|
|
|
3085
|
|
|
|
1
|
|
|
|
|
117
|
|
|
5
|
1
|
|
|
1
|
|
599
|
use Moo 2; |
|
|
1
|
|
|
|
|
11573
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
1
|
|
|
1
|
|
1994
|
use Filter::signatures; |
|
|
1
|
|
|
|
|
24446
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
1
|
|
|
1
|
|
34
|
use feature 'signatures'; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
32
|
|
|
8
|
1
|
|
|
1
|
|
5
|
no warnings 'experimental::signatures'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
912
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Net::Protocol::OBSRemote - event-loop agnostic protocol to control OBS via the WebSocket plugin |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $protocol = Net::Protocol::OBSRemote->new(); |
|
19
|
|
|
|
|
|
|
my $message = $protocol->GetVersion(); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $result = $obs_connection->send_message( $message ); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
See L for a Mojolicious implementation. This module merely |
|
24
|
|
|
|
|
|
|
abstracts constructing the messages. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has id => ( |
|
29
|
|
|
|
|
|
|
is => 'rw', |
|
30
|
|
|
|
|
|
|
default => 1, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
0
|
|
sub nextMessage($self,$msg) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $id = $self->{id}++; |
|
35
|
0
|
|
|
|
|
|
$msg->{"message-id"} = "$id"; |
|
36
|
0
|
|
|
|
|
|
return $msg; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
L |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# See https://github.com/Palakis/obs-websocket/blob/4.x-current/docs/generated/comments.json |
|
46
|
|
|
|
|
|
|
# for the non-code version of this |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
0
|
|
sub GetVersion($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self->nextMessage({'request-type' => 'GetVersion'}) |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
0
|
|
sub GetAuthRequired($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self->nextMessage({'request-type' => 'GetAuthRequired'}) |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
0
|
|
sub Authenticate($self,$password,$saltMsg) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $hash = sha256_base64( $password, $saltMsg->{salt} ); |
|
58
|
0
|
|
|
|
|
|
while( length( $hash )% 4) { |
|
59
|
0
|
|
|
|
|
|
$hash .= '='; |
|
60
|
|
|
|
|
|
|
}; |
|
61
|
0
|
|
|
|
|
|
my $auth_response = sha256_base64( $hash, $saltMsg->{challenge} ); |
|
62
|
0
|
|
|
|
|
|
while( length( $auth_response ) % 4) { |
|
63
|
0
|
|
|
|
|
|
$auth_response .= '='; |
|
64
|
|
|
|
|
|
|
}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $payload = { |
|
67
|
|
|
|
|
|
|
'request-type' => 'Authenticate', |
|
68
|
|
|
|
|
|
|
'auth' => $auth_response, |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
0
|
|
|
|
|
|
return $self->nextMessage($payload) |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
sub GetTextFreetype2Properties($self,%properties) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
75
|
|
|
|
|
|
|
'request-type' => 'GetTextFreetype2Properties', |
|
76
|
|
|
|
|
|
|
%properties, |
|
77
|
|
|
|
|
|
|
}) |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
|
sub SetTextFreetype2Properties($self,%properties) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
82
|
|
|
|
|
|
|
'request-type' => 'SetTextFreetype2Properties', |
|
83
|
|
|
|
|
|
|
%properties, |
|
84
|
|
|
|
|
|
|
}) |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
0
|
|
sub GetSourceSettings($self,%sourceInfo) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
89
|
|
|
|
|
|
|
'request-type' => 'GetSourceSettings', |
|
90
|
|
|
|
|
|
|
%sourceInfo, |
|
91
|
|
|
|
|
|
|
}) |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
0
|
0
|
|
sub SetSourceSettings($self,%sourceInfo) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
96
|
|
|
|
|
|
|
'request-type' => 'SetSourceSettings', |
|
97
|
|
|
|
|
|
|
%sourceInfo, |
|
98
|
|
|
|
|
|
|
}) |
|
99
|
|
|
|
|
|
|
}; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
0
|
0
|
|
sub GetMediaSourcesList($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
103
|
|
|
|
|
|
|
'request-type' => 'GetMediaSourcesList', |
|
104
|
|
|
|
|
|
|
}) |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
0
|
0
|
|
sub GetMediaDuration($self, $sourceName) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
109
|
|
|
|
|
|
|
'request-type' => 'GetMediaDuration', |
|
110
|
|
|
|
|
|
|
sourceName => $sourceName, |
|
111
|
|
|
|
|
|
|
}) |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
0
|
|
sub GetMediaTime($self, $sourceName) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
116
|
|
|
|
|
|
|
'request-type' => 'GetMediaTime', |
|
117
|
|
|
|
|
|
|
sourceName => $sourceName, |
|
118
|
|
|
|
|
|
|
}) |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
0
|
|
sub GetMediaState($self, $sourceName) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
123
|
|
|
|
|
|
|
'request-type' => 'GetMediaState', |
|
124
|
|
|
|
|
|
|
'sourceName' => $sourceName, |
|
125
|
|
|
|
|
|
|
}) |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
0
|
|
sub GetCurrentScene($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
130
|
|
|
|
|
|
|
'request-type' => 'GetCurrentScene', |
|
131
|
|
|
|
|
|
|
}) |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 C<< ->SetCurrentScene $sceneName >> |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Sets the current broadcast scene |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
0
|
1
|
|
sub SetCurrentScene($self, $sceneName) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
142
|
|
|
|
|
|
|
'request-type' => 'SetCurrentScene', |
|
143
|
|
|
|
|
|
|
'scene-name' => $sceneName |
|
144
|
|
|
|
|
|
|
}) |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 C<< ->GetPreviewScene >> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Gets the current preview scene |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
0
|
1
|
|
sub GetPreviewScene($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
155
|
|
|
|
|
|
|
'request-type' => 'GetPreviewScene', |
|
156
|
|
|
|
|
|
|
}) |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 C<< ->SetPreviewScene $sceneName >> |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Sets the current preview scene |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
0
|
1
|
|
sub SetPreviewScene($self, $sceneName) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
167
|
|
|
|
|
|
|
'request-type' => 'SetPreviewScene', |
|
168
|
|
|
|
|
|
|
'scene-name' => $sceneName |
|
169
|
|
|
|
|
|
|
}) |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
0
|
0
|
|
sub StartRecording($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
174
|
|
|
|
|
|
|
'request-type' => 'StartRecording', |
|
175
|
|
|
|
|
|
|
}) |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
0
|
0
|
|
sub StopRecording($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
180
|
|
|
|
|
|
|
'request-type' => 'StopRecording', |
|
181
|
|
|
|
|
|
|
}) |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
0
|
|
|
0
|
0
|
|
sub SetMute($self,%sourceInfo) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
return $self->nextMessage({ |
|
186
|
|
|
|
|
|
|
'request-type' => 'SetMute', |
|
187
|
|
|
|
|
|
|
%sourceInfo, |
|
188
|
|
|
|
|
|
|
}) |
|
189
|
|
|
|
|
|
|
}; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
The public repository of this module is |
|
196
|
|
|
|
|
|
|
L. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SUPPORT |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
The public support forum of this module is L. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 BUG TRACKER |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Please report bugs in this module via the Github bug queue at |
|
205
|
|
|
|
|
|
|
L |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 AUTHOR |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Max Maischein C |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Copyright 2021-2023 by Max Maischein C. |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 LICENSE |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |