| 537 | } |
| 538 | |
| 539 | static int create_capture_session(AVFormatContext *avctx) |
| 540 | { |
| 541 | AndroidCameraCtx *ctx = avctx->priv_data; |
| 542 | camera_status_t ret; |
| 543 | |
| 544 | ret = ACaptureSessionOutputContainer_create(&ctx->capture_session_output_container); |
| 545 | if (ret != ACAMERA_OK) { |
| 546 | av_log(avctx, AV_LOG_ERROR, |
| 547 | "Failed to create capture session output container, error: %s.\n", |
| 548 | camera_status_string(ret)); |
| 549 | return AVERROR_EXTERNAL; |
| 550 | } |
| 551 | |
| 552 | ANativeWindow_acquire(ctx->image_reader_window); |
| 553 | |
| 554 | ret = ACaptureSessionOutput_create(ctx->image_reader_window, &ctx->capture_session_output); |
| 555 | if (ret != ACAMERA_OK) { |
| 556 | av_log(avctx, AV_LOG_ERROR, |
| 557 | "Failed to create capture session container, error: %s.\n", |
| 558 | camera_status_string(ret)); |
| 559 | return AVERROR_EXTERNAL; |
| 560 | } |
| 561 | |
| 562 | ret = ACaptureSessionOutputContainer_add(ctx->capture_session_output_container, |
| 563 | ctx->capture_session_output); |
| 564 | if (ret != ACAMERA_OK) { |
| 565 | av_log(avctx, AV_LOG_ERROR, |
| 566 | "Failed to add output to output container, error: %s.\n", |
| 567 | camera_status_string(ret)); |
| 568 | return AVERROR_EXTERNAL; |
| 569 | } |
| 570 | |
| 571 | ret = ACameraOutputTarget_create(ctx->image_reader_window, &ctx->camera_output_target); |
| 572 | if (ret != ACAMERA_OK) { |
| 573 | av_log(avctx, AV_LOG_ERROR, |
| 574 | "Failed to create camera output target, error: %s.\n", |
| 575 | camera_status_string(ret)); |
| 576 | return AVERROR_EXTERNAL; |
| 577 | } |
| 578 | |
| 579 | ret = ACameraDevice_createCaptureRequest(ctx->camera_dev, TEMPLATE_RECORD, &ctx->capture_request); |
| 580 | if (ret != ACAMERA_OK) { |
| 581 | av_log(avctx, AV_LOG_ERROR, |
| 582 | "Failed to create capture request, error: %s.\n", |
| 583 | camera_status_string(ret)); |
| 584 | return AVERROR_EXTERNAL; |
| 585 | } |
| 586 | |
| 587 | ret = ACaptureRequest_setEntry_i32(ctx->capture_request, ACAMERA_CONTROL_AE_TARGET_FPS_RANGE, |
| 588 | 2, ctx->framerate_range); |
| 589 | if (ret != ACAMERA_OK) { |
| 590 | av_log(avctx, AV_LOG_ERROR, |
| 591 | "Failed to set target fps range in capture request, error: %s.\n", |
| 592 | camera_status_string(ret)); |
| 593 | return AVERROR_EXTERNAL; |
| 594 | } |
| 595 | |
| 596 | ret = ACaptureRequest_addTarget(ctx->capture_request, ctx->camera_output_target); |
no test coverage detected