| 837 | } |
| 838 | |
| 839 | static int mediacodec_encode(AVCodecContext *avctx, AVPacket *pkt) |
| 840 | { |
| 841 | MediaCodecEncContext *s = avctx->priv_data; |
| 842 | int ret; |
| 843 | |
| 844 | // Return on three case: |
| 845 | // 1. Serious error |
| 846 | // 2. Got a packet success |
| 847 | // 3. No AVFrame is available yet (don't return if get_frame return EOF) |
| 848 | while (1) { |
| 849 | if (s->bsf) { |
| 850 | ret = av_bsf_receive_packet(s->bsf, pkt); |
| 851 | if (!ret) |
| 852 | return 0; |
| 853 | if (ret != AVERROR(EAGAIN)) |
| 854 | return ret; |
| 855 | } |
| 856 | |
| 857 | ret = mediacodec_receive(avctx, pkt); |
| 858 | if (s->bsf) { |
| 859 | if (!ret || ret == AVERROR_EOF) |
| 860 | ret = av_bsf_send_packet(s->bsf, pkt); |
| 861 | } else { |
| 862 | if (!ret) |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | if (ret < 0 && ret != AVERROR(EAGAIN)) |
| 867 | return ret; |
| 868 | |
| 869 | if (!s->frame->buf[0]) { |
| 870 | ret = ff_encode_get_frame(avctx, s->frame); |
| 871 | if (ret && ret != AVERROR_EOF) |
| 872 | return ret; |
| 873 | } |
| 874 | |
| 875 | ret = mediacodec_send(avctx, s->frame->buf[0] ? s->frame : NULL); |
| 876 | if (!ret) |
| 877 | av_frame_unref(s->frame); |
| 878 | else if (ret != AVERROR(EAGAIN)) |
| 879 | return ret; |
| 880 | } |
| 881 | |
| 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | static int mediacodec_send_dummy_frame(AVCodecContext *avctx) |
| 886 | { |
nothing calls this directly
no test coverage detected