| | |
| | | #include "PL_H264Decoder.h"
|
| | | #include "MaterialBuffer.h"
|
| | | #include "logger.h"
|
| | |
|
| | | #include <H264VideoRTPSource.hh> // for SPropRecord
|
| | | #include <libbase64.h>
|
| | |
| | |
|
| | | if (!avCodec)
|
| | | {
|
| | | printf("codec not found!\n"); |
| | | LOG(WARN) << "codec not found!"; |
| | | return false;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | if (av_packet_from_data(&packet, buffer, buffSize) != 0)
|
| | | {
|
| | | printf("av_packet_from_data error\n");
|
| | | LOG(WARN) << "av_packet_from_data error";
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | printf("incomplete frame\n");
|
| | | LOG(WARN) << "incomplete frame";
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | bool ret = initH264DecoderEnv(in, sps.sPropBytes, sps.sPropLength, pps.sPropBytes, pps.sPropLength);
|
| | | if (!ret)
|
| | | {
|
| | | LOG(ERROR) << "PL_H264Decoder::pay initH264DecoderEnv error";
|
| | | return false; // #todo log
|
| | | }
|
| | | else
|
| | | in->fmtp_set_to_context = true;
|
| | | }
|
| | |
|
| | | if (pm.buffer == nullptr || pm.buffSize <= 0)
|
| | | if (pm.buffer == nullptr)
|
| | | return false;
|
| | |
|
| | | bool ret = false;
|
| | | if (pm.type == PipeMaterial::PMT_BYTES)
|
| | | {
|
| | | if (pm.buffSize <= 0)
|
| | | return false;
|
| | |
|
| | | timeval pts = {0};
|
| | | ret = decodeH264(in, pm.buffer, pm.buffSize, pts);
|
| | | ret = decodeH264(in, (uint8_t*)pm.buffer, pm.buffSize, pts);
|
| | | }
|
| | | else if (pm.type == PipeMaterial::PMT_FRAME)
|
| | | {
|
| | | MB_Frame* frame = (MB_Frame*)pm.buffer;
|
| | |
|
| | | ret = decodeH264(in, frame->buffer, frame->buffSize, frame->pts);
|
| | | if (frame->buffSize <= 0)
|
| | | return false;
|
| | | |
| | | ret = decodeH264(in, (uint8_t*)frame->buffer, frame->buffSize, frame->pts);
|
| | | 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.width = in->pAVFrame->width;
|
| | | in->lastFrame.height = in->pAVFrame->height;
|
| | | //in->lastFrame.pts = frame->pts;//#todo
|
| | | gettimeofday(&(in->lastFrame.pts),NULL);
|
| | | }
|
| | |
| | | if (!in->payError)
|
| | | {
|
| | | pm.type = PipeMaterial::PMT_FRAME;
|
| | | pm.buffer = (uint8_t*)(&(in->lastFrame));
|
| | | pm.buffSize = sizeof(uint8_t*);
|
| | | pm.buffer = &(in->lastFrame);
|
| | | pm.buffSize = 0;
|
| | | }
|
| | | pm.former = this;
|
| | | return !in->payError;
|