From 663104b9be90ed303b87c8acddac8421583a9e39 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 16 八月 2017 12:38:59 +0800
Subject: [PATCH] aaaaa
---
RtspFace/PL_H264Decoder.cpp | 55 +++++++++++--------------------------------------------
1 files changed, 11 insertions(+), 44 deletions(-)
diff --git a/RtspFace/PL_H264Decoder.cpp b/RtspFace/PL_H264Decoder.cpp
index 55a130c..90681c1 100644
--- a/RtspFace/PL_H264Decoder.cpp
+++ b/RtspFace/PL_H264Decoder.cpp
@@ -1,9 +1,10 @@
#include "PL_H264Decoder.h"
#include "MaterialBuffer.h"
+#include "MediaHelper.h"
#include "logger.h"
-#include <H264VideoRTPSource.hh> // for SPropRecord
-#include <libbase64.h>
+#include <liveMedia/H264VideoRTPSource.hh> // for SPropRecord
+//#include <libbase64.h>
extern "C"
{
@@ -91,41 +92,6 @@
}
-SPropRecord* parseSPropParameterSets(char const* sPropParameterSetsStr, size_t& numSPropRecords) {
- // Make a copy of the input string, so we can replace the commas with '\0's:
- char* inStr = strDup(sPropParameterSetsStr);
- if (inStr == NULL) {
- numSPropRecords = 0;
- return NULL;
- }
-
- // Count the number of commas (and thus the number of parameter sets):
- numSPropRecords = 1;
- char* s;
- for (s = inStr; *s != '\0'; ++s) {
- if (*s == ',') {
- ++numSPropRecords;
- *s = '\0';
- }
- }
-
- // Allocate and fill in the result array:
- SPropRecord* resultArray = new SPropRecord[numSPropRecords];
- s = inStr;
- for (unsigned i = 0; i < numSPropRecords; ++i) {
- resultArray[i].sPropBytes = new uint8_t[256];
-
- size_t sPropLength = 0;
- base64_decode(s, strlen(s), (char*)resultArray[i].sPropBytes, &sPropLength, 0);
- resultArray[i].sPropLength = sPropLength;
-
- s += strlen(s) + 1;
- }
-
- delete[] inStr;
- return resultArray;
-}
-
bool initH264DecoderEnv(H264Decoder_Internal* in,
uint8_t* sps, size_t spsSize, uint8_t* pps, size_t ppsSize)
{
@@ -136,7 +102,7 @@
if (!avCodec)
{
- LOG_WARN << "codec not found!";
+ LOG_WARN << "codec not found!" << std::endl;
return false;
}
@@ -185,7 +151,7 @@
if (av_packet_from_data(&packet, buffer, buffSize) != 0)
{
- LOG_WARN << "av_packet_from_data error";
+ LOG_WARN << "av_packet_from_data error" << std::endl;
return false;
}
@@ -200,7 +166,8 @@
}
else
{
- LOG_WARN << "incomplete frame";
+ //#todo sps sps changing
+ LOG_WARN << "incomplete frame" << std::endl;
return false;
}
}
@@ -216,15 +183,15 @@
if (manager == NULL)
return false;
- std::string fmtp(manager->get_global_param(PLGP_RTSP_FMTP));
+ std::string fmtp(manager->get_param(PLGP_RTSP_FMTP));
if (fmtp.empty())
return false;
- size_t numSPropRecords = 0;
+ int numSPropRecords = 0;
SPropRecord *p_record = parseSPropParameterSets(fmtp.c_str(), numSPropRecords);
if (numSPropRecords < 2)
{
- LOG_WARN << "numSPropRecords < 2";
+ LOG_WARN << "numSPropRecords < 2" << std::endl;
return false;
}
@@ -234,7 +201,7 @@
bool ret = initH264DecoderEnv(in, sps.sPropBytes, sps.sPropLength, pps.sPropBytes, pps.sPropLength);
if (!ret)
{
- LOG_ERROR << "initH264DecoderEnv error";
+ LOG_ERROR << "initH264DecoderEnv error" << std::endl;
return false;
}
else
--
Gitblit v1.8.0