Skip to content

Commit

Permalink
it compiles, but doesnt call ImageReader::ImageCallback
Browse files Browse the repository at this point in the history
I feel I am getting closer
  • Loading branch information
Shaji Khan committed Dec 10, 2023
1 parent 153feae commit 60f9b89
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
10 changes: 9 additions & 1 deletion app/src/main/cpp/android_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "camera_engine.h"
#include "camera_manager.h"
#include "logging_macros.h"

/**
* Application object:
Expand Down Expand Up @@ -130,7 +131,14 @@ Java_com_shajikhan_ladspa_amprack_Camera_onPreviewSurfaceCreated(
"NativeObject should not be null Pointer");
CameraAppEngine *pApp = reinterpret_cast<CameraAppEngine *>(ndkCameraObj);
// pApp->CreateCameraSession(nullptr);
pApp->CreateCameraSession(surface);
HERE
LOGD( "Creating camera session ...\n");
if (pApp->imageReader->GetNativeWindow() == NULL) {
LOGE("uhoh, image reader native window is null!");
} else {
LOGD("image reader native window [ok]!");
}
pApp->CreateCameraSession(surface, pApp->imageReader->GetNativeWindow());
pApp->StartPreview(true);
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/cpp/camera_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ CameraAppEngine::~CameraAppEngine() {
* Create a capture session with given Java Surface Object
* @param surface a {@link Surface} object.
*/
void CameraAppEngine::CreateCameraSession(jobject surface) {
void CameraAppEngine::CreateCameraSession(jobject surface, ANativeWindow * window) {
if (surface == nullptr) {
camera_->CreateSessionVideoCapture(imageReader->GetNativeWindow ());
} else {
surface_ = env_->NewGlobalRef(surface);
camera_->CreateSession(ANativeWindow_fromSurface(env_, surface));
camera_->CreateSession(ANativeWindow_fromSurface(env_, surface), nullptr, window, false, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/camera_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CameraAppEngine {
~CameraAppEngine();

// Manage NDKCamera Object
void CreateCameraSession(jobject surface);
void CreateCameraSession(jobject surface, ANativeWindow * window);
void StartPreview(bool start);
const ImageFormat& GetCompatibleCameraRes() const;
int32_t GetCameraSensorOrientation(int32_t facing);
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/cpp/camera_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void NDKCamera::CreateSessionVideoCapture(ANativeWindow * window) {


void NDKCamera::CreateSession(ANativeWindow* previewWindow,
ANativeWindow* jpgWindow, bool manualPreview,
ANativeWindow* jpgWindow, ANativeWindow * videoCaptureWindow, bool manualPreview,
int32_t imageRotation) {
IN
// Create output from this app's ANativeWindow, and add into output container
Expand All @@ -255,7 +255,10 @@ void NDKCamera::CreateSession(ANativeWindow* previewWindow,
requests_[JPG_CAPTURE_REQUEST_IDX].outputNativeWindow_ = jpgWindow;
requests_[JPG_CAPTURE_REQUEST_IDX].template_ = TEMPLATE_STILL_CAPTURE;

requests_[VIDEO_CAPTURE_REQUEST_IDX].outputNativeWindow_ = videoRecordWindow;
if (videoCaptureWindow == nullptr) {
HERE LOGF("video capture window is null!");
}
requests_[VIDEO_CAPTURE_REQUEST_IDX].outputNativeWindow_ = videoCaptureWindow;
requests_[VIDEO_CAPTURE_REQUEST_IDX].template_ = TEMPLATE_RECORD ;

CALL_CONTAINER(create(&outputContainer_));
Expand Down Expand Up @@ -313,7 +316,7 @@ void NDKCamera::CreateSession(ANativeWindow* previewWindow,
}

void NDKCamera::CreateSession(ANativeWindow* previewWindow) {
CreateSession(previewWindow, nullptr, false, 0);
CreateSession(previewWindow, nullptr, nullptr, false, 0);
}

NDKCamera::~NDKCamera() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/camera_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class NDKCamera {
bool MatchCaptureSizeRequest(int32_t requestWidth, int32_t requestHeight,
ImageFormat* view, ImageFormat* capture);
void CreateSession(ANativeWindow* previewWindow, ANativeWindow* jpgWindow,
bool manaulPreview, int32_t imageRotation);
ANativeWindow * videoCaptureWindow, bool manaulPreview, int32_t imageRotation);
void CreateSession(ANativeWindow* previewWindow);

bool GetSensorOrientation(int32_t* facing, int32_t* angle);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/cpp/image_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ void ImageReader::ImageCallback(AImageReader *reader) {
std::thread writeFileHandler(&ImageReader::WriteFile, this, image);
writeFileHandler.detach();
}

HERE
}

ANativeWindow *ImageReader::GetNativeWindow(void) {
Expand Down

0 comments on commit 60f9b89

Please sign in to comment.