| 773 | } |
| 774 | |
| 775 | static int android_camera_read_header(AVFormatContext *avctx) |
| 776 | { |
| 777 | AndroidCameraCtx *ctx = avctx->priv_data; |
| 778 | int ret; |
| 779 | |
| 780 | atomic_init(&ctx->got_image_format, 0); |
| 781 | atomic_init(&ctx->exit, 0); |
| 782 | |
| 783 | ret = av_thread_message_queue_alloc(&ctx->input_queue, ctx->input_queue_size, sizeof(AVPacket)); |
| 784 | if (ret < 0) { |
| 785 | av_log(avctx, AV_LOG_ERROR, |
| 786 | "Failed to allocate input queue, error: %s.\n", av_err2str(ret)); |
| 787 | goto error; |
| 788 | } |
| 789 | |
| 790 | ctx->camera_mgr = ACameraManager_create(); |
| 791 | if (!ctx->camera_mgr) { |
| 792 | av_log(avctx, AV_LOG_ERROR, "Failed to create Android camera manager.\n"); |
| 793 | ret = AVERROR_EXTERNAL; |
| 794 | goto error; |
| 795 | } |
| 796 | |
| 797 | ret = open_camera(avctx); |
| 798 | if (ret < 0) { |
| 799 | av_log(avctx, AV_LOG_ERROR, "Failed to open camera.\n"); |
| 800 | goto error; |
| 801 | } |
| 802 | |
| 803 | get_sensor_orientation(avctx); |
| 804 | match_video_size(avctx); |
| 805 | match_framerate(avctx); |
| 806 | |
| 807 | ret = create_image_reader(avctx); |
| 808 | if (ret < 0) { |
| 809 | goto error; |
| 810 | } |
| 811 | |
| 812 | ret = create_capture_session(avctx); |
| 813 | if (ret < 0) { |
| 814 | goto error; |
| 815 | } |
| 816 | |
| 817 | ret = add_video_stream(avctx); |
| 818 | |
| 819 | error: |
| 820 | if (ret < 0) { |
| 821 | android_camera_read_close(avctx); |
| 822 | av_log(avctx, AV_LOG_ERROR, "Failed to open android_camera.\n"); |
| 823 | } |
| 824 | |
| 825 | return ret; |
| 826 | } |
| 827 | |
| 828 | static int android_camera_read_packet(AVFormatContext *avctx, AVPacket *pkt) |
| 829 | { |
nothing calls this directly
no test coverage detected