Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activate_feed and deactivate_feed virtual bind to CameraFeed #97571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/classes/CameraFeed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<tutorials>
</tutorials>
<methods>
<method name="_activate_feed" qualifiers="virtual">
<return type="bool" />
<description>
Called when the camera feed is activated.
</description>
</method>
<method name="_deactivate_feed" qualifiers="virtual">
<return type="void" />
<description>
Called when the camera feed is deactivated.
</description>
</method>
<method name="get_datatype" qualifiers="const">
<return type="int" enum="CameraFeed.FeedDataType" />
<description>
Expand Down
10 changes: 7 additions & 3 deletions servers/camera/camera_feed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void CameraFeed::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_formats"), &CameraFeed::get_formats);
ClassDB::bind_method(D_METHOD("set_format", "index", "parameters"), &CameraFeed::set_format);

GDVIRTUAL_BIND(_activate_feed);
GDVIRTUAL_BIND(_deactivate_feed);

ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("format_changed"));

Expand Down Expand Up @@ -256,12 +259,13 @@ void CameraFeed::set_YCbCr_imgs(const Ref<Image> &p_y_img, const Ref<Image> &p_c
}

bool CameraFeed::activate_feed() {
// nothing to do here
return true;
bool ret = true;
GDVIRTUAL_CALL(_activate_feed, ret);
return ret;
}

void CameraFeed::deactivate_feed() {
// nothing to do here
GDVIRTUAL_CALL(_deactivate_feed);
}

bool CameraFeed::set_format(int p_index, const Dictionary &p_parameters) {
Expand Down
3 changes: 3 additions & 0 deletions servers/camera/camera_feed.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class CameraFeed : public RefCounted {

virtual bool activate_feed();
virtual void deactivate_feed();

GDVIRTUAL0R(bool, _activate_feed)
GDVIRTUAL0(_deactivate_feed)
};

VARIANT_ENUM_CAST(CameraFeed::FeedDataType);
Expand Down
Loading