MCPcopy Create free account
hub / github.com/android/ndk-samples / CreateSession

Method CreateSession

camera/basic/src/main/cpp/camera_manager.cpp:224–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void NDKCamera::CreateSession(ANativeWindow* previewWindow,
225 ANativeWindow* jpgWindow, int32_t imageRotation) {
226 // Create output from this app's ANativeWindow, and add into output container
227 requests_[PREVIEW_REQUEST_IDX].outputNativeWindow_ = previewWindow;
228 requests_[PREVIEW_REQUEST_IDX].template_ = TEMPLATE_PREVIEW;
229 requests_[JPG_CAPTURE_REQUEST_IDX].outputNativeWindow_ = jpgWindow;
230 requests_[JPG_CAPTURE_REQUEST_IDX].template_ = TEMPLATE_STILL_CAPTURE;
231
232 CALL_CONTAINER(create(&outputContainer_));
233 for (auto& req : requests_) {
234 ANativeWindow_acquire(req.outputNativeWindow_);
235 CALL_OUTPUT(create(req.outputNativeWindow_, &req.sessionOutput_));
236 CALL_CONTAINER(add(outputContainer_, req.sessionOutput_));
237 CALL_TARGET(create(req.outputNativeWindow_, &req.target_));
238 CALL_DEV(createCaptureRequest(cameras_[activeCameraId_].device_,
239 req.template_, &req.request_));
240 CALL_REQUEST(addTarget(req.request_, req.target_));
241 }
242
243 // Create a capture session for the given preview request
244 captureSessionState_ = CaptureSessionState::READY;
245 CALL_DEV(createCaptureSession(cameras_[activeCameraId_].device_,
246 outputContainer_, GetSessionListener(),
247 &captureSession_));
248
249 ACaptureRequest_setEntry_i32(requests_[JPG_CAPTURE_REQUEST_IDX].request_,
250 ACAMERA_JPEG_ORIENTATION, 1, &imageRotation);
251
252 /*
253 * Only preview request is in manual mode, JPG is always in Auto mode
254 * JPG capture mode could also be switch into manual mode and control
255 * the capture parameters, this sample leaves JPG capture to be auto mode
256 * (auto control has better effect than author's manual control)
257 */
258 uint8_t aeModeOff = ACAMERA_CONTROL_AE_MODE_OFF;
259 CALL_REQUEST(setEntry_u8(requests_[PREVIEW_REQUEST_IDX].request_,
260 ACAMERA_CONTROL_AE_MODE, 1, &aeModeOff));
261 CALL_REQUEST(setEntry_i32(requests_[PREVIEW_REQUEST_IDX].request_,
262 ACAMERA_SENSOR_SENSITIVITY, 1, &sensitivity_));
263 CALL_REQUEST(setEntry_i64(requests_[PREVIEW_REQUEST_IDX].request_,
264 ACAMERA_SENSOR_EXPOSURE_TIME, 1, &exposureTime_));
265}
266
267NDKCamera::~NDKCamera() {
268 valid_ = false;

Callers 1

CreateCameraMethod · 0.45

Calls 1

addFunction · 0.85

Tested by

no test coverage detected