From 51147a836955ed6ff7c111bbce89e244f0c3f27f Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 17 八月 2017 16:20:05 +0800 Subject: [PATCH] aaaaa --- RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp | 38 +++++++++++++++++++++++++++----------- 1 files changed, 27 insertions(+), 11 deletions(-) diff --git a/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp b/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp index fa689f0..79a8a46 100644 --- a/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp +++ b/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp @@ -38,12 +38,15 @@ AMediaCodec* codec; + bool auxIsSet; + PL_AMCD_Internal() : buffSize(0), buffSizeMax(sizeof(buffer)), inputFrameCount(0), lastOutputBuffIdx(-1), lastMbfBuffIdx(), lastMbfBuffer(), config(), - codec(nullptr) + codec(nullptr), + auxIsSet(false) { } @@ -136,12 +139,11 @@ AMediaFormat_setBuffer(format, "csd-1", pps.sPropBytes, pps.sPropLength); // pps */ - // J0LgKI1oCgPaEAAAAwAQAAADAoDxB6gA,KM4ySA== - uint8_t sps[] = {0x27,0x42,0xe0,0x28,0x8d,0x68,0x0a,0x03,0xda,0x10,0x00,0x00,0x03,0x00,0x10,0x00,0x00,0x03,0x02,0x80,0xf1,0x07,0xa8,0x00}; - uint8_t pps[] = {0x28,0xce,0x32,0x48}; - AMediaFormat_setBuffer(format, "csd-0", sps, sizeof(sps)); // sps - AMediaFormat_setBuffer(format, "csd-1", pps, sizeof(pps)); // pps - + // J0LgKI1oCgPaEAAAAwAQAAADAoDxB6gA,KM4ySA== + //uint8_t sps[] = {0x27,0x42,0xe0,0x28,0x8d,0x68,0x0a,0x03,0xda,0x10,0x00,0x00,0x03,0x00,0x10,0x00,0x00,0x03,0x02,0x80,0xf1,0x07,0xa8,0x00}; + //uint8_t pps[] = {0x28,0xce,0x32,0x48}; + //AMediaFormat_setBuffer(format, "csd-0", sps, sizeof(sps)); // sps + //AMediaFormat_setBuffer(format, "csd-1", pps, sizeof(pps)); // pps // should like: // mime: string(video/avc), durationUs: int64(10000000), width: int32(480), height: int32(360), max-input-size: int32(55067), csd-0: data, csd-1: data} @@ -194,7 +196,21 @@ if (pm.buffer == nullptr) return false; - + + if (!in->auxIsSet) + { + //#todo + // find PLGP_DEC_SPS_B64 PLGP_DEC_PPS_B64 in this->manager else nothing + // base64 decode + + //AMediaFormat* format = AMediaCodec_getOutputFormat(in->codec); + //AMediaFormat_setBuffer(format, "csd-1", pps, sizeof(pps)); // pps + //AMediaCodec_setParameters + // #todo delete format + + in->auxIsSet = true; + } + MB_Frame* frame = (MB_Frame*)pm.buffer; if (frame->type != MB_Frame::MBFT_H264_NALU) { @@ -202,9 +218,9 @@ return false; } - static FILE *pFile = fopen("/data/bb.264", "wb"); - fwrite(frame->buffer, sizeof(char), frame->buffSize, pFile); - fflush(pFile); + //static FILE *pFile = fopen("/data/bb.264", "wb"); + //fwrite(frame->buffer, sizeof(char), frame->buffSize, pFile); + //fflush(pFile); ssize_t bufidx = AMediaCodec_dequeueInputBuffer(in->codec, 2000); LOGP(DEBUG, "input buffer bufidx=%zd, inputFrameCount=%d", bufidx, in->inputFrameCount++); -- Gitblit v1.8.0