Skip to content

Commit d0a0f58

Browse files
committed
Merge pull request #97571 from j20001970/camerafeed-virtual
Add `activate_feed` and `deactivate_feed` virtual bind to CameraFeed
2 parents abf4796 + 3720de4 commit d0a0f58

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

doc/classes/CameraFeed.xml

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
<tutorials>
1212
</tutorials>
1313
<methods>
14+
<method name="_activate_feed" qualifiers="virtual">
15+
<return type="bool" />
16+
<description>
17+
Called when the camera feed is activated.
18+
</description>
19+
</method>
20+
<method name="_deactivate_feed" qualifiers="virtual">
21+
<return type="void" />
22+
<description>
23+
Called when the camera feed is deactivated.
24+
</description>
25+
</method>
1426
<method name="get_datatype" qualifiers="const">
1527
<return type="int" enum="CameraFeed.FeedDataType" />
1628
<description>

servers/camera/camera_feed.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ void CameraFeed::_bind_methods() {
5858
ClassDB::bind_method(D_METHOD("get_formats"), &CameraFeed::get_formats);
5959
ClassDB::bind_method(D_METHOD("set_format", "index", "parameters"), &CameraFeed::set_format);
6060

61+
GDVIRTUAL_BIND(_activate_feed);
62+
GDVIRTUAL_BIND(_deactivate_feed);
63+
6164
ADD_SIGNAL(MethodInfo("frame_changed"));
6265
ADD_SIGNAL(MethodInfo("format_changed"));
6366

@@ -273,12 +276,13 @@ void CameraFeed::set_external(int p_width, int p_height) {
273276
}
274277

275278
bool CameraFeed::activate_feed() {
276-
// nothing to do here
277-
return true;
279+
bool ret = true;
280+
GDVIRTUAL_CALL(_activate_feed, ret);
281+
return ret;
278282
}
279283

280284
void CameraFeed::deactivate_feed() {
281-
// nothing to do here
285+
GDVIRTUAL_CALL(_deactivate_feed);
282286
}
283287

284288
bool CameraFeed::set_format(int p_index, const Dictionary &p_parameters) {

servers/camera/camera_feed.h

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class CameraFeed : public RefCounted {
123123

124124
virtual bool activate_feed();
125125
virtual void deactivate_feed();
126+
127+
GDVIRTUAL0R(bool, _activate_feed)
128+
GDVIRTUAL0(_deactivate_feed)
126129
};
127130

128131
VARIANT_ENUM_CAST(CameraFeed::FeedDataType);

0 commit comments

Comments
 (0)