feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef BUFFER_DECODER_H
|
||||
#define BUFFER_DECODER_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/image.h"
|
||||
#include "core/templates/vector.h"
|
||||
|
|
@ -112,5 +111,3 @@ public:
|
|||
JpegBufferDecoder(CameraFeed *p_camera_feed);
|
||||
virtual void decode(StreamingBuffer p_buffer) override;
|
||||
};
|
||||
|
||||
#endif // BUFFER_DECODER_H
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void CameraFeedLinux::_update_buffer() {
|
|||
}
|
||||
|
||||
void CameraFeedLinux::_query_device(const String &p_device_name) {
|
||||
file_descriptor = open(p_device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
|
||||
file_descriptor = open(p_device_name.ascii().get_data(), O_RDWR | O_NONBLOCK, 0);
|
||||
ERR_FAIL_COND_MSG(file_descriptor == -1, vformat("Cannot open file descriptor for %s. Error: %d.", p_device_name, errno));
|
||||
|
||||
struct v4l2_capability capability;
|
||||
|
|
@ -235,7 +235,7 @@ String CameraFeedLinux::get_device_name() const {
|
|||
|
||||
bool CameraFeedLinux::activate_feed() {
|
||||
ERR_FAIL_COND_V_MSG(selected_format == -1, false, "CameraFeed format needs to be set before activating.");
|
||||
file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
|
||||
file_descriptor = open(device_name.ascii().get_data(), O_RDWR | O_NONBLOCK, 0);
|
||||
if (_request_buffers() && _start_capturing()) {
|
||||
buffer_decoder = _create_buffer_decoder();
|
||||
_start_thread();
|
||||
|
|
@ -315,7 +315,7 @@ bool CameraFeedLinux::set_format(int p_index, const Dictionary &p_parameters) {
|
|||
|
||||
FeedFormat feed_format = formats[p_index];
|
||||
|
||||
file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
|
||||
file_descriptor = open(device_name.ascii().get_data(), O_RDWR | O_NONBLOCK, 0);
|
||||
|
||||
struct v4l2_format format;
|
||||
memset(&format, 0, sizeof(format));
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAMERA_FEED_LINUX_H
|
||||
#define CAMERA_FEED_LINUX_H
|
||||
#pragma once
|
||||
|
||||
#include "buffer_decoder.h"
|
||||
|
||||
|
|
@ -41,6 +40,8 @@
|
|||
struct StreamingBuffer;
|
||||
|
||||
class CameraFeedLinux : public CameraFeed {
|
||||
GDSOFTCLASS(CameraFeedLinux, CameraFeed);
|
||||
|
||||
private:
|
||||
SafeFlag exit_flag;
|
||||
Thread *thread = nullptr;
|
||||
|
|
@ -65,14 +66,12 @@ private:
|
|||
|
||||
public:
|
||||
String get_device_name() const;
|
||||
bool activate_feed();
|
||||
void deactivate_feed();
|
||||
bool set_format(int p_index, const Dictionary &p_parameters);
|
||||
Array get_formats() const;
|
||||
FeedFormat get_format() const;
|
||||
bool activate_feed() override;
|
||||
void deactivate_feed() override;
|
||||
bool set_format(int p_index, const Dictionary &p_parameters) override;
|
||||
Array get_formats() const override;
|
||||
FeedFormat get_format() const override;
|
||||
|
||||
CameraFeedLinux(const String &p_device_name);
|
||||
virtual ~CameraFeedLinux();
|
||||
~CameraFeedLinux() override;
|
||||
};
|
||||
|
||||
#endif // CAMERA_FEED_LINUX_H
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void CameraLinux::_add_device(const String &p_device_name) {
|
|||
int CameraLinux::_open_device(const String &p_device_name) {
|
||||
struct stat s;
|
||||
|
||||
if (stat(p_device_name.ascii(), &s) == -1) {
|
||||
if (stat(p_device_name.ascii().get_data(), &s) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ int CameraLinux::_open_device(const String &p_device_name) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
return open(p_device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
|
||||
return open(p_device_name.ascii().get_data(), O_RDWR | O_NONBLOCK, 0);
|
||||
}
|
||||
|
||||
// TODO any cheaper/cleaner way to check if file descriptor is invalid?
|
||||
|
|
@ -162,11 +162,25 @@ bool CameraLinux::_can_query_format(int p_file_descriptor, int p_type) {
|
|||
return ioctl(p_file_descriptor, VIDIOC_G_FMT, &format) != -1;
|
||||
}
|
||||
|
||||
CameraLinux::CameraLinux() {
|
||||
camera_thread.start(CameraLinux::camera_thread_func, this);
|
||||
inline void CameraLinux::set_monitoring_feeds(bool p_monitoring_feeds) {
|
||||
if (p_monitoring_feeds == monitoring_feeds) {
|
||||
return;
|
||||
}
|
||||
|
||||
CameraServer::set_monitoring_feeds(p_monitoring_feeds);
|
||||
if (p_monitoring_feeds) {
|
||||
camera_thread.start(CameraLinux::camera_thread_func, this);
|
||||
} else {
|
||||
exit_flag.set();
|
||||
if (camera_thread.is_started()) {
|
||||
camera_thread.wait_to_finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CameraLinux::~CameraLinux() {
|
||||
exit_flag.set();
|
||||
camera_thread.wait_to_finish();
|
||||
if (camera_thread.is_started()) {
|
||||
camera_thread.wait_to_finish();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAMERA_LINUX_H
|
||||
#define CAMERA_LINUX_H
|
||||
#pragma once
|
||||
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/thread.h"
|
||||
|
|
@ -53,8 +52,8 @@ private:
|
|||
bool _can_query_format(int p_file_descriptor, int p_type);
|
||||
|
||||
public:
|
||||
CameraLinux();
|
||||
CameraLinux() = default;
|
||||
~CameraLinux();
|
||||
};
|
||||
|
||||
#endif // CAMERA_LINUX_H
|
||||
void set_monitoring_feeds(bool p_monitoring_feeds) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAMERA_MACOS_H
|
||||
#define CAMERA_MACOS_H
|
||||
#pragma once
|
||||
|
||||
///@TODO this is a near duplicate of CameraIOS, we should find a way to combine those to minimize code duplication!!!!
|
||||
// If you fix something here, make sure you fix it there as well!
|
||||
|
|
@ -37,10 +36,11 @@
|
|||
#include "servers/camera_server.h"
|
||||
|
||||
class CameraMacOS : public CameraServer {
|
||||
GDSOFTCLASS(CameraMacOS, CameraServer);
|
||||
|
||||
public:
|
||||
CameraMacOS();
|
||||
CameraMacOS() = default;
|
||||
|
||||
void update_feeds();
|
||||
void set_monitoring_feeds(bool p_monitoring_feeds) override;
|
||||
};
|
||||
|
||||
#endif // CAMERA_MACOS_H
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
///@TODO this is a near duplicate of CameraIOS, we should find a way to combine those to minimize code duplication!!!!
|
||||
// If you fix something here, make sure you fix it there as well!
|
||||
|
||||
#include "camera_macos.h"
|
||||
#import "camera_macos.h"
|
||||
|
||||
#include "servers/camera/camera_feed.h"
|
||||
|
||||
|
|
@ -195,6 +195,8 @@
|
|||
// CameraFeedMacOS - Subclass for camera feeds in macOS
|
||||
|
||||
class CameraFeedMacOS : public CameraFeed {
|
||||
GDSOFTCLASS(CameraFeedMacOS, CameraFeed);
|
||||
|
||||
private:
|
||||
AVCaptureDevice *device;
|
||||
MyCaptureSession *capture_session;
|
||||
|
|
@ -206,8 +208,8 @@ public:
|
|||
|
||||
void set_device(AVCaptureDevice *p_device);
|
||||
|
||||
bool activate_feed();
|
||||
void deactivate_feed();
|
||||
bool activate_feed() override;
|
||||
void deactivate_feed() override;
|
||||
};
|
||||
|
||||
AVCaptureDevice *CameraFeedMacOS::get_device() const {
|
||||
|
|
@ -359,10 +361,20 @@ void CameraMacOS::update_feeds() {
|
|||
};
|
||||
}
|
||||
|
||||
CameraMacOS::CameraMacOS() {
|
||||
// Find available cameras we have at this time
|
||||
update_feeds();
|
||||
void CameraMacOS::set_monitoring_feeds(bool p_monitoring_feeds) {
|
||||
if (p_monitoring_feeds == monitoring_feeds) {
|
||||
return;
|
||||
}
|
||||
|
||||
// should only have one of these....
|
||||
device_notifications = [[MyDeviceNotifications alloc] initForServer:this];
|
||||
CameraServer::set_monitoring_feeds(p_monitoring_feeds);
|
||||
if (p_monitoring_feeds) {
|
||||
// Find available cameras we have at this time.
|
||||
update_feeds();
|
||||
|
||||
// Get notified on feed changes.
|
||||
device_notifications = [[MyDeviceNotifications alloc] initForServer:this];
|
||||
} else {
|
||||
// Stop monitoring feed changes.
|
||||
device_notifications = nil;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAMERA_WIN_H
|
||||
#define CAMERA_WIN_H
|
||||
#pragma once
|
||||
|
||||
#include "servers/camera/camera_feed.h"
|
||||
#include "servers/camera_server.h"
|
||||
|
|
@ -42,5 +41,3 @@ public:
|
|||
CameraWindows();
|
||||
~CameraWindows() {}
|
||||
};
|
||||
|
||||
#endif // CAMERA_WIN_H
|
||||
|
|
|
|||
|
|
@ -28,12 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAMERA_REGISTER_TYPES_H
|
||||
#define CAMERA_REGISTER_TYPES_H
|
||||
#pragma once
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_camera_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_camera_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif // CAMERA_REGISTER_TYPES_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue