From 017b7eb736ccc53c52f81486be8196d7fafc3289 Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 28 十二月 2016 10:31:42 +0800 Subject: [PATCH] add MaterialBuffer --- RtspFace/PL_H264Decoder.cpp | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-) diff --git a/RtspFace/PL_H264Decoder.cpp b/RtspFace/PL_H264Decoder.cpp index 879fa6f..7a3b705 100644 --- a/RtspFace/PL_H264Decoder.cpp +++ b/RtspFace/PL_H264Decoder.cpp @@ -1,4 +1,5 @@ #include "PL_H264Decoder.h" +#include "MaterialBuffer.h" #include <H264VideoRTPSource.hh> // for SPropRecord #include <libbase64.h> @@ -20,12 +21,14 @@ AVCodecContext* pAVCodecContext; AVFrame* pAVFrame;//#todo delete + MB_Frame lastFrame; H264Decoder_Internal() : //buffSize(0), buffSizeMax(sizeof(buffer)), fmtp_set_to_context(false), payError(true), - pAVCodecContext(nullptr), pAVFrame(nullptr) + pAVCodecContext(nullptr), pAVFrame(nullptr), + lastFrame() { } @@ -38,6 +41,9 @@ //buffSize = 0; fmtp_set_to_context = false; payError = true; + + MB_Frame _lastFrame; + lastFrame = _lastFrame; } }; @@ -211,7 +217,27 @@ in->fmtp_set_to_context = true; } - bool ret = decodeH264(in, pm.buffer, pm.buffSize); + if (pm.buffer == nullptr || pm.buffSize <= 0) + return false; + + bool ret = false; + if (pm.type == PipeMaterial::PMT_BYTES) + ret = decodeH264(in, pm.buffer, pm.buffSize); + else if (pm.type == PipeMaterial::PMT_FRAME) + { + MB_Frame* frame = (MB_Frame*)pm.buffer; + + ret = decodeH264(in, frame->buffer, frame->buffSize); + if (ret) + { + in->lastFrame.type = MB_Frame::MBFT_PTR_AVFRAME; + in->lastFrame.buffer = (uint8_t*)(in->pAVFrame); + in->lastFrame.buffSize = sizeof(in->pAVFrame); + //in->lastFrame.pts = frame->pts;//#todo + gettimeofday(&(in->lastFrame.pts),NULL); + } + } + in->payError = !ret; return ret; } @@ -222,8 +248,9 @@ if (!in->payError) { - pm.buffer = (uint8_t*)in->pAVFrame;//in->buffer; - pm.buffSize = sizeof(uint8_t*);//in->buffSize; + pm.type = PipeMaterial::PMT_FRAME; + pm.buffer = (uint8_t*)(&(in->lastFrame)); + pm.buffSize = sizeof(uint8_t*); } pm.former = this; return !in->payError; -- Gitblit v1.8.0