From d9ffa50c7e8d6b8c3157690aef8e2a70af1d1695 Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 09 八月 2017 13:58:01 +0800 Subject: [PATCH] rtps server (not ok) --- RtspFace/PL_AndroidMediaCodecEncoder.cpp | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/RtspFace/PL_AndroidMediaCodecEncoder.cpp b/RtspFace/PL_AndroidMediaCodecEncoder.cpp index ca2b98b..481ce39 100644 --- a/RtspFace/PL_AndroidMediaCodecEncoder.cpp +++ b/RtspFace/PL_AndroidMediaCodecEncoder.cpp @@ -91,6 +91,7 @@ AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_BIT_RATE, config->ak_bit_rate); AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_FRAME_RATE, config->ak_frame_rate); AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_I_FRAME_INTERVAL, config->ak_i_frame_interval); + //AMediaFormat_setInt32(format, "profile", 0x00000100); // see: https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_FormatYUV420Flexible #define AMEDIA_COLOR_FormatYUV420Flexible 0x7f420888 @@ -231,7 +232,7 @@ pm.buffSize = 0; //static size_t f = 0; - //static FILE *pFile = fopen("/sdcard/aa.264", "wb"); + //static FILE *pFile = fopen("/data/aa.264", "wb"); //fwrite(in->buffer, sizeof(char), in->buffSize, pFile); //if (++f > 400){ // fclose(pFile); @@ -251,6 +252,24 @@ { auto format = AMediaCodec_getOutputFormat(in->codec); LOGP(INFO, "format changed to: %s", AMediaFormat_toString(format)); + + uint8_t* sps = nullptr; + size_t spsSize = 0; + uint8_t* pps = nullptr; + size_t ppsSize = 0; + + AMediaFormat_getBuffer(format, "csd-0", (void**)&sps, &spsSize); // sps + AMediaFormat_getBuffer(format, "csd-1", (void**)&pps, &ppsSize); // pps + + if (spsSize != 0) + { + std::string spsStr = base64_encode(((const char*)sps) + 4, spsSize - 4);//#todo aux + std::string ppsStr = base64_encode(((const char*)pps) + 4, ppsSize - 4); + + this->manager->set_param(PLGP_ENC_SPS_B64, spsStr); + this->manager->set_param(PLGP_ENC_PPS_B64, ppsStr); + } + AMediaFormat_delete(format); } else if (outputBuffIdx == AMEDIACODEC_INFO_TRY_AGAIN_LATER) -- Gitblit v1.8.0