Skip to content

Commit

Permalink
milestone: going to implement camera
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Mar 14, 2024
1 parent 9243702 commit e1020d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/src/main/cpp/camera_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ void CameraAppEngine::releaseEncoder() {
bool CameraAppEngine::writeFrame(AImage * image){
// Feed any pending encoder output into the muxer.
IN
OUT
return true;
// if (mEncoder == nullptr) {
// LOGD("first time running, trying to create encoder ...");
// createEncoder(filename);
Expand Down Expand Up @@ -299,6 +301,8 @@ bool CameraAppEngine::writeFrame(AImage * image){

void CameraAppEngine::drainEncoder(bool endOfStream) {
IN
OUT
return;
LOGD("end of stream: %d", endOfStream);
if (endOfStream) {
LOGD( "Draining encoder to EOS");
Expand All @@ -313,7 +317,7 @@ void CameraAppEngine::drainEncoder(bool endOfStream) {

while (true) {
LOGD("dequeue output buffer...");
if (mEncoder != nullptr) LOGE("mEncoder is NULL");
if (mEncoder == nullptr) LOGE("mEncoder is NULL");

ssize_t encoderStatus = AMediaCodec_dequeueOutputBuffer(mEncoder, &mBufferInfo, TIMEOUT_USEC);
LOGD("encoder status: %d", encoderStatus);
Expand Down Expand Up @@ -487,10 +491,11 @@ void ImageReader::ImageCallback(AImageReader *reader) {
// if (format == AIMAGE_FORMAT_JPEG)
// {
AImage *image = nullptr;
status = AImageReader_acquireNextImage(reader, &image);
status = AImageReader_acquireLatestImage(reader, &image);
ASSERT(status == AMEDIA_OK && image, "Image is not available");
CameraAppEngine * _app = (CameraAppEngine *) app ;
_app -> writeFrame (image);
AImage_delete(image);
/*
size_t bufferSize = 0;
int inputBufferIdx = AMediaCodec_dequeueInputBuffer(mediaCodec, -1);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/cpp/camera_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ void NDKCamera::CreateSession(ANativeWindow* previewWindow,
CALL_DEV(createCaptureSession(cameras_[activeCameraId_].device_,
outputContainer_, GetSessionListener(),
&captureSession_));
CALL_DEV(createCaptureSession(cameras_[activeCameraId_].device_,
outputContainer_, GetSessionListener(),
&captureSessionV));

if (jpgWindow) {
ACaptureRequest_setEntry_i32(requests_[JPG_CAPTURE_REQUEST_IDX].request_,
Expand Down Expand Up @@ -444,6 +447,9 @@ void NDKCamera::StartPreview(bool start) {
CALL_SESSION(setRepeatingRequest(captureSession_, nullptr, 1,
&requests_[PREVIEW_REQUEST_IDX].request_,
nullptr));
CALL_SESSION(setRepeatingRequest(captureSessionV, nullptr, 1,
&requests_[VIDEO_CAPTURE_REQUEST_IDX].request_,
nullptr));
} else if (!start && captureSessionState_ == CaptureSessionState::ACTIVE) {
ACameraCaptureSession_stopRepeating(captureSession_);
}
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 @@ -89,7 +89,7 @@ class NDKCamera {
std::vector<CaptureRequestInfo> requests_;

ACaptureSessionOutputContainer* outputContainer_;
ACameraCaptureSession* captureSession_;
ACameraCaptureSession* captureSession_, *captureSessionV;
CaptureSessionState captureSessionState_;

// set up exposure control
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/shajikhan/ladspa/amprack/Rack.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,10 @@ public boolean onLongClick(View view) {
@Override
public void onClick(View v) {
// mainActivity.drummer ();
// mainActivity.cameraPreview();
MainActivity.setAudioDevice();
if (BuildConfig.DEBUG)
mainActivity.cameraPreview();
else
MainActivity.setAudioDevice();
return;
}
});
Expand Down

0 comments on commit e1020d5

Please sign in to comment.