| 73 | } |
| 74 | |
| 75 | int bitStreamDecoder::decode(unique_ptr<IAFPacket> &pkt, int index, bool flush) |
| 76 | { |
| 77 | int64_t decodeTime; |
| 78 | |
| 79 | if (index == -1 && pkt != nullptr) { |
| 80 | index = pkt->getInfo().streamIndex; |
| 81 | } |
| 82 | |
| 83 | if (index < 0) { |
| 84 | return -EINVAL; |
| 85 | } |
| 86 | |
| 87 | int ret = 0; |
| 88 | unique_ptr<IAFFrame> frame{}; |
| 89 | decodeTime = af_gettime_relative(); |
| 90 | |
| 91 | do { |
| 92 | ret = mDecoders[index]->getFrame(frame, 0); |
| 93 | |
| 94 | if (ret == 0) { |
| 95 | mListener.onFrame(frame.get(), (int) (af_gettime_relative() - decodeTime + mStatisInfo[index].decoderTimeSend)); |
| 96 | mStatisInfo[index].decoderTimeSend = 0; |
| 97 | mStatisInfo[index].lastFramePTS = frame->getInfo().pts; |
| 98 | // AF_LOGD("%d pts to %lld\n\n", index, mStatisInfo[index].lastFramePTS); |
| 99 | } |
| 100 | } while (ret == 0); |
| 101 | |
| 102 | if (ret == STATUS_EOS) { |
| 103 | AF_LOGD("EOS\n"); |
| 104 | return ret; |
| 105 | } |
| 106 | |
| 107 | if (ret < 0 && ret != -EAGAIN) { |
| 108 | AF_LOGE("decoder error\n"); |
| 109 | } |
| 110 | |
| 111 | if (pkt != nullptr || flush) { |
| 112 | decodeTime = af_gettime_relative(); |
| 113 | ret = mDecoders[index]->send_packet(pkt, 0); |
| 114 | mStatisInfo[index].decoderTimeSend = af_gettime_relative() - decodeTime; |
| 115 | } |
| 116 | |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | int bitStreamDecoder::readPacket() |
| 121 | { |
nothing calls this directly
no test coverage detected