From 0250edfd9c4d453f25a2f9827698ccf87ff5afff Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 17 八月 2017 10:22:18 +0800 Subject: [PATCH] merge home base --- RtspFace/PL_RTSPServer.cpp | 48 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 35 insertions(+), 13 deletions(-) diff --git a/RtspFace/PL_RTSPServer.cpp b/RtspFace/PL_RTSPServer.cpp index ad5d1f9..4f140ca 100644 --- a/RtspFace/PL_RTSPServer.cpp +++ b/RtspFace/PL_RTSPServer.cpp @@ -1,7 +1,9 @@ #include "PL_RTSPServer.h" +#include "MaterialBuffer.h" +#include "logger.h" -#include <liveMedia.hh> -#include <BasicUsageEnvironment.hh> +#include <liveMedia/liveMedia.hh> +#include <BasicUsageEnvironment/BasicUsageEnvironment.hh> #include "FFmpegRTSPServer/IEncoder.h" #include "FFmpegRTSPServer/LiveRTSPServer.h" @@ -94,9 +96,18 @@ ReleaseFrame(); return 0; } - + + //static size_t f = 0; + //static FILE *pFile = fopen("/data/bb.264", "wb"); + //fwrite(in.buffer, sizeof(char), in.buffSize, pFile); + //if (++f > 400){ + // fclose(pFile); + // exit(0); + //} + uint8_t* pBuffer = in.buffer; size_t newBufferSize = in.buffSize; + if (in.config.payWithAux) { if (newBufferSize <= 4) @@ -107,11 +118,12 @@ pBuffer += 4; newBufferSize -= 4; } - + *FrameBuffer = pBuffer; *FrameSize = newBufferSize; - printf("send frame size=%u\n", in.buffSize); + LOG_DEBUG << "send frame size=" << in.buffSize << std::endl; + return 1; } virtual char ReleaseFrame() @@ -123,7 +135,7 @@ int ret = pthread_mutex_unlock(in.frame_mutex); if(ret != 0) { - printf("pthread_mutex_unlock frame_mutex: %s/n", strerror(ret)); + LOG_WARN << "pthread_mutex_unlock frame_mutex: " << strerror(ret) << std::endl; return 0; } } @@ -141,7 +153,7 @@ int ret = pthread_mutex_lock(in.frame_mutex); if(ret != 0) { - printf("pthread_mutex_lock frame_mutex: %s/n", strerror(ret)); + LOG_WARN << "pthread_mutex_lock frame_mutex: " << strerror(ret) << std::endl; return; } } @@ -195,7 +207,7 @@ int ret = pthread_create(&(in->live_daemon_thid), NULL, live_daemon_thd, in); if(ret != 0) { - printf("pthread_create: %s/n", strerror(ret)); + LOG_ERROR << "pthread_create: " << strerror(ret) << std::endl; return false; } @@ -213,15 +225,24 @@ { RTSPServer_Internal* in = (RTSPServer_Internal*)internal; - if (pm.buffer == nullptr || pm.buffSize <= 0) + if (pm.buffer == nullptr) return false; + if (pm.type != PipeMaterial::PMT_FRAME) + { + LOG_ERROR << "PL_RTSPServer::pay only support PMT_FRAME" << std::endl; + return false; + } + if (in->buffSize > 0) - printf("PL_RTSPServer::pay may lost data size=%u\n", in->buffSize); + LOG_WARN << "PL_RTSPServer::pay may lost data size=" << in->buffSize << std::endl; - memcpy(in->buffer, pm.buffer, pm.buffSize); - in->buffSize = pm.buffSize; - + MB_Frame* frame = (MB_Frame*)pm.buffer; + if (frame->buffer == nullptr) + return false; + memcpy(in->buffer, frame->buffer, frame->buffSize); + in->buffSize = frame->buffSize; + if (in->encoderStub == nullptr) return false; @@ -233,6 +254,7 @@ { RTSPServer_Internal* in = (RTSPServer_Internal*)internal; + pm.type = PipeMaterial::PMT_NONE; pm.buffer = nullptr; pm.buffSize = 0; pm.former = this; -- Gitblit v1.8.0