|
|
|
@ -26,19 +26,24 @@ void Camera::InitializeCamera(int cameraID)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::StartCapture() |
|
|
|
|
Aurora::StreamCamera::CameraCapability Camera::StartCapture() |
|
|
|
|
{ |
|
|
|
|
if (m_camera) { |
|
|
|
|
Aurora::StreamCamera::CameraInfo info; |
|
|
|
|
|
|
|
|
|
if (m_camera->getInfo(info)) { |
|
|
|
|
std::vector<Aurora::StreamCamera::CameraCapability> caps; |
|
|
|
|
|
|
|
|
|
if (m_manager->queryCapabilities(info.id, caps)) { |
|
|
|
|
m_camera->startCapture(caps.at(1)); |
|
|
|
|
for(Aurora::StreamCamera::CameraCapability cap : caps) { |
|
|
|
|
if (m_widthTexture + m_heightTexture < cap.width + cap.height) { |
|
|
|
|
m_camera->startCapture(cap); |
|
|
|
|
return cap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return Aurora::StreamCamera::CameraCapability{}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::StopCapture() |
|
|
|
@ -50,15 +55,22 @@ void Camera::StopCapture()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64_t Camera::Register(int cameraID) |
|
|
|
|
std::map<Encodable, Encodable> Camera::Register(int cameraID, int width, int height) |
|
|
|
|
{ |
|
|
|
|
m_widthTexture = width; |
|
|
|
|
m_heightTexture = height; |
|
|
|
|
|
|
|
|
|
m_textureId = m_plugin->RegisterTexture( |
|
|
|
|
[this](size_t width, size_t height) { return this->m_buffer; }); |
|
|
|
|
|
|
|
|
|
InitializeCamera(cameraID); |
|
|
|
|
StartCapture(); |
|
|
|
|
auto cab = StartCapture(); |
|
|
|
|
|
|
|
|
|
return m_textureId; |
|
|
|
|
return std::map<Encodable, Encodable>{ |
|
|
|
|
{"textureId", m_textureId}, |
|
|
|
|
{"width", cab.width}, |
|
|
|
|
{"height", cab.height}, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::Unregister() |
|
|
|
@ -72,10 +84,18 @@ void Camera::onCameraFrame(std::shared_ptr<Aurora::StreamCamera::GraphicBuffer>
|
|
|
|
|
if (buffer->handleType == Aurora::StreamCamera::HandleType::EGL) { |
|
|
|
|
// @todo Not tested. The device needs to be completed.
|
|
|
|
|
auto eglImage = CameraEGLHelper::EGLCreateImage(buffer); |
|
|
|
|
this->m_buffer = new TextureVariant(FlutterEGLImage{eglImage}); |
|
|
|
|
this->m_buffer = new TextureVariant(FlutterEGLImage{ |
|
|
|
|
eglImage, |
|
|
|
|
buffer->width, |
|
|
|
|
buffer->height, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
auto pixels = CameraPixelsHelper::YUVtoARGB(buffer->mapYCbCr()); |
|
|
|
|
this->m_buffer = new TextureVariant(FlutterPixelBuffer{pixels}); |
|
|
|
|
this->m_buffer = new TextureVariant(FlutterPixelBuffer{ |
|
|
|
|
pixels, |
|
|
|
|
buffer->width, |
|
|
|
|
buffer->height, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m_plugin->MarkTextureAvailable(m_textureId); |
|
|
|
@ -83,7 +103,8 @@ void Camera::onCameraFrame(std::shared_ptr<Aurora::StreamCamera::GraphicBuffer>
|
|
|
|
|
|
|
|
|
|
void Camera::onCameraError(const std::string &errorDescription) |
|
|
|
|
{ |
|
|
|
|
std::cout << "onCameraError" << std::endl; |
|
|
|
|
this->Unregister(); |
|
|
|
|
std::cout << errorDescription << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Camera::onCameraParameterChanged(Aurora::StreamCamera::CameraParameter parameter, |
|
|
|
|